From c57cb20afda358880ef5b50aaa003457b51bbc36 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 11 Nov 2010 15:55:38 -0500 Subject: [PATCH] Handle renames better. --- rcs-fast-import | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/rcs-fast-import b/rcs-fast-import index e470926..ca58903 100755 --- a/rcs-fast-import +++ b/rcs-fast-import @@ -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)) -- 2.43.0