script to retroactively add commitids to past openbsd commits

my cvs and rlog patches have been committed

+5 -236
+5 -8
README.md
··· 20 20 21 21 `$ ruby openbsd-commitid.rb` 22 22 23 - **NOTE**: `rlog` in path must be modified to separate revisions and files 24 - with an arbitrary delimiter, not just a line of dashes since those appear in 25 - some commit messages. This allows the script to accurately separate each 26 - revision from `rlog`. This change might be committed, but is included here 27 - as a patch for now. 23 + **NOTE**: This script relies on recently added changes to OpenBSD's `rlog` 24 + and `cvs` tools: 28 25 29 - **NOTE**: This script relies on a newly added `-C` flag to `cvs admin`, which 30 - sets a `commitid` in an RCS file. This change has not yet been committed and 31 - is included as a patch here. 26 + - `cvs admin -C` to set a revision's `commitid` 27 + - `rlog -E` and `rlog -S` to control the revision separators in `rlog` 28 + output, since the default line of dashes appears in old commit messages 32 29 33 30 ####Details 34 31
-100
patches/patch-cvs_admin_commitid.diff
··· 1 - # add a -C flag to 'cvs admin' to assign a commitid to an existing revision 2 - # 3 - # waiting to be committed 4 - 5 - Index: gnu/usr.bin/cvs/src/admin.c 6 - =================================================================== 7 - RCS file: /cvs/src/gnu/usr.bin/cvs/src/admin.c,v 8 - retrieving revision 1.2 9 - diff -u -p -u -p -r1.2 admin.c 10 - --- gnu/usr.bin/cvs/src/admin.c 11 May 2008 12:16:00 -0000 1.2 11 - +++ gnu/usr.bin/cvs/src/admin.c 6 Aug 2014 23:37:35 -0000 12 - @@ -27,6 +27,7 @@ static const char *const admin_usage[] = 13 - "\t-A file Append another file's access list.\n", 14 - "\t-b[rev] Set default branch (highest branch on trunk if omitted).\n", 15 - "\t-c string Set comment leader.\n", 16 - + "\t-C rev:id Replace revision's commit id.\n", 17 - "\t-e[users] Remove (comma-separated) user names from access list\n", 18 - "\t (all names if omitted).\n", 19 - "\t-I Run interactively.\n", 20 - @@ -167,7 +168,7 @@ admin (argc, argv) 21 - optind = 0; 22 - only_k_option = 1; 23 - while ((c = getopt (argc, argv, 24 - - "+ib::c:a:A:e::l::u::LUn:N:m:o:s:t::IqxV:k:")) != -1) 25 - + "+ib::c:C:a:A:e::l::u::LUn:N:m:o:s:t::IqxV:k:")) != -1) 26 - { 27 - if (c != 'k') 28 - only_k_option = 0; 29 - @@ -209,6 +210,11 @@ admin (argc, argv) 30 - strcat (admin_data.comment, optarg); 31 - break; 32 - 33 - + case 'C': 34 - + /* Change or add commitid. */ 35 - + arg_add (&admin_data, 'C', optarg); 36 - + break; 37 - + 38 - case 'a': 39 - arg_add (&admin_data, 'a', optarg); 40 - break; 41 - @@ -689,7 +695,7 @@ admin_fileproc (callerdat, finfo) 42 - for (i = 0; i < admin_data->ac; ++i) 43 - { 44 - char *arg; 45 - - char *p, *rev, *revnum, *tag, *msg; 46 - + char *p, *rev, *revnum, *tag, *msg, *commitid; 47 - char **users; 48 - int argc, u; 49 - Node *n; 50 - @@ -736,6 +742,50 @@ admin_fileproc (callerdat, finfo) 51 - for (u = 0; u < argc; ++u) 52 - RCS_addaccess (rcs, users[u]); 53 - free_names (&argc, users); 54 - + break; 55 - + case 'C': 56 - + p = strchr (arg, ':'); 57 - + if (p == NULL) 58 - + { 59 - + error (0, 0, "%s: -C option lacks commitid", rcs->path); 60 - + status = 1; 61 - + continue; 62 - + } 63 - + *p = '\0'; 64 - + rev = RCS_gettag (rcs, arg + 2, 0, NULL); 65 - + if (rev == NULL) 66 - + { 67 - + error (0, 0, "%s: no such revision %s", rcs->path, rev); 68 - + status = 1; 69 - + continue; 70 - + } 71 - + *p++ = ':'; 72 - + commitid = p; 73 - + 74 - + n = findnode (rcs->versions, rev); 75 - + free (rev); 76 - + delta = (RCSVers *) n->data; 77 - + 78 - + if (delta->other_delta == NULL) 79 - + delta->other_delta = getlist(); 80 - + 81 - + n = findnode (delta->other_delta, "commitid"); 82 - + if (n == NULL) { 83 - + if (strlen(commitid)) { 84 - + n = getnode(); 85 - + n->type = RCSFIELD; 86 - + n->key = xstrdup ("commitid"); 87 - + n->data = xstrdup(commitid); 88 - + addnode (delta->other_delta, n); 89 - + } 90 - + } else { 91 - + if (strlen(commitid)) { 92 - + free (n->data); 93 - + n->data = xstrdup(commitid); 94 - + } else 95 - + delnode(n); 96 - + } 97 - + 98 - break; 99 - case 'n': /* fall through */ 100 - case 'N':
-128
patches/patch-rcs_rlog_revsep.diff
··· 1 - # add -E and -S flags to rlog to allow changing RCS end and revision separators 2 - # to something non-standard, since lines of all dashes appear inside of some 3 - # existing commit messages, making it impossible to accurately parse rlog 4 - # output 5 - # 6 - # might be committed 7 - 8 - Index: usr.bin/rcs/rlog.1 9 - =================================================================== 10 - RCS file: /var/cvs/src/usr.bin/rcs/rlog.1,v 11 - retrieving revision 1.24 12 - diff -u -p -u -p -r1.24 rlog.1 13 - --- usr.bin/rcs/rlog.1 3 Sep 2010 11:09:29 -0000 1.24 14 - +++ usr.bin/rcs/rlog.1 21 Jan 2016 20:27:27 -0000 15 - @@ -24,8 +24,10 @@ 16 - .Nm 17 - .Op Fl bhLNRtV 18 - .Op Fl d Ns Ar dates 19 - +.Op Fl E Ns Ar endsep 20 - .Op Fl l Ns Op Ar lockers 21 - .Op Fl r Ns Op Ar revs 22 - +.Op Fl S Ns Ar revsep 23 - .Op Fl s Ns Ar states 24 - .Op Fl w Ns Op Ar logins 25 - .Op Fl x Ns Ar suffixes 26 - @@ -82,6 +84,11 @@ character. 27 - See also the 28 - .Fl z 29 - option, below. 30 - +.It Fl E Ns Ar endsep 31 - +Print 32 - +.Ar endsep 33 - +at the end of each RCS file, instead of the default string of 34 - +77 equal signs. 35 - .It Fl h 36 - Print the RCS header, 37 - describing a file's branch, lock details, symbolic names, etc. 38 - @@ -131,6 +138,11 @@ and 39 - Without argument, the 40 - .Fl r 41 - option means the latest revision of the default branch. 42 - +.It Fl S Ns Ar revsep 43 - +Print 44 - +.Ar revsep 45 - +at the end of each RCS revision, instead of the default string of 46 - +28 dash signs. 47 - .It Fl s Ns Ar states 48 - Print information about revisions whose state matches one of the 49 - specified 50 - Index: usr.bin/rcs/rlog.c 51 - =================================================================== 52 - RCS file: /var/cvs/src/usr.bin/rcs/rlog.c,v 53 - retrieving revision 1.71 54 - diff -u -p -u -p -r1.71 rlog.c 55 - --- usr.bin/rcs/rlog.c 16 Jan 2015 06:40:11 -0000 1.71 56 - +++ usr.bin/rcs/rlog.c 21 Jan 2016 20:29:26 -0000 57 - @@ -46,10 +46,7 @@ static int rlog_select_daterev(RCSFILE * 58 - static void rlog_file(const char *, RCSFILE *); 59 - static void rlog_rev_print(struct rcs_delta *); 60 - 61 - -#define RLOG_OPTSTRING "d:hLl::NqRr::s:TtVw::x::z::" 62 - -#define REVSEP "----------------------------" 63 - -#define REVEND \ 64 - - "=============================================================================" 65 - +#define RLOG_OPTSTRING "d:E:hLl::NqRr::S:s:TtVw::x::z::" 66 - 67 - static int dflag, hflag, Lflag, lflag, rflag, tflag, Nflag, wflag; 68 - static char *llist = NULL; 69 - @@ -57,14 +54,18 @@ static char *slist = NULL; 70 - static char *wlist = NULL; 71 - static char *revisions = NULL; 72 - static char *rlog_dates = NULL; 73 - +static char *revsep = "----------------------------"; 74 - +static char *revend = "=====================================================" 75 - + "========================"; 76 - 77 - __dead void 78 - rlog_usage(void) 79 - { 80 - fprintf(stderr, 81 - - "usage: rlog [-bhLNRtV] [-ddates] [-l[lockers]] [-r[revs]]\n" 82 - - " [-sstates] [-w[logins]] [-xsuffixes]\n" 83 - - " [-ztz] file ...\n"); 84 - + "usage: rlog [-bhLNRtV] [-ddates] [-Eendsep] [-l[lockers]] " 85 - + "[-r[revs]]\n" 86 - + " [-Srevsep] [-sstates] [-w[logins]] [-xsuffixes] " 87 - + "[-ztz] file ...\n"); 88 - 89 - exit(1); 90 - } 91 - @@ -85,6 +86,9 @@ rlog_main(int argc, char **argv) 92 - dflag = 1; 93 - rlog_dates = rcs_optarg; 94 - break; 95 - + case 'E': 96 - + revend = rcs_optarg; 97 - + break; 98 - case 'h': 99 - hflag = 1; 100 - break; 101 - @@ -110,6 +114,9 @@ rlog_main(int argc, char **argv) 102 - rflag = 1; 103 - revisions = rcs_optarg; 104 - break; 105 - + case 'S': 106 - + revsep = rcs_optarg; 107 - + break; 108 - case 's': 109 - slist = rcs_optarg; 110 - break; 111 - @@ -420,7 +427,7 @@ rlog_file(const char *fname, RCSFILE *fi 112 - } 113 - } 114 - 115 - - printf("%s\n", REVEND); 116 - + printf("%s\n", revend); 117 - } 118 - 119 - static void 120 - @@ -501,7 +508,7 @@ rlog_rev_print(struct rcs_delta *rdp) 121 - (slist != NULL || lflag == 1 || wflag == 1)) && found == 0)) 122 - return; 123 - 124 - - printf("%s\n", REVSEP); 125 - + printf("%s\n", revsep); 126 - 127 - rcsnum_tostr(rdp->rd_num, numb, sizeof(numb)); 128 -