Let's say that I have two files in a Subversion repo:
workingcopy/
file1.txt
file2.txt
And then I rename one, external to SVN:
$ mv file1.txt fileA.txt
Now, SVN marks file1.txt as missing, fileA.txt
as unversioned
$ svn st
! file1.txt
? fileA.txt
As far as SVN knows, I deleted file1.txt
and created a completely different file fileA.txt
, so it won't know to track changes between the files.
EDIT: this does work, I just can't spell filenames correctly :)
Similarly, if you delete a file
$ rm file2.txt
$ svn st
! file2.txt
SVN only knows that a file went missing, and trying to mark it removed doesn't work:
$ svn remove file2.txt
svn: 'file2.txt' does not exist
I know that in Mercurial, you can mark a file as moved, copied, deleted, etc after the fact with the --after
flag, regardless of what Mercurial sees in the working copy.
Is there a similar trick in SVN?
Maybe you need to update your version of Subversion:
$ svn --version
svn, version 1.6.16 (r1073529)
$ rm data.xml
$ svn status
! data.xml
$ svn rm data.xml
D data.xml
$ svn status
D data.xml
The same thing does not work with rename, but it would be super easy to write a shell script that does it:
#!/bin/sh
mv $2 $1
svn rename $1 $2
Or just for fun you could add the following to your .bashrc or .bash_profile:
svn_mv_after()
{
mv $2 $1
svn mv $1 $2
}
alias svnmva=svn_mv_after
If you are using TortiseSVN you can do this from the commit screen. Right click on the deleted and added file (the same file, just moved) together you get an option to repair the move.
http://tortoisesvn.net/repairmoves.html
No SVN has no such thing, cause you left SVN by using an operation command "mv .." instead of "svn mv ..." for "rm ..." this is the same as well...
SVN follows filenames with the meta information "contents" whereas in git, hg and bzr the contents is follwed with the meta information file name. This is the reason why you can do things in git, hg(i don't know), bzr(i don't know as well) if you can use operation system commands for renaming and deleting files.
What you can do after you recognized that you missed something...for example if you accidently deleted a file:
svn revert deleted.file.ext
svn rm deleted.file.ext
In the case of renaming a file you can do this only in the case you didn't change anything in the new file afterwards you renamed it by
mv file1.txt fileA.txt
you can do the same
svn revert file1.txt
delete the fileA.txt first and then
svn mv file1.txt fileA.txt
If you have changed something in the renamed file (fileA.txt) just make a copy of that file and do the same procecure and replace the file contents after "svn mv ..."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With