diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -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 @@ def make_file(repo, pat, node=None, 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 @@ def copy(ui, repo, pats, opts, rename=Fa 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 --git a/mercurial/posix.py b/mercurial/posix.py --- a/mercurial/posix.py +++ b/mercurial/posix.py @@ -13,6 +13,7 @@ posixfile = file nulldev = '/dev/null' normpath = os.path.normpath samestat = os.path.samestat +expandglobs = False umask = os.umask(0) os.umask(umask) diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -16,7 +16,7 @@ hide platform-specific details from the 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 @@ def lookup_reg(key, name=None, scope=Non 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 --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -280,3 +280,5 @@ try: from win32 import * except ImportError: pass + +expandglobs = True