[PATCH] Permit glob patterns to use nested curly braces
Jesse Glick
Jesse.Glick at Sun.COM
Fri Jan 25 14:55:40 CST 2008
# HG changeset patch
# User Jesse Glick <jesse.glick at sun.com>
# Date 1201294465 18000
# Node ID 45f47da4586b5e1fcf5147d05d317fb6ec78211f
# Parent 7316523eddf1577970d5fd7f050f5229b27af482
Permit glob patterns to use nested curly braces.
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -262,7 +262,7 @@ def globre(pat, head='^', tail='$'):
"convert a glob pattern into a regexp"
i, n = 0, len(pat)
res = ''
- group = False
+ group = 0
def peek(): return i < n and pat[i]
while i < n:
c = pat[i]
@@ -292,11 +292,11 @@ def globre(pat, head='^', tail='$'):
stuff = '\\' + stuff
res = '%s[%s]' % (res, stuff)
elif c == '{':
- group = True
+ group += 1
res += '(?:'
elif c == '}' and group:
res += ')'
- group = False
+ group -= 1
elif c == ',' and group:
res += '|'
elif c == '\\':
diff --git a/tests/test-walk b/tests/test-walk
--- a/tests/test-walk
+++ b/tests/test-walk
@@ -58,6 +58,7 @@ debugwalk ../.hg
debugwalk ../.hg
chdir ..
debugwalk -Ibeans
+debugwalk -I '{*,{b,m}*/*}k'
debugwalk 'glob:mammals/../beans/b*'
debugwalk '-X*/Procyonidae' mammals
debugwalk path:mammals
diff --git a/tests/test-walk.out b/tests/test-walk.out
--- a/tests/test-walk.out
+++ b/tests/test-walk.out
@@ -174,6 +174,11 @@ f beans/pinto beans/pinto
f beans/pinto beans/pinto
f beans/turtle beans/turtle
+hg debugwalk -I {*,{b,m}*/*}k
+f beans/black beans/black
+f fenugreek fenugreek
+f mammals/skunk mammals/skunk
+
hg debugwalk glob:mammals/../beans/b*
f beans/black beans/black
f beans/borlotti beans/borlotti
More information about the Mercurial-devel
mailing list