summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Clatworthy <ian.clatworthy@internode.on.net>2009-04-07 06:30:19 +1000
committerIan Clatworthy <ian.clatworthy@internode.on.net>2009-04-07 06:30:19 +1000
commit62909e699260d5378c41551dd2db9ac61184b159 (patch)
tree513247b2e72a0f6d678aa12c1d93c9acf82cddcd
parent2b7738fe863626e2d90d8dadb2786fa888795413 (diff)
downloadpython-fastimport-62909e699260d5378c41551dd2db9ac61184b159.tar.gz
fix rename adjustment & kind change logic in fast-export
-rwxr-xr-xbzr_exporter.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/bzr_exporter.py b/bzr_exporter.py
index 3cda615..399dea7 100755
--- a/bzr_exporter.py
+++ b/bzr_exporter.py
@@ -284,12 +284,7 @@ class BzrFastExporter(object):
self.note("Skipping empty dir %s in rev %s" % (oldpath,
revision_id))
continue
- for old, new in renamed:
- # If a previous rename is found in this rename, we should
- # adjust the path
- if old in oldpath:
- oldpath = oldpath.replace(old + "/", new + "/")
- self.note("Fixing recursive rename for %s" % oldpath)
+ oldpath = self._adjust_path_for_renames(oldpath, renamed)
renamed.append([oldpath, newpath])
file_cmds.append(commands.FileRenameCommand(oldpath, newpath))
if text_modified or meta_modified:
@@ -297,15 +292,16 @@ class BzrFastExporter(object):
# Record deletes
for path, id_, kind in changes.removed:
- for old, new in renamed:
- path = path.replace(old + "/", new + "/")
+ path = self._adjust_path_for_renames(path, renamed)
file_cmds.append(commands.FileDeleteCommand(path))
# Map kind changes to a delete followed by an add
for path, id_, kind1, kind2 in changes.kind_changed:
- for old, new in renamed:
- path = path.replace(old + "/", new + "/")
- file_cmds.append(commands.FileDeleteCommand(path))
+ path = self._adjust_path_for_renames(path, renamed)
+ # IGC: I don't understand why a delete is needed here.
+ # In fact, it seems harmful? If you uncomment this line,
+ # please file a bug explaining why you needed to.
+ #file_cmds.append(commands.FileDeleteCommand(path))
my_modified.append((path, id_, kind2))
# Record modifications
@@ -323,6 +319,18 @@ class BzrFastExporter(object):
continue
return file_cmds
+ def _adjust_path_for_renames(self, path, renamed):
+ # If a previous rename is found, we should adjust the path
+ for old, new in renamed:
+ if path == old:
+ self.note("Changing path %s given rename to %s" % (path, new))
+ path = new
+ elif path.startswith(old + '/'):
+ self.note("Adjusting path %s given rename of %s to %s" %
+ (path, old, new))
+ path = path.replace(old + "/", new + "/")
+ return path
+
def emit_tags(self):
for tag, revid in self.branch.tags.get_tag_dict().items():
try: