bug-cvs
[Top][All Lists]
Advanced

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

Re: definition for CVS history file 'X' character


From: Mark D. Baushke
Subject: Re: definition for CVS history file 'X' character
Date: Wed, 07 Jun 2006 03:01:06 -0700

> Greetings,
> 
> The NetBSD version of CVS adds a definition for
> the 'X' character as a record type in the
> CVSROOT/history file. I think it is a reasonable
> addition and would like to hear if there are any
> objections before I adopt it and commit it to the
> FEATURE branch.
> 
> For what it may be worth, I have verified that the
> CVSNT sources do not currently appear to use this
> 'X' record type AND that the patch I am providing
> might even drop into their sources (modulo the
> names of the files being .cpp rather than .c).
> 
> Note: I have not yet come up with any sanity.sh
> tests, I plan to do that after the idea is
> approved.
> 
> The patch is after my .signature.
> 
>       Thanks,
>       -- Mark

My apologies. My last message contained the wrong patch.

        Thanks,
        -- Mark

Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3436
diff -u -p -r1.3436 ChangeLog
--- ChangeLog   7 Jun 2006 06:59:14 -0000       1.3436
+++ ChangeLog   7 Jun 2006 09:54:12 -0000
@@ -1,5 +1,12 @@
 2006-06-07  Mark D. Baushke  <mdb@gnu.org>
 
+       * admin.c (admin_fileproc): Used by NetBSD, add 'X' to the
+       pantheon of history record types to keep "cvs admin" command
+       information.
+       * history.c: Document addition of the 'X' history record type.
+       (report_hrecs): Add support for printing the 'X' record type.
+       * history.h (ALL_HISTORY_REC_TYPES): Add 'X' to the list.
+       
        * modules.c (my_module): Remove unused variable xvalue.
        [Fixes NetBSD coverity cid-705.]
        
Index: admin.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/admin.c,v
retrieving revision 1.114
diff -u -p -r1.114 admin.c
--- admin.c     16 May 2006 01:30:34 -0000      1.114
+++ admin.c     7 Jun 2006 09:54:12 -0000
@@ -122,6 +122,11 @@ struct admin_data
     int ac;
     char **av;
     int av_alloc;
+
+    /* This contains a printable version of the command line used
+     * for logging
+     */
+    char *cmdline;
 };
 
 /* Add an argument.  OPT is the option letter, e.g. 'a'.  ARG is the
@@ -332,6 +337,62 @@ make_UserAdminOptions (const char *infop
 
 
 
+static size_t
+wescape(char *dst, const char *src)
+{
+    const unsigned char *s = src;
+    char *d = dst;
+    for (; *s; s++) {
+       if (!isprint (*s) || isspace (*s) || *s == '|') {
+           *d++ = '\\';
+           *d++ = ((*s >> 6) & 3) + '0';
+           *d++ = ((*s >> 3) & 7) + '0';
+           *d++ = ((*s >> 0) & 7) + '0';
+       } else  {
+           *d++ = *s;
+       }
+    }
+    *d = '\0';
+    return d - dst;
+}
+
+
+
+static char *
+makecmdline (int argc, char **argv)
+{
+    size_t clen = 1024, wlen = 1024, len, cpos = 0, i;
+    char *cmd = xmalloc (clen);
+    char *word = xmalloc (wlen);
+
+    for (i = 0; i < argc; i++) {
+       char *arg = (strncmp (argv[i], "cvs ", 4) == 0)
+           ? argv[i] + 4 : argv[i];
+       len = strlen (arg);
+       if (len * 4 < wlen) {
+           wlen += len * 4;
+           word = xrealloc (word, wlen);
+       }
+       len = wescape (word, arg);
+       if (clen - cpos < len + 2) {
+           clen += len + 2;
+           cmd = xrealloc (cmd, clen);
+       }
+       memcpy (&cmd[cpos], word, len);
+       cpos += len;
+       cmd[cpos++] = ' ';
+    }
+    if (cpos != 0)
+       cmd[cpos - 1] = '\0';
+    else
+       cmd[cpos] = '\0';
+    free (word);
+
+    return cmd;
+}
+
+
+
 int
 admin (int argc, char **argv)
 {
@@ -347,6 +408,7 @@ admin (int argc, char **argv)
     wrap_setup ();
 
     memset (&admin_data, 0, sizeof admin_data);
+    admin_data.cmdline = makecmdline (argc, argv);
 
     /* TODO: get rid of `-' switch notation in admin_data.  For
        example, admin_data->branch should be not `-bfoo' but simply `foo'. */
@@ -735,6 +797,9 @@ admin_fileproc (void *callerdat, struct 
        goto exitfunc;
     }
 
+    history_write ('X', finfo->update_dir, admin_data->cmdline, finfo->file,
+                  finfo->repository);
+
     rcs = vers->srcfile;
     if (rcs == NULL)
     {
Index: history.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/history.c,v
retrieving revision 1.97
diff -u -p -r1.97 history.c
--- history.c   24 Apr 2006 18:50:26 -0000      1.97
+++ history.c   7 Jun 2006 09:54:12 -0000
@@ -54,6 +54,7 @@
  *             M       "Commit" cmd - "Modified" file.
  *             A       "Commit" cmd - "Added" file.
  *             R       "Commit" cmd - "Removed" file.
+ *             X       "Admin"  cmd.
  *
  *  date       is a fixed length 8-char hex representation of a Unix time_t.
  *             [Starting here, variable fields are delimited by '|' chars.]
@@ -88,7 +89,7 @@
  *
  *   Extract list of record types
  *
- *     -e, -x [TOEFWUPGCMAR]
+ *     -e, -x [TOEFWUPGCMARX]
  *
  *             Extracted records are simply printed, No analysis is performed.
  *             All "field" modifiers apply.  -e chooses all types.
@@ -1632,6 +1633,7 @@ report_hrecs (void)
            case 'M':
            case 'A':
            case 'R':
+           case 'X':
                (void) printf (" %-*s %-*s %-*s =%s= %s", rev_len, lr->rev,
                               file_len, lr->file, repos_len, repos,
                               lr->mod ? lr->mod : "", workdir);
Index: history.h
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/history.h,v
retrieving revision 1.4
diff -u -p -r1.4 history.h
--- history.h   1 Feb 2005 22:20:06 -0000       1.4
+++ history.h   7 Jun 2006 09:54:12 -0000
@@ -14,5 +14,5 @@
 
 #ifndef HISTORY_H
 # define HISTORY_H
-#define ALL_HISTORY_REC_TYPES "TOEFWUPCGMAR"
+#define ALL_HISTORY_REC_TYPES "TOEFWUPCGMARX"
 #endif /* HISTORY_H */

 ------- message ends -------




reply via email to

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