~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

Faster partial commits by walking less data (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1011
1011
                # if we finished all children, pop it off the stack
1012
1012
                stack.pop()
1013
1013
 
1014
 
    def iter_entries_by_dir(self, from_dir=None, specific_file_ids=None):
 
1014
    def iter_entries_by_dir(self, from_dir=None, specific_file_ids=None,
 
1015
        yield_parents=False):
1015
1016
        """Iterate over the entries in a directory first order.
1016
1017
 
1017
1018
        This returns all entries for a directory before returning
1019
1020
        lexicographically sorted order, and is a hybrid between
1020
1021
        depth-first and breadth-first.
1021
1022
 
 
1023
        :param yield_parents: If True, yield the parents from the root leading
 
1024
            down to specific_file_ids that have been requested. This has no
 
1025
            impact if specific_file_ids is None.
1022
1026
        :return: This yields (path, entry) pairs
1023
1027
        """
1024
1028
        if specific_file_ids:
1030
1034
            if self.root is None:
1031
1035
                return
1032
1036
            # Optimize a common case
1033
 
            if specific_file_ids is not None and len(specific_file_ids) == 1:
 
1037
            if (not yield_parents and specific_file_ids is not None and
 
1038
                len(specific_file_ids) == 1):
1034
1039
                file_id = list(specific_file_ids)[0]
1035
1040
                if file_id in self:
1036
1041
                    yield self.id2path(file_id), self[file_id]
1037
1042
                return 
1038
1043
            from_dir = self.root
1039
 
            if (specific_file_ids is None or 
 
1044
            if (specific_file_ids is None or yield_parents or
1040
1045
                self.root.file_id in specific_file_ids):
1041
1046
                yield u'', self.root
1042
1047
        elif isinstance(from_dir, basestring):
1071
1076
                child_relpath = cur_relpath + child_name
1072
1077
 
1073
1078
                if (specific_file_ids is None or 
1074
 
                    child_ie.file_id in specific_file_ids):
 
1079
                    child_ie.file_id in specific_file_ids or
 
1080
                    (yield_parents and child_ie.file_id in parents)):
1075
1081
                    yield child_relpath, child_ie
1076
1082
 
1077
1083
                if child_ie.kind == 'directory':