Freigeben über


What's in a (re)name?

Like several other source control systems, Subversion does rename via branch/delete - of course, since branch is just another name for copy in Subversion, it's a copy and delete.

Say I decide on a rename and then decide against it.  It takes 3 operations (2 svn revert's and a rm) to get back to my initial state.

~/dev/project/testing/dir% ls -ltotal 4-rw------- 1 jmm jmm 4 Apr 20 12:08 foo.txt~/dev/project/testing/dir% svn status~/dev/project/testing/dir% svn rename foo.txt bar.txtA bar.txt<br>D foo.txt~/dev/project/testing/dir% ls -ltotal 4 -rw------- 1 jmm jmm 4 Apr 20 12:10 bar.txt~/dev/project/testing/dir% svn statusD foo.txt<br>A + bar.txt~/dev/project/testing/dir% svn revert bar.txtReverted 'bar.txt'~/dev/project/testing/dir% ls -ltotal 4 -rw------- 1 jmm jmm 4 Apr 20 12:10 bar.txt~/dev/project/testing/dir% svn status ? bar.txt<br>D foo.txt~/dev/project/testing/dir% svn revert foo.txtReverted 'foo.txt'~/dev/project/testing/dir% svn status ? bar.txt~/dev/project/testing/dir% ls -ltotal 8 -rw------- 1 jmm jmm 4 Apr 20 12:10 bar.txt<br>-rw------- 1 jmm jmm 4 Apr 20 12:11 foo.txt~/dev/project/testing/dir% rm bar.txt~/dev/project/testing/dir% ls -ltotal 4 -rw------- 1 jmm jmm 4 Apr 20 12:11 foo.txt~/dev/project/testing/dir% svn status~/dev/project/testing/dir%

In Team Foundation, we treat rename as its own operation, separate from branch (label and undelete are also their own operations as well).  This makes our job tougher, but (should make) your life easier.

C:\test\tfs>h rename foo.txt bar.txtbar.txtC:\test\tfs>dirVolume in drive C has no label.Volume Serial Number is 2088-B3A5Directory of C:\test\tfs04/20/2005  01:49 PM    <DIR>          .04/20/2005  01:49 PM    <DIR>          ..04/20/2005 01:48 PM 4 bar.txt              1 File(s)              4 bytes              2 Dir(s)  11,778,043,904 bytes freeC:\test\tfs>h statusFile name Change Local path<br>--------- ------ ---------------------------------------------------------------<br>$/proj<br>bar.txt rename C:\test\tfs\bar.txt<br>1 change(s) C:\test\tfs>h undo bar.txtundoing rename: bar.txtC:\test\tfs>dirVolume in drive C has no label.Volume Serial Number is 2088-B3A5Directory of C:\test\tfs04/20/2005  01:49 PM    <DIR>          .04/20/2005  01:49 PM    <DIR>          ..04/20/2005 01:48 PM 4 foo.txt              1 File(s)              4 bytes              2 Dir(s)  11,778,027,520 bytes freeC:\test\tfs>h statusThere are no pending changes. C:\test\tfs>

This is a known state of affairs in Subversion, of course.  BitKeeper had called it out (see Subversion's debunking page) and it's been agreed to and is being worked on.

    It's true that Subversion has weak rename support (work is under way to fix this).

Comments

  • Anonymous
    April 20, 2005
    It seems like Subversion's "rename" would also make tracking the history of a file more difficult? Team Foundation's history command on a file spans renames, deletes/undeletes, etc. without issue.
  • Anonymous
    April 25, 2005
    Visual Studio Team System
    Beta 2 is out and thousands of you have downloaded and installed it with varying...
  • Anonymous
    April 25, 2005
    Actually, Subversion's rename system does preserve file history. This is one of its biggest advantages over CVS.