/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/osutils.py

  • Committer: Johan Walles
  • Date: 2009-05-05 06:02:29 UTC
  • mto: This revision was merged to the branch mainline in revision 4343.
  • Revision ID: johan.walles@gmail.com-20090505060229-lv655dd7wzkm7gs5
Use a linear algorithm for osutil.minimum_path_selection().

This speeds up "bzr rm *" operations a lot and resolves bazaar bug 180116.

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
    :return: A set of paths sufficient to include everything in paths via
100
100
        is_inside_any, drawn from the paths parameter.
101
101
    """
102
 
    search_paths = set()
103
 
    paths = set(paths)
104
 
    for path in paths:
105
 
        other_paths = paths.difference([path])
106
 
        if not is_inside_any(other_paths, path):
107
 
            # this is a top level path, we must check it.
108
 
            search_paths.add(path)
109
 
    return search_paths
 
102
    search_paths = []
 
103
    sorted_paths = list(paths)
 
104
    sorted_paths.sort()
 
105
    for path in sorted_paths:
 
106
        if len(search_paths) == 0:
 
107
            # Result is empty, add first path
 
108
            search_paths.append(path)
 
109
            continue
 
110
        if not is_inside(search_paths[-1], path):
 
111
            # This path is unique, add it
 
112
            search_paths.append(path)
 
113
            continue
 
114
    return set(search_paths)
110
115
 
111
116
 
112
117
_QUOTE_RE = None
1742
1747
 
1743
1748
def re_compile_checked(re_string, flags=0, where=""):
1744
1749
    """Return a compiled re, or raise a sensible error.
1745
 
    
 
1750
 
1746
1751
    This should only be used when compiling user-supplied REs.
1747
1752
 
1748
1753
    :param re_string: Text form of regular expression.
1749
1754
    :param flags: eg re.IGNORECASE
1750
 
    :param where: Message explaining to the user the context where 
 
1755
    :param where: Message explaining to the user the context where
1751
1756
        it occurred, eg 'log search filter'.
1752
1757
    """
1753
1758
    # from https://bugs.launchpad.net/bzr/+bug/251352