Mercurial > evolve
diff hgext3rd/topic/topicmap.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 | 88472e743c64 |
children | bb2b4f6c99dc |
line wrap: on
line diff
--- a/hgext3rd/topic/topicmap.py Tue Aug 06 15:06:27 2019 +0200 +++ b/hgext3rd/topic/topicmap.py Tue Aug 06 15:06:38 2019 +0200 @@ -16,22 +16,22 @@ common, ) -basefilter = set(['base', 'immutable']) +basefilter = set([b'base', b'immutable']) def topicfilter(name): """return a "topic" version of a filter level""" if name in basefilter: return name elif name is None: return None - elif name.endswith('-topic'): + elif name.endswith(b'-topic'): return name else: - return name + '-topic' + return name + b'-topic' def istopicfilter(filtername): if filtername is None: return False - return filtername.endswith('-topic') + return filtername.endswith(b'-topic') def gettopicrepo(repo): if not common.hastopicext(repo): @@ -61,8 +61,8 @@ if newfilter not in funcmap: funcmap[newfilter] = revsfunc partialmap[newfilter] = base - funcmap['unfiltered-topic'] = lambda repo: frozenset() - partialmap['unfiltered-topic'] = 'visible-topic' + funcmap[b'unfiltered-topic'] = lambda repo: frozenset() + partialmap[b'unfiltered-topic'] = b'visible-topic' def _phaseshash(repo, maxrev): """uniq ID for a phase matching a set of rev""" @@ -80,7 +80,7 @@ if revs: s = hashlib.sha1() for rev in revs: - s.update('%d;' % rev) + s.update(b'%d;' % rev) key = s.digest() return key @@ -100,7 +100,7 @@ # wrap commit status use the topic branch heads ctx = repo[node] if ctx.topic() and ctx.branch() == branch: - bheads = repo.branchheads("%s:%s" % (branch, ctx.topic())) + bheads = repo.branchheads(b"%s:%s" % (branch, ctx.topic())) ret = orig(repo, node, branch, bheads=bheads, opts=opts) @@ -113,8 +113,8 @@ if (not opts.get(b'amend') and bheads and node not in bheads and not [x for x in parents if x.node() in bheads and x.branch() == branch]): - repo.ui.status(_("(consider using topic for lightweight branches." - " See 'hg help topic')\n")) + repo.ui.status(_(b"(consider using topic for lightweight branches." + b" See 'hg help topic')\n")) return ret @@ -179,17 +179,17 @@ new.phaseshash = self.phaseshash return new - def branchtip(self, branch, topic=''): + def branchtip(self, branch, topic=b''): '''Return the tipmost open head on branch head, otherwise return the tipmost closed head on branch. Raise KeyError for unknown branch.''' if topic: - branch = '%s:%s' % (branch, topic) + branch = b'%s:%s' % (branch, topic) return super(_topiccache, self).branchtip(branch) - def branchheads(self, branch, closed=False, topic=''): + def branchheads(self, branch, closed=False, topic=b''): if topic: - branch = '%s:%s' % (branch, topic) + branch = b'%s:%s' % (branch, topic) return super(_topiccache, self).branchheads(branch, closed=closed) def validfor(self, repo): @@ -229,13 +229,13 @@ def branchinfo(r, changelog=None): info = oldgetbranchinfo(r) - topic = '' + topic = b'' ctx = unfi[r] if ctx.mutable(): topic = ctx.topic() branch = info[0] if topic: - branch = '%s:%s' % (branch, topic) + branch = b'%s:%s' % (branch, topic) return (branch, info[1]) try: unfi.revbranchcache().branchinfo = branchinfo