On Sun, Jun 29, 2014 at 07:37:18PM -0500, joshua stein wrote:

> This adds a -C option to cvs's admin command which can add, change,
> or delete a revision's commitid.  I couldn't find any similar
> functionality in any other CVS implementations, nor any using 'admin
> -C'.
> 
> Add or change a commitid:
> 
>     cd /usr/src/bin/cat
>     cvs admin -C 1.1:abcdef123456 cat.c
> 
> Delete a commitid (ends up removing the commitid line from the RCS
> file):
> 
>     cd /usr/src/bin/cat
>     cvs admin -C 1.1: cat.c

I tried to find out how to use commitids with cvs status, cvs log or
cvs diff and others, but no luck. I cannot specify commitids to select
revs. I hope you find time to add selection of revs based on
commitids, because without them commitids sound pretty useless to me. 

        -Otto

> 
> Index: gnu/usr.bin/cvs/src/admin.c
> ===================================================================
> RCS file: /cvs/src/gnu/usr.bin/cvs/src/admin.c,v
> retrieving revision 1.2
> diff -u -p -u -p -r1.2 admin.c
> --- gnu/usr.bin/cvs/src/admin.c       11 May 2008 12:16:00 -0000      1.2
> +++ gnu/usr.bin/cvs/src/admin.c       30 Jun 2014 00:20:58 -0000
> @@ -27,6 +27,7 @@ static const char *const admin_usage[] =
>      "\t-A file    Append another file's access list.\n",
>      "\t-b[rev]    Set default branch (highest branch on trunk if 
> omitted).\n",
>      "\t-c string  Set comment leader.\n",
> +    "\t-C rev:id  Replace revision's commit id.\n",
>      "\t-e[users]  Remove (comma-separated) user names from access list\n",
>      "\t           (all names if omitted).\n",
>      "\t-I         Run interactively.\n",
> @@ -167,7 +168,7 @@ admin (argc, argv)
>      optind = 0;
>      only_k_option = 1;
>      while ((c = getopt (argc, argv,
> -                     "+ib::c:a:A:e::l::u::LUn:N:m:o:s:t::IqxV:k:")) != -1)
> +                     "+ib::c:C:a:A:e::l::u::LUn:N:m:o:s:t::IqxV:k:")) != -1)
>      {
>       if (c != 'k')
>           only_k_option = 0;
> @@ -209,6 +210,11 @@ admin (argc, argv)
>               strcat (admin_data.comment, optarg);
>               break;
>  
> +         case 'C':
> +             /* Change or add commitid. */
> +             arg_add (&admin_data, 'C', optarg);
> +             break;
> +
>           case 'a':
>               arg_add (&admin_data, 'a', optarg);
>               break;
> @@ -689,7 +695,7 @@ admin_fileproc (callerdat, finfo)
>      for (i = 0; i < admin_data->ac; ++i)
>      {
>       char *arg;
> -     char *p, *rev, *revnum, *tag, *msg;
> +     char *p, *rev, *revnum, *tag, *msg, *commitid;
>       char **users;
>       int argc, u;
>       Node *n;
> @@ -736,6 +742,45 @@ admin_fileproc (callerdat, finfo)
>               for (u = 0; u < argc; ++u)
>                   RCS_addaccess (rcs, users[u]);
>               free_names (&argc, users);
> +             break;
> +         case 'C':
> +             p = strchr (arg, ':');
> +             if (p == NULL)
> +             {
> +                 error (0, 0, "%s: -C option lacks commitid", rcs->path);
> +                 status = 1;
> +                 continue;
> +             }
> +             *p = '\0';
> +             rev = RCS_gettag (rcs, arg + 2, 0, NULL);
> +             if (rev == NULL)
> +             {
> +                 error (0, 0, "%s: no such revision %s", rcs->path, rev);
> +                 status = 1;
> +                 continue;
> +             }
> +             *p++ = ':';
> +             commitid = p;
> +
> +             n = findnode (rcs->versions, rev);
> +             free (rev);
> +             delta = (RCSVers *) n->data;
> +
> +             if (delta->other_delta == NULL)
> +                 delta->other_delta = getlist();
> +
> +             n = findnode (delta->other_delta, "commitid");
> +             if (n == NULL) {
> +                 n = getnode();
> +                 n->type = RCSFIELD;
> +                 n->key = xstrdup ("commitid");
> +                 n->data = xstrdup(commitid);
> +                 addnode (delta->other_delta, n);
> +             } else {
> +                 free (n->data);
> +                 n->data = xstrdup(commitid);
> +             }
> +
>               break;
>           case 'n': /* fall through */
>           case 'N':

Reply via email to