diff -r 67567d7f1174 -r 48b30ff742cb hgext3rd/topic/stack.py --- a/hgext3rd/topic/stack.py Tue Aug 06 15:06:27 2019 +0200 +++ b/hgext3rd/topic/stack.py Tue Aug 06 15:06:38 2019 +0200 @@ -26,7 +26,7 @@ username = None if user: # user is of form "abc " - username = user.split('<')[0] + username = user.split(b'<')[0] if not username: # assuming user is of form "" if len(user) > 1: @@ -45,10 +45,10 @@ """ phasesets = repo._phasecache._phasesets if not phasesets or None in phasesets[phases.draft:]: - return repo.revs('(not public()) - obsolete()') + return repo.revs(b'(not public()) - obsolete()') result = set.union(*phasesets[phases.draft:]) - result -= obsolete.getrevs(repo, 'obsolete') + result -= obsolete.getrevs(repo, b'obsolete') return result class stack(object): @@ -63,13 +63,13 @@ subset = _stackcandidates(repo) if topic is not None and branch is not None: - raise error.ProgrammingError('both branch and topic specified (not defined yet)') + raise error.ProgrammingError(b'both branch and topic specified (not defined yet)') elif topic is not None: - trevs = repo.revs("%ld and topic(%s)", subset, topic) + trevs = repo.revs(b"%ld and topic(%s)", subset, topic) elif branch is not None: - trevs = repo.revs("%ld and branch(%s) - topic()", subset, branch) + trevs = repo.revs(b"%ld and branch(%s) - topic()", subset, branch) else: - raise error.ProgrammingError('neither branch and topic specified (not defined yet)') + raise error.ProgrammingError(b'neither branch and topic specified (not defined yet)') self._revs = trevs def __iter__(self): @@ -169,7 +169,7 @@ if revs: pt1 = self._repo[revs[0]].p1() else: - pt1 = self._repo['.'] + pt1 = self._repo[b'.'] if pt1.obsolete(): pt1 = self._repo[_singlesuccessor(self._repo, pt1)] @@ -197,15 +197,15 @@ if revs: minroot = [min(r for r in revs if not deps[r])] try: - dest = destutil.destmerge(self._repo, action='rebase', + dest = destutil.destmerge(self._repo, action=b'rebase', sourceset=minroot, onheadcheck=False) - return len(self._repo.revs("only(%d, %ld)", dest, minroot)) + return len(self._repo.revs(b"only(%d, %ld)", dest, minroot)) except error.NoMergeDestAbort: return 0 except error.ManyMergeDestAbort as exc: # XXX we should make it easier for upstream to provide the information - self.behinderror = pycompat.bytestr(exc).split('-', 1)[0].rstrip() + self.behinderror = pycompat.bytestr(exc).split(b'-', 1)[0].rstrip() return -1 return 0 @@ -217,68 +217,68 @@ return branches def labelsgen(prefix, parts): - fmt = prefix + '.%s' - return prefix + ' ' + ' '.join(fmt % p.replace(' ', '-') for p in parts) + fmt = prefix + b'.%s' + return prefix + b' ' + b' '.join(fmt % p.replace(b' ', b'-') for p in parts) def showstack(ui, repo, branch=None, topic=None, opts=None): if opts is None: opts = {} if topic is not None and branch is not None: - msg = 'both branch and topic specified [%s]{%s}(not defined yet)' + msg = b'both branch and topic specified [%s]{%s}(not defined yet)' msg %= (branch, topic) raise error.ProgrammingError(msg) elif topic is not None: - prefix = 's' + prefix = b's' if topic not in repo.topics: - raise error.Abort(_('cannot resolve "%s": no such topic found') % topic) + raise error.Abort(_(b'cannot resolve "%s": no such topic found') % topic) elif branch is not None: - prefix = 's' + prefix = b's' else: - raise error.ProgrammingError('neither branch and topic specified (not defined yet)') + raise error.ProgrammingError(b'neither branch and topic specified (not defined yet)') - fm = ui.formatter('topicstack', opts) + fm = ui.formatter(b'topicstack', opts) prev = None entries = [] idxmap = {} - label = 'topic' + label = b'topic' if topic == repo.currenttopic: - label = 'topic.active' + label = b'topic.active' st = stack(repo, branch, topic) if topic is not None: - fm.plain(_('### topic: %s') + fm.plain(_(b'### topic: %s') % ui.label(topic, label), - label='stack.summary.topic') + label=b'stack.summary.topic') if 1 < len(st.heads): - fm.plain(' (') - fm.plain('%d heads' % len(st.heads), - label='stack.summary.headcount.multiple') - fm.plain(')') - fm.plain('\n') - fm.plain(_('### target: %s (branch)') - % '+'.join(st.branches), # XXX handle multi branches - label='stack.summary.branches') + fm.plain(b' (') + fm.plain(b'%d heads' % len(st.heads), + label=b'stack.summary.headcount.multiple') + fm.plain(b')') + fm.plain(b'\n') + fm.plain(_(b'### target: %s (branch)') + % b'+'.join(st.branches), # XXX handle multi branches + label=b'stack.summary.branches') if topic is None: if 1 < len(st.heads): - fm.plain(' (') - fm.plain('%d heads' % len(st.heads), - label='stack.summary.headcount.multiple') - fm.plain(')') + fm.plain(b' (') + fm.plain(b'%d heads' % len(st.heads), + label=b'stack.summary.headcount.multiple') + fm.plain(b')') else: if st.behindcount == -1: - fm.plain(', ') - fm.plain('ambiguous rebase destination - %s' % st.behinderror, - label='stack.summary.behinderror') + fm.plain(b', ') + fm.plain(b'ambiguous rebase destination - %s' % st.behinderror, + label=b'stack.summary.behinderror') elif st.behindcount: - fm.plain(', ') - fm.plain('%d behind' % st.behindcount, label='stack.summary.behindcount') - fm.plain('\n') + fm.plain(b', ') + fm.plain(b'%d behind' % st.behindcount, label=b'stack.summary.behindcount') + fm.plain(b'\n') if not st: - fm.plain(_("(stack is empty)\n")) + fm.plain(_(b"(stack is empty)\n")) st = stack(repo, branch=branch, topic=topic) for idx, r in enumerate(st, 0): @@ -318,39 +318,39 @@ symbol = None states = [] if opts.get(b'children'): - expr = 'children(%d) and merge() - %ld' + expr = b'children(%d) and merge() - %ld' revisions = repo.revs(expr, ctx.rev(), st._revs) if len(revisions) > 0: - states.append('external-children') + states.append(b'external-children') if ctx.orphan(): - symbol = '$' - states.append('orphan') + symbol = b'$' + states.append(b'orphan') if ctx.contentdivergent(): - symbol = '$' - states.append('content divergent') + symbol = b'$' + states.append(b'content divergent') if ctx.phasedivergent(): - symbol = '$' - states.append('phase divergent') + symbol = b'$' + states.append(b'phase divergent') - iscurrentrevision = repo.revs('%d and parents()', ctx.rev()) + iscurrentrevision = repo.revs(b'%d and parents()', ctx.rev()) if iscurrentrevision: - symbol = '@' - states.append('current') + symbol = b'@' + states.append(b'current') if not isentry: - symbol = '^' + symbol = b'^' # "base" is kind of a "ghost" entry - states.append('base') + states.append(b'base') # none of the above if statments get executed if not symbol: - symbol = ':' + symbol = b':' if not states: - states.append('clean') + states.append(b'clean') states.sort() @@ -368,22 +368,22 @@ spacewidth = 2 + 40 # s# alias width spacewidth += 2 - fm.plain(' ' * spacewidth) + fm.plain(b' ' * spacewidth) else: - fm.write('stack_index', '%s%%d' % prefix, idx, - label=labelsgen('stack.index', states)) + fm.write(b'stack_index', b'%s%%d' % prefix, idx, + label=labelsgen(b'stack.index', states)) if ui.verbose: - fm.write('node', '(%s)', fm.hexfunc(ctx.node()), - label=labelsgen('stack.shortnode', states)) + fm.write(b'node', b'(%s)', fm.hexfunc(ctx.node()), + label=labelsgen(b'stack.shortnode', states)) else: fm.data(node=fm.hexfunc(ctx.node())) - fm.write('symbol', '%s', symbol, - label=labelsgen('stack.state', states)) - fm.plain(' ') - fm.write('desc', '%s', ctx.description().splitlines()[0], - label=labelsgen('stack.desc', states)) - fm.condwrite(states != ['clean'] and idx is not None, 'state', - ' (%s)', fm.formatlist(states, 'stack.state'), - label=labelsgen('stack.state', states)) - fm.plain('\n') + fm.write(b'symbol', b'%s', symbol, + label=labelsgen(b'stack.state', states)) + fm.plain(b' ') + fm.write(b'desc', b'%s', ctx.description().splitlines()[0], + label=labelsgen(b'stack.desc', states)) + fm.condwrite(states != [b'clean'] and idx is not None, b'state', + b' (%s)', fm.formatlist(states, b'stack.state'), + label=labelsgen(b'stack.state', states)) + fm.plain(b'\n') fm.end()