Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGdadbfcc63b3e: match: delete unused uipath() and _uipathrelative (API)
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/match.py (21 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Feb 8 2019, 3:00 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
kindpats.append((kind, p, source)) | kindpats.append((kind, p, source)) | ||||
kindpats.append((kind, pats, source)) | kindpats.append((kind, pats, source)) | ||||
return kindpats | return kindpats | ||||
if patterns: | if patterns: | ||||
kindpats = normalize(patterns, default, root, cwd, auditor, warn) | kindpats = normalize(patterns, default, root, cwd, auditor, warn) | ||||
if _kindpatsalwaysmatch(kindpats): | if _kindpatsalwaysmatch(kindpats): | ||||
m = alwaysmatcher(root, cwd, badfn, relativeuipath=True) | m = alwaysmatcher(root, cwd, badfn) | ||||
else: | else: | ||||
m = _buildkindpatsmatcher(patternmatcher, root, cwd, kindpats, | m = _buildkindpatsmatcher(patternmatcher, root, cwd, kindpats, | ||||
ctx=ctx, listsubrepos=listsubrepos, | ctx=ctx, listsubrepos=listsubrepos, | ||||
badfn=badfn) | badfn=badfn) | ||||
else: | else: | ||||
# It's a little strange that no patterns means to match everything. | # It's a little strange that no patterns means to match everything. | ||||
# Consider changing this to match nothing (probably using nevermatcher). | # Consider changing this to match nothing (probably using nevermatcher). | ||||
m = alwaysmatcher(root, cwd, badfn) | m = alwaysmatcher(root, cwd, badfn) | ||||
(pat, stringutil.forcebytestr(inst.strerror))) | (pat, stringutil.forcebytestr(inst.strerror))) | ||||
continue | continue | ||||
# else: re or relre - which cannot be normalized | # else: re or relre - which cannot be normalized | ||||
kindpats.append((kind, pat, '')) | kindpats.append((kind, pat, '')) | ||||
return kindpats | return kindpats | ||||
class basematcher(object): | class basematcher(object): | ||||
def __init__(self, root, cwd, badfn=None, relativeuipath=True): | def __init__(self, root, cwd, badfn=None): | ||||
self._root = root | self._root = root | ||||
self._cwd = cwd | self._cwd = cwd | ||||
if badfn is not None: | if badfn is not None: | ||||
self.bad = badfn | self.bad = badfn | ||||
self._relativeuipath = relativeuipath | |||||
def __call__(self, fn): | def __call__(self, fn): | ||||
return self.matchfn(fn) | return self.matchfn(fn) | ||||
def __iter__(self): | def __iter__(self): | ||||
for f in self._files: | for f in self._files: | ||||
yield f | yield f | ||||
# Callbacks related to how the matcher is used by dirstate.walk. | # Callbacks related to how the matcher is used by dirstate.walk. | ||||
# Subscribers to these events must monkeypatch the matcher object. | # Subscribers to these events must monkeypatch the matcher object. | ||||
'''Convert a repo path back to path that is relative to the root of the | '''Convert a repo path back to path that is relative to the root of the | ||||
matcher.''' | matcher.''' | ||||
return f | return f | ||||
def rel(self, f): | def rel(self, f): | ||||
'''Convert repo path back to path that is relative to cwd of matcher.''' | '''Convert repo path back to path that is relative to cwd of matcher.''' | ||||
return util.pathto(self._root, self._cwd, f) | return util.pathto(self._root, self._cwd, f) | ||||
def uipath(self, f): | |||||
'''Convert repo path to a display path. If patterns or -I/-X were used | |||||
to create this matcher, the display path will be relative to cwd. | |||||
Otherwise it is relative to the root of the repo.''' | |||||
return (self._relativeuipath and self.rel(f)) or self.abs(f) | |||||
@propertycache | @propertycache | ||||
def _files(self): | def _files(self): | ||||
return [] | return [] | ||||
def files(self): | def files(self): | ||||
'''Explicitly listed files or patterns or roots: | '''Explicitly listed files or patterns or roots: | ||||
if no patterns or .always(): empty list, | if no patterns or .always(): empty list, | ||||
if exact: list exact files, | if exact: list exact files, | ||||
def anypats(self): | def anypats(self): | ||||
'''None of .always(), .isexact(), and .prefix() is true -- | '''None of .always(), .isexact(), and .prefix() is true -- | ||||
optimizations will be difficult.''' | optimizations will be difficult.''' | ||||
return not self.always() and not self.isexact() and not self.prefix() | return not self.always() and not self.isexact() and not self.prefix() | ||||
class alwaysmatcher(basematcher): | class alwaysmatcher(basematcher): | ||||
'''Matches everything.''' | '''Matches everything.''' | ||||
def __init__(self, root, cwd, badfn=None, relativeuipath=False): | def __init__(self, root, cwd, badfn=None): | ||||
super(alwaysmatcher, self).__init__(root, cwd, badfn, | super(alwaysmatcher, self).__init__(root, cwd, badfn) | ||||
relativeuipath=relativeuipath) | |||||
def always(self): | def always(self): | ||||
return True | return True | ||||
def matchfn(self, f): | def matchfn(self, f): | ||||
return True | return True | ||||
def visitdir(self, dir): | def visitdir(self, dir): | ||||
m = copy.copy(m2) | m = copy.copy(m2) | ||||
# TODO: Consider encapsulating these things in a class so there's only | # TODO: Consider encapsulating these things in a class so there's only | ||||
# one thing to copy from m1. | # one thing to copy from m1. | ||||
m.bad = m1.bad | m.bad = m1.bad | ||||
m.explicitdir = m1.explicitdir | m.explicitdir = m1.explicitdir | ||||
m.traversedir = m1.traversedir | m.traversedir = m1.traversedir | ||||
m.abs = m1.abs | m.abs = m1.abs | ||||
m.rel = m1.rel | m.rel = m1.rel | ||||
m._relativeuipath |= m1._relativeuipath | |||||
return m | return m | ||||
if m2.always(): | if m2.always(): | ||||
m = copy.copy(m1) | m = copy.copy(m1) | ||||
m._relativeuipath |= m2._relativeuipath | |||||
return m | return m | ||||
return intersectionmatcher(m1, m2) | return intersectionmatcher(m1, m2) | ||||
class intersectionmatcher(basematcher): | class intersectionmatcher(basematcher): | ||||
def __init__(self, m1, m2): | def __init__(self, m1, m2): | ||||
super(intersectionmatcher, self).__init__(m1._root, m1._cwd) | super(intersectionmatcher, self).__init__(m1._root, m1._cwd) | ||||
self._m1 = m1 | self._m1 = m1 | ||||
self._m2 = m2 | self._m2 = m2 | ||||
self._matcher.bad(self._path + "/" + f, msg) | self._matcher.bad(self._path + "/" + f, msg) | ||||
def abs(self, f): | def abs(self, f): | ||||
return self._matcher.abs(self._path + "/" + f) | return self._matcher.abs(self._path + "/" + f) | ||||
def rel(self, f): | def rel(self, f): | ||||
return self._matcher.rel(self._path + "/" + f) | return self._matcher.rel(self._path + "/" + f) | ||||
def uipath(self, f): | |||||
return self._matcher.uipath(self._path + "/" + f) | |||||
def matchfn(self, f): | def matchfn(self, f): | ||||
# Some information is lost in the superclass's constructor, so we | # Some information is lost in the superclass's constructor, so we | ||||
# can not accurately create the matching function for the subdirectory | # can not accurately create the matching function for the subdirectory | ||||
# from the inputs. Instead, we override matchfn() and visitdir() to | # from the inputs. Instead, we override matchfn() and visitdir() to | ||||
# call the original matcher with the subdirectory path prepended. | # call the original matcher with the subdirectory path prepended. | ||||
return self._matcher.matchfn(self._path + "/" + f) | return self._matcher.matchfn(self._path + "/" + f) | ||||
def visitdir(self, dir): | def visitdir(self, dir): |