info-cvs
[Top][All Lists]
Advanced

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

Re: CVS update bug


From: Kaz Kylheku
Subject: Re: CVS update bug
Date: Thu, 4 Apr 2002 16:38:32 -0800 (PST)

On Thu, 4 Apr 2002, Kaz Kylheku wrote:

> Date: Thu, 4 Apr 2002 11:31:08 -0800 (PST)
> From: Kaz Kylheku <address@hidden>
> To: address@hidden
> Subject: [self-mail] CVS update bug
> 
> If you add files, and then switch to a branch, the files are not made
> sticky to that new branch. A subsequent commit succeeds, but for these
> added files it goes to the wrong place.   This breaks the classic CVS
> use case of hacking on some changes, and then later deciding to switch
> to a branch and commit there instead.  It was reproduced with CVS 1.11p1. 

Here is a patch, against the bleeding edge CVS. Here is how it
works. 

Firstly, in tag.c it defeats the stupid check that prevents tagging if
there are one or more locally added files. If an entry has no RCS
version file, we check its status. If its status is T_ADDED, then we
simply skip the file.

Secondly, in tag.c, there is a second check when an added file is being
tagged. We change the return value here to pretend that we did tag.
If we don't, it causes a problem in the case that the added files
are the *only* ones in the given directory. The problem is that the
tag won't then be written to val-tags, and CVS won't know that the
tag exists.

Lastly, in update.c, we add a case for T_ADDED. Register() is now
called to register the file in CVS/Entries. The version is specified
as the hard-coded string "0", mimicking what cvs add does.

So now you can create an empty project, cvs add a file, then 
cvs tag -b to create a branch, cvs update -r to switch to that branch,
and then commit the added file there.

? cvs.diff
Index: tag.c
===================================================================
RCS file: /cvs/ccvs/src/tag.c,v
retrieving revision 1.94
diff -u -r1.94 tag.c
--- tag.c       6 Jun 2001 19:43:04 -0000       1.94
+++ tag.c       5 Apr 2002 00:31:00 -0000
@@ -420,7 +420,7 @@
     char *xdir;
     Node *p;
     Vers_TS *vers;
-    
+
     if (check_uptodate) 
     {
        Ctype status = Classify_File (finfo, (char *) NULL, (char *) NULL,
@@ -466,11 +466,18 @@
     p->delproc = tag_delproc;
     if (vers->srcfile == NULL)
     {
-        if (!really_quiet)
+        int result = 1;
+       Ctype status = Classify_File (finfo, (char *) NULL, (char *) NULL,
+                                     (char *) NULL, 1, 0, &vers, 0);
+
+       if (status == T_ADDED)
+           result = 0;
+
+        if (result == 1 && !really_quiet)
            error (0, 0, "nothing known about %s", finfo->file);
        freevers_ts (&vers);
        freenode (p);
-       return (1);
+       return (result);
     }
 
     /* Here we duplicate the calculation in tag_fileproc about which
@@ -958,7 +965,7 @@
        if (!quiet)
            error (0, 0, "couldn't tag added but un-commited file `%s'", 
finfo->file);
        freevers_ts (&vers);
-       return (0);
+       return (1);
     }
     else if (version[0] == '-')
     {
Index: update.c
===================================================================
RCS file: /cvs/ccvs/src/update.c,v
retrieving revision 1.197
diff -u -r1.197 update.c
--- update.c    8 Jul 2001 20:51:46 -0000       1.197
+++ update.c    5 Apr 2002 00:31:00 -0000
@@ -770,6 +770,12 @@
                retval = checkout_file (finfo, vers, 0, 0, 1);
                break;
            case T_ADDED:               /* added but not committed */
+               /* Reregister to set any sticky tag, so when the
+                  add is committed, it goes to the right place. */
+               Register (finfo->entries, finfo->file, 
+                         "0", vers->ts_rcs,
+                         vers->options, vers->tag,
+                         vers->date, (char *)0);
                write_letter (finfo, 'A');
                retval = 0;
                break;

-- 
Meta-CVS: solid version control tool with directory structure versioning. 
http://users.footprints.net/~kaz/mcvs.html




reply via email to

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