]> thyrsus.com Git - rcs-fast-import.git/commitdiff
Handle renames better.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 11 Nov 2010 20:55:38 +0000 (15:55 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 11 Nov 2010 20:55:38 +0000 (15:55 -0500)
rcs-fast-import

index e470926a6bddc88c9adb54d8731a9021a3f7d255..ca58903a50c84adb9752cae8274ebe5bea7077ed 100755 (executable)
@@ -607,33 +607,30 @@ class RCS:
         # FIXME: Someday, do real branch structure here.
         if event.is_tip():
             do_or_die("rcs -n'%s': %s" % (event.branch, " ".join(RCS.rcsfiles())))
-    def delete(self, commit, path):
-        "Mark a path deleted."
+    def delete(self, commit, path, legend="Delete"):
+        "Mark a path deleted, but don't actually remove the master."
         file(path, "w").close()
-        if roundtrip:
-            comment = event.email_out()
-        else:
-            comment = event.comment
         command = "ci -l"
-        command += " -sDeleted" 
+        command += " -s" + legend
         command += " -d'%s'" % event.committer.date.rfc822()
-        command += ' -m"%s"' % comment.replace('"', '\\"')
+        command += ' -m"%s of %s"' % (legend, path)
         command += " " + path + " " + RCS.master(path)
+        do_or_die(command, legend.lower())
         os.remove(path)
-    def rename(self, source, target):
-        "Perform RCS renames."
-        # Dodgy, but since user is more likely to be
-        # interested in later versions this is better
-        # than doing nothing.
-        os.rename(RCS.master(op.source), RCS.master(op.target))
     def copy(self, source, target):
-        "Perform RCS copies. Start the copy with no history"
+        "Perform RCS copies. Start the copy with no history."
         uphere = os.path.basename(target)
         do_or_die("co %s" % RCS.master(source), "copy checkout")
         os.rename(source, here)
         do_or_die("ci -i -m'Copy of %s' -l %s %s"
-                  % (source, uphere, RCS.master(target)))
+                  % (source, uphere, RCS.master(target)),
+                  "copy")
         os.remove(uphere)
+    def rename(self, commit, source, target):
+        "Perform RCS renames, carrying history with the rename."
+        shutil.copy(RCS.master(op.source), RCS.master(op.target))
+        # History is *not* removed from the source
+        self.delete(commit, source, legend="Rename")
     def checkout(self, switch):
         "Post-conversion actions."
         if switch != '-l':
@@ -684,7 +681,7 @@ if __name__ == '__main__':
                         if verbose:
                             announce("%5s R '%s' '%s'" % (event.mark, op.source, op.target))
                         if not dryrun:
-                            vcs.rename(op.source, op.target)
+                            vcs.rename(event, op.source, op.target)
                     elif op.op == "C":
                         if verbose:
                             announce("%5s C '%s' '%s'" % (event.mark, op.source, op.target))