updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / bzr-fastimport-deleted-entries-fix / fix-deleted-entries-in-renamed-directory.patch
blob031ea005f9eea962139f846562be5e2ec4907de2
1 diff --git a/exporter.py b/exporter.py
2 index 6d1a9c0..d1b358f 100644
3 --- a/exporter.py
4 +++ b/exporter.py
5 @@ -413,6 +413,7 @@ class BzrFastExporter(object):
7 # 1) bzr rm a; bzr mv b a; bzr commit
8 # 2) bzr mv x/y z; bzr rm x; commmit
9 + # 3) bzr mv x y; bzr rm y/z; bzr commit
11 # The first must come out with the delete first like this:
13 @@ -424,6 +425,11 @@ class BzrFastExporter(object):
14 # R x/y z
15 # D x
17 + # The third case must come out with delete first like this:
18 + #
19 + # D x/z
20 + # R x y
21 + #
22 # So outputting all deletes first or all renames first won't work.
23 # Instead, we need to make multiple passes over the various lists to
24 # get the ordering right.
25 @@ -431,6 +437,7 @@ class BzrFastExporter(object):
26 must_be_renamed = {}
27 old_to_new = {}
28 deleted_paths = set([p for p, _, _ in deletes])
29 + deleted_child_paths = set()
30 for (oldpath, newpath, id_, kind,
31 text_modified, meta_modified) in renames:
32 emit = kind != 'directory' or not self.plain_format
33 @@ -442,6 +449,17 @@ class BzrFastExporter(object):
34 self.note("Skipping empty dir %s in rev %s" % (oldpath,
35 revision_id))
36 continue
38 + if kind == 'directory':
39 + # handling deleted children in renamed directory (case 3 above)
40 + for p, e in tree_old.inventory.iter_entries_by_dir(from_dir=id_):
41 + old_child_path = osutils.pathjoin(oldpath, p)
42 + new_child_path = osutils.pathjoin(newpath, p)
43 + if old_child_path in deleted_paths:
44 + file_cmds.append(commands.FileDeleteCommand(old_child_path.encode("utf-8")))
45 + deleted_paths.remove(old_child_path)
46 + deleted_child_paths.add(old_child_path)
48 #oldpath = self._adjust_path_for_renames(oldpath, renamed,
49 # revision_id)
50 renamed.append([oldpath, newpath])
51 @@ -460,6 +478,8 @@ class BzrFastExporter(object):
52 continue
53 old_child_path = osutils.pathjoin(oldpath, p)
54 new_child_path = osutils.pathjoin(newpath, p)
55 + if old_child_path in deleted_child_paths:
56 + continue
57 must_be_renamed[old_child_path] = new_child_path
59 # Add children not already renamed