问题
I have a project with one directory that was originally (several hundred commits ago) copied verbatim from another directory, but svn cp wasn't used so there's a disconnect in history. Is it possible to connect the two directories at the initial copy point now, or is it too late?
回答1:
Let me guess what you're talking about:
- Directory
foo
is in Subversion - In revision #100, someone copied
foo
tobar
- They then added
bar
to the repository and did a commit and created revision #101. - Now Subversion is at revision #2302.
What you want to do is somehow go back in history back to revision #100, and redo the copy and add with a true svn copy
. That way, you can see the history of bar that it was copied from foo.
There might be a way of doing an svnadmin dump
of the repository, and then an svnadmin load
.
You need to create a dump of revisions 1 to 100 and another dump of 102 to head. You load in revisions 1 to 100 into the repository. Then you do your svn copy
and commit revision 101. Finally, you load in revisions 102 to head into the repository.
That, in theory, should fix the issue. I have never done this particular fix, but I've done other selective dump and loads where I changed the history.
回答2:
Move your unversioned directory out of the way, then svn cp
from the older revision of the original directory to the new one. You can use @<revision-number>
after the name of the source directory in the svn cp
command to specify the revision. Then copy your changes on top of the now version-controlled copy and commit them.
Here's a contrived example:
$ cd working-copy
$ ls -R
.:
copy-of-original original
./copy-of-original:
bar foo
./original:
bar foo
$ svn info original
Path: original
URL: file:///home/gardnerm/repo/original
Repository Root: file:///home/gardnerm/repo
Repository UUID: 6124f37b-b9bf-4d8a-906d-c4015c6f74ad
Revision: 2
Node Kind: directory
Schedule: normal
Last Changed Author: gardnerm
Last Changed Rev: 2
Last Changed Date: 2011-05-04 19:48:00 -0400 (Wed, 04 May 2011)
$ svn info copy-of-original
copy-of-original: (Not a versioned resource)
svn: A problem occurred; see other errors for details
$ mv copy-of-original backup-copy
$ svn cp original@1 copy-of-original ## this is a copy from a previous revision
A copy-of-original/foo
A copy-of-original/bar
Updated to revision 1.
A copy-of-original
$ svn commit -m 'copying from original r1'
Adding copy-of-original
Committed revision 3.
$ cp -r backup-copy/* copy-of-original ## bringing up to date
$ svn commit -m 'updating copy with latest changes'
Sending copy-of-original/bar
Sending copy-of-original/foo
Transmitting file data ..
Committed revision 4.
$ rm -r backup-copy
来源:https://stackoverflow.com/questions/5524083/is-it-possible-to-retroactively-add-history-that-would-have-been-there-if-an-svn