]> thyrsus.com Git - rcs-fast-import.git/commitdiff
Move more code into parent class.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 13 Nov 2010 20:44:48 +0000 (15:44 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 13 Nov 2010 20:44:48 +0000 (15:44 -0500)
rcs-fast-import

index d2aa450cdb62164e9ac50971be7bc5f3be0c5f38..d9f56a77f75971a9dcb419fc5c1b13bc531e5b4f 100755 (executable)
@@ -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)