cvs-cvs
[Top][All Lists]
Advanced

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

[Cvs-cvs] ccvs/src ChangeLog client.c client.h sign.c [signed-commits3]


From: Derek Robert Price
Subject: [Cvs-cvs] ccvs/src ChangeLog client.c client.h sign.c [signed-commits3]
Date: Tue, 10 Jan 2006 18:49:35 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Branch:         signed-commits3
Changes by:     Derek Robert Price <address@hidden>     06/01/10 18:49:34

Modified files:
        src            : ChangeLog client.c client.h sign.c 

Log message:
        * client.c (send_fileproc): Compare files to base revision when
        available.
        (send_files): Accept FORCE_SIGNATURE flag.
        * client.h: Define FORCE_SIGNATURE.
        * sign.c (sign_check_fileproc): New function to verify files are
        unmodified before wasting bandwidth.
        (sign, sign_fileproc): Accept -d flag.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/ChangeLog.diff?only_with_tag=signed-commits3&tr1=1.3328.2.20&tr2=1.3328.2.21&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/client.c.diff?only_with_tag=signed-commits3&tr1=1.438.2.6&tr2=1.438.2.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/client.h.diff?only_with_tag=signed-commits3&tr1=1.61.4.3&tr2=1.61.4.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/cvs/ccvs/src/sign.c.diff?only_with_tag=signed-commits3&tr1=1.1.6.5&tr2=1.1.6.6&r1=text&r2=text

Patches:
Index: ccvs/src/ChangeLog
diff -u ccvs/src/ChangeLog:1.3328.2.20 ccvs/src/ChangeLog:1.3328.2.21
--- ccvs/src/ChangeLog:1.3328.2.20      Tue Jan 10 18:44:08 2006
+++ ccvs/src/ChangeLog  Tue Jan 10 18:49:34 2006
@@ -1,5 +1,13 @@
 2006-01-10  Derek Price  <address@hidden>
 
+       * client.c (send_fileproc): Compare files to base revision when
+       available.
+       (send_files): Accept FORCE_SIGNATURE flag.
+       * client.h: Define FORCE_SIGNATURE.
+       * sign.c (sign_check_fileproc): New function to verify files are
+       unmodified before wasting bandwidth.
+       (sign, sign_fileproc): Accept -d flag.
+
        * no_diff.h, wrapper.h: New files with decls from...
        * cvs.h: ...here.  Some decls moved to...
        * filesubr.h, vers_ts.h: ...here.
Index: ccvs/src/client.c
diff -u ccvs/src/client.c:1.438.2.6 ccvs/src/client.c:1.438.2.7
--- ccvs/src/client.c:1.438.2.6 Tue Jan 10 02:27:46 2006
+++ ccvs/src/client.c   Tue Jan 10 18:49:34 2006
@@ -35,6 +35,7 @@
 #include "edit.h"
 #include "ignore.h"
 #include "recurse.h"
+#include "wrapper.h"
 
 #include "cvs.h"
 
@@ -5207,6 +5208,7 @@
     bool force;
     bool no_contents;
     bool backup_modified;
+    bool force_signatures;
 };
 
 /* Deal with one file.  */
@@ -5219,6 +5221,7 @@
     /* File name to actually use.  Might differ in case from
        finfo->file.  */
     const char *filename;
+    bool may_be_modified;
 
     send_a_repository ("", finfo->repository, finfo->update_dir);
 
@@ -5307,60 +5310,79 @@
        /* File no longer exists.  Don't do anything, missing files
           just happen.  */
     }
