# HG changeset patch # User Matt Mackall # Date 1243201109 18000 # Node ID 573734e7e6d0dcbc36e44ee6d8bb52e2844edc79 # Parent 4dea46d4e3f861a0b83181fcee2da82ed99fb045 cmdutils: Take over glob expansion duties from util diff -r 4dea46d4e3f8 -r 573734e7e6d0 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Sun May 24 16:37:34 2009 -0500 +++ b/mercurial/cmdutil.py Sun May 24 16:38:29 2009 -0500 @@ -7,7 +7,7 @@ from node import hex, nullid, nullrev, short from i18n import _ -import os, sys, bisect, stat, errno, re +import os, sys, bisect, stat, errno, re, glob import mdiff, bdiff, util, templater, patch, error, encoding import match as _match @@ -235,9 +235,23 @@ pathname), mode) +def expandpats(pats): + if not util.expandglobs: + return list(pats) + ret = [] + for p in pats: + kind, name = _match._patsplit(p, None) + if kind is None: + globbed = glob.glob(name) + if globbed: + ret.extend(globbed) + continue + ret.append(p) + return ret + def match(repo, pats=[], opts={}, globbed=False, default='relpath'): if not globbed and default == 'relpath': - pats = util.expand_glob(pats or []) + pats = expandpats(pats or []) m = _match.match(repo.root, repo.getcwd(), pats, opts.get('include'), opts.get('exclude'), default) def badfn(f, msg): @@ -487,7 +501,7 @@ return res - pats = util.expand_glob(pats) + pats = expandpats(pats) if not pats: raise util.Abort(_('no source or destination specified')) if len(pats) == 1: diff -r 4dea46d4e3f8 -r 573734e7e6d0 mercurial/posix.py --- a/mercurial/posix.py Sun May 24 16:37:34 2009 -0500 +++ b/mercurial/posix.py Sun May 24 16:38:29 2009 -0500 @@ -13,6 +13,7 @@ nulldev = '/dev/null' normpath = os.path.normpath samestat = os.path.samestat +expandglobs = False umask = os.umask(0) os.umask(umask) diff -r 4dea46d4e3f8 -r 573734e7e6d0 mercurial/util.py --- a/mercurial/util.py Sun May 24 16:37:34 2009 -0500 +++ b/mercurial/util.py Sun May 24 16:38:29 2009 -0500 @@ -16,7 +16,7 @@ from i18n import _ import error, osutil import cStringIO, errno, re, shutil, sys, tempfile, traceback -import os, stat, time, calendar, glob, random +import os, stat, time, calendar, random import imp # Python compatibility @@ -540,19 +540,6 @@ if os.name == 'nt': from windows import * - def expand_glob(pats): - '''On Windows, expand the implicit globs in a list of patterns''' - ret = [] - for p in pats: - kind, name = _patsplit(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 else: from posix import * diff -r 4dea46d4e3f8 -r 573734e7e6d0 mercurial/windows.py --- a/mercurial/windows.py Sun May 24 16:37:34 2009 -0500 +++ b/mercurial/windows.py Sun May 24 16:38:29 2009 -0500 @@ -280,3 +280,5 @@ from win32 import * except ImportError: pass + +expandglobs = True