info-cvs
[Top][All Lists]
Advanced

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

Re: Verifymsg on branches?


From: Uwe Fritsch
Subject: Re: Verifymsg on branches?
Date: Wed, 22 Nov 2000 11:47:44 -0800

Hi Mark,

sounds nice. Is this patch necessary only for the server side of cvs or
also for the client?

We have world wide distributed developers and I don't want to update
them all and maintain this if we want to use new features in the
standard cvs distribution. Would be nice if this could be added to the
standard cvs.

Thanks,
Uwe.

----- Original Message -----
From: "Mark D. Baushke" <address@hidden>
To: <address@hidden>
Sent: Sunday, November 19, 2000 11:40 PM
Subject: Re: Verifymsg on branches?


> 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).
>
>
> _______________________________________________
> Info-cvs mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/info-cvs
>
>
>




reply via email to

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