From: Eric S. Raymond Date: Sat, 13 Nov 2010 20:44:48 +0000 (-0500) Subject: Move more code into parent class. X-Git-Tag: 0.1~26 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=b1a8a2bd038abf56f48288575b2134165ec61be8;p=rcs-fast-import.git Move more code into parent class. --- diff --git a/rcs-fast-import b/rcs-fast-import index d2aa450..d9f56a7 100755 --- a/rcs-fast-import +++ b/rcs-fast-import @@ -618,6 +618,22 @@ class Generic: def precommit(self, event): #self.record("commit") pass + def modify(self, event, path, mode, copyfile): + "Perform RCS file checkins and modifications," + self.sanecheck(event, path, mode, copyfile) + self.instantiate(path, copyfile) + self.checkin(event, path, "modify") + #self.record("M", path) + def copy(self, commit, source, target, legend="Copy"): + "Perform RCS copies. Start the copy with no history." + if os.path.exists(self.master(target)): + raise FatalException("copy to existing file") + self.checkout(commit, source, legend) + self.instantiate(target) + loud_rename(source, target) + self.checkin(commit, target, legend="copy") + #self.record("C", source) + #self.record("T", target) def delete(self, commit, path, legend="delete"): "Mark a path deleted, but don't actually remove the master." self.instantiate(path) @@ -638,6 +654,9 @@ class RCS(Generic): value = value[:-1] return value raise FatalException("missing '%s' in %s" % (header, master)) + def sanecheck(self, event, path, mode, copyfile): + if mode == "160000": + raise FatalException("ignoring a submodule link %s", path) def checkin(self, commit, path, legend, state=None): "Check in a new revision - also used to create new masters." if self.roundtrip: @@ -652,24 +671,9 @@ class RCS(Generic): command += " " + path + " " + self.master(path) do_or_die(command, legend) loud_remove(path) - def modify(self, event, path, mode, copyfile): - "Perform RCS file checkins and modifications," - if mode == "160000": - raise FatalException("ignoring a submodule link %s", path) - else: - self.instantiate(path, copyfile) - self.checkin(event, path, "modify") - #self.record("M", path) - def copy(self, commit, source, target, legend="Copy"): - "Perform RCS copies. Start the copy with no history." - if os.path.exists(self.master(target)): - raise FatalException("copy to existing file") + def checkout(self, commit, source, legend): + # FIXME: not presently adjusted for commit's branch do_or_die("co %s" % self.master(source), legend) - self.instantiate(target) - loud_rename(source, target) - self.checkin(commit, target, legend="copy") - #self.record("C", source) - #self.record("T", target) def postcommit(self, event): # Save annotated tags for round-tripping for tag in event.taglist: @@ -679,7 +683,7 @@ class RCS(Generic): % (tag.name, tag.tagger.date.rfc822())) os.remove("ANNOTATED-TAGS") do_or_die("rcs -n'%s': %s" % (tag.name, " ".join(self.masterfiles()))) - def checkout(self, switch): + def postactions(self, switch): "Post-conversion actions." if switch != '-l': do_or_die("rcs -u %s" % (" ".join(self.masterfiles()),)) @@ -751,7 +755,7 @@ if __name__ == '__main__': os.chdir(here) finally: nuke(tempdir, "cleaning up") - vcs.checkout(checkout_mode) + vcs.postactions(checkout_mode) raise SystemExit, 0 except FatalException, e: complain(e.msg)