-    else if (!vers->ts_rcs || args->force
-            || strcmp (vers->ts_conflict
-                       ? vers->ts_conflict : vers->ts_rcs, vers->ts_user)
+    else if (!vers->ts_rcs || args->force)
+       may_be_modified = true;
+    else if (strcmp (vers->ts_conflict
+                    ? vers->ts_conflict : vers->ts_rcs, vers->ts_user)
             || (vers->ts_conflict && !strcmp (cvs_cmd_name, "diff")))
     {
-       if (!strcmp (cvs_cmd_name, "sign")
-           || (!strcmp (cvs_cmd_name, "commit")
-               && get_sign_commits (false, supported_request ("Signature"))))
-       {
-           if (!supported_request ("Signature"))
-               error (1, 0, "Server doesn't support commit signatures.");
-
-           send_signature (Short_Repository (finfo->repository),
-                           finfo->file, finfo->fullname,
-                           vers && !strcmp (vers->options, "-kb"));
-       }
-
-       if (args->no_contents
-           && supported_request ("Is-modified"))
-       {
-           send_to_server ("Is-modified ", 0);
-           send_to_server (filename, 0);
-           send_to_server ("\012", 1);
-       }
+       char *basefn = make_base_file_name (filename, vers->ts_user);
+       if (!isfile (basefn) || xcmp (filename, basefn))
+           may_be_modified = true;
        else
-           send_modified (filename, finfo->fullname, vers);
-
-        if (args->backup_modified)
-        {
-            char *bakname;
-            bakname = backup_file (filename, vers->vn_user);
-            /* This behavior is sufficiently unexpected to
-               justify overinformativeness, I think. */
-            if (! really_quiet)
-                printf ("(Locally modified %s moved to %s)\n",
-                        filename, bakname);
-            free (bakname);
-        }
+           may_be_modified = false;
+       free (basefn);
     }
     else
     {
-       if (!strcmp (cvs_cmd_name, "sign"))
+       may_be_modified = false;
+    }
+
+    if (vers->ts_user)
+    {
+       if (may_be_modified)
        {
-           if (!supported_request ("Signature"))
-               error (1, 0, "Server doesn't support commit signatures.");
+           if (args->force_signatures
+               || (!strcmp (cvs_cmd_name, "commit")
+                   && get_sign_commits (false,
+                                        supported_request ("Signature"))))
+           {
+               if (!supported_request ("Signature"))
+                   error (1, 0, "Server doesn't support commit signatures.");
+
+               send_signature (Short_Repository (finfo->repository),
+                               finfo->file, finfo->fullname,
+                               vers && !strcmp (vers->options, "-kb"));
+           }
 
-           send_signature (Short_Repository (finfo->repository),
-                           finfo->file, finfo->fullname,
-                           vers && !strcmp (vers->options, "-kb"));
+           if (args->no_contents
+               && supported_request ("Is-modified"))
+           {
+               send_to_server ("Is-modified ", 0);
+               send_to_server (filename, 0);
+               send_to_server ("\012", 1);
+           }
+           else
+               send_modified (filename, finfo->fullname, vers);
+
+           if (args->backup_modified)
+           {
+               char *bakname;
+               bakname = backup_file (filename, vers->vn_user);
+               /* This behavior is sufficiently unexpected to
+                  justify overinformativeness, I think. */
+               if (! really_quiet)
+                   printf ("(Locally modified %s moved to %s)\n",
+                           filename, bakname);
+               free (bakname);
+           }
        }
+       else
+       {
+           if (args->force_signatures)
+           {
+               if (!supported_request ("Signature"))
+                   error (1, 0, "Server doesn't support commit signatures.");
 
-       send_to_server ("Unchanged ", 0);
-       send_to_server (filename, 0);
-       send_to_server ("\012", 1);
+               send_signature (Short_Repository (finfo->repository),
+                               finfo->file, finfo->fullname,
+                               vers && !strcmp (vers->options, "-kb"));
+           }
+
+           send_to_server ("Unchanged ", 0);
+           send_to_server (filename, 0);
+           send_to_server ("\012", 1);
+       }
     }
 
     /* if this directory has an ignore list, add this file to it */
@@ -5741,6 +5763,9 @@
  *             server as though they were modified.
  *             FLAGS & SEND_NO_CONTENTS means that this command only needs to
  *             know _whether_ a file is modified, not the contents.
+ *             FLAGS & FORCE_SIGNATURES means that OpenPGP signatures should
+ *             be sent with files regardless of other settings, including
+ *             server support.
  *
  * RETURNS
  *   Nothing.
@@ -5762,6 +5787,7 @@
     args.force = flags & SEND_FORCE;
     args.no_contents = flags & SEND_NO_CONTENTS;
     args.backup_modified = flags & BACKUP_MODIFIED_FILES;
+    args.force_signatures = flags & FORCE_SIGNATURES;
     err = start_recursion
        (send_fileproc, send_filesdoneproc, send_dirent_proc,
          send_dirleave_proc, &args, argc, argv, local, W_LOCAL, aflag,
Index: ccvs/src/client.h
diff -u ccvs/src/client.h:1.61.4.3 ccvs/src/client.h:1.61.4.4
--- ccvs/src/client.h:1.61.4.3  Fri Jan  6 20:37:13 2006
+++ ccvs/src/client.h   Tue Jan 10 18:49:34 2006
@@ -128,6 +128,7 @@
 # define SEND_FORCE            (1 << 1)
 # define SEND_NO_CONTENTS      (1 << 2)
 # define BACKUP_MODIFIED_FILES (1 << 3)
+# define FORCE_SIGNATURES      (1 << 4)
 
 /* Send an argument to the remote server.  */
 void
Index: ccvs/src/sign.c
diff -u ccvs/src/sign.c:1.1.6.5 ccvs/src/sign.c:1.1.6.6
--- ccvs/src/sign.c:1.1.6.5     Fri Jan  6 20:37:13 2006
+++ ccvs/src/sign.c     Tue Jan 10 18:49:34 2006
@@ -37,6 +37,7 @@
 #include "xalloc.h"
 
 /* CVS headers.  */
+#include "base.h"
 #include "classify.h"
 #include "client.h"
 #include "filesubr.h"
@@ -383,11 +384,63 @@
 
 
 static int
+sign_check_fileproc (void *callerdat, struct file_info *finfo)
+{
+    int err = 0;
+    struct file_info xfinfo;
+    Vers_TS *vers;
+
+    TRACE (TRACE_FUNCTION, "sign_check_fileproc (%s)", finfo->fullname);
+
+    xfinfo = *finfo;
+    xfinfo.repository = NULL;
+    xfinfo.rcs = NULL;
+    vers = Version_TS (&xfinfo, NULL, NULL, NULL, 0, 0);
+
+    if (!vers->ts_user)
+    {
+       error (0, 0, "No such file `%s'", finfo->fullname);
+       return 1;
+    }
+
+    if (!vers->ts_rcs)
+    {
+       error (0, 0, "Uncommitted file `%s' may not be signed.",
+              finfo->fullname);
+        return 1;
+    }
+
+    if (strcmp (vers->ts_conflict
+               ? vers->ts_conflict : vers->ts_rcs, vers->ts_user))
+    {
+       char *basefn = make_base_file_name (finfo->file, vers->ts_user);
+       if (!isfile (basefn))
+       {
+           /* FIXME: This could refetch.  */
+           error (0, 0, "Base file `%s' not found for `%s'",
+                  basefn, finfo->fullname);
+           err++;
+       }
+       else if (xcmp (finfo->file, basefn))
+       {
+           error (0, 0, "Cannot sign modified file `%s'", finfo->fullname);
+           err++;
+       }
+       free (basefn);
+    }
+
+    return err;
+}
+
+
+
+static int
 sign_fileproc (void *callerdat, struct file_info *finfo)
 {
     Vers_TS *vers;
     int err = 0;
     Ctype status;
+    const char *delkey = callerdat;
 
     TRACE (TRACE_FUNCTION, "sign_fileproc (%s)", finfo->fullname);
 
@@ -461,6 +514,7 @@
     "Usage: %s %s [-lR] [files...]\n",
     "\t-l\tProcess this directory only (not recursive).\n",
     "\t-R\tProcess directories recursively.\n",
+    "\t-d KEYID\tDelete signatures with key ID KEYID from revision.\n",
     "(Specify the --help global option for a list of other help options)\n",
     NULL
 };
@@ -471,15 +525,20 @@
     int c;
     int err = 0;
     bool local = false;
+    char *delkey = NULL;
 
     if (argc == -1)
        usage (sign_usage);
 
     optind = 0;
-    while ((c = getopt (argc, argv, "+lR")) != -1)
+    while ((c = getopt (argc, argv, "+d:lR")) != -1)
     {
        switch (c)
        {
+           case 'd':
+               if (delkey) free (delkey);
+               delkey = xstrdup (optarg);
+               break;
            case 'l':
                local = 1;
                break;
@@ -495,6 +554,14 @@
     argc -= optind;
     argv += optind;
 
+    if (!delkey)
+       err = start_recursion
+           (sign_check_fileproc, NULL, NULL, NULL, NULL,
+            argc, argv, local, W_LOCAL, false, CVS_LOCK_NONE, NULL,
+            current_parsed_root->isremote ? false : true, NULL);
+    if (err)
+       error (1, 0, "Correct above errors before rerunning this command.");
+
 #ifdef CLIENT_SUPPORT
     if (current_parsed_root->isremote)
     {
@@ -503,10 +570,19 @@
        ign_setup ();
 
        if (local)
-           send_arg("-l");
+           send_arg ("-l");
+       if (delkey)
+       {
+           send_arg ("-d");
+           send_arg (delkey);
+       }
        send_arg ("--");
 
-       send_files (argc, argv, local, false, 0);
+       /* Full file contents need to be sent to the server when signing since
+        * the server may have unique keywords configured in CVSROOT/config.
+        */
+       send_files (argc, argv, local, false,
+                   delkey ? SEND_NO_CONTENTS : FORCE_SIGNATURES);
        send_file_names (argc, argv, SEND_EXPAND_WILD);
 
        send_to_server ("sign\012", 0);
@@ -517,7 +593,7 @@
 #endif
 
     /* start the recursion processor */
-    err = start_recursion (sign_fileproc, NULL, NULL, NULL, NULL, argc, argv,
+    err = start_recursion (sign_fileproc, NULL, NULL, NULL, delkey, argc, argv,
                           local, W_LOCAL, false, CVS_LOCK_WRITE, NULL, true,
                           NULL);
 




reply via email to

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