bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cvs clears default branch when adding a file to a new branch with 'cvs


From: Mark D. Baushke
Subject: cvs clears default branch when adding a file to a new branch with 'cvs add'
Date: Fri, 07 Feb 2003 11:13:59 -0800

Background:

The following fix to src/commit.c has been part of the FreeBSD cvs since
1997-07-05. It was reported by Bill Fenner originally.

I have verified this bug still exists in the latest cvshome.org release
1.11.5 and in top-of-tree. I provide the fix and a test case for
sanity.sh to verify that the problem is fixed.

Here is the bulk of the FreeBSD problem report 4033:
                            ---------------
Description

    When using "cvs add" in a directory with a sticky tag (e.g. to bring a
    file onto a branch), "cvs commit" clears out the default branch in the
    RCS file before choosing the revision number for the new branch, and
    does not put it back.
    
    This causes:
    a) confusion.  Normally a file with a vendor branch cannot have a
    1.1.2.x branch.
    b) bloat.  Since HEAD is no longer on the vendor branch, any commits
    onto the vendor branch have to be merged onto HEAD, even if there have
    been no local changes.
    c) inconsistency.  Files that were on the vendor branch when the tree
    was tagged (e.g. when "cvs tag -b RELENG_2_2 happened) will have
    RELENG_2_2 branches of 1.1.1.1.2, while files that were imported later
    and then "cvs add"ed will have RELENG_2_2 branches of 1.1.2 .
    d) In my test case, it caused an extraneous conflict on $Id$ lines
    when importing a new version onto the vendor branch, but that might
    just have been a poorly-formed test case.

How-To-Repeat

    - "cvs import ttt" into an empty repository
    - "cvs co ttt" the new module
    - "cvs tag -b TESTOTRON *.c" some of the files in the module
    - "cvs release -d ttt" the directory I was working in
    Right now, the file "tcpdump.1,v" has branch:1.1.1
    - "cvs co -rTESTOTRON ttt"
    - cp (where-I-imported-from)/tcpdump.1 .
    - "cvs add tcpdump.1"
    - "cvs commit"
    The TESTOTRON branch is 1.1.2 in tcpdump.1, where it's 1.1.1.1.2 in *.c .
    tcpdump.1 has also lost its "branch:" info, so HEAD is now 1.1 instead
    of 1.1.1.1 .
                            ---------------
Here is my suggested fix.

ChangeLog entry:

2003-02-07  Mark D Baushke <mdb@cvshome.org>

        * commit.c (checkaddfile): Do not lose the vendor branch when
        adding files to a new branch. Avoids extranious conflicts for
        future vendor imports. This was found and fixed in FreeBSD cvs.
        See http://www.freebsd.org/cgi/query-pr.cgi?pr=4033 for details.

        * sanity.sh (branch-after-import): New test.

Index: src/commit.c
===================================================================
RCS file: /cvs/ccvs/src/commit.c,v
retrieving revision 1.187
diff -u -p -r1.187 commit.c
--- src/commit.c        8 Jan 2003 21:44:46 -0000       1.187
+++ src/commit.c        7 Feb 2003 18:52:25 -0000
@@ -2145,6 +2145,8 @@ checkaddfile (file, repository, tag, opt
            char *head;
            char *magicrev;
 
+           fixbranch (rcsfile, sbranch);
+
            head = RCS_getversion (rcsfile, NULL, NULL, 0, (int *) NULL);
            magicrev = RCS_magicrev (rcsfile, head);
 
Index: src/sanity.sh
===================================================================
RCS file: /cvs/ccvs/src/sanity.sh,v
retrieving revision 1.753
diff -u -p -r1.753 sanity.sh
--- src/sanity.sh       4 Feb 2003 14:45:21 -0000       1.753
+++ src/sanity.sh       7 Feb 2003 18:52:25 -0000
@@ -677,7 +677,7 @@ if test x"$*" = x; then
        tests="${tests} rdiff diff death death2 rm-update-message rmadd rmadd2"
        tests="${tests} dirs dirs2 branches branches2 tagc tagf"
        tests="${tests} rcslib multibranch import importb importc"
-       tests="${tests} update-p import-after-initial"
+       tests="${tests} update-p import-after-initial branch-after-import"
        tests="${tests} join join2 join3 join-readonly-conflict"
        tests="${tests} join-admin join-admin-2"
        tests="${tests} new newb conflicts conflicts2 conflicts3"
@@ -6997,6 +6997,60 @@ done"
          cd ../..
          rm -rf 1
          rm -rf ${CVSROOT_DIRNAME}/$module
+         ;;
+
+        branch-after-import)
+         # Test branching after an import via both cvs tag -b and
+         # cvs add to verify that the HEAD remains at 1.1.1.1
+         # This was a FreeBSD bug documented at the URL:
+         # http://www.freebsd.org/cgi/query-pr.cgi?pr=4033
+
+         # OK, first we get some sources from the NetMunger project,
+         # and import them into the 1.1.1 vendor branch.
+         mkdir imp-dir
+         cd imp-dir
+         echo 'OpenMunger sources' >file1
+         echo 'OpenMunger sources' >file2
+         dotest_sort branch-after-import-1 \
+"${testcvs} import -m add first-dir openmunger openmunger-1_0" \
+'
+
+N first-dir/file1
+N first-dir/file2
+No conflicts created by this import'
+         cd ..
+
+         # Next checkout the new module
+         dotest branch-after-import-2 \
+"${testcvs} -q co first-dir" \
+'U first-dir/file1
+U first-dir/file2'
+         cd first-dir
+         # Branch tag the file1 and cvs add file2,
+         # the branch should remain the same in both cases
+         # such that a new import will not require a conflict
+         # resolution.
+         dotest branch-after-import-3 \
+"${testcvs} tag -b TESTTOTRON file1" \
+'T file1'
+         dotest branch-after-import-4 \
+"${testcvs} -q update -r TESTTOTRON" \
+'cvs update: file2 is no longer in the repository'
+
+         cp ../imp-dir/file2 .
+         dotest branch-after-import-5 \
+"${testcvs} add file2" \
+'cvs add: scheduling file `file2'\'' for addition on branch `TESTTOTRON'\''
+cvs add: use '\''cvs commit'\'' to add this file permanently'
+
+         dotest branch-after-import-6 \
+"${testcvs} commit -m cvs-add file2" \
+"Checking in file2;
+${CVSROOT_DIRNAME}/first-dir/file2,v  <--  file2
+new revision: 1.1.1.1.2.1; previous revision: 1.1.1.1
+done"
+         cd ..
+         rm -r imp-dir first-dir
          ;;
 
        join)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]