From eac419e4f8b634beb822de04f2e6355d5f0fc695 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 13 Jul 2007 14:34:15 +0000 Subject: [PATCH] Trim comment sequence correctly. --- sccs2rcs | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/sccs2rcs b/sccs2rcs index 7236830..95f8c66 100755 --- a/sccs2rcs +++ b/sccs2rcs @@ -112,6 +112,11 @@ def workfile(f): def rcsfile(f): return os.path.join("RCS", f + ",v") +def record(msg): + global logtext + msg = "sccs2rcs: " + msg + logtext += msg + "\n" + def progress(msg): global logtext msg = "sccs2rcs: " + msg @@ -127,7 +132,7 @@ def get_output(command): def die(msg): print >>sys.stderr, "sccs2rcs: fatal error, ", msg - progress("error recovery begins") + record("error recovery begins") for master in os.listdir("SCCS"): if is_sccsmaster(master): get_output("unget " + master) @@ -226,7 +231,7 @@ if __name__ == '__main__': revisions.reverse() # Now use prs to run through the revision list extracting data - progress("%s revisions: %s" % (stem, ", ".join(revisions))) + record("%s revisions: %s" % (stem, ", ".join(revisions))) for rev in revisions: cmd = 'prs -d":Dd: :Dm: :Dy: :T: :P:" -r%s SCCS/s.%s' % (rev, stem) date = get_output_or_die(cmd).strip() @@ -245,8 +250,8 @@ if __name__ == '__main__': rcsdate = day + " " + months[int(month)-1] + " " + year + " " + tod progress("==> file %s, rev=%s, date=%s, author=%s" \ % (stem, rev, rcsdate, author)) - get_output_or_die("get -e -r%s SCCS/s.%s" % (rev, stem)) - progress("checked out of SCCS") + get_output_or_die("get -e -r%s %s" % (rev, sccsmaster(stem))) + record("checked out of SCCS") # replace SCCS keywords with RCS keywords try: @@ -260,7 +265,7 @@ if __name__ == '__main__': wfp.close() except OSError: die("keyword substitution failed") - progress("performed keyword substitutions") + record("performed keyword substitutions") # check file into RCS if firsttime: @@ -275,7 +280,7 @@ if __name__ == '__main__': % (rev, rcsdate, author, stem) cmd = "echo 'Initial revision.' | " + cmd get_output_or_die(cmd) - progress("initial checkin successful") + record("initial checkin successful") else: # get RCS lock revparts = rev.split(".") @@ -286,32 +291,33 @@ if __name__ == '__main__': # but it's not at all clear why this lock can be allowed # to fail while the trunk one must succeed. get_output("rcs -l%s %s" % (lckrev, stem)) - progress("got branch lock") + record("got branch lock") else: # need to lock the trunk -- must succeed get_output_or_die("rcs -l %s" % (stem,)) - progress("got trunk lock") + record("got trunk lock") # Extract the delta message for this revision deltamsg = get_output_or_die("prs -r$rev SCCS/s.%s" % stem) deltalines = deltamsg.split("\n") while deltalines: + line = deltalines[0] deltalines.pop(0) - if deltalines[0].startswith("COMMENTS"): + if line.startswith("COMMENTS"): break - while not deltalines.strip(): + while not deltalines[0].strip(): deltalines.pop(0) - deltamsg = deltalines.join("\n") - cmd = 'ci -f -r%s -d"%s" -w%s %s' % (rev, date, author, stem) + deltamsg = "\n".join(deltalines) + cmd = 'ci -f -r%s -d"%s" -w%s %s' % (rev, rcsdate, author, stem) # FIXME: output of this command isn't logged - progress("$ " + cmd) + record("$ " + cmd) try: cfp = os.popen(cmd, "w") cfp.write(deltamsg) cfp.close() except OSError: die("RCS checkin of delta failed") - # We're done - get_output_or_die("unget " + sccsmaster(stem)) + # We're done with this master, unlock it. + get_output_or_die("unget -r%s %s" % (rev, sccsmaster(stem))) # Replace all files for which there exist SCCS masters, progress("replacing workfiles...") -- 2.43.0