Move a file in CVS without resetting the revision number

Kevin Gale picture Kevin Gale · Sep 25, 2008 · Viewed 11.8k times · Source

Lately I've be moving source files around in our source tree. For example placing a bunch of files into a common assembly. I've been doing this my deleting the file from CVS and then adding it again in the new spot. The problem is the revision number of the file resets back to 1.1. Is there some simple way to move things without having the number reset.

I probably should have mentioned that I don't have access to the repository so anything that requires that doesn't help me but it might help others.

Answer

Diomidis Spinellis picture Diomidis Spinellis · Sep 25, 2008

The generally accepted way to achieve this effect is to perform the following steps. The technical term for this is a repocopy.

  1. Login on the server hosting the CVS repository and copy (don't move) the repository file from the location you want it to the new location.
  2. On the client side cvs delete the file from the old location.
  3. On the client side cvs update the directory contents in the new location (so that the file will appear there).
  4. On the client side perform a forced cvs commit (using the -f flag) of the copied file to log the fact that it was repocopied (add a log comment to that effect).

This procedure maintains the file history in its new location, and also doesn't break the backward continuity of the repository. If you move back in time, the file will correctly appear in its old location. You can also use the same procedure to rename a file.