--- 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:
--- 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)
--- 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 *
--- 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