Mercurial > hg
comparison mercurial/context.py @ 25122:755d23a49170
match: resolve filesets in subrepos for commands given the '-S' argument
This will work for any command that creates its matcher via scmutil.match(), but
only the files command is tested here (both workingctx and basectx based tests).
The previous behavior was to completely ignore the files in the subrepo, even
though -S was given.
My first attempt was to teach context.walk() to optionally recurse, but once
that was in place and the complete file list was built up, the predicate test
would fail with 'path in nested repo' when a file in a subrepo was accessed
through the parent context.
There are two slightly surprising behaviors with this functionality. First, any
path provided inside the fileset isn't narrowed when it is passed to the
subrepo. I dont see any clean way to do that in the matcher. Fortunately, the
'subrepo()' fileset is the only one to take a path.
The second surprise is that status predicates are resolved against the subrepo,
not the parent like 'hg status -S' is. I don't see any way to fix that either,
given the path auditor error mentioned above.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 16 May 2015 00:36:35 -0400 |
parents | d9fb88c045a0 |
children | 472a685a4961 |
comparison
equal
deleted
inserted
replaced
25121:df63d4843581 | 25122:755d23a49170 |
---|---|
249 return '' | 249 return '' |
250 | 250 |
251 def sub(self, path): | 251 def sub(self, path): |
252 return subrepo.subrepo(self, path) | 252 return subrepo.subrepo(self, path) |
253 | 253 |
254 def match(self, pats=[], include=None, exclude=None, default='glob'): | 254 def match(self, pats=[], include=None, exclude=None, default='glob', |
255 listsubrepos=False): | |
255 r = self._repo | 256 r = self._repo |
256 return matchmod.match(r.root, r.getcwd(), pats, | 257 return matchmod.match(r.root, r.getcwd(), pats, |
257 include, exclude, default, | 258 include, exclude, default, |
258 auditor=r.auditor, ctx=self) | 259 auditor=r.auditor, ctx=self, |
260 listsubrepos=listsubrepos) | |
259 | 261 |
260 def diff(self, ctx2=None, match=None, **opts): | 262 def diff(self, ctx2=None, match=None, **opts): |
261 """Returns a diff generator for the given contexts and matcher""" | 263 """Returns a diff generator for the given contexts and matcher""" |
262 if ctx2 is None: | 264 if ctx2 is None: |
263 ctx2 = self.p1() | 265 ctx2 = self.p1() |
1435 self._repo.dirstate.normallookup(dest) | 1437 self._repo.dirstate.normallookup(dest) |
1436 self._repo.dirstate.copy(source, dest) | 1438 self._repo.dirstate.copy(source, dest) |
1437 finally: | 1439 finally: |
1438 wlock.release() | 1440 wlock.release() |
1439 | 1441 |
1440 def match(self, pats=[], include=None, exclude=None, default='glob'): | 1442 def match(self, pats=[], include=None, exclude=None, default='glob', |
1443 listsubrepos=False): | |
1441 r = self._repo | 1444 r = self._repo |
1442 | 1445 |
1443 # Only a case insensitive filesystem needs magic to translate user input | 1446 # Only a case insensitive filesystem needs magic to translate user input |
1444 # to actual case in the filesystem. | 1447 # to actual case in the filesystem. |
1445 if not util.checkcase(r.root): | 1448 if not util.checkcase(r.root): |
1446 return matchmod.icasefsmatcher(r.root, r.getcwd(), pats, include, | 1449 return matchmod.icasefsmatcher(r.root, r.getcwd(), pats, include, |
1447 exclude, default, r.auditor, self) | 1450 exclude, default, r.auditor, self, |
1451 listsubrepos=listsubrepos) | |
1448 return matchmod.match(r.root, r.getcwd(), pats, | 1452 return matchmod.match(r.root, r.getcwd(), pats, |
1449 include, exclude, default, | 1453 include, exclude, default, |
1450 auditor=r.auditor, ctx=self) | 1454 auditor=r.auditor, ctx=self, |
1455 listsubrepos=listsubrepos) | |
1451 | 1456 |
1452 def _filtersuspectsymlink(self, files): | 1457 def _filtersuspectsymlink(self, files): |
1453 if not files or self._repo.dirstate._checklink: | 1458 if not files or self._repo.dirstate._checklink: |
1454 return files | 1459 return files |
1455 | 1460 |