#
# 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)
"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
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)
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")