~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-04-21 15:11:39 UTC
  • mfrom: (2438.1.16 rename_directory_105479)
  • Revision ID: pqm@pqm.ubuntu.com-20070421151139-5wau2ukbpx5z1hv2
(John Arbash Meinel) Fix bug #105479: properly handle moving a directory with children that have been added, renamed, removed

Show diffs side-by-side

added added

removed removed

Lines of Context:
670
670
            new_entry = to_block[1][added_entry_index]
671
671
            rollbacks.append(lambda:state._make_absent(new_entry))
672
672
 
673
 
        # create rename entries and tuples
674
673
        for from_rel in from_paths:
675
674
            # from_rel is 'pathinroot/foo/bar'
676
675
            from_rel_utf8 = from_rel.encode('utf8')
774
773
 
775
774
                if minikind == 'd':
776
775
                    def update_dirblock(from_dir, to_key, to_dir_utf8):
777
 
                        """all entries in this block need updating.
778
 
 
779
 
                        TODO: This is pretty ugly, and doesn't support
780
 
                        reverting, but it works.
781
 
                        """
 
776
                        """Recursively update all entries in this dirblock."""
782
777
                        assert from_dir != '', "renaming root not supported"
783
778
                        from_key = (from_dir, '')
784
779
                        from_block_idx, present = \
795
790
                        to_block_index = state._ensure_block(
796
791
                            to_block_index, to_entry_index, to_dir_utf8)
797
792
                        to_block = state._dirblocks[to_block_index]
798
 
                        for entry in from_block[1]:
 
793
 
 
794
                        # Grab a copy since move_one may update the list.
 
795
                        for entry in from_block[1][:]:
799
796
                            assert entry[0][0] == from_dir
800
797
                            cur_details = entry[1][0]
801
798
                            to_key = (to_dir_utf8, entry[0][1], entry[0][2])
802
799
                            from_path_utf8 = osutils.pathjoin(entry[0][0], entry[0][1])
803
800
                            to_path_utf8 = osutils.pathjoin(to_dir_utf8, entry[0][1])
804
801
                            minikind = cur_details[0]
 
802
                            if minikind in 'ar':
 
803
                                # Deleted children of a renamed directory
 
804
                                # Do not need to be updated.
 
805
                                # Children that have been renamed out of this
 
806
                                # directory should also not be updated
 
807
                                continue
805
808
                            move_one(entry, from_path_utf8=from_path_utf8,
806
809
                                     minikind=minikind,
807
810
                                     executable=cur_details[3],
1920
1923
                    #       parent entry will be the same as the source entry.
1921
1924
                    target_parent_entry = state._get_entry(target_index,
1922
1925
                                                           path_utf8=new_dirname)
 
1926
                    assert target_parent_entry != (None, None), (
 
1927
                        "Could not find target parent in wt: %s\nparent of: %s"
 
1928
                        % (new_dirname, entry))
1923
1929
                    target_parent_id = target_parent_entry[0][2]
1924
1930
                    if target_parent_id == entry[0][2]:
1925
1931
                        # This is the root, so the parent is None