Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/context.py @ 24381:82b82168d045
context.walk: walk all files when file and '.' given
When both '.' (the working copy root) and an explicit file (or files)
are in match.files(), we only walk the explicitly listed files. This
is because we remove the '.' from the set too early. Move later and
add a test for it. Before this change, the last test would print only
"3".
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 18 Mar 2015 11:42:09 -0700 |
parents | dd3bccb4b820 |
children | 1cfded2fa1a9 |
comparison
equal
deleted
inserted
replaced
24380:dd3bccb4b820 | 24381:82b82168d045 |
---|---|
586 """True if other is descendant of this changeset""" | 586 """True if other is descendant of this changeset""" |
587 return self._repo.changelog.descendant(self._rev, other._rev) | 587 return self._repo.changelog.descendant(self._rev, other._rev) |
588 | 588 |
589 def walk(self, match): | 589 def walk(self, match): |
590 fset = set(match.files()) | 590 fset = set(match.files()) |
591 # for dirstate.walk, files=['.'] means "walk the whole tree". | |
592 # follow that here, too | |
593 fset.discard('.') | |
594 | |
595 # avoid the entire walk if we're only looking for specific files | 591 # avoid the entire walk if we're only looking for specific files |
596 if fset and not match.anypats(): | 592 if fset and not match.anypats(): |
597 if util.all(fn in self for fn in fset): | 593 if util.all(fn in self for fn in fset): |
598 for fn in sorted(fset): | 594 for fn in sorted(fset): |
599 if match(fn): | 595 if match(fn): |
604 if fn in fset: | 600 if fn in fset: |
605 # specified pattern is the exact name | 601 # specified pattern is the exact name |
606 fset.remove(fn) | 602 fset.remove(fn) |
607 if match(fn): | 603 if match(fn): |
608 yield fn | 604 yield fn |
605 # for dirstate.walk, files=['.'] means "walk the whole tree". | |
606 # follow that here, too | |
607 fset.discard('.') | |
609 for fn in sorted(fset): | 608 for fn in sorted(fset): |
610 if not self.hasdir(fn): | 609 if not self.hasdir(fn): |
611 match.bad(fn, _('no such file in rev %s') % self) | 610 match.bad(fn, _('no such file in rev %s') % self) |
612 | 611 |
613 def matches(self, match): | 612 def matches(self, match): |