1 diff --git a/exporter.py b/exporter.py
2 index 6d1a9c0..d1b358f 100644
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):
17 + # The third case must come out with delete first like this:
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):
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,
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,
50 renamed.append([oldpath, newpath])
51 @@ -460,6 +478,8 @@ class BzrFastExporter(object):
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:
57 must_be_renamed[old_child_path] = new_child_path
59 # Add children not already renamed