views:

54

answers:

1

Does CVS allow committing a file to a different branch than the one it was checked out from? The man page and some sites suggest that we can do a cvs ci -r branch-1 file.c but it gives the following error:

cvs commit: Up-to-date check failed for `file.c'
cvs [commit aborted]: correct above errors first!

I did a cvs diff -r branch-1 file.c to make sure that contents of file.c in my BASE and branch-1 are indeed the same.

I know that we can manually check out using cvs co -r branch-1, merge the main branch to it (and fix any merge issues) and then do a check in. The problem is that there are a number of branches and I would like to automate things using a script. This thread seems to suggest that -r has been removed. Can someone confirm that?

If ci -r is not supported, I am thinking of doing something like:

  • Make sure the branch versions and base version are the same with a cvs diff
  • Check in to the current branch
  • Keep a copy of the file in a temp file
  • For each branch:
    • Check out from branch with -r
    • replace the file with the temp file
    • Check in (it'll go the branch as -r is sticky)
  • Delete the temp file

The replacing part sounds like cheating to me - can you think of any potential issues that might occur? Anything I should be careful about? Is there any other way to automate this process?

+1  A: 

Note that a file may not be up-to-date even if diff shows zero output. For example, if you add a line of text to a file in one commit and remove it in the next you have zero difference along the path of two revisions.

As for the commit -r -issue. To me it seems like an experimental feature, and actually one you are better off by just using:

cvs update -r <branch> <file>
cvs update -j <ver> -j <ver> <file>
cvs commit <file>

Besides, propagating a single commit to all other branches programatically like the way you suggested is slightly questionable business since you usually need a quite a bit of human brain to resolve the conflicts.

psp
If there was an edit-undo, the revision history would still reflect that even after I force commit. I just want to make sure that I don't commit to version whose contents differ from the contents of the base version that I am editing (and thus lose any changes made to that branch). And ya, human intervention seems to be the only practical way to fix the merge conflicts.
Amarghosh