On Sun, Jun 29, 2014 at 07:39:59PM -0500, joshua stein wrote:
> On Sun, 29 Jun 2014 at 19:37:18 -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'.
>
> Oops, here's the proper diff that actually deletes empty commitids.
This may be a silly question, but how do commitids get
set/generated/applied?
only one paragraph in cvs man page mentions it, but does
not indicate how they are gotten.
--patrick
>
>
> 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:39:08 -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,50 @@ 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) {
> + if (strlen(commitid)) {
> + n = getnode();
> + n->type = RCSFIELD;
> + n->key = xstrdup ("commitid");
> + n->data = xstrdup(commitid);
> + addnode (delta->other_delta, n);
> + }
> + } else {
> + if (strlen(commitid)) {
> + free (n->data);
> + n->data = xstrdup(commitid);
> + } else
> + delnode(n);
> + }
> +
> break;
> case 'n': /* fall through */
> case 'N':
>