Search code examples
svntortoisesvnvisual-sourcesafe

How do I mirror an SVN repo dir structure in my working dir without a full root checkout?


First, a couple operating parameters:

  • .NET development using Visual Studio 2005/2008
  • TortoiseSVN client

I've only primarily worked with Visual Source Safe and SourceGear Vault source control systems. In each, I map the root of the repository to a local working directory. For example:

$/  -->  C:\source

As long as the local directory exists, I've got my "working copy" (svn) or "working folder" (VSS) set up.

To work on a new project that is already in the source code repository I need to "get the latest" (VSS) version of that project's directory.

When I go into any child directory in the repository and "Get Latest" (i.e. svn checkout) the client will automatically create the complete directory hierarchy for me, mirroring the structure on my local disk. Thus when I get latest of

$/foo/bar/project1

it is created on the drive at

C:\source\foo\bar\project1

In subversion, when I check out a directory, I must specify the working copy directory location. If I want to properly mirror my working copy directory structure to match the repository I have to either manually construct every child directory in the path or do a checkout of the repository root to the working copy root, getting everything in the repository.

Is there a way to get a repository directory down in the hierarchy such that it will be created in a matching local working copy directory structure without all the manual intervention?

This isn't a problem with a small repository, but in most cases, I don't need a large percentage of the source repository. It's imperative that the physical structure is maintained in order for file references to projects and resources not to break. Plus the disk cost of SVN is twice the actual source size given all the working base copies of the files.

I'm currently using Tortoise. Is it possible there are other SVN clients that will do what I'm looking for?


Solution

  • I seemed to have found a suitable solution to my problem.

    Using TortoiseSVN, the "Update item to revision" action within the repo browser can be used to locally reconstruct the repository's folder structure for an arbitrary repo path.

    Detailed steps are:

    1. Create a local folder to be the working copy root of the highest repository folder for which you need to maintain physical folder structure
    2. Do a shallow checkout of the repository root (checkout, select "Checkout Depth" of anything except "Fully recursive")
    3. Launch repo browser from the working copy folder
    4. Find repo path you want to get
    5. Right-click on desired folder, choose "Update item to revision"
    6. Leave defaults of HEAD revision and "Working copy" update depth, click OK

    This will update your working copy with the contents of the chosen repo path including all the parent directories up to the start of the checkout working copy thus mirroring the folder hierarchy of the repository in your working copy.

    Notes on the "Update item to revision" context menu option:

    • This option only appears on repository paths that don't already exist in the local working copy
    • It looks like leaving the "Update Depth" to the default of "Working Copy" is fine for getting all contents of the chosen path. (Rather than having to explicitly select "Fully recursive".)