##// END OF EJS Templates
dirstate: drop explicit files that shouldn't match (BC) (issue4679)...
Yuya Nishihara -
r36218:deb85191 default
parent child Browse files
Show More
@@ -23,8 +23,11 b' def setup(repo):'
23 def walk(orig, self, match, subrepos, unknown, ignored, full=True,
23 def walk(orig, self, match, subrepos, unknown, ignored, full=True,
24 narrowonly=True):
24 narrowonly=True):
25 if narrowonly:
25 if narrowonly:
26 narrowmatch = repo.narrowmatch()
26 # hack to not exclude explicitly-specified paths so that they can
27 match = matchmod.intersectmatchers(match, narrowmatch)
27 # be warned later on e.g. dirstate.add()
28 em = matchmod.exact(match._root, match._cwd, match.files())
29 nm = matchmod.unionmatcher([repo.narrowmatch(), em])
30 match = matchmod.intersectmatchers(match, nm)
28 return orig(self, match, subrepos, unknown, ignored, full)
31 return orig(self, match, subrepos, unknown, ignored, full)
29
32
30 extensions.wrapfunction(dirstate.dirstate, 'walk', walk)
33 extensions.wrapfunction(dirstate.dirstate, 'walk', walk)
@@ -194,7 +194,11 b' def _setupdirstate(ui):'
194 """
194 """
195
195
196 def walk(orig, self, match, subrepos, unknown, ignored, full=True):
196 def walk(orig, self, match, subrepos, unknown, ignored, full=True):
197 match = matchmod.intersectmatchers(match, self._sparsematcher)
197 # hack to not exclude explicitly-specified paths so that they can
198 # be warned later on e.g. dirstate.add()
199 em = matchmod.exact(match._root, match._cwd, match.files())
200 sm = matchmod.unionmatcher([self._sparsematcher, em])
201 match = matchmod.intersectmatchers(match, sm)
198 return orig(self, match, subrepos, unknown, ignored, full)
202 return orig(self, match, subrepos, unknown, ignored, full)
199
203
200 extensions.wrapfunction(dirstate.dirstate, 'walk', walk)
204 extensions.wrapfunction(dirstate.dirstate, 'walk', walk)
@@ -787,6 +787,17 b' class dirstate(object):'
787 else:
787 else:
788 badfn(ff, encoding.strtolocal(inst.strerror))
788 badfn(ff, encoding.strtolocal(inst.strerror))
789
789
790 # match.files() may contain explicitly-specified paths that shouldn't
791 # be taken; drop them from the list of files found. dirsfound/notfound
792 # aren't filtered here because they will be tested later.
793 if match.anypats():
794 for f in list(results):
795 if f == '.hg' or f in subrepos:
796 # keep sentinel to disable further out-of-repo walks
797 continue
798 if not match(f):
799 del results[f]
800
790 # Case insensitive filesystems cannot rely on lstat() failing to detect
801 # Case insensitive filesystems cannot rely on lstat() failing to detect
791 # a case-only rename. Prune the stat object for any file that does not
802 # a case-only rename. Prune the stat object for any file that does not
792 # match the case in the filesystem, if there are multiple files that
803 # match the case in the filesystem, if there are multiple files that
@@ -146,6 +146,13 b' Issue683: peculiarity with hg revert of '
146 M a
146 M a
147 ? a.orig
147 ? a.orig
148
148
149 excluded file shouldn't be added even if it is explicitly specified
150
151 $ hg add a.orig -X '*.orig'
152 $ hg st
153 M a
154 ? a.orig
155
149 Forgotten file can be added back (as either clean or modified)
156 Forgotten file can be added back (as either clean or modified)
150
157
151 $ hg forget b
158 $ hg forget b
@@ -55,6 +55,11 b' Can not modify dirstate outside'
55 $ hg add outside/f3
55 $ hg add outside/f3
56 abort: cannot track 'outside/f3' - it is outside the narrow clone
56 abort: cannot track 'outside/f3' - it is outside the narrow clone
57 [255]
57 [255]
58
59 But adding a truly excluded file shouldn't count
60
61 $ hg add outside/f3 -X outside/f3
62
58 $ rm -r outside
63 $ rm -r outside
59
64
60 Can modify dirstate inside
65 Can modify dirstate inside
@@ -129,6 +129,10 b' Adding an excluded file should fail'
129 (include file with `hg debugsparse --include <pattern>` or use `hg add -s <file>` to include file directory while adding)
129 (include file with `hg debugsparse --include <pattern>` or use `hg add -s <file>` to include file directory while adding)
130 [255]
130 [255]
131
131
132 But adding a truly excluded file shouldn't count
133
134 $ hg add hide3 -X hide3
135
132 Verify deleting sparseness while a file has changes fails
136 Verify deleting sparseness while a file has changes fails
133
137
134 $ hg debugsparse --delete 'show*'
138 $ hg debugsparse --delete 'show*'
@@ -304,12 +304,10 b''
304 f beans/turtle beans/turtle
304 f beans/turtle beans/turtle
305 $ hg debugwalk -Xbeans/black beans/black
305 $ hg debugwalk -Xbeans/black beans/black
306 matcher: <differencematcher m1=<patternmatcher patterns='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans\\/black(?:/|$))'>>
306 matcher: <differencematcher m1=<patternmatcher patterns='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans\\/black(?:/|$))'>>
307 f beans/black beans/black exact
308 $ hg debugwalk -Xbeans/black -Ibeans/black
307 $ hg debugwalk -Xbeans/black -Ibeans/black
309 matcher: <differencematcher m1=<includematcher includes='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans\\/black(?:/|$))'>>
308 matcher: <differencematcher m1=<includematcher includes='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans\\/black(?:/|$))'>>
310 $ hg debugwalk -Xbeans beans/black
309 $ hg debugwalk -Xbeans beans/black
311 matcher: <differencematcher m1=<patternmatcher patterns='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans(?:/|$))'>>
310 matcher: <differencematcher m1=<patternmatcher patterns='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans(?:/|$))'>>
312 f beans/black beans/black exact
313 $ hg debugwalk -Xbeans -Ibeans/black
311 $ hg debugwalk -Xbeans -Ibeans/black
314 matcher: <differencematcher m1=<includematcher includes='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans(?:/|$))'>>
312 matcher: <differencematcher m1=<includematcher includes='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans(?:/|$))'>>
315 $ hg debugwalk 'glob:mammals/../beans/b*'
313 $ hg debugwalk 'glob:mammals/../beans/b*'
@@ -345,17 +343,13 b''
345 [255]
343 [255]
346
344
347 Test explicit paths and excludes:
345 Test explicit paths and excludes:
348 (BROKEN: nothing should be included, but wctx.walk() does)
349
346
350 $ hg debugwalk fennel -X fennel
347 $ hg debugwalk fennel -X fennel
351 matcher: <differencematcher m1=<patternmatcher patterns='(?:fennel(?:/|$))'>, m2=<includematcher includes='(?:fennel(?:/|$))'>>
348 matcher: <differencematcher m1=<patternmatcher patterns='(?:fennel(?:/|$))'>, m2=<includematcher includes='(?:fennel(?:/|$))'>>
352 f fennel fennel exact
353 $ hg debugwalk fennel -X 'f*'
349 $ hg debugwalk fennel -X 'f*'
354 matcher: <differencematcher m1=<patternmatcher patterns='(?:fennel(?:/|$))'>, m2=<includematcher includes='(?:f[^/]*(?:/|$))'>>
350 matcher: <differencematcher m1=<patternmatcher patterns='(?:fennel(?:/|$))'>, m2=<includematcher includes='(?:f[^/]*(?:/|$))'>>
355 f fennel fennel exact
356 $ hg debugwalk beans/black -X 'path:beans'
351 $ hg debugwalk beans/black -X 'path:beans'
357 matcher: <differencematcher m1=<patternmatcher patterns='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans(?:/|$))'>>
352 matcher: <differencematcher m1=<patternmatcher patterns='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans(?:/|$))'>>
358 f beans/black beans/black exact
359 $ hg debugwalk -I 'path:beans/black' -X 'path:beans'
353 $ hg debugwalk -I 'path:beans/black' -X 'path:beans'
360 matcher: <differencematcher m1=<includematcher includes='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans(?:/|$))'>>
354 matcher: <differencematcher m1=<includematcher includes='(?:beans\\/black(?:/|$))'>, m2=<includematcher includes='(?:beans(?:/|$))'>>
361
355
General Comments 0
You need to be logged in to leave comments. Login now