From 7af1b4e61a329bc2bf7aa6be1690ed686dcecab5 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 13 Nov 2010 16:24:09 -0500 Subject: [PATCH] Yet more refactoring. --- rcs-fast-import | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/rcs-fast-import b/rcs-fast-import index 16f1bdc..c42bbf0 100755 --- a/rcs-fast-import +++ b/rcs-fast-import @@ -569,30 +569,30 @@ def loud_rename(source, target): # # All VCS-specific code is beyond this point. At the moment there's # just one VCS class, for RCS, but it would be easy to write another -# for, say, SCCS. +# subclass for, say, SCCS. # +# The Generic class assumes that the VCS is file-oriented and that +# the checkout tool can operate from a top-level directory to check +# our working-file paths. It also assumes that we have to stuff +# commit metadata in comments as RFC822 headers if we want to keep it. class Generic: "Generic file-oriented VCS - could be used for, say. SCCS as well as RCS." def __init__(self): self.roundtrip = False if verbose: - if not os.path.exists(self.__class__.repodir): + if not os.path.exists(self.__class__.repodirectory): try: - os.makedirs(self.__class__.repodir) + os.makedirs(self.__class__.repodirectory) except OSError: raise FatalException("can't create RCS directory.") def master(self, filename): "Return the master file corresponding to a specified filename." parts = list(os.path.split(filename)) - parts.insert(-1, self.__class__.repodir) - return os.path.join(*parts) + ",v" - def rename(self, commit, source, target): - "Perform RCS renames, carrying history with the rename." - self.copy(commit, source, target, legend="Rename") - self.delete(commit, source, legend="Rename") + parts.insert(-1, self.__class__.repodirectory) + return self.__class__.mastertemplate % os.path.join(*parts) def instantiate(self, path, copyfile=None): - rcsdir = os.path.join(os.path.dirname(path), self.__class__.repodir) + rcsdir = os.path.join(os.path.dirname(path), self.__class__.repodirectory) if not os.path.exists(rcsdir): try: os.makedirs(rcsdir) @@ -611,7 +611,7 @@ class Generic: "List all masters." res = [] for root, dirs, files in os.walk(os.getcwd(), topdown=False): - if root.endswith(os.sep + self.__class__.repodir): + if root.endswith(os.sep + self.__class__.repodirectory): for name in files: res.append(os.path.join(root, name)) return res @@ -648,10 +648,15 @@ class Generic: open(path, "w").close() self.supercheckin(commit, "D", path, "delete") #self.record("D", path) + def rename(self, commit, source, target): + "Perform RCS renames, carrying history with the rename." + self.copy(commit, source, target, legend="Rename") + self.delete(commit, source, legend="Rename") class RCS(Generic): "Class encapsulating RCS version-control operations." - repodir = "RCS" + repodirectory = "RCS" + mastertemplate = "%s,v" def gethdr(self, path, header): "Retrieve a required header from a master file" master = self.master(path) @@ -755,7 +760,8 @@ if __name__ == '__main__': else: raise FatalException("unknown op type %s" % op.op) vcs.postcommit(event) - loud_rename(vcs.repodir, os.path.join(here, vcs.repodir)) + loud_rename(vcs.repodirectory, + os.path.join(here, vcs.repodirectory)) os.chdir(here) finally: nuke(tempdir, "cleaning up") -- 2.43.0