Mercurial > hg
changeset 45428:9b9071fabcd3
revset: remove indirect indexing of status tuple
Just use the attribute name.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 09 Sep 2020 11:51:51 +0900 |
parents | 78861610ded8 |
children | 9c8d2cf7f591 |
files | mercurial/revset.py |
diffstat | 1 files changed, 8 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Tue Aug 25 23:18:42 2020 -0400 +++ b/mercurial/revset.py Wed Sep 09 11:51:51 2020 +0900 @@ -411,7 +411,7 @@ """ # i18n: "adds" is a keyword pat = getstring(x, _(b"adds requires a pattern")) - return checkstatus(repo, subset, pat, 1) + return checkstatus(repo, subset, pat, 'added') @predicate(b'ancestor(*changeset)', safe=True, weight=0.5) @@ -681,12 +681,8 @@ def checkstatus(repo, subset, pat, field): """Helper for status-related revsets (adds, removes, modifies). - The field parameter says which kind is desired: - 0: modified - 1: added - 2: removed + The field parameter says which kind is desired. """ - label = {0: 'modified', 1: 'added', 2: 'removed'}[field] hasset = matchmod.patkind(pat) == b'set' mcache = [None] @@ -707,7 +703,7 @@ else: if not any(m(f) for f in c.files()): return False - files = getattr(repo.status(c.p1().node(), c.node()), label) + files = getattr(repo.status(c.p1().node(), c.node()), field) if fname is not None: if fname in files: return True @@ -715,7 +711,9 @@ if any(m(f) for f in files): return True - return subset.filter(matches, condrepr=(b'<status[%r] %r>', field, pat)) + return subset.filter( + matches, condrepr=(b'<status.%s %r>', pycompat.sysbytes(field), pat) + ) def _children(repo, subset, parentset): @@ -1631,7 +1629,7 @@ """ # i18n: "modifies" is a keyword pat = getstring(x, _(b"modifies requires a pattern")) - return checkstatus(repo, subset, pat, 0) + return checkstatus(repo, subset, pat, 'modified') @predicate(b'named(namespace)') @@ -2090,7 +2088,7 @@ """ # i18n: "removes" is a keyword pat = getstring(x, _(b"removes requires a pattern")) - return checkstatus(repo, subset, pat, 2) + return checkstatus(repo, subset, pat, 'removed') @predicate(b'rev(number)', safe=True)