Mercurial > hg
comparison mercurial/context.py @ 25435:a592a6a6f4fe
context: replace match.bad() monkey patching with match.badmatch()
No known issues with the previous code since it restored the original method,
but this is cleaner.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 04 Jun 2015 21:37:59 -0400 |
parents | 95c271356a66 |
children | f472228a9e5e |
comparison
equal
deleted
inserted
replaced
25434:5984dd42e140 | 25435:a592a6a6f4fe |
---|---|
7 | 7 |
8 from node import nullid, nullrev, short, hex, bin | 8 from node import nullid, nullrev, short, hex, bin |
9 from i18n import _ | 9 from i18n import _ |
10 import mdiff, error, util, scmutil, subrepo, patch, encoding, phases | 10 import mdiff, error, util, scmutil, subrepo, patch, encoding, phases |
11 import match as matchmod | 11 import match as matchmod |
12 import copy, os, errno, stat | 12 import os, errno, stat |
13 import obsolete as obsmod | 13 import obsolete as obsmod |
14 import repoview | 14 import repoview |
15 import fileset | 15 import fileset |
16 import revlog | 16 import revlog |
17 | 17 |
593 return self._repo.changelog.descendant(self._rev, other._rev) | 593 return self._repo.changelog.descendant(self._rev, other._rev) |
594 | 594 |
595 def walk(self, match): | 595 def walk(self, match): |
596 '''Generates matching file names.''' | 596 '''Generates matching file names.''' |
597 | 597 |
598 # Override match.bad method to have message with nodeid | 598 # Wrap match.bad method to have message with nodeid |
599 match = copy.copy(match) | |
600 oldbad = match.bad | |
601 def bad(fn, msg): | 599 def bad(fn, msg): |
602 # The manifest doesn't know about subrepos, so don't complain about | 600 # The manifest doesn't know about subrepos, so don't complain about |
603 # paths into valid subrepos. | 601 # paths into valid subrepos. |
604 if any(fn == s or fn.startswith(s + '/') | 602 if any(fn == s or fn.startswith(s + '/') |
605 for s in self.substate): | 603 for s in self.substate): |
606 return | 604 return |
607 oldbad(fn, _('no such file in rev %s') % self) | 605 match.bad(fn, _('no such file in rev %s') % self) |
608 match.bad = bad | 606 |
609 | 607 m = matchmod.badmatch(match, bad) |
610 return self._manifest.walk(match) | 608 return self._manifest.walk(m) |
611 | 609 |
612 def matches(self, match): | 610 def matches(self, match): |
613 return self.walk(match) | 611 return self.walk(match) |
614 | 612 |
615 class basefilectx(object): | 613 class basefilectx(object): |