~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-05-07 17:47:41 UTC
  • mfrom: (4325.3.9 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090507174741-gavb04vy1c6s0w9n
(Johan Walles) fix bug #180116 by using a sort() and linear operation
        for osutils.minimum_path_selection()

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
 
98
98
    :param paths: A container (and hence not None) of paths.
99
99
    :return: A set of paths sufficient to include everything in paths via
100
 
        is_inside_any, drawn from the paths parameter.
 
100
        is_inside, 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
    if len(paths) < 2:
 
103
        return set(paths)
 
104
 
 
105
    def sort_key(path):
 
106
        return path.split('/')
 
107
    sorted_paths = sorted(list(paths), key=sort_key)
 
108
 
 
109
    search_paths = [sorted_paths[0]]
 
110
    for path in sorted_paths[1:]:
 
111
        if not is_inside(search_paths[-1], path):
 
112
            # This path is unique, add it
 
113
            search_paths.append(path)
 
114
 
 
115
    return set(search_paths)
110
116
 
111
117
 
112
118
_QUOTE_RE = None
1756
1762
 
1757
1763
def re_compile_checked(re_string, flags=0, where=""):
1758
1764
    """Return a compiled re, or raise a sensible error.
1759
 
    
 
1765
 
1760
1766
    This should only be used when compiling user-supplied REs.
1761
1767
 
1762
1768
    :param re_string: Text form of regular expression.
1763
1769
    :param flags: eg re.IGNORECASE
1764
 
    :param where: Message explaining to the user the context where 
 
1770
    :param where: Message explaining to the user the context where
1765
1771
        it occurred, eg 'log search filter'.
1766
1772
    """
1767
1773
    # from https://bugs.launchpad.net/bzr/+bug/251352