Paste #RkQv6L04tlDMqKNVHg0A

a/exporter.py [2014-05-15 09:26:03 +0000]
b/exporter.py [2015-05-04 13:08:57 +0000]
514 514 #
515 515 # 1) bzr rm a; bzr mv b a; bzr commit
516 516 # 2) bzr mv x/y z; bzr rm x; commmit
517 # 3) bzr mv x y; bzr rm y/z; bzr commit
517 518 #
518 519 # The first must come out with the delete first like this:
519 520 #
525 526 # R x/y z
526 527 # D x
527 528 #
529 # The third case must come out with delete first like this:
530 #
531 # D x/z
532 # R x y
533 #
528 534 # So outputting all deletes first or all renames first won't work.
529 535 # Instead, we need to make multiple passes over the various lists to
530 536 # get the ordering right.
532 538 must_be_renamed = {}
533 539 old_to_new = {}
534 540 deleted_paths = set([p for p, _, _ in deletes])
541 deleted_child_paths = set()
535 542 for (oldpath, newpath, id_, kind,
536 543 text_modified, meta_modified) in renames:
537 544 emit = kind != 'directory' or not self.plain_format
543 550 self.note("Skipping empty dir %s in rev %s" % (oldpath,
544 551 revision_id))
545 552 continue
553
554 if kind == 'directory':
555 # handling deleted children in renamed directory (case 3 above)
556 for p, e in tree_old.inventory.iter_entries_by_dir(from_dir=id_):
557 if e.kind == 'directory' or not self.plain_format:
558 continue
559 old_child_path = osutils.pathjoin(oldpath, p)
560 new_child_path = osutils.pathjoin(newpath, p)
561 if old_child_path in deleted_paths:
562 file_cmds.append(commands.FileDeleteCommand(old_child_path.encode("utf-8")))
563 deleted_paths.remove(old_child_path)
564 deleted_child_paths.add(old_child_path)
565
566
546 567 #oldpath = self._adjust_path_for_renames(oldpath, renamed,
547 568 # revision_id)
548 569 renamed.append([oldpath, newpath])
561 582 continue
562 583 old_child_path = osutils.pathjoin(oldpath, p)
563 584 new_child_path = osutils.pathjoin(newpath, p)
585 if old_child_path in deleted_child_paths:
586 continue
564 587 must_be_renamed[old_child_path] = new_child_path
565 588
566 589 # Add children not already renamed