vcs = RCS()
try:
with Repository() as repo:
- repo.fast_import(sys.stdin, progress=verbose>0)
- repo.roundtrip = roundtrip
- for event in repo.commits():
- vcs.precommit(event)
- for op in event.fileops:
- if op.op == "M":
- if verbose:
- announce("%5s M %s" % (event.mark, op.path))
- if op.mode == "160000":
- complain("cannot represent a submodule link in RCS")
+ here = os.getcwd()
+ tempdir = "rcs-fast-import-" + `os.getpid()`
+ try:
+ try:
+ os.mkdir(tempdir)
+ os.chdir(tempdir)
+ except OSError:
+ raise FatalException("Couldn't create working directory.")
+ repo.fast_import(sys.stdin, progress=verbose>0)
+ repo.roundtrip = roundtrip
+ for event in repo.commits():
+ vcs.precommit(event)
+ for op in event.fileops:
+ if op.op == "M":
+ if verbose:
+ announce("%5s M %s" % (event.mark, op.path))
+ if op.mode == "160000":
+ complain("cannot represent a submodule link in RCS")
+ else:
+ vcs.modify(event, op.path, op.mode, op.copyname)
+ elif op.op in ("D", "deleteall"):
+ if verbose:
+ announce("%5s D %s" % (event.mark, op.path))
+ if not dryrun:
+ vcs.remove(op.path)
+ elif op.op == "R":
+ if verbose:
+ announce("%5s R '%s' '%s'" % (event.mark, op.source, op.target))
+ if not dryrun:
+ vcs.rename(event, op.source, op.target)
+ elif op.op == "C":
+ if verbose:
+ announce("%5s C '%s' '%s'" % (event.mark, op.source, op.target))
+ if not dryrun:
+ vcs.copy(commit, ops.source, op.target)
else:
- vcs.modify(event, op.path, op.mode, op.copyname)
- elif op.op in ("D", "deleteall"):
- if verbose:
- announce("%5s D %s" % (event.mark, op.path))
- if not dryrun:
- vcs.remove(op.path)
- elif op.op == "R":
- if verbose:
- announce("%5s R '%s' '%s'" % (event.mark, op.source, op.target))
- if not dryrun:
- vcs.rename(event, op.source, op.target)
- elif op.op == "C":
- if verbose:
- announce("%5s C '%s' '%s'" % (event.mark, op.source, op.target))
- if not dryrun:
- vcs.copy(commit, ops.source, op.target)
- else:
- raise FatalException("unknown op type %s" % op.op)
- vcs.postcommit(event)
+ raise FatalException("unknown op type %s" % op.op)
+ vcs.postcommit(event)
+ loud_rename("RCS", os.path.join(here, "RCS"))
+ os.chdir(here)
+ finally:
+ nuke(tempdir, "cleaning up")
vcs.checkout(checkout_mode)
raise SystemExit, 0
except FatalException, e:
stdin into individual RCS master files in RCS subdirectories of the
corresponding directory structure.</para>
-<para>It is recommended that you run this in an empty directory, as it
-will terminate with error rather than stepping on files that already
-exist in the current directory.</para>
+<para>It is recommended that you run this in an empty directory, as the
+checkout of the RCS files may step on files that exist in the current
+directory.</para>
<para>Normally, committer and author data are written into each comment as
RFC-822 mail headers, followed by a blank line. The -p option suppresses