Mercurial > evolve
diff hgext3rd/topic/revset.py @ 4814:48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Using the format-source extension smooth out the pain of merging after
auto-formatting.
This change makes all of the Evolve test suite pass under python3 and has
added benefit of being 100% automated using mercurial's `byteify-strings`
script version 1.0 (revision 11498aa91c036c6d70f7ac5ee5af2664a84a1130).
How to benefit from the help of format-source is explained in the README.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Tue, 06 Aug 2019 15:06:38 +0200 |
parents | 7b36f9728351 |
children | a4d081923c81 a828c7a7ace1 |
line wrap: on
line diff
--- a/hgext3rd/topic/revset.py Tue Aug 06 15:06:27 2019 +0200 +++ b/hgext3rd/topic/revset.py Tue Aug 06 15:06:38 2019 +0200 @@ -24,7 +24,7 @@ revsetpredicate = registrar.revsetpredicate() def getstringstrict(x, err): - if x and x[0] == 'string': + if x and x[0] == b'string': return x[1] raise error.ParseError(err) @@ -36,7 +36,7 @@ If `string` starts with `re:` the remainder of the name is treated as a regular expression. """ - args = revset.getargs(x, 0, 1, 'topic takes one or no arguments') + args = revset.getargs(x, 0, 1, b'topic takes one or no arguments') mutable = revset._notpublic(repo, revset.fullreposet(repo), ()) @@ -44,15 +44,15 @@ return (subset & mutable).filter(lambda r: bool(repo[r].topic())) try: - topic = getstringstrict(args[0], '') + topic = getstringstrict(args[0], b'') except error.ParseError: # not a string, but another revset pass else: kind, pattern, matcher = mkmatcher(topic) - if topic.startswith('literal:') and pattern not in repo.topics: - raise error.RepoLookupError("topic '%s' does not exist" % pattern) + if topic.startswith(b'literal:') and pattern not in repo.topics: + raise error.RepoLookupError(b"topic '%s' does not exist" % pattern) def matches(r): topic = repo[r].topic() @@ -64,7 +64,7 @@ s = revset.getset(repo, revset.fullreposet(repo), x) topics = {repo[r].topic() for r in s} - topics.discard('') + topics.discard(b'') def matches(r): if r in s: @@ -82,11 +82,11 @@ Name is horrible so that people change it. """ - args = revset.getargs(x, 1, 1, 'ngtip takes one argument') + args = revset.getargs(x, 1, 1, b'ngtip takes one argument') # match a specific topic - branch = revset.getstring(args[0], 'ngtip requires a string') - if branch == '.': - branch = repo['.'].branch() + branch = revset.getstring(args[0], b'ngtip requires a string') + if branch == b'.': + branch = repo[b'.'].branch() return subset & revset.baseset(destination.ngtip(repo, branch)) @revsetpredicate(b'stack()') @@ -97,7 +97,7 @@ unstable changeset after there future parent (as if evolve where already run). """ - err = 'stack takes no arguments, it works on current topic' + err = b'stack takes no arguments, it works on current topic' revset.getargs(x, 0, 0, err) topic = None branch = None @@ -120,8 +120,8 @@ if isinstance(z, tuple): a, b = revset.getintrange( z, - 'relation subscript must be an integer or a range', - 'relation subscript bounds must be integers', + b'relation subscript must be an integer or a range', + b'relation subscript bounds must be integers', None, None) else: a = b = z @@ -159,12 +159,12 @@ return subset & revset.baseset(revs) - revset.subscriptrelations['stack'] = stackrel - revset.subscriptrelations['s'] = stackrel + revset.subscriptrelations[b'stack'] = stackrel + revset.subscriptrelations[b's'] = stackrel def topicrel(repo, subset, x, *args): subset &= topicset(repo, subset, x) return revset.generationsrel(repo, subset, x, *args) - revset.subscriptrelations['topic'] = topicrel - revset.subscriptrelations['t'] = topicrel + revset.subscriptrelations[b'topic'] = topicrel + revset.subscriptrelations[b't'] = topicrel