cvs-cvs
[Top][All Lists]
Advanced

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

[Cvs-cvs] ccvs/src ChangeLog rcs.c [cvs1-11-x-branch]


From: Mark D. Baushke
Subject: [Cvs-cvs] ccvs/src ChangeLog rcs.c [cvs1-11-x-branch]
Date: Tue, 09 May 2006 20:50:04 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Branch:         cvs1-11-x-branch
Changes by:     Mark D. Baushke <address@hidden>        06/05/09 20:50:03

Modified files:
        src            : ChangeLog rcs.c 

Log message:
        * rcs.c (findhighestmagicrev_proc): New function to find the
        highest magic rev with the required number of dots.
        (findnextmagicrev): New function to walk the symbolic tag list
        calling findhighestmagicrev_proc() to find the next unused magic
        branch revision.
        (RCS_magicrev): Use findnextmagicrev().
        (Patch suggested by "Kelly F. Hickel" <address@hidden> based
        on advice from Larry Jones.)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/ChangeLog.diff?only_with_tag=cvs1-11-x-branch&tr1=1.2336.2.442&tr2=1.2336.2.443&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/rcs.c.diff?only_with_tag=cvs1-11-x-branch&tr1=1.262.4.46&tr2=1.262.4.47&r1=text&r2=text

Patches:
Index: ccvs/src/ChangeLog
diff -u ccvs/src/ChangeLog:1.2336.2.442 ccvs/src/ChangeLog:1.2336.2.443
--- ccvs/src/ChangeLog:1.2336.2.442     Thu May  4 09:53:08 2006
+++ ccvs/src/ChangeLog  Tue May  9 20:50:03 2006
@@ -1,3 +1,14 @@
+2006-05-09  Mark D. Baushke  <address@hidden>
+
+       * rcs.c (findhighestmagicrev_proc): New function to find the
+       highest magic rev with the required number of dots.
+       (findnextmagicrev): New function to walk the symbolic tag list
+       calling findhighestmagicrev_proc() to find the next unused magic
+       branch revision.
+       (RCS_magicrev): Use findnextmagicrev().
+       (Patch suggested by "Kelly F. Hickel" <address@hidden> based
+       on advice from Larry Jones <address@hidden>.)
+
 2006-05-04  Mark D. Baushke  <address@hidden>
 
        * filesubr.c (cvs_temp_file): Avoid keeping pointers to free()'d
Index: ccvs/src/rcs.c
diff -u ccvs/src/rcs.c:1.262.4.46 ccvs/src/rcs.c:1.262.4.47
--- ccvs/src/rcs.c:1.262.4.46   Fri Apr  7 01:48:51 2006
+++ ccvs/src/rcs.c      Tue May  9 20:50:03 2006
@@ -133,6 +133,8 @@
 static FILE *rcs_internal_lockfile PROTO ((char *));
 static void rcs_internal_unlockfile PROTO ((FILE *, char *));
 static char *rcs_lockfilename PROTO ((const char *));
+static int findnextmagicrev PROTO ((RCSNode *rcs, char *rev, int default_rv));
+static int findhighestmagicrev_proc PROTO((Node *p, void *closure));
 
 /* The RCS file reading functions are called a lot, and they do some
    string comparisons.  This macro speeds things up a bit by skipping
@@ -2549,8 +2551,13 @@
     xrev = xmalloc (strlen (rev) + 14); /* enough for .0.number */
     check_rev = xrev;
 
+    /* prime the pump by finding the next unused magic rev,
+     * if none are found, it should return 2.
+     */
+    rev_num = findnextmagicrev (rcs, rev, 2);
+    
     /* only look at even numbered branches */
-    for (rev_num = 2; ; rev_num += 2)
+    for (; ; rev_num += 2)
     {
        /* see if the physical branch exists */
        (void) sprintf (xrev, "%s.%d", rev, rev_num);
@@ -8822,3 +8829,66 @@
     }
     return label;
 }
+
+/*
+ * Go through the symbolic tag list, find the next unused magic
+ * branch revision.
+ *
+ * Returns 2 if it can't figure anything out, then the caller
+ * will end up doing a linear search.
+ */
+static int findnextmagicrev_dots;
+static int
+findnextmagicrev (rcs, rev, defaultrv)
+    RCSNode *rcs;
+    char *rev;
+    int defaultrv;
+{
+    int rv = defaultrv;
+
+    /* Tell the walklist proc how many dots we're looking for,
+     * which is the number of dots in the existing rev, plus
+     * 2.  one for RCS_MAGIC_BRANCH and one for the new rev number.
+     */
+    findnextmagicrev_dots = numdots (rev) + 2;
+  
+    /* walk the symbols list to find the highest revision. */
+    (void) walklist (RCS_symbols (rcs), findhighestmagicrev_proc, &rv);
+
+    /* adjust to next even number if we found something */
+    if (rv != defaultrv)
+    {
+       if ((rv % 2) != 0)
+           rv++;
+       else
+           rv += 2;
+    }
+
+    return rv;
+}
+
+/*
+ * walklist proc to find the highest magic rev with
+ * the required number of dots.
+ */
+static int
+findhighestmagicrev_proc (p, closure)
+    Node *p;
+    void *closure;
+{
+    int *rev = (int *)closure;
+
+    if (numdots (p->data) == findnextmagicrev_dots) {
+       /* if the last term of the rev is greater than the current
+          max, update */
+       char *cp;
+       cp = strrchr (p->data, '.');
+       if ((cp != NULL) && (cp[1] != 0))
+       {
+           int new_rev = atoi (cp + 1);
+           if (new_rev > *rev)
+               *rev = new_rev;
+       }
+    }
+    return 1;
+}




reply via email to

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