Mercurial > evolve
changeset 6638:0a7487cdfe20
topic: remove subscript relation compatibility check for hg 4.8
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 03 Nov 2023 13:47:13 -0300 |
parents | 8a51498b9976 |
children | 6518a3b951dc |
files | hgext3rd/topic/revset.py |
diffstat | 1 files changed, 59 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/revset.py Fri Nov 03 13:44:45 2023 -0300 +++ b/hgext3rd/topic/revset.py Fri Nov 03 13:47:13 2023 -0300 @@ -147,75 +147,72 @@ branch = repo[None].branch() return revset.baseset(stack.stack(repo, branch=branch, topic=topic)[1:]) & subset -# x#y[z] revset operator support (no support for older version) -# hg <= 4.8 (e54bfde922f2) -if util.safehasattr(revset, 'subscriptrelations'): - def stacksubrel(repo, subset, x, rel, z, order): - """This is a revset-flavored implementation of stack aliases. +def stacksubrel(repo, subset, x, rel, z, order): + """This is a revset-flavored implementation of stack aliases. - The syntax is: rev#stack[n] or rev#s[n]. Plenty of logic is borrowed - from topic._namemap, but unlike that function, which prefers to abort - (e.g. when stack index is too high), this returns empty set to be more - revset-friendly. - """ - a, b = revset.getintrange( - z, - b'relation subscript must be an integer or a range', - b'relation subscript bounds must be integers', - None, None) + The syntax is: rev#stack[n] or rev#s[n]. Plenty of logic is borrowed + from topic._namemap, but unlike that function, which prefers to abort + (e.g. when stack index is too high), this returns empty set to be more + revset-friendly. + """ + a, b = revset.getintrange( + z, + b'relation subscript must be an integer or a range', + b'relation subscript bounds must be integers', + None, None) - s = revset.getset(repo, revset.fullreposet(repo), x) - if not s: - return revset.baseset() + s = revset.getset(repo, revset.fullreposet(repo), x) + if not s: + return revset.baseset() - def getrange(st, a, b): - start = 1 if a is None else a - end = len(st.revs) if b is None else b + 1 - return range(start, end) + def getrange(st, a, b): + start = 1 if a is None else a + end = len(st.revs) if b is None else b + 1 + return range(start, end) - revs = [] - for r in s: - topic = repo[r].topic() - if topic: - st = stack.stack(repo, topic=topic) - else: - st = stack.stack(repo, branch=repo[r].branch()) - for n in getrange(st, a, b): - if abs(n) >= len(st.revs): - # also means stack base is not accessible with n < 0, which - # is by design - continue - if n == 0 and b != 0 and a != 0: - # quirk: we don't want stack base unless specifically asked - # for it (at least one of the indices is 0) - continue - rev = st.revs[n] - if rev == -1 and n == 0: - continue - if rev not in revs: - revs.append(rev) + revs = [] + for r in s: + topic = repo[r].topic() + if topic: + st = stack.stack(repo, topic=topic) + else: + st = stack.stack(repo, branch=repo[r].branch()) + for n in getrange(st, a, b): + if abs(n) >= len(st.revs): + # also means stack base is not accessible with n < 0, which + # is by design + continue + if n == 0 and b != 0 and a != 0: + # quirk: we don't want stack base unless specifically asked + # for it (at least one of the indices is 0) + continue + rev = st.revs[n] + if rev == -1 and n == 0: + continue + if rev not in revs: + revs.append(rev) - return subset & revset.baseset(revs) + return subset & revset.baseset(revs) - revset.subscriptrelations[b'stack'] = stacksubrel - revset.subscriptrelations[b's'] = stacksubrel +revset.subscriptrelations[b'stack'] = stacksubrel +revset.subscriptrelations[b's'] = stacksubrel - def topicsubrel(repo, subset, x, *args): - subset &= topicset(repo, subset, x) - # not using revset.generationssubrel directly because it was renamed - # hg <= 5.3 (8859de3e83dc) - generationssubrel = revset.subscriptrelations[b'generations'] - return generationssubrel(repo, subset, x, *args) +def topicsubrel(repo, subset, x, *args): + subset &= topicset(repo, subset, x) + # not using revset.generationssubrel directly because it was renamed + # hg <= 5.3 (8859de3e83dc) + generationssubrel = revset.subscriptrelations[b'generations'] + return generationssubrel(repo, subset, x, *args) - revset.subscriptrelations[b'topic'] = topicsubrel - revset.subscriptrelations[b't'] = topicsubrel +revset.subscriptrelations[b'topic'] = topicsubrel +revset.subscriptrelations[b't'] = topicsubrel - # x#y revset operator support (no support for older version) - # hg <= 5.3 (eca82eb9d777) - if util.safehasattr(revset, 'relations'): - def stackrel(repo, subset, x, rel, order): - z = (b'rangeall', None) - return stacksubrel(repo, subset, x, rel, z, order) +# x#y revset operator support (no support for older version) +# hg <= 5.3 (eca82eb9d777) +if util.safehasattr(revset, 'relations'): + def stackrel(repo, subset, x, rel, order): + z = (b'rangeall', None) + return stacksubrel(repo, subset, x, rel, z, order) - revset.relations[b'stack'] = stackrel - revset.relations[b's'] = stackrel + revset.relations[b'stack'] = stackrel + revset.relations[b's'] = stackrel