script to retroactively add commitids to past openbsd commits

update rcs patch to add formal -E and -S options to pass our end/revsep

+130 -25
+7 -6
README.md
··· 20 20 21 21 `$ ruby openbsd-commitid.rb` 22 22 23 - **NOTE**: `rlog` in path must be modified to end revisions with `[...]---###`, 24 - not just a line of dashes since those appear in some commit messages. This 25 - allows the script to accurately separate each revision from `rlog`. This 26 - change will not be committed, and is included as a patch here. 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. 27 28 28 29 **NOTE**: This script relies on a newly added `-C` flag to `cvs admin`, which 29 30 sets a `commitid` in an RCS file. This change has not yet been committed and ··· 45 46 3. Fetch all revisions not already matched to a changeset, ordered by author 46 47 then date, and bundle them into changesets. Create a new "changesets" record 47 48 for each, then update each of those "revisions" records with the new changeset 48 - id. By sorting all commits by author name, it's possible to accurately find 49 - all files touched by an author in the same commit window. 49 + id. By sorting all commits by author and date, it's possible to accurately 50 + find all files touched by an author in the same commit window. 50 51 51 52 4. For each newly created "changesets" record, update them with a definitive 52 53 timestamp, log message, author, and commitid (creating a new one if needed)
+6 -5
lib/rcsfile.rb
··· 1 1 class RCSFile 2 2 attr_accessor :revisions, :first_undead_version 3 3 4 + RCSEND = "==================OPENBSD_COMMITID_RCS_END==================" 5 + REVSEP = "------------------OPENBSD_COMMITID_REV_SEP------------------" 6 + 4 7 def initialize(file) 5 8 @revisions = {} 6 9 7 - # rcs modified to end revs in ### 8 10 blocks = [] 9 - IO.popen([ "rlog", file ]) do |rlog| 10 - # rlog modified to end revision and file separators with ### 11 + IO.popen([ "rlog", "-E#{RCSEND}", "-S#{REVSEP}", file ]) do |rlog| 11 12 blocks = rlog.read.force_encoding("binary"). 12 - split(/^(-{28}|={77})###\n?$/). 13 - reject{|b| b.match(/\A(-{28}|={77})\z/) } 13 + split(/^(#{REVSEP}|#{RCSEND})\n?$/). 14 + reject{|b| b == RCSEND || b == REVSEP } 14 15 end 15 16 16 17 if !blocks.first.match(/^RCS file/)
+117 -14
patches/patch-rcs_rlog_revsep.diff
··· 1 - # change revision separator to something unique, since all dashes appear inside 2 - # of some existing commit messages, making it impossible to accurately parse 3 - # rlog output 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 4 5 # 5 - # not to be committed 6 + # might be committed 6 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 7 50 Index: usr.bin/rcs/rlog.c 8 51 =================================================================== 9 - RCS file: /cvs/src/usr.bin/rcs/rlog.c,v 10 - retrieving revision 1.67 11 - diff -u -p -u -p -r1.67 rlog.c 12 - --- usr.bin/rcs/rlog.c 7 Jan 2014 14:08:16 -0000 1.67 13 - +++ usr.bin/rcs/rlog.c 6 Aug 2014 23:38:02 -0000 14 - @@ -47,9 +47,9 @@ static void rlog_file(const char *, RCSF 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 *); 15 59 static void rlog_rev_print(struct rcs_delta *); 16 60 17 - #define RLOG_OPTSTRING "d:hLl::NqRr::s:TtVw::x::z::" 61 + -#define RLOG_OPTSTRING "d:hLl::NqRr::s:TtVw::x::z::" 18 62 -#define REVSEP "----------------------------" 19 - +#define REVSEP "----------------------------###" 20 - #define REVEND \ 63 + -#define REVEND \ 21 64 - "=============================================================================" 22 - + "=============================================================================###" 65 + +#define RLOG_OPTSTRING "d:E:hLl::NqRr::S:s:TtVw::x::z::" 23 66 24 67 static int dflag, hflag, Lflag, lflag, rflag, tflag, Nflag, wflag; 25 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 +