#
# 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.
+# 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
#
# There is one option. With -c you can specify an initial-comments file.
# Each line should consist of a filename followed by a colon, followed
-# by the RCS initial coment to set for that file.
+# by the RCS initial comment to set for that file.
#
# LICENSE:
#
#
# HISTORY:
#
-# This tool has a complicated history for its size. It began life as a
+# This tool has a complicated history for its size. It began life as a
# script in C-shell written by a hacker named Ken Cox in 1991.
#
-# In 1993 I applied some minor fixes for newer RCS versions and it
+# In 1993 I applied some minor fixes for newer RCS versions and it
# shipped as part of one of Rich Morin's Prime Time Freeware releases.
#
# In 1994 Brian Berliner hacked Ken Cox's original in a slightly
# In 2003 I folded in a minor bug fix from Roger Pilkey.
# In 2007 I merged in the missing features from Brian Berliner's version
# and sent it to the GNU RCS project hoping they'd take it off my hands.
-#
+#
# Then it started to bother me that I was casting the thing loose in a
# dying language, so I decided to port it to Python and clean it up.
# I added error checking, added the comments-file processing, added
# Ken said:
# "This file may be copied, processed, hacked, mutilated, and
# even destroyed as long as you don't tell anyone you wrote it."
-# Those were more innocent days. This version is released under MIT terms.
+# Those were more innocent days. This version is released under MIT terms.
#
# Ken also said:
# + If a particular module is hanging you up, consider
# I removed the dependencies on the BSD/SV `sccs' utility; this script
# will now work on any system that has the base SCCS/RCS tools available.
#
-# 1.2: Merges in Roger Pilkey's fix for the case in which date spans
-# cross the millenium boundary. Use GNU tac instead of tail, which can't
+# 1.2: Merges in Roger Pilkey's fix for the case in which date spans
+# cross the millenium boundary. Use GNU tac instead of tail, which can't
# reverse large files properly.
#
# 1.3: Merges in Brian Berliner's branch hack from the other fork
-# of this script, the one distributed with CVS. That and four SCCS
+# of this script, the one distributed with CVS. That and four SCCS
# keyword substitutions were the only thing it did that this didn't.
#
# 1.4: Python rewrite described above. Interface cleanup. Auto-checkout
def is_sccsmaster(f):
return os.path.basename(f).startswith("s.")
-
+
def workfile(f):
assert os.path.basename(f).startswith("s.")
return os.path.basename(f)[2:]
def do_it(command):
global logtext
logtext += "$ " + command + "\n"
- (st, out) = commands.getstatusoutput(command)
+ (_, out) = commands.getstatusoutput(command)
logtext += out + "\n"
return out + "\n"
def die(msg):
print >>sys.stderr, "sccs2rcs: fatal error, ", msg
record("error recovery begins")
- for master in os.listdir("SCCS"):
- if is_sccsmaster(master):
- do_it("unget " + master)
+ for sccsfile in os.listdir("SCCS"):
+ if is_sccsmaster(sccsfile):
+ do_it("unget " + sccsfile)
print >>sys.stderr, """\
Danger! Danger!
Incomplete history in ./RCS -- remove it.
"""
if logtext:
if logfile:
- wfp = open(logfile, "w")
- wfp.write(logtext)
- wfp.close()
+ lfp = open(logfile, "w")
+ lfp.write(logtext)
+ lfp.close()
else:
print "Log follows:"
print logtext
def warn(msg):
global logtext
msg = "sccs2rcs: warning, " + msg
- logtext += msg + "\n"
+ logtext += msg + "\n"
print >>sys.stderr, msg
def do_it_or_die(command):
logfile = val
# User may have supplied a comments file
- initstrings = {}
+ initstrings = {}
if comments:
for line in open(comments):
try:
# This assumption works under Debian/Ubuntu and will be harmless elsewhere.
os.environ["PATH"] += ":/usr/lib/cssc:/usr/lib/x86_64-linux-gnu/cssc"
- logtext = ""
+ logtext = ""
# Sanity checks on the directory
if not writeable("."):
if os.path.exists(stem):
workfiles.append(stem)
- # Extract a list of revisions from the master
+ # Extract a list of revisions from the master
revisions = []
try:
for line in os.popen("prs " + sccsmaster(stem), "r"):
try:
(day, month, year, tod, author) = date.split()
except ValueError:
- die("prs output %s from '%s'was ill-formed" % (`date`, cmd))
+ die("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.
rcsdate = day + " " + months[int(month)-1] + " " + year + " " + tod
progress("==> file %s, rev=%s, date=%s, author=%s" \
- % (stem, rev, rcsdate, author))
+ % (stem, rev, rcsdate, author))
do_it_or_die("get -e -r%s %s" % (rev, sccsmaster(stem)))
record("checked out of SCCS")
do_it_or_die(cmd)
record("initial checkin successful")
else:
- # get RCS lock
+ # get RCS lock
revparts = rev.split(".")
lckrev = ".".join(revparts[:-1])
if rev.count(".") > 1:
deltalines.pop(0)
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
+ # FIX-ME: output of this command isn't logged
record("$ " + cmd)
try:
cfp = os.popen(cmd, "w")