info-cvs
[Top][All Lists]
Advanced

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

Re: Verifymsg on branches?


From: Mark D. Baushke
Subject: Re: Verifymsg on branches?
Date: Sun, 19 Nov 2000 23:40:32 -0800

On Tue, 14 Nov 2000 10:03:16 EST, Laird Nelson
<address@hidden> wrote:
>2. You can't add anything to the message at commitinfo or verifymsg
>time.  The message being verified is read only.

Actually, the FreeBSD version of cvs *does* allow the verifymsg script
to make modifications to the log message. This is a VERY useful
feature that I would very much like to see it added to the cvshome.org
version of cvs. [Patches attached at the end of this message.]

        Enjoy!
        -- Mark

PS: Here are the essential patches to provide this feature as it is
found in the FreeBSD top-of-tree sources. If you wish to see what
other features have been added to the FreeBSD sources, you may
checkout your own copy of the sources using the commands:

  cvs -d :pserver:address@hidden:/home/ncvs login
  CVS password: anoncvs
  cvs -d :pserver:address@hidden:/home/ncvs co contrib_cvs

or just browse through the web via

  http://www.FreeBSD.org/cgi/cvsweb.cgi/src/contrib/cvs/

to take a look at the sources.

Sun Nov 19 23:24:05 2000  Mark D Baushke  <address@hidden>

        * Apply changes from FreeBSD cvs sources to implement a read-write
        user-defined verification script.
        * commit.c (commit): do_verify saved_message is now read-write
        * import.c (import): do_verify saved_message is now read-write
        * cvs.h (do_verify): Update do_verify prototype to expect a
        pointer to the saved_message.
        * logmsg.c (do_verify): Update do_verify to expect a pointer
        to the saved message. The file should be re-read after the
        user-defined verification script has been run. The user-defined
        verification script is allowed to modify the message.

Index:src/commit.c
--- cvs-1.11/src/commit.c       Wed Jul 26 12:29:01 2000
+++ cvs-1.11.pch/src/commit.c   Sun Nov 19 23:23:55 2000
@@ -498,7 +498,7 @@
        /* Run the user-defined script to verify/check information in
         *the log message
         */
-       do_verify (saved_message, (char *)NULL);
+       do_verify (&saved_message, (char *)NULL);       
 
        /* We always send some sort of message, even if empty.  */
        /* FIXME: is that true?  There seems to be some code in do_editor
@@ -1240,7 +1240,7 @@
        if (use_editor)
            do_editor (finfo->update_dir, &saved_message,
                       finfo->repository, ulist);
-       do_verify (saved_message, finfo->repository);
+       do_verify (&saved_message, finfo->repository);  
     }
 
     p = findnode (cilist, finfo->file);
@@ -1556,7 +1556,7 @@
     got_message = 1;
     if (use_editor)
        do_editor (update_dir, &saved_message, real_repos, ulist);
-    do_verify (saved_message, real_repos);
+    do_verify (&saved_message, real_repos);
     free (real_repos);
     return (R_PROCESS);
 }
Index:src/cvs.h
--- cvs-1.11/src/cvs.h  Sat Jul  8 12:57:21 2000
+++ cvs-1.11.pch/src/cvs.h      Sun Nov 19 23:23:55 2000
@@ -577,7 +577,7 @@
 void do_editor PROTO((char *dir, char **messagep,
                      char *repository, List * changes));
 
-void do_verify PROTO((char *message, char *repository));
+void do_verify PROTO((char **messagep, char *repository));
 
 typedef        int (*CALLBACKPROC)     PROTO((int argc, char *argv[], char 
*where,
        char *mwhere, char *mfile, int shorten, int local_specified,
Index:src/import.c
--- cvs-1.11/src/import.c       Tue Jul 11 13:32:02 2000
+++ cvs-1.11.pch/src/import.c   Sun Nov 19 23:23:55 2000
@@ -220,7 +220,7 @@
        do_editor ((char *) NULL, &message, repository,
                   (List *) NULL);
     }
-    do_verify (message, repository);
+    do_verify (&message, repository);
     msglen = message == NULL ? 0 : strlen (message);
     if (msglen == 0 || message[msglen - 1] != '\n')
     {
Index:src/logmsg.c
--- cvs-1.11/src/logmsg.c       Wed Mar  1 08:33:39 2000
+++ cvs-1.11.pch/src/logmsg.c   Sun Nov 19 23:23:55 2000
@@ -387,14 +387,20 @@
    independant of the running of an editor for getting a message.
  */
 void
