Hi tech,

I noticed this OpenCVS bug a couple of months ago but I've
only just written this report.

Comparing "cvs log" output between GNU CVS 1.11.1p1 and OpenCVS...

$ diff -U 6 log_c.h_cvs log_c.h_ocvs
--- log_c.h_cvs Sun Jul  1 07:08:57 2012
+++ log_c.h_ocvs        Sun Jul  1 07:09:10 2012
@@ -4,13 +4,13 @@
 head: 1.3
 branch:
 locks: strict
 access list:
 symbolic names:
        start: 1.1.1.1
-       mwb: 1.1.1
+       mwb: 1.1.0.1
 keyword substitution: kv
 total revisions: 4;    selected revisions: 4
 description:
 ----------------------------
 revision 1.3
 date: 2009/07/08 00:08:06;  author: Brendan;  state: Exp;  lines: +2 -1

OpenCVS mangles the revision number.

The output of the rlog(1) tool in OpenRCS agrees with the output of CVS,
so it is most likely that OpenCVS is at fault. As expected, the only
difference in the rlog(1) output is the RCS file path.

$ diff -u log_c.h_cvs log_c.h_rlog
--- log_c.h_cvs Sun Jul  1 07:08:57 2012
+++ log_c.h_rlog        Sun Jul  1 07:17:48 2012
@@ -1,5 +1,5 @@

-RCS file: /home/mwb/repo0/ladcc-port/ladcc-port/c.h,v
+RCS file: c.h,v
 Working file: c.h
 head: 1.3
 branch:

We also compare the output of rlog(1) from GNU RCS 5.8.
GNU RCS rlog(1) and OpenRCS rlog(1) agree exactly.

$ md5 log_c.h_rlog log_c.h_gnurlog
MD5 (log_c.h_rlog) = 4a81f159e94bf0991dac1557fc29c924
MD5 (log_c.h_gnurlog) = 4a81f159e94bf0991dac1557fc29c924

Now it is clear that OpenCVS is to blame. The -t option points me
to function cvs_log_local(). The codes does...

getlog.c:
271         TAILQ_FOREACH(sym, &(cf->file_rcs->rf_symbols), rs_list) {
272             rev = rcsnum_alloc();
273             rcsnum_cpy(sym->rs_num, rev, 0);
274             if (RCSNUM_ISBRANCH(sym->rs_num))
275                 rcsnum_addmagic(rev);
276
277             cvs_printf("\t%s: %s\n", sym->rs_name,
278                 rcsnum_tostr(rev, numb, sizeof(numb)));
279             rcsnum_free(rev);
280         }

The RCS number 1.1.1 is a branch number and RCSNUM_ISBRANCH correctly
returns true. When commenting out the call to rcsnum_addmagic(), 
"opencvs log" correctly prints "mwb: 1.1.1".

OpenCVS and OpenRCS both define the function rcsnum_addmagic(),
but OpenRCS does not use this in its rlog(1) code. The code in
OpenRCS looks like...

rlog.c:
390         TAILQ_FOREACH(sym, &(file->rf_symbols), rs_list) {
391             printf("\t%s: %s\n", sym->rs_name,
392                 rcsnum_tostr(sym->rs_num, numb, sizeof(numb)));
393         }

So it looks like branch numbers that we read in don't need to
be translated in any way. My proposed fix is below. As a side
effect of removing the call to rcsnum_addmagic(), we can also
remove the allocation of a copy of sym->rcs_num and use rcs_num 
directly in the printf().


Index: getlog.c
===================================================================
RCS file: /cvs/src/usr.bin/cvs/getlog.c,v
retrieving revision 1.95
diff -u -r1.95 getlog.c
--- getlog.c    30 Jul 2010 21:47:18 -0000      1.95
+++ getlog.c    1 Jul 2012 00:08:38 -0000
@@ -269,14 +269,8 @@
        if (!(runflags & L_NOTAGS)) {
                cvs_printf("symbolic names:\n");
                TAILQ_FOREACH(sym, &(cf->file_rcs->rf_symbols), rs_list) {
-                       rev = rcsnum_alloc();
-                       rcsnum_cpy(sym->rs_num, rev, 0);
-                       if (RCSNUM_ISBRANCH(sym->rs_num))
-                               rcsnum_addmagic(rev);
-
                        cvs_printf("\t%s: %s\n", sym->rs_name,
-                           rcsnum_tostr(rev, numb, sizeof(numb)));
-                       rcsnum_free(rev);
+                           rcsnum_tostr(sym->rs_num, numb, sizeof(numb)));
                }
        }


I tested this patch on OpenBSD/amd64 5.1. 
OpenCVS output now matches GNU CVS, OpenRCS and GNU RCS.

$ md5 log_c.h_new_ocvs log_c.h_cvs
MD5 (log_c.h_new_ocvs) = f5e20ff3a95d7938abcb3139ed159cc0
MD5 (log_c.h_cvs) = f5e20ff3a95d7938abcb3139ed159cc0

- Michael

Reply via email to