···20202121 `$ ruby openbsd-commitid.rb`
22222323-**NOTE**: `rlog` in path must be modified to separate revisions and files
2424-with an arbitrary delimiter, not just a line of dashes since those appear in
2525-some commit messages. This allows the script to accurately separate each
2626-revision from `rlog`. This change might be committed, but is included here
2727-as a patch for now.
2323+**NOTE**: This script relies on recently added changes to OpenBSD's `rlog`
2424+and `cvs` tools:
28252929-**NOTE**: This script relies on a newly added `-C` flag to `cvs admin`, which
3030-sets a `commitid` in an RCS file. This change has not yet been committed and
3131-is included as a patch here.
2626+- `cvs admin -C` to set a revision's `commitid`
2727+- `rlog -E` and `rlog -S` to control the revision separators in `rlog`
2828+ output, since the default line of dashes appears in old commit messages
32293330####Details
3431
-100
patches/patch-cvs_admin_commitid.diff
···11-# add a -C flag to 'cvs admin' to assign a commitid to an existing revision
22-#
33-# waiting to be committed
44-55-Index: gnu/usr.bin/cvs/src/admin.c
66-===================================================================
77-RCS file: /cvs/src/gnu/usr.bin/cvs/src/admin.c,v
88-retrieving revision 1.2
99-diff -u -p -u -p -r1.2 admin.c
1010---- gnu/usr.bin/cvs/src/admin.c 11 May 2008 12:16:00 -0000 1.2
1111-+++ gnu/usr.bin/cvs/src/admin.c 6 Aug 2014 23:37:35 -0000
1212-@@ -27,6 +27,7 @@ static const char *const admin_usage[] =
1313- "\t-A file Append another file's access list.\n",
1414- "\t-b[rev] Set default branch (highest branch on trunk if omitted).\n",
1515- "\t-c string Set comment leader.\n",
1616-+ "\t-C rev:id Replace revision's commit id.\n",
1717- "\t-e[users] Remove (comma-separated) user names from access list\n",
1818- "\t (all names if omitted).\n",
1919- "\t-I Run interactively.\n",
2020-@@ -167,7 +168,7 @@ admin (argc, argv)
2121- optind = 0;
2222- only_k_option = 1;
2323- while ((c = getopt (argc, argv,
2424-- "+ib::c:a:A:e::l::u::LUn:N:m:o:s:t::IqxV:k:")) != -1)
2525-+ "+ib::c:C:a:A:e::l::u::LUn:N:m:o:s:t::IqxV:k:")) != -1)
2626- {
2727- if (c != 'k')
2828- only_k_option = 0;
2929-@@ -209,6 +210,11 @@ admin (argc, argv)
3030- strcat (admin_data.comment, optarg);
3131- break;
3232-3333-+ case 'C':
3434-+ /* Change or add commitid. */
3535-+ arg_add (&admin_data, 'C', optarg);
3636-+ break;
3737-+
3838- case 'a':
3939- arg_add (&admin_data, 'a', optarg);
4040- break;
4141-@@ -689,7 +695,7 @@ admin_fileproc (callerdat, finfo)
4242- for (i = 0; i < admin_data->ac; ++i)
4343- {
4444- char *arg;
4545-- char *p, *rev, *revnum, *tag, *msg;
4646-+ char *p, *rev, *revnum, *tag, *msg, *commitid;
4747- char **users;
4848- int argc, u;
4949- Node *n;
5050-@@ -736,6 +742,50 @@ admin_fileproc (callerdat, finfo)
5151- for (u = 0; u < argc; ++u)
5252- RCS_addaccess (rcs, users[u]);
5353- free_names (&argc, users);
5454-+ break;
5555-+ case 'C':
5656-+ p = strchr (arg, ':');
5757-+ if (p == NULL)
5858-+ {
5959-+ error (0, 0, "%s: -C option lacks commitid", rcs->path);
6060-+ status = 1;
6161-+ continue;
6262-+ }
6363-+ *p = '\0';
6464-+ rev = RCS_gettag (rcs, arg + 2, 0, NULL);
6565-+ if (rev == NULL)
6666-+ {
6767-+ error (0, 0, "%s: no such revision %s", rcs->path, rev);
6868-+ status = 1;
6969-+ continue;
7070-+ }
7171-+ *p++ = ':';
7272-+ commitid = p;
7373-+
7474-+ n = findnode (rcs->versions, rev);
7575-+ free (rev);
7676-+ delta = (RCSVers *) n->data;
7777-+
7878-+ if (delta->other_delta == NULL)
7979-+ delta->other_delta = getlist();
8080-+
8181-+ n = findnode (delta->other_delta, "commitid");
8282-+ if (n == NULL) {
8383-+ if (strlen(commitid)) {
8484-+ n = getnode();
8585-+ n->type = RCSFIELD;
8686-+ n->key = xstrdup ("commitid");
8787-+ n->data = xstrdup(commitid);
8888-+ addnode (delta->other_delta, n);
8989-+ }
9090-+ } else {
9191-+ if (strlen(commitid)) {
9292-+ free (n->data);
9393-+ n->data = xstrdup(commitid);
9494-+ } else
9595-+ delnode(n);
9696-+ }
9797-+
9898- break;
9999- case 'n': /* fall through */
100100- case 'N':
-128
patches/patch-rcs_rlog_revsep.diff
···11-# add -E and -S flags to rlog to allow changing RCS end and revision separators
22-# to something non-standard, since lines of all dashes appear inside of some
33-# existing commit messages, making it impossible to accurately parse rlog
44-# output
55-#
66-# might be committed
77-88-Index: usr.bin/rcs/rlog.1
99-===================================================================
1010-RCS file: /var/cvs/src/usr.bin/rcs/rlog.1,v
1111-retrieving revision 1.24
1212-diff -u -p -u -p -r1.24 rlog.1
1313---- usr.bin/rcs/rlog.1 3 Sep 2010 11:09:29 -0000 1.24
1414-+++ usr.bin/rcs/rlog.1 21 Jan 2016 20:27:27 -0000
1515-@@ -24,8 +24,10 @@
1616- .Nm
1717- .Op Fl bhLNRtV
1818- .Op Fl d Ns Ar dates
1919-+.Op Fl E Ns Ar endsep
2020- .Op Fl l Ns Op Ar lockers
2121- .Op Fl r Ns Op Ar revs
2222-+.Op Fl S Ns Ar revsep
2323- .Op Fl s Ns Ar states
2424- .Op Fl w Ns Op Ar logins
2525- .Op Fl x Ns Ar suffixes
2626-@@ -82,6 +84,11 @@ character.
2727- See also the
2828- .Fl z
2929- option, below.
3030-+.It Fl E Ns Ar endsep
3131-+Print
3232-+.Ar endsep
3333-+at the end of each RCS file, instead of the default string of
3434-+77 equal signs.
3535- .It Fl h
3636- Print the RCS header,
3737- describing a file's branch, lock details, symbolic names, etc.
3838-@@ -131,6 +138,11 @@ and
3939- Without argument, the
4040- .Fl r
4141- option means the latest revision of the default branch.
4242-+.It Fl S Ns Ar revsep
4343-+Print
4444-+.Ar revsep
4545-+at the end of each RCS revision, instead of the default string of
4646-+28 dash signs.
4747- .It Fl s Ns Ar states
4848- Print information about revisions whose state matches one of the
4949- specified
5050-Index: usr.bin/rcs/rlog.c
5151-===================================================================
5252-RCS file: /var/cvs/src/usr.bin/rcs/rlog.c,v
5353-retrieving revision 1.71
5454-diff -u -p -u -p -r1.71 rlog.c
5555---- usr.bin/rcs/rlog.c 16 Jan 2015 06:40:11 -0000 1.71
5656-+++ usr.bin/rcs/rlog.c 21 Jan 2016 20:29:26 -0000
5757-@@ -46,10 +46,7 @@ static int rlog_select_daterev(RCSFILE *
5858- static void rlog_file(const char *, RCSFILE *);
5959- static void rlog_rev_print(struct rcs_delta *);
6060-6161--#define RLOG_OPTSTRING "d:hLl::NqRr::s:TtVw::x::z::"
6262--#define REVSEP "----------------------------"
6363--#define REVEND \
6464-- "============================================================================="
6565-+#define RLOG_OPTSTRING "d:E:hLl::NqRr::S:s:TtVw::x::z::"
6666-6767- static int dflag, hflag, Lflag, lflag, rflag, tflag, Nflag, wflag;
6868- static char *llist = NULL;
6969-@@ -57,14 +54,18 @@ static char *slist = NULL;
7070- static char *wlist = NULL;
7171- static char *revisions = NULL;
7272- static char *rlog_dates = NULL;
7373-+static char *revsep = "----------------------------";
7474-+static char *revend = "====================================================="
7575-+ "========================";
7676-7777- __dead void
7878- rlog_usage(void)
7979- {
8080- fprintf(stderr,
8181-- "usage: rlog [-bhLNRtV] [-ddates] [-l[lockers]] [-r[revs]]\n"
8282-- " [-sstates] [-w[logins]] [-xsuffixes]\n"
8383-- " [-ztz] file ...\n");
8484-+ "usage: rlog [-bhLNRtV] [-ddates] [-Eendsep] [-l[lockers]] "
8585-+ "[-r[revs]]\n"
8686-+ " [-Srevsep] [-sstates] [-w[logins]] [-xsuffixes] "
8787-+ "[-ztz] file ...\n");
8888-8989- exit(1);
9090- }
9191-@@ -85,6 +86,9 @@ rlog_main(int argc, char **argv)
9292- dflag = 1;
9393- rlog_dates = rcs_optarg;
9494- break;
9595-+ case 'E':
9696-+ revend = rcs_optarg;
9797-+ break;
9898- case 'h':
9999- hflag = 1;
100100- break;
101101-@@ -110,6 +114,9 @@ rlog_main(int argc, char **argv)
102102- rflag = 1;
103103- revisions = rcs_optarg;
104104- break;
105105-+ case 'S':
106106-+ revsep = rcs_optarg;
107107-+ break;
108108- case 's':
109109- slist = rcs_optarg;
110110- break;
111111-@@ -420,7 +427,7 @@ rlog_file(const char *fname, RCSFILE *fi
112112- }
113113- }
114114-115115-- printf("%s\n", REVEND);
116116-+ printf("%s\n", revend);
117117- }
118118-119119- static void
120120-@@ -501,7 +508,7 @@ rlog_rev_print(struct rcs_delta *rdp)
121121- (slist != NULL || lflag == 1 || wflag == 1)) && found == 0))
122122- return;
123123-124124-- printf("%s\n", REVSEP);
125125-+ printf("%s\n", revsep);
126126-127127- rcsnum_tostr(rdp->rd_num, numb, sizeof(numb));
128128-