Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG727f0be3539a: match: delete unused abs() (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 (11 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| Martin von Zweigbergk | Feb 8 2019, 4:27 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 |
| # If an explicitdir is set, it will be called when an explicitly listed | # If an explicitdir is set, it will be called when an explicitly listed | ||||
| # directory is visited. | # directory is visited. | ||||
| explicitdir = None | explicitdir = None | ||||
| # If an traversedir is set, it will be called when a directory discovered | # If an traversedir is set, it will be called when a directory discovered | ||||
| # by recursive traversal is visited. | # by recursive traversal is visited. | ||||
| traversedir = None | traversedir = None | ||||
| def abs(self, f): | |||||
| '''Convert a repo path back to path that is relative to the root of the | |||||
| matcher.''' | |||||
| 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) | ||||
| @propertycache | @propertycache | ||||
| def _files(self): | def _files(self): | ||||
| return [] | return [] | ||||
| return m1 or m2 | return m1 or m2 | ||||
| if m1.always(): | if m1.always(): | ||||
| 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.rel = m1.rel | m.rel = m1.rel | ||||
| return m | return m | ||||
| if m2.always(): | if m2.always(): | ||||
| m = copy.copy(m1) | m = copy.copy(m1) | ||||
| return m | return m | ||||
| return intersectionmatcher(m1, m2) | return intersectionmatcher(m1, m2) | ||||
| class intersectionmatcher(basematcher): | class intersectionmatcher(basematcher): | ||||
| True | True | ||||
| >>> util.pconvert(m2.rel(b'b.txt')) | >>> util.pconvert(m2.rel(b'b.txt')) | ||||
| 'sub/b.txt' | 'sub/b.txt' | ||||
| >>> def bad(f, msg): | >>> def bad(f, msg): | ||||
| ... print(pycompat.sysstr(b"%s: %s" % (f, msg))) | ... print(pycompat.sysstr(b"%s: %s" % (f, msg))) | ||||
| >>> m1.bad = bad | >>> m1.bad = bad | ||||
| >>> m2.bad(b'x.txt', b'No such file') | >>> m2.bad(b'x.txt', b'No such file') | ||||
| sub/x.txt: No such file | sub/x.txt: No such file | ||||
| >>> m2.abs(b'c.txt') | |||||
| 'sub/c.txt' | |||||
| """ | """ | ||||
| def __init__(self, path, matcher): | def __init__(self, path, matcher): | ||||
| super(subdirmatcher, self).__init__(matcher._root, matcher._cwd) | super(subdirmatcher, self).__init__(matcher._root, matcher._cwd) | ||||
| self._path = path | self._path = path | ||||
| self._matcher = matcher | self._matcher = matcher | ||||
| self._always = matcher.always() | self._always = matcher.always() | ||||
| self._files = [f[len(path) + 1:] for f in matcher._files | self._files = [f[len(path) + 1:] for f in matcher._files | ||||
| if f.startswith(path + "/")] | if f.startswith(path + "/")] | ||||
| # If the parent repo had a path to this subrepo and the matcher is | # If the parent repo had a path to this subrepo and the matcher is | ||||
| # a prefix matcher, this submatcher always matches. | # a prefix matcher, this submatcher always matches. | ||||
| if matcher.prefix(): | if matcher.prefix(): | ||||
| self._always = any(f == path for f in matcher._files) | self._always = any(f == path for f in matcher._files) | ||||
| def bad(self, f, msg): | def bad(self, f, msg): | ||||
| self._matcher.bad(self._path + "/" + f, msg) | self._matcher.bad(self._path + "/" + f, msg) | ||||
| def abs(self, 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 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. | ||||