Mercurial > evolve
diff hgext3rd/topic/discovery.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 | 079dbf36e884 |
children | bb2b4f6c99dc |
line wrap: on
line diff
--- a/hgext3rd/topic/discovery.py Tue Aug 06 15:06:27 2019 +0200 +++ b/hgext3rd/topic/discovery.py Tue Aug 06 15:06:38 2019 +0200 @@ -28,12 +28,12 @@ repo = pushop.repo.unfiltered() remote = pushop.remote - publishing = ('phases' not in remote.listkeys('namespaces') - or bool(remote.listkeys('phases').get('publishing', False))) + publishing = (b'phases' not in remote.listkeys(b'namespaces') + or bool(remote.listkeys(b'phases').get(b'publishing', False))) if not common.hastopicext(pushop.repo): return orig(pushop, *args, **kwargs) - elif ((publishing or not remote.capable('topics')) + elif ((publishing or not remote.capable(b'topics')) and not getattr(pushop, 'publish', False)): return orig(pushop, *args, **kwargs) @@ -41,7 +41,7 @@ remotebranchmap = None origremotebranchmap = remote.branchmap publishednode = [c.node() for c in pushop.outdatedphases] - publishedset = repo.revs('ancestors(%ln + %ln)', + publishedset = repo.revs(b'ancestors(%ln + %ln)', publishednode, pushop.remotephases.publicheads) @@ -51,17 +51,17 @@ # drop topic information from changeset about to be published result = collections.defaultdict(list) for branch, heads in compat.branchmapitems(origremotebranchmap()): - if ':' not in branch: + if b':' not in branch: result[branch].extend(heads) else: - namedbranch = branch.split(':', 1)[0] + namedbranch = branch.split(b':', 1)[0] for h in heads: r = rev(h) if r is not None and r in publishedset: result[namedbranch].append(h) else: result[branch].append(h) - for heads in result.itervalues(): + for heads in result.values(): heads.sort() return result @@ -78,7 +78,7 @@ return branch topic = ctx.topic() if topic: - branch = "%s:%s" % (branch, topic) + branch = b"%s:%s" % (branch, topic) return branch ctx.branch = branch @@ -96,7 +96,7 @@ return branch, close topic = repo[rev].topic() if topic: - branch = "%s:%s" % (branch, topic) + branch = b"%s:%s" % (branch, topic) return branch, close rbc.branchinfo = branchinfo @@ -107,12 +107,12 @@ repo.__class__ = repocls if remotebranchmap is not None: remote.branchmap = remotebranchmap - unxx = repo.filtered('unfiltered-topic') + unxx = repo.filtered(b'unfiltered-topic') repo.unfiltered = lambda: unxx pushop.repo = repo summary = orig(pushop) for key, value in summary.items(): - if ':' in key: # This is a topic + if b':' in key: # This is a topic if value[0] is None and value[1]: summary[key] = ([value[1][0]], ) + value[1:] return summary @@ -147,7 +147,7 @@ def _nbheads(repo): data = {} for b in repo.branchmap().iterbranches(): - if ':' in b[0]: + if b':' in b[0]: continue data[b[0]] = len(b[1]) return data @@ -158,7 +158,7 @@ if not common.hastopicext(op.repo) or op.repo.publishing(): return tr = op.gettransaction() - if tr.hookargs['source'] not in ('push', 'serve'): # not a push + if tr.hookargs[b'source'] not in (b'push', b'serve'): # not a push return tr._prepushheads = _nbheads(op.repo) reporef = weakref.ref(op.repo) @@ -175,11 +175,11 @@ for branch, oldnb in tr._prepushheads.items(): newnb = finalheads.pop(branch, 0) if oldnb < newnb: - msg = _('push create a new head on branch "%s"' % branch) + msg = _(b'push create a new head on branch "%s"' % branch) raise error.Abort(msg) for branch, newnb in finalheads.items(): if 1 < newnb: - msg = _('push create more than 1 head on new branch "%s"' + msg = _(b'push create more than 1 head on new branch "%s"' % branch) raise error.Abort(msg) return oldvalidator(tr) @@ -191,7 +191,7 @@ def _pushb2phases(orig, pushop, bundler): if common.hastopicext(pushop.repo): - checktypes = ('check:heads', 'check:updated-heads') + checktypes = (b'check:heads', b'check:updated-heads') hascheck = any(p.type in checktypes for p in bundler._parts) if not hascheck and pushop.outdatedphases: exchange._pushb2ctxcheckheads(pushop, bundler) @@ -199,8 +199,8 @@ def wireprotocaps(orig, repo, proto): caps = orig(repo, proto) - if common.hastopicext(repo) and repo.peer().capable('topics'): - caps.append('topics') + if common.hastopicext(repo) and repo.peer().capable(b'topics'): + caps.append(b'topics') return caps def modsetup(ui): @@ -211,11 +211,11 @@ # we need a proper wrap b2 part stuff extensions.wrapfunction(bundle2, 'handlecheckheads', handlecheckheads) bundle2.handlecheckheads.params = frozenset() - bundle2.parthandlermapping['check:heads'] = bundle2.handlecheckheads + bundle2.parthandlermapping[b'check:heads'] = bundle2.handlecheckheads if util.safehasattr(bundle2, 'handlecheckupdatedheads'): # we still need a proper wrap b2 part stuff extensions.wrapfunction(bundle2, 'handlecheckupdatedheads', handlecheckheads) bundle2.handlecheckupdatedheads.params = frozenset() - bundle2.parthandlermapping['check:updated-heads'] = bundle2.handlecheckupdatedheads + bundle2.parthandlermapping[b'check:updated-heads'] = bundle2.handlecheckupdatedheads extensions.wrapfunction(exchange, '_pushb2phases', _pushb2phases) - exchange.b2partsgenmapping['phase'] = exchange._pushb2phases + exchange.b2partsgenmapping[b'phase'] = exchange._pushb2phases