Mercurial > hg-stable
changeset 4309:d4f0405fadac
Merge last few matcher/locate fixes.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Wed, 04 Apr 2007 04:22:08 -0300 |
parents | d69bdc1091b8 (current diff) a5cde03cd019 (diff) |
children | c8919eb0f315 |
files | mercurial/commands.py mercurial/util.py tests/test-walk tests/test-walk.out |
diffstat | 6 files changed, 42 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Mon Apr 02 14:16:44 2007 -0500 +++ b/mercurial/commands.py Wed Apr 04 04:22:08 2007 -0300 @@ -1658,7 +1658,10 @@ ret = 1 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node, + badmatch=util.always, default='relglob'): + if src == 'b': + continue if not node and repo.dirstate.state(abs) == '?': continue if opts['fullpath']:
--- a/mercurial/util.py Mon Apr 02 14:16:44 2007 -0500 +++ b/mercurial/util.py Wed Apr 04 04:22:08 2007 -0300 @@ -447,7 +447,7 @@ if c in _globchars: return True return False - def regex(kind, name): + def regex(kind, name, tail): '''convert a pattern into a regular expression''' if not name: return '' @@ -456,23 +456,23 @@ elif kind == 'path': return '^' + re.escape(name) + '(?:/|$)' elif kind == 'relglob': - return globre(name, '(?:|.*/)', '(?:/|$)') + return globre(name, '(?:|.*/)', tail) elif kind == 'relpath': return re.escape(name) + '(?:/|$)' elif kind == 'relre': if name.startswith('^'): return name return '.*' + name - return globre(name, '', '(?:/|$)') + return globre(name, '', tail) - def matchfn(pats): + def matchfn(pats, tail): """build a matching function from a set of patterns""" if not pats: return matches = [] for k, p in pats: try: - pat = '(?:%s)' % regex(k, p) + pat = '(?:%s)' % regex(k, p, tail) matches.append(re.compile(pat).match) except re.error: if src: raise Abort("%s: invalid pattern (%s): %s" % (src, k, p)) @@ -520,15 +520,15 @@ roots, pats, anypats = normalizepats(names, dflt_pat) - patmatch = matchfn(pats) or always + patmatch = matchfn(pats, '$') or always incmatch = always if inc: dummy, inckinds, dummy = normalizepats(inc, 'glob') - incmatch = matchfn(inckinds) + incmatch = matchfn(inckinds, '(?:/|$)') excmatch = lambda fn: False if exc: dummy, exckinds, dummy = normalizepats(exc, 'glob') - excmatch = matchfn(exckinds) + excmatch = matchfn(exckinds, '(?:/|$)') if not names and inc and not exc: # common case: hgignore patterns
--- a/tests/test-locate Mon Apr 02 14:16:44 2007 -0500 +++ b/tests/test-locate Wed Apr 04 04:22:08 2007 -0300 @@ -19,6 +19,8 @@ echo 0 > t/x echo 0 > t/b echo 0 > t/e.h +mkdir dir.h +echo 0 > dir.h/foo hg ci -A -m m -d "1000000 0" touch nottracked hglocate a && echo locate succeeded || echo locate failed @@ -28,9 +30,11 @@ hg ci -m m -d "1000000 0" hglocate a hglocate NONEXISTENT +hglocate relpath:NONEXISTENT hglocate hglocate -r 0 a hglocate -r 0 NONEXISTENT +hglocate -r 0 relpath:NONEXISTENT hglocate -r 0 echo % -I/-X with relative path should work cd t @@ -39,14 +43,14 @@ # test issue294 cd .. rm -r t -hglocate t +hglocate 't/**' mkdir otherdir cd otherdir hglocate b hglocate '*.h' hglocate path:t/x -hglocate 're:.*\.h' +hglocate 're:.*\.h$' hglocate -r 0 b hglocate -r 0 '*.h' hglocate -r 0 path:t/x -hglocate -r 0 're:.*\.h' +hglocate -r 0 're:.*\.h$'
--- a/tests/test-locate.out Mon Apr 02 14:16:44 2007 -0500 +++ b/tests/test-locate.out Wed Apr 04 04:22:08 2007 -0300 @@ -1,5 +1,6 @@ adding a adding b +adding dir.h/foo adding t.h adding t/b adding t/e.h @@ -14,6 +15,7 @@ hg locate a b +dir.h/foo t.h t/b t/e.h @@ -23,8 +25,11 @@ hg locate NONEXISTENT +hg locate relpath:NONEXISTENT + hg locate b +dir.h/foo t.h t/b t/e.h @@ -35,9 +40,12 @@ hg locate -r 0 NONEXISTENT +hg locate -r 0 relpath:NONEXISTENT + hg locate -r 0 a b +dir.h/foo t.h t/b t/e.h @@ -46,6 +54,7 @@ % -I/-X with relative path should work hg locate b +dir.h/foo t.h t/b t/e.h @@ -56,7 +65,7 @@ t/e.h t/x -hg locate t +hg locate t/** t/b t/e.h t/x @@ -72,7 +81,7 @@ hg locate path:t/x ../t/x -hg locate re:.*\.h +hg locate re:.*\.h$ ../t.h ../t/e.h @@ -87,7 +96,7 @@ hg locate -r 0 path:t/x ../t/x -hg locate -r 0 re:.*\.h +hg locate -r 0 re:.*\.h$ ../t.h ../t/e.h
--- a/tests/test-walk Mon Apr 02 14:16:44 2007 -0500 +++ b/tests/test-walk Wed Apr 04 04:22:08 2007 -0300 @@ -72,11 +72,13 @@ #debugwalk `pwd`/beans #debugwalk `pwd`/.. debugwalk glob:\* +debugwalk 'glob:**e' debugwalk 're:.*[kb]$' debugwalk path:beans/black debugwalk path:beans//black debugwalk relglob:Procyonidae -debugwalk relglob:Procyonidae/ fennel +debugwalk 'relglob:Procyonidae/**' +debugwalk 'relglob:Procyonidae/**' fennel debugwalk beans 'glob:beans/*' debugwalk 'glob:mamm**' debugwalk 'glob:mamm**' fennel
--- a/tests/test-walk.out Mon Apr 02 14:16:44 2007 -0500 +++ b/tests/test-walk.out Wed Apr 04 04:22:08 2007 -0300 @@ -210,20 +210,14 @@ beans/.hg: No such file or directory hg debugwalk glob:* -f beans/black beans/black -f beans/borlotti beans/borlotti -f beans/kidney beans/kidney -f beans/navy beans/navy -f beans/pinto beans/pinto +f fennel fennel +f fenugreek fenugreek +f fiddlehead fiddlehead +f glob:glob glob:glob + +hg debugwalk glob:**e f beans/turtle beans/turtle -f fennel fennel -f fenugreek fenugreek -f fiddlehead fiddlehead -f glob:glob glob:glob f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle -f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi -f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon -f mammals/skunk mammals/skunk hg debugwalk re:.*[kb]$ f beans/black beans/black @@ -238,11 +232,13 @@ f beans/black beans/black exact hg debugwalk relglob:Procyonidae + +hg debugwalk relglob:Procyonidae/** f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon -hg debugwalk relglob:Procyonidae/ fennel +hg debugwalk relglob:Procyonidae/** fennel f fennel fennel exact f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi