=== modified file 'exporters/bzr-fast-export.py' --- exporters/bzr-fast-export.py 2008-09-23 03:13:28 +0000 +++ exporters/bzr-fast-export.py 2008-10-17 20:14:17 +0000 @@ -200,29 +200,84 @@ class BzrFastExporter: sys.stdout.write('D %s\n' % (self.my_quote(path),)) my_modified.append((path, id_, kind2)) - # We have to keep track of previous renames in this commit + # Iterate through renamed files (to find conflicts) + # of type mv a t; mv b a; mv t b + renames = {} + for (oldpath, newpath, id_, kind, + text_modified, meta_modified) in changes.renamed: + + if (self.is_empty_dir(tree_old, oldpath)): + sys.stderr.write("Skipping empty dir %s in rev %s\n" % + (oldpath, revobj.revision_id)) + continue + + if text_modified or meta_modified: + my_modified.append((newpath, id_, kind)) + + renames[oldpath] = newpath + + # renames all directories that dont have conflict directly + # and those with conflict to a temp-name + tmp_renames = {} + # keep track of renamed directories for recursive rename renamed = {} for (oldpath, newpath, id_, kind, text_modified, meta_modified) in changes.renamed: - + + if kind not in ('directory'): + continue + if (self.is_empty_dir(tree_old, oldpath)): - sys.stderr.write("Skipping empty dir %s in rev %s\n" % (oldpath, revobj.revision_id)) continue + renamed[oldpath] = newpath + + if renames.has_key(newpath): + tmppath = oldpath + "." + id_ + tmp_renames[tmppath] = newpath + sys.stdout.write('R %s %s\n' % (self.my_quote(oldpath, True), + self.my_quote(tmppath))) + else: + sys.stdout.write('R %s %s\n' % (self.my_quote(oldpath, True), + self.my_quote(newpath))) + + # and rename the temp files to correct new names + for old, new in tmp_renames.iteritems(): + sys.stdout.write('R %s %s\n' % (self.my_quote(old, True), + self.my_quote(new))) + + # renames all files that dont have conflict directly + # and those with conflict to a temp-name + tmp_renames = {} + for (oldpath, newpath, id_, kind, + text_modified, meta_modified) in changes.renamed: + + if kind in ('directory'): + continue + + tmpoldpath = oldpath for old, new in renamed.iteritems(): # If a previous rename is found in this rename, we should # adjust the path - if old in oldpath: - oldpath = oldpath.replace(old + "/", new + "/") - self.debug("Fixing recursive rename for %s" % oldpath) - - renamed[oldpath] = newpath - - sys.stdout.write('R %s %s\n' % (self.my_quote(oldpath, True), - self.my_quote(newpath))) - if text_modified or meta_modified: - my_modified.append((newpath, id_, kind)) + if old in tmpoldpath: + tmpoldpath = tmpoldpath.replace(old + "/", new + "/") + self.debug("Fixing recursive rename for %s" % tmpoldpath) + break + + if renames.has_key(newpath): + tmppath = tmpoldpath + "." + id_ + tmp_renames[tmppath] = newpath + sys.stdout.write('R %s %s\n' % (self.my_quote(tmpoldpath, True), + self.my_quote(tmppath))) + else: + sys.stdout.write('R %s %s\n' % (self.my_quote(tmpoldpath, True), + self.my_quote(newpath))) + # and rename the temp files to correct new names + for old, new in tmp_renames.iteritems(): + sys.stdout.write('R %s %s\n' % (self.my_quote(old, True), + self.my_quote(new))) + for path, id_, kind in changes.added + my_modified: if kind in ('file', 'symlink'): entry = tree_new.inventory[id_]