From 5bad31f69b40863b67f507b2b3c5684084524efa Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 6 Nov 2014 10:03:19 -0500 Subject: [PATCH] Make it work with or without the sccs front end. --- NEWS | 2 +- sccs2rcs | 25 +++++++++++++++---------- sccs2rcs.xml | 12 ++---------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/NEWS b/NEWS index c3642e2..857de4b 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ sccs2rcs project news Repository head: - Forward-ported to use GNU CSSC tools. Logging option added. + Documentation imoprovements. Logging option added. Tested on a collection of SCCS masters from BSD. 1.8: 2011-08-09 diff --git a/sccs2rcs b/sccs2rcs index 214da1a..6658e4b 100755 --- a/sccs2rcs +++ b/sccs2rcs @@ -7,9 +7,8 @@ # It requires that the SCCS and RCS tools be installed on your system. # # This code requires only get, unget, and prs from the SCCS tools. -# If what you have installed is cssc, you may have to find where -# its commands are installed (probably in a /usr/lib subdirectory -# for arch-specific binaries) and add that to your PATH. +# It should work with either the bare tools or the sccs front end +# in the BSD and GNU versions. # # Run this in a directory with an SCCS subdirectory. It will convert # all the SCCS files to corresponding RCS master files in a new RCS @@ -170,7 +169,7 @@ def die(msg): record("error recovery begins") for sccsfile in os.listdir("SCCS"): if is_sccsmaster(sccsfile): - do_it("unget " + sccsfile) + do_it(sccs + "unget " + sccsfile) print >>sys.stderr, """\ Danger! Danger! Incomplete history in ./RCS -- remove it. @@ -231,6 +230,12 @@ if __name__ == '__main__': # This assumption works under Debian/Ubuntu and will be harmless elsewhere. os.environ["PATH"] += ":/usr/lib/cssc:/usr/lib/x86_64-linux-gnu/cssc" + # Should we run through a front end? + if os.system("sccs >/dev/null 2>&1") == 0: + sccs = "sccs " + else: + sccs = "" + logtext = "" # Sanity checks on the directory @@ -264,7 +269,7 @@ if __name__ == '__main__': # Extract a list of revisions from the master revisions = [] try: - for line in os.popen("prs " + sccsmaster(stem), "r"): + for line in os.popen(sccs + "prs " + sccsmaster(stem), "r"): if line.startswith("D "): revisions.append(line.split()[1]) except OSError: @@ -276,12 +281,12 @@ if __name__ == '__main__': # Now use sccs prs to run through the revision list extracting data record("%s revisions: %s" % (stem, ", ".join(revisions))) for rev in revisions: - cmd = 'sccs prs -d":Dd: :Dm: :Dy: :T: :P:" -r%s SCCS/s.%s' % (rev, stem) + cmd = sccs + 'prs -d":Dd: :Dm: :Dy: :T: :P:" -r%s SCCS/s.%s' % (rev, stem) date = do_it_or_die(cmd).strip() try: (day, month, year, tod, author) = date.split() except ValueError: - die("prs output %s from '%s'was ill-formed" % (repr(date), cmd)) + die(sccs + "prs output %s from '%s'was ill-formed" % (repr(date), cmd)) # We assume here that no SCCS archives were made before 1970. # If you're converting an SCCS archive made after 2070, you lose. @@ -293,7 +298,7 @@ if __name__ == '__main__': rcsdate = day + " " + months[int(month)-1] + " " + year + " " + tod progress("==> file %s, rev=%s, date=%s, author=%s" \ % (stem, rev, rcsdate, author)) - do_it_or_die("get -e -r%s %s" % (rev, sccsmaster(stem))) + do_it_or_die(sccs + "get -e -r%s %s" % (rev, sccsmaster(stem))) record("checked out of SCCS") # replace SCCS keywords with RCS keywords @@ -346,7 +351,7 @@ if __name__ == '__main__': do_it_or_die("rcs -l %s" % (stem,)) record("got trunk lock") # Extract the delta message for this revision - deltamsg = do_it_or_die("prs -r%s SCCS/s.%s" % (rev, stem)) + deltamsg = do_it_or_die(sccs + "prs -r%s SCCS/s.%s" % (rev, stem)) deltalines = deltamsg.split("\n") while deltalines: line = deltalines[0] @@ -368,7 +373,7 @@ if __name__ == '__main__': except OSError: die("RCS checkin of delta failed") # We're done with this master, unlock it. - do_it_or_die("unget -r%s %s" % (rev, sccsmaster(stem))) + do_it_or_die(sccs + "unget -r%s %s" % (rev, sccsmaster(stem))) # Generate tags from snapshots created by Emacs VC mode tagnames = os.path.join("SCCS", "VC-names") diff --git a/sccs2rcs.xml b/sccs2rcs.xml index 46f430e..95485a5 100644 --- a/sccs2rcs.xml +++ b/sccs2rcs.xml @@ -29,7 +29,8 @@ sccs2rcs is a script to convert an existing SCCS history into an RCS history without losing any of the information contained therein. It requires that the SCCS and RCS tools be -installed on your system. +installed on your system. It will cope gracefull with the BSD/GNU +sccs front end. Run this in a directory with an SCCS subdirectory. It will convert all the SCCS files to corresponding RCS master files in a new RCS @@ -55,15 +56,6 @@ file, whether the program fails or succeeds. This is mainly useful for debugging unusual situations. -PROBLEMS -This code requires only get, unget, and prs from the SCCS tools. -If what you have installed is cssc, you may have to find where -its commands are installed (probably in a /usr/lib subdirectory -for arch-specific binaries) and add that to your PATH. - - - - ERROR RETURNS Returns 1 on any error, 0 otherwise. -- 2.43.0