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
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)
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()
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:
wfp.close()
except OSError:
die("keyword substitution failed")
- progress("performed keyword substitutions")
+ record("performed keyword substitutions")
# check file into RCS
if firsttime:
% (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(".")
# 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...")