Previous: The Flying Fish Approach -- A Simpler Way To Do It, Up: Going Out On A Limb (How To Work With Branches And Survive)


Branches And Keyword Expansion – Natural Enemies

If your files contain RCS keywords that expand differently on branch and trunk, you're almost guaranteed to get spurious conflicts on every merge. Even if nothing else changed, the keywords are overlapping, and their expansions won't match. For example, if README.txt contains this on the trunk

     $Revision: 1.14 $

and this on the branch

     $Revision: 1.14.2.1 $

then when the merge is performed, you'll get the following conflict:

     floss$ cvs update -j Exotic_Greetings-branch
     RCS file: /usr/local/newrepos/myproj/README.txt,v
     retrieving revision 1.14
     retrieving revision 1.14.2.1
     Merging differences between 1.14 and 1.14.2.1 into README.txt
     rcsmerge: warning: conflicts during merge
     floss$ cat README.txt
      ...
     <<<<<<< README.txt
     key $Revision: 1.14 $
     =======
     key $Revision: 1.14.2.1 $
     >>>>>>> 1.14.2.1
      ...
     floss$

To avoid this, you can temporarily disable expansion by passing the -kk option (I don't know what it stands for; "kill keywords" maybe?) when you do the merge:

     floss$ cvs update -kk -j Exotic_Greetings-branch
     RCS file: /usr/local/newrepos/myproj/README.txt,v
     retrieving revision 1.14
     retrieving revision 1.14.2.1
     Merging differences between 1.14 and 1.14.2.1 into README.txt
     floss$ cat README.txt
      ...
     $Revision$
      ...
     floss$

There is one thing to be careful of, however: If you use -kk, it overrides whatever other keyword expansion mode you may have set for that file. Specifically, this is a problem for binary files, which are normally -kb (which suppresses all keyword expansion and line-end conversion). So if you have to merge binary files in from a branch, don't use -kk. Just deal with the conflicts by hand instead.

Karl Fogel wrote this book. Buy a printed copy via his homepage at red-bean.com

copyright  ©  July 22 2019 sean dreilinger url: https://durak.org/sean/pubs/software/cvsbook/Branches-And-Keyword-Expansion-_002d_002d-Natural-Enemies.html