# HG changeset patch # User Alexis S. L. Carvalho # Date 1175671326 10800 # Node ID 702f48570eb34b1a91a955e04dc2b34574cbd63e # Parent 6cecaec07cc9a47757a939ac3dc7d6875d648a01 change relglob: patterns to be consistent with glob: patterns With this change, you have to use "hg locate 'hgweb/**'" to locate all the files in directories named hgweb. OTOH, "hg locate '*l'" will locate only files that end with "l" - e.g. a file called "hg.py" will not be matched just because it's in a directory whose name ends with "l" (e.g. "mercurial"). diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -436,7 +436,7 @@ def _matcher(canonroot, cwd, names, inc, 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': diff --git a/tests/test-locate b/tests/test-locate --- a/tests/test-locate +++ b/tests/test-locate @@ -19,6 +19,8 @@ mkdir t 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 @@ -39,14 +41,14 @@ hglocate -I ../t # 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$' diff --git a/tests/test-locate.out b/tests/test-locate.out --- a/tests/test-locate.out +++ b/tests/test-locate.out @@ -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 @@ locate failed hg locate a b +dir.h/foo t.h t/b t/e.h @@ -25,6 +27,7 @@ hg locate NONEXISTENT hg locate b +dir.h/foo t.h t/b t/e.h @@ -38,6 +41,7 @@ hg locate -r 0 NONEXISTENT hg locate -r 0 a b +dir.h/foo t.h t/b t/e.h @@ -46,6 +50,7 @@ t/x % -I/-X with relative path should work hg locate b +dir.h/foo t.h t/b t/e.h @@ -56,7 +61,7 @@ t/b t/e.h t/x -hg locate t +hg locate t/** t/b t/e.h t/x @@ -72,7 +77,7 @@ hg locate *.h hg locate path:t/x ../t/x -hg locate re:.*\.h +hg locate re:.*\.h$ ../t.h ../t/e.h @@ -87,7 +92,7 @@ hg locate -r 0 *.h 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 diff --git a/tests/test-walk b/tests/test-walk --- a/tests/test-walk +++ b/tests/test-walk @@ -77,7 +77,8 @@ 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 diff --git a/tests/test-walk.out b/tests/test-walk.out --- a/tests/test-walk.out +++ b/tests/test-walk.out @@ -232,11 +232,13 @@ hg debugwalk path:beans//black 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