@@ -23,8 +23,11 @@ def setup(repo):
def walk(orig, self, match, subrepos, unknown, ignored, full=True,
narrowonly=True):
if narrowonly:
- narrowmatch = repo.narrowmatch()
- match = matchmod.intersectmatchers(match, narrowmatch)
+ # hack to not exclude explicitly-specified paths so that they can
+ # be warned later on e.g. dirstate.add()
+ em = matchmod.exact(match._root, match._cwd, match.files())
+ nm = matchmod.unionmatcher([repo.narrowmatch(), em])
+ match = matchmod.intersectmatchers(match, nm)
return orig(self, match, subrepos, unknown, ignored, full)
extensions.wrapfunction(dirstate.dirstate, 'walk', walk)
@@ -194,7 +194,11 @@ def _setupdirstate(ui):
"""
def walk(orig, self, match, subrepos, unknown, ignored, full=True):
- match = matchmod.intersectmatchers(match, self._sparsematcher)
+ # hack to not exclude explicitly-specified paths so that they can
+ # be warned later on e.g. dirstate.add()
+ em = matchmod.exact(match._root, match._cwd, match.files())
+ sm = matchmod.unionmatcher([self._sparsematcher, em])
+ match = matchmod.intersectmatchers(match, sm)
return orig(self, match, subrepos, unknown, ignored, full)
extensions.wrapfunction(dirstate.dirstate, 'walk', walk)
@@ -787,6 +787,17 @@ class dirstate(object):
else:
badfn(ff, encoding.strtolocal(inst.strerror))
+ # match.files() may contain explicitly-specified paths that shouldn't
+ # be taken; drop them from the list of files found. dirsfound/notfound
+ # aren't filtered here because they will be tested later.
+ if match.anypats():
+ for f in list(results):
+ if f == '.hg' or f in subrepos:
+ # keep sentinel to disable further out-of-repo walks
+ continue
+ if not match(f):
+ del results[f]
+
# Case insensitive filesystems cannot rely on lstat() failing to detect
# a case-only rename. Prune the stat object for any file that does not
# match the case in the filesystem, if there are multiple files that
@@ -146,6 +146,13 @@ Issue683: peculiarity with hg revert of
M a
? a.orig
+excluded file shouldn't be added even if it is explicitly specified
+
+ $ hg add a.orig -X '*.orig'
+ $ hg st
+ M a
+ ? a.orig
+
Forgotten file can be added back (as either clean or modified)
$ hg forget b
@@ -55,6 +55,11 @@ Can not modify dirstate outside
$ hg add outside/f3
abort: cannot track 'outside/f3' - it is outside the narrow clone
[255]
+
+But adding a truly excluded file shouldn't count
+
+ $ hg add outside/f3 -X outside/f3
+
$ rm -r outside
Can modify dirstate inside
@@ -129,6 +129,10 @@ Adding an excluded file should fail
(include file with `hg debugsparse --include <pattern>` or use `hg add -s <file>` to include file directory while adding)
[255]
+But adding a truly excluded file shouldn't count
+
+ $ hg add hide3 -X hide3
+
Verify deleting sparseness while a file has changes fails
$ hg debugsparse --delete 'show*'
@@ -304,12 +304,10 @@
f beans/turtle beans/turtle
$ hg debugwalk -Xbeans/black beans/black
matcher: <differencematcher m1=<patternmatcher patterns='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans\\/black(?:/|$))'>>
- f beans/black beans/black exact
$ hg debugwalk -Xbeans/black -Ibeans/black
matcher: <differencematcher m1=<includematcher includes='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans\\/black(?:/|$))'>>
$ hg debugwalk -Xbeans beans/black
matcher: <differencematcher m1=<patternmatcher patterns='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans(?:/|$))'>>
- f beans/black beans/black exact
$ hg debugwalk -Xbeans -Ibeans/black
matcher: <differencematcher m1=<includematcher includes='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans(?:/|$))'>>
$ hg debugwalk 'glob:mammals/../beans/b*'
@@ -345,17 +343,13 @@
[255]
Test explicit paths and excludes:
-(BROKEN: nothing should be included, but wctx.walk() does)
$ hg debugwalk fennel -X fennel
matcher: <differencematcher m1=<patternmatcher patterns='(?:fennel(?:/|$))'>, m2=<includematcher includes='(?:fennel(?:/|$))'>>
- f fennel fennel exact
$ hg debugwalk fennel -X 'f*'
matcher: <differencematcher m1=<patternmatcher patterns='(?:fennel(?:/|$))'>, m2=<includematcher includes='(?:f[^/]*(?:/|$))'>>
- f fennel fennel exact
$ hg debugwalk beans/black -X 'path:beans'
matcher: <differencematcher m1=<patternmatcher patterns='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans(?:/|$))'>>
- f beans/black beans/black exact
$ hg debugwalk -I 'path:beans/black' -X 'path:beans'
matcher: <differencematcher m1=<includematcher includes='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans(?:/|$))'>>