diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -797,7 +797,7 @@ def _regex(kind, pat, globsuffix): if kind == 'path': if pat == '.': return '' - return '^' + util.re.escape(pat) + '(?:/|$)' + return util.re.escape(pat) + '(?:/|$)' if kind == 'rootfilesin': if pat == '.': escaped = '' @@ -805,7 +805,7 @@ def _regex(kind, pat, globsuffix): # Pattern is a directory name. escaped = util.re.escape(pat) + '/' # Anything after the pattern must be a non-directory. - return '^' + escaped + '[^/]+$' + return escaped + '[^/]+$' if kind == 'relglob': return '(?:|.*/)' + _globre(pat) + globsuffix if kind == 'relpath': diff --git a/tests/test-walk.t b/tests/test-walk.t --- a/tests/test-walk.t +++ b/tests/test-walk.t @@ -109,7 +109,7 @@ f fenugreek ../fenugreek f mammals/skunk skunk $ hg debugwalk -I 'path:beans' - matcher: + matcher: f beans/black ../beans/black f beans/borlotti ../beans/borlotti f beans/kidney ../beans/kidney @@ -126,27 +126,27 @@ f beans/turtle ../beans/turtle $ hg debugwalk 'rootfilesin:' - matcher: + matcher: f fennel ../fennel f fenugreek ../fenugreek f fiddlehead ../fiddlehead $ hg debugwalk -I 'rootfilesin:' - matcher: + matcher: f fennel ../fennel f fenugreek ../fenugreek f fiddlehead ../fiddlehead $ hg debugwalk 'rootfilesin:.' - matcher: + matcher: f fennel ../fennel f fenugreek ../fenugreek f fiddlehead ../fiddlehead $ hg debugwalk -I 'rootfilesin:.' - matcher: + matcher: f fennel ../fennel f fenugreek ../fenugreek f fiddlehead ../fiddlehead $ hg debugwalk -X 'rootfilesin:' - matcher: , m2=> + matcher: , m2=> f beans/black ../beans/black f beans/borlotti ../beans/borlotti f beans/kidney ../beans/kidney @@ -158,15 +158,15 @@ f mammals/Procyonidae/raccoon Procyonidae/raccoon f mammals/skunk skunk $ hg debugwalk 'rootfilesin:fennel' - matcher: + matcher: $ hg debugwalk -I 'rootfilesin:fennel' - matcher: + matcher: $ hg debugwalk 'rootfilesin:skunk' - matcher: + matcher: $ hg debugwalk -I 'rootfilesin:skunk' - matcher: + matcher: $ hg debugwalk 'rootfilesin:beans' - matcher: + matcher: f beans/black ../beans/black f beans/borlotti ../beans/borlotti f beans/kidney ../beans/kidney @@ -174,7 +174,7 @@ f beans/pinto ../beans/pinto f beans/turtle ../beans/turtle $ hg debugwalk -I 'rootfilesin:beans' - matcher: + matcher: f beans/black ../beans/black f beans/borlotti ../beans/borlotti f beans/kidney ../beans/kidney @@ -182,19 +182,19 @@ f beans/pinto ../beans/pinto f beans/turtle ../beans/turtle $ hg debugwalk 'rootfilesin:mammals' - matcher: + matcher: f mammals/skunk skunk $ hg debugwalk -I 'rootfilesin:mammals' - matcher: + matcher: f mammals/skunk skunk $ hg debugwalk 'rootfilesin:mammals/' - matcher: + matcher: f mammals/skunk skunk $ hg debugwalk -I 'rootfilesin:mammals/' - matcher: + matcher: f mammals/skunk skunk $ hg debugwalk -X 'rootfilesin:mammals' - matcher: , m2=> + matcher: , m2=> f beans/black ../beans/black f beans/borlotti ../beans/borlotti f beans/kidney ../beans/kidney @@ -320,7 +320,7 @@ matcher: , m2=> f mammals/skunk mammals/skunk $ hg debugwalk path:mammals - matcher: + matcher: f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon @@ -383,7 +383,7 @@ Test patterns: matcher: f glob:glob glob:glob exact $ hg debugwalk path:glob:glob - matcher: + matcher: f glob:glob glob:glob exact $ rm glob:glob $ hg addremove @@ -402,10 +402,10 @@ Test patterns: f mammals/skunk mammals/skunk $ hg debugwalk path:beans/black - matcher: + matcher: f beans/black beans/black exact $ hg debugwalk path:beans//black - matcher: + matcher: f beans/black beans/black exact $ hg debugwalk relglob:Procyonidae