views:

293

answers:

6

If I move a directory to another place inside the same repository by dragging it to the new place in Tortoise, I cannot checkout revisions prior to the move, because the URL to these old revisions is not valid anymore.

How do you move a directory and still be able to access revisions before the move?


Example: If I move

trunk/folder1/source

to

trunk/folder2/source

then I can see the "source" folder now under folder2, and I can checkout the head revision, meaning the revision that produced the move.

However, if I try to checkout an older revision that was committed before the move, I get an error that the url doesn't exist. I guess it's because the url of the older revision still points to the old path.

But there must be a way to fix this, otherwise a move would not make sense if you loose access to older revisions.

+1  A: 

Instead of just drag-and-drop, do the drag-and-drop with the right mouse button, and when you release, in the context menu that pops up choose "SVN Move versioned files here".

Amber
please see my comment to Soviut's answer.
Holgerwa
+2  A: 

You can move directories several ways.

The easiest way is to right mouse drag the directory and click "SVN Move versioned files here" when you drop.

You can use the rename function to rename a file from "blah.js" to "mydirectory/blah.js".

Lastly, you can use the commit window and drag items within there before you commit. A small red dot appears beside the checkbox when a file is set to be moved.

Soviut
Moving itself is easy, right. The problem is, that you cannot checkout revisions prior to the move anymore, because their url is now invalid.
Holgerwa
the older revision 'lives' in the old directory, it might not make sense to check it out to the new location. You can check out the old revision's parent directory to get the old rev though, but it will be in the old location. Alternatively, you can export the file to any location you like.
gbjbaanb
use a series of move and checkins (with proper messages) and you'll maintain full history while doing the re-basing.
Soviut
+2  A: 

Open the repository browser, then either drag+drop using the right mouse button (only feels strange the first time you do it), or use the 'Copy to...' menu item.

This will not affect your working copy at all, you can then update your WC to get the new directory, and delete+commit the old directory from your WC.

gbjbaanb
please see my comment to Soviut's answer.
Holgerwa
+1  A: 

Iam not sure if I understand your problem correctly. To mee it sounds a bit like this:

Assuming you have folder

/svn/trunk/folder1

and move it to

/svn/trunk/folder2

then you cannot access folder1 with this url:

/svn/trunk/folder2

you have to use

/svn/trunk/

depending on the revision you would then either see folder1 or folder2.

Stefan Egli
I added an example, please see above.
Holgerwa
A: 

Problem was: I tried to checkout an old revision while looking at the tree of the head revision in the repository browser. In that view, I tried to checkout trunk/folder2/source of an older revision, which didn't exist in that older revision because of the move.

Solution:

  • Check the log for the revision you need
  • switch the whole repository browser to that revision
  • now you can see the folder you need in it's original path, where it was back in that revision
  • check out this folder

Thanks to all for the hints, which led me into the right direction.

Holgerwa
+1  A: 

What wasn't mentioned in the previous answers was the SVN feature called "peg revision". Use the peg revision when you want to refer to a directory structure which no longer exists. From the SVN book:

In version 1.1, Subversion introduced a way for you to tell it exactly which Main Street you meant. It's called the peg revision, and it is provided to Subversion for the sole purpose of identifying a unique line of history. Because at most, one versioned object may occupy a path at any given time—or, more precisely, in any one revision—the combination of a path and a peg revision is all that is needed to refer to a specific line of history. Peg revisions are specified to the Subversion command-line client using at syntax, so called because the syntax involves appending an “at sign” (@) and the peg revision to the end of the path with which the revision is associated.

E.g.: http://svn.example.com/skinproj@148

See the SVN book for details: http://svnbook.red-bean.com/en/1.5/svn.advanced.pegrevs.html

William Leara
Looks interesting! But it doens't seem to be built into TortoiseSVN (yet).
Holgerwa