-do_verify (message, repository)
-    char *message;
+do_verify (messagep, repository)
+    char **messagep;
     char *repository;
 {
     FILE *fp;
     char *fname;
     int retcode = 0;
 
+    char *line;
+    int line_length;
+    size_t line_chars_allocated;
+    char *p;
+    struct stat stbuf;
+
 #ifdef CLIENT_SUPPORT
     if (client_active)
        /* The verification will happen on the server.  */
@@ -408,7 +414,7 @@
 
     /* If there's no message, then we have nothing to verify.  Can this
        case happen?  And if so why would we print a message?  */
-    if (message == NULL)
+    if (*messagep == NULL)
     {
        cvs_output ("No message to verify\n", 0);
        return;
@@ -424,9 +430,9 @@
        error (1, errno, "cannot create temporary file %s", fname);
     else
     {
-       fprintf (fp, "%s", message);
-       if ((message)[0] == '\0' ||
-           (message)[strlen (message) - 1] != '\n')
+       fprintf (fp, "%s", *messagep);
+       if ((*messagep)[0] == '\0' ||
+           (*messagep)[strlen (*messagep) - 1] != '\n')
            (void) fprintf (fp, "%s", "\n");
        if (fclose (fp) == EOF)
            error (1, errno, "%s", fname);
@@ -455,6 +461,55 @@
                       "Message verification failed");
            }
        }
+
+       /* put the entire message back into the *messagep variable */
+
+       fp = open_file (fname, "r");
+       if (fp == NULL)
+       {
+           error (1, errno, "cannot open temporary file %s", fname);
+           return;
+       }
+
+       if (*messagep)
+           free (*messagep);
+
+       if ( CVS_STAT (fname, &stbuf) != 0)
+               error (1, errno, "cannot find size of temp file %s", fname);
+
+       if (stbuf.st_size == 0)
+           *messagep = NULL;
+       else
+       {
+           /* On NT, we might read less than st_size bytes, but we won't
+              read more.  So this works.  */
+           *messagep = (char *) xmalloc (stbuf.st_size + 1);
+           *messagep[0] = '\0';
+       }
+
+       line = NULL;
+       line_chars_allocated = 0;
+
+       if (*messagep)
+       {
+           p = *messagep;
+           while (1)
+           {
+               line_length = getline (&line, &line_chars_allocated, fp);
+               if (line_length == -1)
+               {
+                   if (ferror (fp))
+                       error (0, errno, "warning: cannot read %s", fname);
+                   break;
+               }
+               if (strncmp (line, CVSEDITPREFIX, CVSEDITPREFIXLEN) == 0)
+                   continue;
+               (void) strcpy (p, line);
+               p += line_length;
+           }
+       }
+       if (fclose (fp) < 0)
+           error (0, errno, "warning: cannot close %s", fname);
 
        /* Delete the temp file  */
 

In case this e-mail gets mangled, a uuencoded copy of the patch
follows (without the src/CommitLog addition).

begin 644 cvs-1.11.patch.gz
M'XL(",_1&#H``V1I9F9S`(57>W/:1A#_&WV*K3N-P0);PL:.26GL.F3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C(I<address@hidden>KN:@W6X>3F!N5L80R
M.)R%`\U7],`,U]G'E$E$$/8W%`SP%YJH!*%;address@hidden'7B576R<KAM"[T
M016,2,!6#0M]3TCY*MZ>M0<(-)&+)=64/F.9#M_=3AX>address@hidden
M]+DQ=G&4,Z%281$J=!/<)1")2*4TGH`YV!KB"AI$ZG9`ZM>R;G]\72FW.0[D
8K'['0D:#8\XJ?2/V)</X'address@hidden@``
`
end



reply via email to

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