~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

Fix the behaviour of dirstate optimised iter_changes recursing its disk iterator into subtrees inappropriately.

Show diffs side-by-side

added added

removed removed

Lines of Context:
305
305
        self._inventory = None
306
306
        self._dirty = False
307
307
 
 
308
    @needs_tree_write_lock
 
309
    def _gather_kinds(self, files, kinds):
 
310
        """See MutableTree._gather_kinds."""
 
311
        for pos, f in enumerate(files):
 
312
            if kinds[pos] is None:
 
313
                kinds[pos] = self._kind(f)
 
314
 
308
315
    def _generate_inventory(self):
309
316
        """Create and set self.inventory from the dirstate object.
310
317
        
1863
1870
                        last_source_parent[0] = old_dirname
1864
1871
                        last_source_parent[1] = source_parent_id
1865
1872
                        last_source_parent[2] = source_parent_entry
1866
 
 
1867
1873
                new_dirname = entry[0][0]
1868
1874
                if new_dirname == last_target_parent[0]:
1869
1875
                    target_parent_id = last_target_parent[1]
1950
1956
                    % (source_minikind, target_minikind))
1951
1957
                ## import pdb;pdb.set_trace()
1952
1958
            return ()
 
1959
 
1953
1960
        while search_specific_files:
1954
1961
            # TODO: the pending list should be lexically sorted?  the
1955
1962
            # interface doesn't require it.
2008
2015
                    (None, None),
2009
2016
                    (None, splitpath(current_root)[-1]),
2010
2017
                    (None, root_dir_info[2]), (None, new_executable))
2011
 
            dir_iterator = osutils._walkdirs_utf8(root_abspath, prefix=current_root)
2012
2018
            initial_key = (current_root, '', '')
2013
2019
            block_index, _ = state._find_block_index_from_key(initial_key)
2014
2020
            if block_index == 0:
2015
2021
                # we have processed the total root already, but because the
2016
2022
                # initial key matched it we should skip it here.
2017
2023
                block_index +=1
2018
 
            try:
2019
 
                current_dir_info = dir_iterator.next()
2020
 
            except OSError, e:
2021
 
                if e.errno in (errno.ENOENT, errno.ENOTDIR):
2022
 
                    # there may be directories in the inventory even though
2023
 
                    # this path is not a file on disk: so mark it as end of
2024
 
                    # iterator
2025
 
                    current_dir_info = None
 
2024
            if root_dir_info and root_dir_info[2] == 'tree-reference':
 
2025
                current_dir_info = None
 
2026
            else:
 
2027
                dir_iterator = osutils._walkdirs_utf8(root_abspath, prefix=current_root)
 
2028
                try:
 
2029
                    current_dir_info = dir_iterator.next()
 
2030
                except OSError, e:
 
2031
                    if e.errno in (errno.ENOENT, errno.ENOTDIR):
 
2032
                        # there may be directories in the inventory even though
 
2033
                        # this path is not a file on disk: so mark it as end of
 
2034
                        # iterator
 
2035
                        current_dir_info = None
 
2036
                    else:
 
2037
                        raise
2026
2038
                else:
2027
 
                    raise
2028
 
            else:
2029
 
                if current_dir_info[0][0] == '':
2030
 
                    # remove .bzr from iteration
2031
 
                    bzr_index = bisect_left(current_dir_info[1], ('.bzr',))
2032
 
                    assert current_dir_info[1][bzr_index][0] == '.bzr'
2033
 
                    del current_dir_info[1][bzr_index]
 
2039
                    if current_dir_info[0][0] == '':
 
2040
                        # remove .bzr from iteration
 
2041
                        bzr_index = bisect_left(current_dir_info[1], ('.bzr',))
 
2042
                        assert current_dir_info[1][bzr_index][0] == '.bzr'
 
2043
                        del current_dir_info[1][bzr_index]
2034
2044
            # walk until both the directory listing and the versioned metadata
2035
2045
            # are exhausted. 
2036
2046
            if (block_index < len(state._dirblocks) and
2202
2212
                                        (None, new_executable))
2203
2213
                            # dont descend into this unversioned path if it is
2204
2214
                            # a dir
2205
 
                            if current_path_info[2] in (
2206
 
                                'directory', 'tree-referene'):
 
2215
                            if current_path_info[2] in ('directory'):
2207
2216
                                del current_dir_info[1][path_index]
2208
2217
                                path_index -= 1
 
2218
                        # dont descend the disk iterator into any tree 
 
2219
                        # paths.
 
2220
                        if current_path_info[2] == 'tree-reference':
 
2221
                            del current_dir_info[1][path_index]
 
2222
                            path_index -= 1
2209
2223
                        path_index += 1
2210
2224
                        if path_index < len(current_dir_info[1]):
2211
2225
                            current_path_info = current_dir_info[1][path_index]