# HG changeset patch # User Alexis S. L. Carvalho # Date 1170189138 7200 # Node ID e6d54283c0905704c29f14425fe64423d5e93a38 # Parent 994fec0ee900a8901ea50998da729ed847b533f0 Explicitly expand globs on Windows diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -15,7 +15,7 @@ platform-specific details from the core. from i18n import gettext as _ from demandload import * demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile") -demandload(globals(), "os threading time calendar ConfigParser locale") +demandload(globals(), "os threading time calendar ConfigParser locale glob") _encoding = os.environ.get("HGENCODING") or locale.getpreferredencoding() \ or "ascii" @@ -234,6 +234,22 @@ class UnexpectedOutput(Abort): def always(fn): return True def never(fn): return False +def expand_glob(pats): + '''On Windows, expand the implicit globs in a list of patterns''' + if os.name != 'nt': + return list(pats) + ret = [] + for p in pats: + kind, name = patkind(p, None) + if kind is None: + globbed = glob.glob(name) + if globbed: + ret.extend(globbed) + continue + # if we couldn't expand the glob, just keep it around + ret.append(p) + return ret + def patkind(name, dflt_pat='glob'): """Split a string into an optional pattern kind prefix and the actual pattern.""" @@ -360,11 +376,8 @@ def matcher(canonroot, cwd='', names=['. return _matcher(canonroot, cwd, names, inc, exc, head, 'glob', src) def cmdmatcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head='', src=None): - if os.name == 'nt': - dflt_pat = 'glob' - else: - dflt_pat = 'relpath' - return _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src) + names = expand_glob(names) + return _matcher(canonroot, cwd, names, inc, exc, head, 'relpath', src) def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src): """build a function to match a set of file patterns