/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Robert Collins
  • Date: 2007-09-20 07:03:33 UTC
  • mto: (2843.1.1 ianc-integration2)
  • mto: This revision was merged to the branch mainline in revision 2844.
  • Revision ID: robertc@robertcollins.net-20070920070333-eedxrxidkignx4i1
* Partial commits are now approximately 40% faster by walking over the
  unselected current tree more efficiently. (Robert Collins)

* New method ``bzrlib.osutils.minimum_path_selection`` useful for removing
  duplication from user input, when a user mentions both a path and an item
  contained within that path. (Robert Collins)

* New parameter yield_parents on ``Inventory.iter_entries_by_dir`` which
  causes the parents of a selected id to be returned recursively, so all the
  paths from the root down to each element of selected_file_ids are
  returned. (Robert Collins)

Show diffs side-by-side

added added

removed removed

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