[PATCH evolve-ext v2] py3: broad pass for python3 compatibility

Martin von Zweigbergk martinvonz at google.com
Tue Jul 2 09:02:33 EDT 2019


On Tue, Jul 2, 2019, 01:46 Pierre-Yves David <pierre-yves.david at ens-lyon.org>
wrote:

> This patch don't apply anymore :-/


Should be okay to apply only the changes that applied, I think. It looks
like they're independent.


It is also very invasive and will be
> painful for all other contributors.
>
> Do you think we could get to a point where no manual tweaking is needed
> ? (could be simply adding dedicated comment to line that need to be
> skipped). If we have a script only approach we could use the
> format-source extensions for that.
>

I'm curious to hear what Ludovic thinks, but I'm doubtful that saves other
contributors more time than it costs for Ludovic, so it's a net negative.

I assume you know that Python 2's end of life is Jan 1 2020, so this is
getting urgent. I don't know about others, but my team will need to have
Mercurial and extensions on Python 3 by then.


> On 7/1/19 7:39 AM, Ludovic Chabant wrote:
> > # HG changeset patch
> > # User Ludovic Chabant <ludovic at chabant.com>
> > # Date 1561959530 0
> > #      Mon Jul 01 05:38:50 2019 +0000
> > # Branch stable
> > # Node ID 89e3ab4dcbc56ee72ce1d4d17527337e01d99467
> > # Parent  90daf413dfc7a7e4762e6445f05c52b123c6188f
> > py3: broad pass for python3 compatibility
> >
> > - ran mercurial's bytify-strings script
> > - excluded some places where we use strings to pass to setattr()
> > - re-decode some template funcions' docstrings that were previously
> encoded
> >    (probably by the hgloader?)
> >
> > diff --git a/hgext3rd/evolve/__init__.py b/hgext3rd/evolve/__init__.py
> > --- a/hgext3rd/evolve/__init__.py
> > +++ b/hgext3rd/evolve/__init__.py
> > @@ -258,7 +258,7 @@
> >       registrar.templatekeyword # new in hg-3.8
> >   except ImportError:
> >       from . import metadata
> > -    raise ImportError('evolve needs Mercurial version %s or above' %
> > +    raise ImportError(b'evolve needs Mercurial version %s or above' %
> >                         min(metadata.testedwith.split()))
> >
> >   import mercurial
> > @@ -311,25 +311,25 @@
> >   buglink = metadata.buglink
> >
> >   # Flags for enabling optional parts of evolve
> > -commandopt = 'allnewcommands'
> > +commandopt = b'allnewcommands'
> >
> >   obsexcmsg = utility.obsexcmsg
> >   shorttemplate = utility.shorttemplate
> >
> > -colortable = {'evolve.node': 'yellow',
> > -              'evolve.user': 'green',
> > -              'evolve.rev': 'blue',
> > -              'evolve.short_description': '',
> > -              'evolve.date': 'cyan',
> > -              'evolve.current_rev': 'bold',
> > -              'evolve.verb': '',
> > -              'evolve.operation': 'bold'
> > +colortable = {b'evolve.node': b'yellow',
> > +              b'evolve.user': b'green',
> > +              b'evolve.rev': b'blue',
> > +              b'evolve.short_description': b'',
> > +              b'evolve.date': b'cyan',
> > +              b'evolve.current_rev': b'bold',
> > +              b'evolve.verb': b'',
> > +              b'evolve.operation': b'bold'
> >                 }
> >
> >   _pack = struct.pack
> >   _unpack = struct.unpack
> >
> > -aliases, entry = cmdutil.findcmd('commit', commands.table)
> > +aliases, entry = cmdutil.findcmd(b'commit', commands.table)
> >   commitopts3 = cmdrewrite.commitopts3
> >   interactiveopt = cmdrewrite.interactiveopt
> >   rewrite = rewriteutil.rewrite
> > @@ -362,13 +362,13 @@
> >   templatekeyword = eh.templatekeyword
> >
> >   # Configuration
> > -eh.configitem('experimental', 'evolutioncommands', [])
> > -eh.configitem('experimental', 'evolution.allnewcommands', None)
> > -eh.configitem('experimental', 'prunestrip', False)
> > +eh.configitem(b'experimental', b'evolutioncommands', [])
> > +eh.configitem(b'experimental', b'evolution.allnewcommands', None)
> > +eh.configitem(b'experimental', b'prunestrip', False)
> >
> >   # pre hg 4.0 compat
> >
> > -if not util.safehasattr(dirstate.dirstate, 'parentchange'):
> > +if not util.safehasattr(dirstate.dirstate, b'parentchange'):
> >       import contextlib
> >
> >       @contextlib.contextmanager
> > @@ -397,14 +397,14 @@
> >   def _configureoptions(ui, repo):
> >       # If no capabilities are specified, enable everything.
> >       # This is so existing evolve users don't need to change their
> config.
> > -    evolveopts = repo.ui.configlist('experimental', 'evolution')
> > +    evolveopts = repo.ui.configlist(b'experimental', b'evolution')
> >       if not evolveopts:
> > -        evolveopts = ['all']
> > -        repo.ui.setconfig('experimental', 'evolution', evolveopts,
> 'evolve')
> > -    if obsolete.isenabled(repo, 'exchange'):
> > +        evolveopts = [b'all']
> > +        repo.ui.setconfig(b'experimental', b'evolution', evolveopts,
> b'evolve')
> > +    if obsolete.isenabled(repo, b'exchange'):
> >           # if no config explicitly set, disable bundle1
> > -        if not isinstance(repo.ui.config('server', 'bundle1'), str):
> > -            repo.ui.setconfig('server', 'bundle1', False)
> > +        if not isinstance(repo.ui.config(b'server', b'bundle1'), str):
> > +            repo.ui.setconfig(b'server', b'bundle1', False)
> >
> >       class trdescrepo(repo.__class__):
> >
> > @@ -422,18 +422,18 @@
> >       # This must be in the same function as the option configuration
> above to
> >       # guarantee it happens after the above configuration, but before
> the
> >       # extsetup functions.
> > -    evolvecommands = ui.configlist('experimental', 'evolutioncommands')
> > -    evolveopts = ui.configlist('experimental', 'evolution')
> > +    evolvecommands = ui.configlist(b'experimental',
> b'evolutioncommands')
> > +    evolveopts = ui.configlist(b'experimental', b'evolution')
> >       if evolveopts and (commandopt not in evolveopts
> > -                       and 'all' not in evolveopts):
> > +                       and b'all' not in evolveopts):
> >           # We build whitelist containing the commands we want to enable
> >           whitelist = set()
> >           for cmd in evolvecommands:
> >               matchingevolvecommands = [e for e in cmdtable.keys() if
> cmd in e]
> >               if not matchingevolvecommands:
> > -                raise error.Abort(_('unknown command: %s') % cmd)
> > +                raise error.Abort(_(b'unknown command: %s') % cmd)
> >               elif len(matchingevolvecommands) > 1:
> > -                msg = _('ambiguous command specification: "%s" matches
> %r')
> > +                msg = _(b'ambiguous command specification: "%s" matches
> %r')
> >                   raise error.Abort(msg % (cmd, matchingevolvecommands))
> >               else:
> >                   whitelist.add(matchingevolvecommands[0])
> > @@ -464,10 +464,10 @@
> >   @eh.uisetup
> >   def setupparentcommand(ui):
> >
> > -    _alias, statuscmd = cmdutil.findcmd('status', commands.table)
> > -    pstatusopts = [o for o in statuscmd[1] if o[1] != 'rev']
> > +    _alias, statuscmd = cmdutil.findcmd(b'status', commands.table)
> > +    pstatusopts = [o for o in statuscmd[1] if o[1] != b'rev']
> >
> > -    @eh.command('pstatus', pstatusopts)
> > +    @eh.command(b'pstatus', pstatusopts)
> >       def pstatus(ui, repo, *args, **kwargs):
> >           """show status combining committed and uncommited changes
> >
> > @@ -476,13 +476,13 @@
> >           match the content of the commit that a bare :hg:`amend` will
> creates.
> >
> >           See :hg:`help status` for details."""
> > -        kwargs['rev'] = ['.^']
> > +        kwargs[b'rev'] = [b'.^']
> >           return statuscmd[0](ui, repo, *args, **kwargs)
> >
> > -    _alias, diffcmd = cmdutil.findcmd('diff', commands.table)
> > -    pdiffopts = [o for o in diffcmd[1] if o[1] != 'rev']
> > +    _alias, diffcmd = cmdutil.findcmd(b'diff', commands.table)
> > +    pdiffopts = [o for o in diffcmd[1] if o[1] != b'rev']
> >
> > -    @eh.command('pdiff', pdiffopts)
> > +    @eh.command(b'pdiff', pdiffopts)
> >       def pdiff(ui, repo, *args, **kwargs):
> >           """show diff combining committed and uncommited changes
> >
> > @@ -491,32 +491,32 @@
> >           match the content of the commit that a bare :hg:`amend` will
> creates.
> >
> >           See :hg:`help diff` for details."""
> > -        kwargs['rev'] = ['.^']
> > +        kwargs[b'rev'] = [b'.^']
> >           return diffcmd[0](ui, repo, *args, **kwargs)
> >
> >   @eh.uisetup
> >   def _installalias(ui):
> > -    if ui.config('alias', 'odiff', None) is None:
> > -        ui.setconfig('alias', 'odiff',
> > -                     "diff --hidden --rev 'limit(predecessors(.),1)'
> --rev .",
> > -                     'evolve')
> > +    if ui.config(b'alias', b'odiff', None) is None:
> > +        ui.setconfig(b'alias', b'odiff',
> > +                     b"diff --hidden --rev 'limit(predecessors(.),1)'
> --rev .",
> > +                     b'evolve')
> >
> >   ### Unstable revset symbol
> >
> > - at eh.revsetpredicate('unstable()')
> > + at eh.revsetpredicate(b'unstable()')
> >   def revsetunstable(repo, subset, x):
> >       """Changesets with instabilities.
> >       """
> > -    revset.getargs(x, 0, 0, 'unstable takes no arguments')
> > +    revset.getargs(x, 0, 0, b'unstable takes no arguments')
> >       troubled = set()
> > -    troubled.update(getrevs(repo, 'orphan'))
> > -    troubled.update(getrevs(repo, 'phasedivergent'))
> > -    troubled.update(getrevs(repo, 'contentdivergent'))
> > +    troubled.update(getrevs(repo, b'orphan'))
> > +    troubled.update(getrevs(repo, b'phasedivergent'))
> > +    troubled.update(getrevs(repo, b'contentdivergent'))
> >       troubled = revset.baseset(troubled)
> >       troubled.sort() # set is non-ordered, enforce order
> >       return subset & troubled
> >
> > - at eh.revsetpredicate('troubled()')    # legacy name
> > + at eh.revsetpredicate(b'troubled()')    # legacy name
> >   def revsettroubled(repo, subset, x):
> >       return revsetunstable(repo, subset, x)
> >
> > @@ -615,17 +615,17 @@
> >
> >
> >   ### XXX I'm not sure this revset is useful
> > - at eh.revsetpredicate('suspended()')
> > + at eh.revsetpredicate(b'suspended()')
> >   def revsetsuspended(repo, subset, x):
> >       """Obsolete changesets with non-obsolete descendants.
> >       """
> > -    revset.getargs(x, 0, 0, 'suspended takes no arguments')
> > -    suspended = revset.baseset(getrevs(repo, 'suspended'))
> > +    revset.getargs(x, 0, 0, b'suspended takes no arguments')
> > +    suspended = revset.baseset(getrevs(repo, b'suspended'))
> >       suspended.sort()
> >       return subset & suspended
> >
> >
> > - at eh.revsetpredicate('predecessors(set)')
> > + at eh.revsetpredicate(b'predecessors(set)')
> >   def revsetpredecessors(repo, subset, x):
> >       """Immediate predecessors of changesets in set.
> >       """
> > @@ -635,12 +635,12 @@
> >       return subset & s
> >
> >
> > - at eh.revsetpredicate('precursors(set)')   # legacy name for predecessors
> > + at eh.revsetpredicate(b'precursors(set)')   # legacy name for predecessors
> >   def revsetprecursors(repo, subset, x):
> >       return revsetpredecessors(repo, subset, x)
> >
> >
> > - at eh.revsetpredicate('allpredecessors(set)')
> > + at eh.revsetpredicate(b'allpredecessors(set)')
> >   def revsetallpredecessors(repo, subset, x):
> >       """Transitive predecessors of changesets in set.
> >       """
> > @@ -650,12 +650,12 @@
> >       return subset & s
> >
> >
> > - at eh.revsetpredicate('allprecursors(set)')   # legacy name for
> allpredecessors
> > + at eh.revsetpredicate(b'allprecursors(set)')   # legacy name for
> allpredecessors
> >   def revsetallprecursors(repo, subset, x):
> >       return revsetallpredecessors(repo, subset, x)
> >
> >
> > - at eh.revsetpredicate('successors(set)')
> > + at eh.revsetpredicate(b'successors(set)')
> >   def revsetsuccessors(repo, subset, x):
> >       """Immediate successors of changesets in set.
> >       """
> > @@ -664,7 +664,7 @@
> >       s.sort()
> >       return subset & s
> >
> > - at eh.revsetpredicate('allsuccessors(set)')
> > + at eh.revsetpredicate(b'allsuccessors(set)')
> >   def revsetallsuccessors(repo, subset, x):
> >       """Transitive successors of changesets in set.
> >       """
> > @@ -681,87 +681,87 @@
> >   # This section take care of issue warning to the user when troubles
> appear
> >
> >   def _warnobsoletewc(ui, repo, prevnode=None, wasobs=None):
> > -    rev = repo['.']
> > +    rev = repo[b'.']
> >
> >       if not rev.obsolete():
> >           return
> >
> >       if rev.node() == prevnode and wasobs:
> >           return
> > -    msg = _("working directory parent is obsolete! (%s)\n")
> > +    msg = _(b"working directory parent is obsolete! (%s)\n")
> >       shortnode = node.short(rev.node())
> >
> >       ui.warn(msg % shortnode)
> >
> >       # Check that evolve is activated for performance reasons
> > -    evolvecommandenabled = any('evolve' in e for e in cmdtable)
> > +    evolvecommandenabled = any(b'evolve' in e for e in cmdtable)
> >       if ui.quiet or not evolvecommandenabled:
> >           return
> >
> >       # Show a warning for helping the user to solve the issue
> >       reason, successors = obshistory._getobsfateandsuccs(repo,
> rev.node())
> >
> > -    if reason == 'pruned':
> > -        solvemsg = _("use 'hg evolve' to update to its parent
> successor")
> > -    elif reason == 'diverged':
> > -        debugcommand = "hg evolve --list --content-divergent"
> > -        basemsg = _("%s has diverged, use '%s' to resolve the issue")
> > +    if reason == b'pruned':
> > +        solvemsg = _(b"use 'hg evolve' to update to its parent
> successor")
> > +    elif reason == b'diverged':
> > +        debugcommand = b"hg evolve --list --content-divergent"
> > +        basemsg = _(b"%s has diverged, use '%s' to resolve the issue")
> >           solvemsg = basemsg % (shortnode, debugcommand)
> > -    elif reason == 'superseed':
> > -        msg = _("use 'hg evolve' to update to its successor: %s")
> > +    elif reason == b'superseed':
> > +        msg = _(b"use 'hg evolve' to update to its successor: %s")
> >           solvemsg = msg % successors[0]
> > -    elif reason == 'superseed_split':
> > -        msg = _("use 'hg evolve' to update to its tipmost successor:
> %s")
> > +    elif reason == b'superseed_split':
> > +        msg = _(b"use 'hg evolve' to update to its tipmost successor:
> %s")
> >
> >           if len(successors) <= 2:
> > -            solvemsg = msg % ", ".join(successors)
> > +            solvemsg = msg % b", ".join(successors)
> >           else:
> > -            firstsuccessors = ", ".join(successors[:2])
> > +            firstsuccessors = b", ".join(successors[:2])
> >               remainingnumber = len(successors) - 2
> > -            successorsmsg = _("%s and %d more") % (firstsuccessors,
> remainingnumber)
> > +            successorsmsg = _(b"%s and %d more") % (firstsuccessors,
> remainingnumber)
> >               solvemsg = msg % successorsmsg
> >       else:
> >           raise ValueError(reason)
> >
> > -    ui.warn("(%s)\n" % solvemsg)
> > +    ui.warn(b"(%s)\n" % solvemsg)
> >
> > -if util.safehasattr(context, '_filterederror'): # <= hg-4.5
> > -    @eh.wrapfunction(context, '_filterederror')
> > +if util.safehasattr(context, b'_filterederror'): # <= hg-4.5
> > +    @eh.wrapfunction(context, b'_filterederror')
> >       def evolve_filtererror(original, repo, changeid):
> >           """build an exception to be raised about a filtered changeid
> >
> >           This is extracted in a function to help extensions (eg:
> evolve) to
> >           experiment with various message variants."""
> > -        if repo.filtername.startswith('visible'):
> > +        if repo.filtername.startswith(b'visible'):
> >
> >               unfilteredrepo = repo.unfiltered()
> >               rev = repo[scmutil.revsingle(unfilteredrepo, changeid)]
> >               reason, successors =
> obshistory._getobsfateandsuccs(unfilteredrepo, rev.node())
> >
> >               # Be more precise in case the revision is superseed
> > -            if reason == 'superseed':
> > -                reason = _("successor: %s") % successors[0]
> > -            elif reason == 'superseed_split':
> > +            if reason == b'superseed':
> > +                reason = _(b"successor: %s") % successors[0]
> > +            elif reason == b'superseed_split':
> >                   if len(successors) <= 2:
> > -                    reason = _("successors: %s") % ", ".join(successors)
> > +                    reason = _(b"successors: %s") % b",
> ".join(successors)
> >                   else:
> > -                    firstsuccessors = ", ".join(successors[:2])
> > +                    firstsuccessors = b", ".join(successors[:2])
> >                       remainingnumber = len(successors) - 2
> > -                    successorsmsg = _("%s and %d more") %
> (firstsuccessors, remainingnumber)
> > -                    reason = _("successors: %s") % successorsmsg
> > +                    successorsmsg = _(b"%s and %d more") %
> (firstsuccessors, remainingnumber)
> > +                    reason = _(b"successors: %s") % successorsmsg
> >
> > -            msg = _("hidden revision '%s'") % changeid
> > -            hint = _('use --hidden to access hidden revisions; %s') %
> reason
> > +            msg = _(b"hidden revision '%s'") % changeid
> > +            hint = _(b'use --hidden to access hidden revisions; %s') %
> reason
> >               return error.FilteredRepoLookupError(msg, hint=hint)
> > -        msg = _("filtered revision '%s' (not in '%s' subset)")
> > +        msg = _(b"filtered revision '%s' (not in '%s' subset)")
> >           msg %= (changeid, repo.filtername)
> >           return error.FilteredRepoLookupError(msg)
> >
> > - at eh.wrapcommand("update")
> > - at eh.wrapcommand("pull")
> > + at eh.wrapcommand(b"update")
> > + at eh.wrapcommand(b"pull")
> >   def wrapmayobsoletewc(origfn, ui, repo, *args, **opts):
> >       """Warn that the working directory parent is an obsolete
> changeset"""
> > -    ctx = repo['.']
> > +    ctx = repo[b'.']
> >       node = ctx.node()
> >       isobs = ctx.obsolete()
> >
> > @@ -776,23 +776,23 @@
> >           lockmod.release(wlock)
> >       return res
> >
> > - at eh.wrapcommand("parents")
> > + at eh.wrapcommand(b"parents")
> >   def wrapparents(origfn, ui, repo, *args, **opts):
> >       res = origfn(ui, repo, *args, **opts)
> >       _warnobsoletewc(ui, repo)
> >       return res
> >
> > - at eh.wrapfunction(mercurial.exchange, 'push')
> > + at eh.wrapfunction(mercurial.exchange, b'push')
> >   def push(orig, repo, *args, **opts):
> >       """Add a hint for "hg evolve" when troubles make push fails
> >       """
> >       try:
> >           return orig(repo, *args, **opts)
> >       except error.Abort as ex:
> > -        hint = _("use 'hg evolve' to get a stable history "
> > -                 "or --force to ignore warnings")
> > +        hint = _(b"use 'hg evolve' to get a stable history "
> > +                 b"or --force to ignore warnings")
> >           if (len(ex.args) >= 1
> > -            and ex.args[0].startswith('push includes ')
> > +            and ex.args[0].startswith(b'push includes ')
> >               and ex.hint is None):
> >               ex.hint = hint
> >           raise
> > @@ -801,11 +801,11 @@
> >       evolvestate = state.cmdstate(repo)
> >       if evolvestate:
> >           # i18n: column positioning for "hg summary"
> > -        ui.status(_('evolve: (evolve --continue)\n'))
> > +        ui.status(_(b'evolve: (evolve --continue)\n'))
> >
> >   @eh.extsetup
> >   def obssummarysetup(ui):
> > -    cmdutil.summaryhooks.add('evolve', summaryhook)
> > +    cmdutil.summaryhooks.add(b'evolve', summaryhook)
> >
> >   #####################################################################
> >   ### Old Evolve extension content                                  ###
> > @@ -816,20 +816,20 @@
> >
> >   @eh.uisetup
> >   def _installimportobsolete(ui):
> > -    entry = cmdutil.findcmd('import', commands.table)[1]
> > -    entry[1].append(('', 'obsolete', False,
> > -                    _('mark the old node as obsoleted by '
> > -                      'the created commit')))
> > +    entry = cmdutil.findcmd(b'import', commands.table)[1]
> > +    entry[1].append((b'', b'obsolete', False,
> > +                     _(b'mark the old node as obsoleted by '
> > +                       b'the created commit')))
> >
> >   def _getnodefrompatch(patch, dest):
> > -    patchnode = patch.get('nodeid')
> > +    patchnode = patch.get(b'nodeid')
> >       if patchnode is not None:
> > -        dest['node'] = node.bin(patchnode)
> > +        dest[b'node'] = node.bin(patchnode)
> >
> > - at eh.wrapfunction(mercurial.cmdutil, 'tryimportone')
> > + at eh.wrapfunction(mercurial.cmdutil, b'tryimportone')
> >   def tryimportone(orig, ui, repo, hunk, parents, opts, *args, **kwargs):
> > -    expected = {'node': None}
> > -    if not util.safehasattr(hunk, 'get'): # hg < 4.6
> > +    expected = {b'node': None}
> > +    if not util.safehasattr(hunk, b'get'): # hg < 4.6
> >           oldextract = patch.extract
> >
> >           def extract(*args, **kwargs):
> > @@ -845,12 +845,12 @@
> >           _getnodefrompatch(hunk, expected)
> >           ret = orig(ui, repo, hunk, parents, opts, *args, **kwargs)
> >       created = ret[1]
> > -    if (opts['obsolete'] and None not in (created, expected['node'])
> > -        and created != expected['node']):
> > -        tr = repo.transaction('import-obs')
> > +    if (opts[b'obsolete'] and None not in (created, expected[b'node'])
> > +        and created != expected[b'node']):
> > +        tr = repo.transaction(b'import-obs')
> >           try:
> > -            metadata = {'user': ui.username()}
> > -            repo.obsstore.create(tr, expected['node'], (created,),
> > +            metadata = {b'user': ui.username()}
> > +            repo.obsstore.create(tr, expected[b'node'], (created,),
> >                                    metadata=metadata)
> >               tr.close()
> >           finally:
> > @@ -878,62 +878,62 @@
> >           if e is entry:
> >               break
> >
> > -    synopsis = '(DEPRECATED)'
> > +    synopsis = b'(DEPRECATED)'
> >       if len(entry) > 2:
> >           fn, opts, _syn = entry
> >       else:
> >           fn, opts, = entry
> > -    deprecationwarning = _('%s have been deprecated in favor of %s\n')
> % (
> > +    deprecationwarning = _(b'%s have been deprecated in favor of %s\n')
> % (
> >           oldalias, newalias)
> >
> >       def newfn(*args, **kwargs):
> >           ui = args[0]
> >           ui.warn(deprecationwarning)
> >           util.checksignature(fn)(*args, **kwargs)
> > -    newfn.__doc__ = deprecationwarning + ' (DEPRECATED)'
> > +    newfn.__doc__ = deprecationwarning + b' (DEPRECATED)'
> >       cmdwrapper = eh.command(oldalias, opts, synopsis)
> >       cmdwrapper(newfn)
> >
> >   @eh.extsetup
> >   def deprecatealiases(ui):
> > -    _deprecatealias('gup', 'next')
> > -    _deprecatealias('gdown', 'previous')
> > +    _deprecatealias(b'gup', b'next')
> > +    _deprecatealias(b'gdown', b'previous')
> >
> >   def _gettopic(ctx):
> >       """handle topic fetching with or without the extension"""
> > -    return getattr(ctx, 'topic', lambda: '')()
> > +    return getattr(ctx, 'topic', lambda: b'')()
> >
> >   def _gettopicidx(ctx):
> >       """handle topic fetching with or without the extension"""
> >       return getattr(ctx, 'topicidx', lambda: None)()
> >
> >   def _getcurrenttopic(repo):
> > -    return getattr(repo, 'currenttopic', '')
> > +    return getattr(repo, 'currenttopic', b'')
> >
> >   def _prevupdate(repo, displayer, target, bookmark, dryrun, mergeopt):
> >       if dryrun:
> > -        repo.ui.write(_('hg update %s;\n') % target)
> > +        repo.ui.write(_(b'hg update %s;\n') % target)
> >           if bookmark is not None:
> > -            repo.ui.write(_('hg bookmark %s -r %s;\n')
> > +            repo.ui.write(_(b'hg bookmark %s -r %s;\n')
> >                             % (bookmark, target))
> >       else:
> >           updatecheck = None
> >           # --merge is passed, we don't need to care about
> commands.update.check
> >           # config option
> >           if mergeopt:
> > -            updatecheck = 'none'
> > +            updatecheck = b'none'
> >           try:
> >               ret = hg.updatetotally(repo.ui, repo, target.node(), None,
> >                                      updatecheck=updatecheck)
> >           except error.Abort as exc:
> >               # replace the hint to mention about --merge option
> > -            exc.hint = _('do you want --merge?')
> > +            exc.hint = _(b'do you want --merge?')
> >               raise
> >           if not ret:
> >               tr = lock = None
> >               try:
> >                   lock = repo.lock()
> > -                tr = repo.transaction('previous')
> > +                tr = repo.transaction(b'previous')
> >                   if bookmark is not None:
> >                       bmchanges = [(bookmark, target.node())]
> >                       repo._bookmarks.applychanges(repo, tr, bmchanges)
> > @@ -961,75 +961,75 @@
> >
> >       # issue message for the various case
> >       if p1.node() == node.nullid:
> > -        repo.ui.warn(_('already at repository root\n'))
> > +        repo.ui.warn(_(b'already at repository root\n'))
> >       elif not parents and currenttopic:
> > -        repo.ui.warn(_('no parent in topic "%s"\n') % currenttopic)
> > -        repo.ui.warn(_('(do you want --no-topic)\n'))
> > +        repo.ui.warn(_(b'no parent in topic "%s"\n') % currenttopic)
> > +        repo.ui.warn(_(b'(do you want --no-topic)\n'))
> >       elif len(parents) == 1:
> >           target = parents[0]
> >           bookmark = None
> >           if movebookmark:
> >               bookmark = repo._activebookmark
> >       else:
> > -        header = _("multiple parents, choose one to update:")
> > +        header = _(b"multiple parents, choose one to update:")
> >           prevs = [p.rev() for p in parents]
> >           choosedrev = utility.revselectionprompt(repo.ui, repo, prevs,
> header)
> >           if choosedrev is None:
> >               for p in parents:
> >                   displayer.show(p)
> > -            repo.ui.warn(_('multiple parents, explicitly update to
> one\n'))
> > +            repo.ui.warn(_(b'multiple parents, explicitly update to
> one\n'))
> >           else:
> >               target = repo[choosedrev]
> >       return target, bookmark
> >
> >   @eh.command(
> > -    'previous',
> > -    [('B', 'move-bookmark', False,
> > -        _('move active bookmark after update')),
> > -     ('m', 'merge', False, _('bring uncommitted change along')),
> > -     ('', 'no-topic', False, _('ignore topic and move topologically')),
> > -     ('n', 'dry-run', False,
> > -        _('do not perform actions, just print what would be done'))],
> > -    '[OPTION]...',
> > +    b'previous',
> > +    [(b'B', b'move-bookmark', False,
> > +        _(b'move active bookmark after update')),
> > +     (b'm', b'merge', False, _(b'bring uncommitted change along')),
> > +     (b'', b'no-topic', False, _(b'ignore topic and move
> topologically')),
> > +     (b'n', b'dry-run', False,
> > +        _(b'do not perform actions, just print what would be done'))],
> > +    b'[OPTION]...',
> >       helpbasic=True)
> >   def cmdprevious(ui, repo, **opts):
> >       """update to parent revision
> >
> >       Displays the summary line of the destination for clarity."""
> >       wlock = None
> > -    dryrunopt = opts['dry_run']
> > -    mergeopt = opts['merge']
> > +    dryrunopt = opts[b'dry_run']
> > +    mergeopt = opts[b'merge']
> >       if not dryrunopt:
> >           wlock = repo.wlock()
> >       try:
> >           wkctx = repo[None]
> >           wparents = wkctx.parents()
> >           if len(wparents) != 1:
> > -            raise error.Abort(_('merge in progress'))
> > +            raise error.Abort(_(b'merge in progress'))
> >           if not mergeopt:
> >               # we only skip the check if noconflict is set
> > -            if ui.config('commands', 'update.check') == 'noconflict':
> > +            if ui.config(b'commands', b'update.check') == b'noconflict':
> >                   pass
> >               else:
> > -                cmdutil.bailifchanged(repo, hint=_('do you want
> --merge?'))
> > +                cmdutil.bailifchanged(repo, hint=_(b'do you want
> --merge?'))
> >
> > -        topic = not opts.get("no_topic", False)
> > +        topic = not opts.get(b"no_topic", False)
> >           hastopic = bool(_getcurrenttopic(repo))
> >
> >           template = shorttemplate
> >           if topic and hastopic:
> >               template = utility.stacktemplate
> >
> > -        displayer = compat.changesetdisplayer(ui, repo, {'template':
> template})
> > +        displayer = compat.changesetdisplayer(ui, repo, {b'template':
> template})
> >
> >           target, bookmark = _findprevtarget(repo, displayer,
> > -                                           opts.get('move_bookmark'),
> topic)
> > +                                           opts.get(b'move_bookmark'),
> topic)
> >           if target is not None:
> > -            backup = repo.ui.backupconfig('_internal', 'keep-topic')
> > +            backup = repo.ui.backupconfig(b'_internal', b'keep-topic')
> >               try:
> >                   if topic and _getcurrenttopic(repo) !=
> _gettopic(target):
> > -                    repo.ui.setconfig('_internal', 'keep-topic', 'yes',
> > -                                      source='topic-extension')
> > +                    repo.ui.setconfig(b'_internal', b'keep-topic',
> b'yes',
> > +                                      source=b'topic-extension')
> >                   _prevupdate(repo, displayer, target, bookmark,
> dryrunopt,
> >                               mergeopt)
> >               finally:
> > @@ -1041,15 +1041,15 @@
> >           lockmod.release(wlock)
> >
> >   @eh.command(
> > -    'next',
> > -    [('B', 'move-bookmark', False,
> > -        _('move active bookmark after update')),
> > -     ('m', 'merge', False, _('bring uncommitted change along')),
> > -     ('', 'evolve', True, _('evolve the next changeset if necessary')),
> > -     ('', 'no-topic', False, _('ignore topic and move topologically')),
> > -     ('n', 'dry-run', False,
> > -      _('do not perform actions, just print what would be done'))],
> > -    '[OPTION]...',
> > +    b'next',
> > +    [(b'B', b'move-bookmark', False,
> > +        _(b'move active bookmark after update')),
> > +     (b'm', b'merge', False, _(b'bring uncommitted change along')),
> > +     (b'', b'evolve', True, _(b'evolve the next changeset if
> necessary')),
> > +     (b'', b'no-topic', False, _(b'ignore topic and move
> topologically')),
> > +     (b'n', b'dry-run', False,
> > +      _(b'do not perform actions, just print what would be done'))],
> > +    b'[OPTION]...',
> >       helpbasic=True)
> >   def cmdnext(ui, repo, **opts):
> >       """update to next child revision
> > @@ -1060,29 +1060,29 @@
> >       Displays the summary line of the destination for clarity.
> >       """
> >       wlock = None
> > -    dryrunopt = opts['dry_run']
> > +    dryrunopt = opts[b'dry_run']
> >       if not dryrunopt:
> >           wlock = repo.wlock()
> >       try:
> >           wkctx = repo[None]
> >           wparents = wkctx.parents()
> >           if len(wparents) != 1:
> > -            raise error.Abort(_('merge in progress'))
> > +            raise error.Abort(_(b'merge in progress'))
> >
> >           children = [ctx for ctx in wparents[0].children() if not
> ctx.obsolete()]
> >           topic = _getcurrenttopic(repo)
> >           filtered = set()
> >           template = shorttemplate
> > -        if topic and not opts.get("no_topic", False):
> > +        if topic and not opts.get(b"no_topic", False):
> >               filtered = set(ctx for ctx in children if ctx.topic() !=
> topic)
> >               children = [ctx for ctx in children if ctx not in filtered]
> >               template = utility.stacktemplate
> > -            opts['stacktemplate'] = True
> > -        displayer = compat.changesetdisplayer(ui, repo, {'template':
> template})
> > +            opts[b'stacktemplate'] = True
> > +        displayer = compat.changesetdisplayer(ui, repo, {b'template':
> template})
> >
> >           # check if we need to evolve while updating to the next child
> revision
> >           needevolve = False
> > -        aspchildren = evolvecmd._aspiringchildren(repo,
> [repo['.'].rev()])
> > +        aspchildren = evolvecmd._aspiringchildren(repo,
> [repo[b'.'].rev()])
> >           if topic:
> >               filtered.update(repo[c] for c in aspchildren
> >                               if repo[c].topic() != topic)
> > @@ -1101,54 +1101,54 @@
> >               needevolve = True
> >
> >           # check if working directory is clean before we evolve the
> next cset
> > -        if needevolve and opts['evolve']:
> > -            hint = _('use `hg amend`, `hg revert` or `hg shelve`')
> > +        if needevolve and opts[b'evolve']:
> > +            hint = _(b'use `hg amend`, `hg revert` or `hg shelve`')
> >               cmdutil.bailifchanged(repo, hint=hint)
> >
> > -        if not (opts['merge'] or (needevolve and opts['evolve'])):
> > +        if not (opts[b'merge'] or (needevolve and opts[b'evolve'])):
> >               # we only skip the check if noconflict is set
> > -            if ui.config('commands', 'update.check') == 'noconflict':
> > +            if ui.config(b'commands', b'update.check') == b'noconflict':
> >                   pass
> >               else:
> > -                cmdutil.bailifchanged(repo, hint=_('do you want
> --merge?'))
> > +                cmdutil.bailifchanged(repo, hint=_(b'do you want
> --merge?'))
> >
> >           if len(children) == 1:
> >               c = children[0]
> >               return _updatetonext(ui, repo, c, displayer, opts)
> >           elif children:
> > -            cheader = _("ambiguous next changeset, choose one to
> update:")
> > +            cheader = _(b"ambiguous next changeset, choose one to
> update:")
> >               crevs = [c.rev() for c in children]
> >               choosedrev = utility.revselectionprompt(ui, repo, crevs,
> cheader)
> >               if choosedrev is None:
> > -                ui.warn(_("ambiguous next changeset:\n"))
> > +                ui.warn(_(b"ambiguous next changeset:\n"))
> >                   for c in children:
> >                       displayer.show(c)
> > -                ui.warn(_("explicitly update to one of them\n"))
> > +                ui.warn(_(b"explicitly update to one of them\n"))
> >                   return 1
> >               else:
> >                   return _updatetonext(ui, repo, repo[choosedrev],
> displayer, opts)
> >           else:
> > -            if not opts['evolve'] or not aspchildren:
> > +            if not opts[b'evolve'] or not aspchildren:
> >                   if filtered:
> > -                    ui.warn(_('no children on topic "%s"\n') % topic)
> > -                    ui.warn(_('do you want --no-topic\n'))
> > +                    ui.warn(_(b'no children on topic "%s"\n') % topic)
> > +                    ui.warn(_(b'do you want --no-topic\n'))
> >                   else:
> > -                    ui.warn(_('no children\n'))
> > +                    ui.warn(_(b'no children\n'))
> >                   if aspchildren:
> > -                    msg = _('(%i unstable changesets to be evolved
> here, '
> > -                            'do you want --evolve?)\n')
> > +                    msg = _(b'(%i unstable changesets to be evolved
> here, '
> > +                            b'do you want --evolve?)\n')
> >                       ui.warn(msg % len(aspchildren))
> >                   return 1
> >               elif len(aspchildren) > 1:
> > -                cheader = _("ambiguous next (unstable) changeset,
> choose one to"
> > -                            " evolve and update:")
> > +                cheader = _(b"ambiguous next (unstable) changeset,
> choose one to"
> > +                            b" evolve and update:")
> >                   choosedrev = utility.revselectionprompt(ui, repo,
> >                                                           aspchildren,
> cheader)
> >                   if choosedrev is None:
> > -                    ui.warn(_("ambiguous next (unstable) changeset:\n"))
> > +                    ui.warn(_(b"ambiguous next (unstable)
> changeset:\n"))
> >                       for c in aspchildren:
> >                           displayer.show(repo[c])
> > -                    ui.warn(_("(run 'hg evolve --rev REV' on one of
> them)\n"))
> > +                    ui.warn(_(b"(run 'hg evolve --rev REV' on one of
> them)\n"))
> >                       return 1
> >                   else:
> >                       return _nextevolve(ui, repo, repo[choosedrev],
> opts)
> > @@ -1161,51 +1161,51 @@
> >       """logic for hg next command to evolve and update to an aspiring
> children"""
> >
> >       cmdutil.bailifchanged(repo)
> > -    evolvestate = state.cmdstate(repo, opts={'command': 'next',
> > -                                             'bookmarkchanges': []})
> > +    evolvestate = state.cmdstate(repo, opts={b'command': b'next',
> > +                                             b'bookmarkchanges': []})
> >       with repo.wlock(), repo.lock():
> > -        tr = repo.transaction("evolve")
> > +        tr = repo.transaction(b"evolve")
> >           with util.acceptintervention(tr):
> >               result = evolvecmd._solveone(ui, repo, repo[aspchildren],
> > -                                         evolvestate,
> opts.get('dry_run'),
> > +                                         evolvestate,
> opts.get(b'dry_run'),
> >                                            False,
> > -                                         lambda: None,
> category='orphan',
> > -
>  stacktmplt=opts.get('stacktemplate',
> > +                                         lambda: None,
> category=b'orphan',
> > +
>  stacktmplt=opts.get(b'stacktemplate',
> >                                                                False))
> >       # making sure a next commit is formed
> >       if result[0] and result[1]:
> > -        ui.status(_('working directory is now at %s\n')
> > -                  % ui.label(str(repo['.']), 'evolve.node'))
> > +        ui.status(_(b'working directory is now at %s\n')
> > +                  % ui.label(str(repo[b'.']), b'evolve.node'))
> >       return 0
> >
> >   def _updatetonext(ui, repo, children, displayer, opts):
> >       """ logic for `hg next` command to update to children and move
> bookmarks if
> >       required """
> >       bm = repo._activebookmark
> > -    shouldmove = opts.get('move_bookmark') and bm is not None
> > -    if opts.get('dry_run'):
> > -        ui.write(_('hg update %s;\n') % children)
> > +    shouldmove = opts.get(b'move_bookmark') and bm is not None
> > +    if opts.get(b'dry_run'):
> > +        ui.write(_(b'hg update %s;\n') % children)
> >           if shouldmove:
> > -            ui.write(_('hg bookmark %s -r %s;\n') % (bm, children))
> > +            ui.write(_(b'hg bookmark %s -r %s;\n') % (bm, children))
> >       else:
> >           updatecheck = None
> >           # --merge is passed, we don't need to care about
> commands.update.check
> >           # config option
> > -        if opts['merge']:
> > -            updatecheck = 'none'
> > +        if opts[b'merge']:
> > +            updatecheck = b'none'
> >           try:
> >               ret = hg.updatetotally(ui, repo, children.node(), None,
> >                                      updatecheck=updatecheck)
> >           except error.Abort as exc:
> >               # replace the hint to mention about --merge option
> > -            exc.hint = _('do you want --merge?')
> > +            exc.hint = _(b'do you want --merge?')
> >               raise
> >
> >           if not ret:
> >               lock = tr = None
> >               try:
> >                   lock = repo.lock()
> > -                tr = repo.transaction('next')
> > +                tr = repo.transaction(b'next')
> >                   if shouldmove:
> >                       bmchanges = [(bm, children.node())]
> >                       repo._bookmarks.applychanges(repo, tr, bmchanges)
> > @@ -1218,28 +1218,28 @@
> >           displayer.show(children)
> >       return 0
> >
> > - at eh.wrapcommand('commit')
> > + at eh.wrapcommand(b'commit')
> >   def commitwrapper(orig, ui, repo, *arg, **kwargs):
> >       tr = None
> > -    if kwargs.get('amend', False):
> > +    if kwargs.get(b'amend', False):
> >           wlock = lock = None
> >       else:
> >           wlock = repo.wlock()
> >           lock = repo.lock()
> >       try:
> > -        obsoleted = kwargs.get('obsolete', [])
> > +        obsoleted = kwargs.get(b'obsolete', [])
> >           if obsoleted:
> > -            obsoleted = repo.set('%lr', obsoleted)
> > +            obsoleted = repo.set(b'%lr', obsoleted)
> >           result = orig(ui, repo, *arg, **kwargs)
> >           if not result: # commit succeeded
> > -            new = repo['tip']
> > +            new = repo[b'tip']
> >               oldbookmarks = []
> >               markers = []
> >               for old in obsoleted:
> >                   oldbookmarks.extend(repo.nodebookmarks(old.node()))
> >                   markers.append((old, (new,)))
> >               if markers:
> > -                obsolete.createmarkers(repo, markers, operation="amend")
> > +                obsolete.createmarkers(repo, markers,
> operation=b"amend")
> >               bmchanges = []
> >               for book in oldbookmarks:
> >                   bmchanges.append((book, new.node()))
> > @@ -1248,70 +1248,70 @@
> >                       wlock = repo.wlock()
> >                   if not lock:
> >                       lock = repo.lock()
> > -                tr = repo.transaction('commit')
> > +                tr = repo.transaction(b'commit')
> >                   repo._bookmarks.applychanges(repo, tr, bmchanges)
> >                   tr.close()
> >           return result
> >       finally:
> >           lockmod.release(tr, lock, wlock)
> >
> > - at eh.wrapcommand('strip', extension='strip', opts=[
> > -    ('', 'bundle', None, _("delete the commit entirely and move it to a
> "
> > -                           "backup bundle")),
> > + at eh.wrapcommand(b'strip', extension=b'strip', opts=[
> > +    (b'', b'bundle', None, _(b"delete the commit entirely and move it
> to a "
> > +                             b"backup bundle")),
> >       ])
> >   def stripwrapper(orig, ui, repo, *revs, **kwargs):
> > -    if (not ui.configbool('experimental', 'prunestrip')
> > -        or kwargs.get('bundle', False)):
> > +    if (not ui.configbool(b'experimental', b'prunestrip')
> > +        or kwargs.get(b'bundle', False)):
> >           return orig(ui, repo, *revs, **kwargs)
> >
> > -    if kwargs.get('force'):
> > -        ui.warn(_("warning: --force has no effect during strip with
> evolve "
> > -                  "enabled\n"))
> > -    if kwargs.get('no_backup', False):
> > -        ui.warn(_("warning: --no-backup has no effect during strips
> with "
> > -                  "evolve enabled\n"))
> > +    if kwargs.get(b'force'):
> > +        ui.warn(_(b"warning: --force has no effect during strip with
> evolve "
> > +                  b"enabled\n"))
> > +    if kwargs.get(b'no_backup', False):
> > +        ui.warn(_(b"warning: --no-backup has no effect during strips
> with "
> > +                  b"evolve enabled\n"))
> >
> > -    revs = list(revs) + kwargs.pop('rev', [])
> > +    revs = list(revs) + kwargs.pop(b'rev', [])
> >       revs = set(scmutil.revrange(repo, revs))
> > -    revs = repo.revs("(%ld)::", revs)
> > -    kwargs['rev'] = []
> > -    kwargs['new'] = []
> > -    kwargs['succ'] = []
> > -    kwargs['biject'] = False
> > +    revs = repo.revs(b"(%ld)::", revs)
> > +    kwargs[b'rev'] = []
> > +    kwargs[b'new'] = []
> > +    kwargs[b'succ'] = []
> > +    kwargs[b'biject'] = False
> >       return cmdrewrite.cmdprune(ui, repo, *revs, **kwargs)
> >
> >   @eh.extsetup
> >   def oldevolveextsetup(ui):
> > -    entry = cmdutil.findcmd('commit', commands.table)[1]
> > -    entry[1].append(('o', 'obsolete', [],
> > -                     _("make commit obsolete this revision
> (DEPRECATED)")))
> > +    entry = cmdutil.findcmd(b'commit', commands.table)[1]
> > +    entry[1].append((b'o', b'obsolete', [],
> > +                     _(b"make commit obsolete this revision
> (DEPRECATED)")))
> >
> > - at eh.wrapfunction(obsolete, '_checkinvalidmarkers')
> > + at eh.wrapfunction(obsolete, b'_checkinvalidmarkers')
> >   def _checkinvalidmarkers(orig, markers):
> >       """search for marker with invalid data and raise error if needed
> >
> >       Exist as a separated function to allow the evolve extension for a
> more
> >       subtle handling.
> >       """
> > -    if 'debugobsconvert' in sys.argv:
> > +    if b'debugobsconvert' in sys.argv:
> >           return
> >       for mark in markers:
> >           if node.nullid in mark[1]:
> > -            msg = _('bad obsolescence marker detected: invalid
> successors nullid')
> > -            hint = _('You should run `hg debugobsconvert`')
> > +            msg = _(b'bad obsolescence marker detected: invalid
> successors nullid')
> > +            hint = _(b'You should run `hg debugobsconvert`')
> >               raise error.Abort(msg, hint=hint)
> >
> >   @eh.command(
> > -    'debugobsconvert',
> > -    [('', 'new-format', obsexchange._bestformat, _('Destination format
> for markers.'))],
> > -    '')
> > +    b'debugobsconvert',
> > +    [(b'', b'new-format', obsexchange._bestformat, _(b'Destination
> format for markers.'))],
> > +    b'')
> >   def debugobsconvert(ui, repo, new_format):
> >       origmarkers = repo.obsstore._all  # settle version
> >       if new_format == repo.obsstore._version:
> > -        msg = _('New format is the same as the old format, not
> upgrading!')
> > +        msg = _(b'New format is the same as the old format, not
> upgrading!')
> >           raise error.Abort(msg)
> >       with repo.lock():
> > -        f = repo.svfs('obsstore', 'wb', atomictemp=True)
> > +        f = repo.svfs(b'obsstore', b'wb', atomictemp=True)
> >           known = set()
> >           markers = []
> >           for m in origmarkers:
> > @@ -1324,11 +1324,11 @@
> >                   continue
> >               known.add(m)
> >               markers.append(m)
> > -        ui.write(_('Old store is version %d, will rewrite in version
> %d\n') % (
> > +        ui.write(_(b'Old store is version %d, will rewrite in version
> %d\n') % (
> >               repo.obsstore._version, new_format))
> >           map(f.write, obsolete.encodemarkers(markers, True, new_format))
> >           f.close()
> > -    ui.write(_('Done!\n'))
> > +    ui.write(_(b'Done!\n'))
> >
> >
> >   def _helploader(ui):
> > @@ -1337,40 +1337,40 @@
> >   @eh.uisetup
> >   def _setuphelp(ui):
> >       for entry in help.helptable:
> > -        if entry[0] == "evolution":
> > +        if entry[0] == b"evolution":
> >               break
> >       else:
> > -        help.helptable.append((["evolution"], _("Safely Rewriting
> History"),
> > -                              _helploader))
> > +        help.helptable.append(([b"evolution"], _(b"Safely Rewriting
> History"),
> > +                               _helploader))
> >           help.helptable.sort()
> >
> >   evolvestateversion = 0
> >
> >   def _evolvemessage():
> > -    _msg = _('To continue:    hg evolve --continue\n'
> > -             'To abort:       hg evolve --abort\n'
> > -             'To stop:        hg evolve --stop\n'
> > -             '(also see `hg help evolve.interrupted`)')
> > +    _msg = _(b'To continue:    hg evolve --continue\n'
> > +             b'To abort:       hg evolve --abort\n'
> > +             b'To stop:        hg evolve --stop\n'
> > +             b'(also see `hg help evolve.interrupted`)')
> >       return cmdutil._commentlines(_msg)
> >
> >   @eh.uisetup
> >   def setupevolveunfinished(ui):
> > -    data = ('evolvestate', False, False, _('evolve in progress'),
> > -            _("use 'hg evolve --continue' or 'hg evolve --abort' to
> abort"))
> > +    data = (b'evolvestate', False, False, _(b'evolve in progress'),
> > +            _(b"use 'hg evolve --continue' or 'hg evolve --abort' to
> abort"))
> >       cmdutil.unfinishedstates.append(data)
> >
> > -    afterresolved = ('evolvestate', _('hg evolve --continue'))
> > -    pickresolved = ('pickstate', _('hg pick --continue'))
> > +    afterresolved = (b'evolvestate', _(b'hg evolve --continue'))
> > +    pickresolved = (b'pickstate', _(b'hg pick --continue'))
> >       cmdutil.afterresolvedstates.append(afterresolved)
> >       cmdutil.afterresolvedstates.append(pickresolved)
> >
> > -    if util.safehasattr(cmdutil, 'STATES'):
> > -        statedata = ('evolve',
> cmdutil.fileexistspredicate('evolvestate'),
> > +    if util.safehasattr(cmdutil, b'STATES'):
> > +        statedata = (b'evolve',
> cmdutil.fileexistspredicate(b'evolvestate'),
> >                        _evolvemessage)
> >           cmdutil.STATES = (statedata, ) + cmdutil.STATES
> >
> > - at eh.wrapfunction(hg, 'clean')
> > + at eh.wrapfunction(hg, b'clean')
> >   def clean(orig, repo, *args, **kwargs):
> >       ret = orig(repo, *args, **kwargs)
> > -    util.unlinkpath(repo.vfs.join('evolvestate'), ignoremissing=True)
> > +    util.unlinkpath(repo.vfs.join(b'evolvestate'), ignoremissing=True)
> >       return ret
> > diff --git a/hgext3rd/evolve/cmdrewrite.py
> b/hgext3rd/evolve/cmdrewrite.py
> > --- a/hgext3rd/evolve/cmdrewrite.py
> > +++ b/hgext3rd/evolve/cmdrewrite.py
> > @@ -61,17 +61,17 @@
> >   def _checknotesize(ui, opts):
> >       """ make sure note is of valid format """
> >
> > -    note = opts.get('note')
> > +    note = opts.get(b'note')
> >       if not note:
> >           return
> >
> >       if not compat.isobsnotesupported():
> > -        ui.warn(_("current hg version does not support storing"
> > -                  " note in obsmarker\n"))
> > +        ui.warn(_(b"current hg version does not support storing"
> > +                  b" note in obsmarker\n"))
> >       if len(note) > 255:
> > -        raise error.Abort(_("cannot store a note of more than 255
> bytes"))
> > -    if '\n' in note:
> > -        raise error.Abort(_("note cannot contain a newline"))
> > +        raise error.Abort(_(b"cannot store a note of more than 255
> bytes"))
> > +    if b'\n' in note:
> > +        raise error.Abort(_(b"note cannot contain a newline"))
> >
> >   def _resolveoptions(ui, opts):
> >       """modify commit options dict to handle related options
> > @@ -80,34 +80,34 @@
> >       -d was supplied.
> >       """
> >       # N.B. this is extremely similar to setupheaderopts() in mq.py
> > -    if not opts.get('date') and opts.get('current_date'):
> > -        opts['date'] = '%d %d' % compat.makedate()
> > -    if not opts.get('user') and opts.get('current_user'):
> > -        opts['user'] = ui.username()
> > +    if not opts.get(b'date') and opts.get(b'current_date'):
> > +        opts[b'date'] = b'%d %d' % compat.makedate()
> > +    if not opts.get(b'user') and opts.get(b'current_user'):
> > +        opts[b'user'] = ui.username()
> >
> >   commitopts3 = [
> > -    ('D', 'current-date', None,
> > -     _('record the current date as commit date')),
> > -    ('U', 'current-user', None,
> > -     _('record the current user as committer')),
> > +    (b'D', b'current-date', None,
> > +     _(b'record the current date as commit date')),
> > +    (b'U', b'current-user', None,
> > +     _(b'record the current user as committer')),
> >   ]
> >
> > -interactiveopt = [['i', 'interactive', None, _('use interactive mode')]]
> > +interactiveopt = [[b'i', b'interactive', None, _(b'use interactive
> mode')]]
> >
> >   @eh.command(
> > -    'amend|refresh',
> > -    [('A', 'addremove', None,
> > -      _('mark new/missing files as added/removed before committing')),
> > -     ('a', 'all', False, _("match all files")),
> > -     ('e', 'edit', False, _('invoke editor on commit messages')),
> > -     ('', 'extract', False, _('extract changes from the commit to the
> working copy')),
> > -     ('', 'patch', False, _('make changes to wdir parent by editing
> patch')),
> > -     ('', 'close-branch', None,
> > -      _('mark a branch as closed, hiding it from the branch list')),
> > -     ('s', 'secret', None, _('use the secret phase for committing')),
> > -     ('n', 'note', '', _('store a note on amend'), _('TEXT')),
> > -    ] + walkopts + commitopts + commitopts2 + commitopts3 +
> interactiveopt,
> > -    _('[OPTION]... [FILE]...'),
> > +    b'amend|refresh',
> > +    [(b'A', b'addremove', None,
> > +      _(b'mark new/missing files as added/removed before committing')),
> > +     (b'a', b'all', False, _(b"match all files")),
> > +     (b'e', b'edit', False, _(b'invoke editor on commit messages')),
> > +     (b'', b'extract', False, _(b'extract changes from the commit to
> the working copy')),
> > +     (b'', b'patch', False, _(b'make changes to wdir parent by editing
> patch')),
> > +     (b'', b'close-branch', None,
> > +      _(b'mark a branch as closed, hiding it from the branch list')),
> > +     (b's', b'secret', None, _(b'use the secret phase for committing')),
> > +     (b'n', b'note', b'', _(b'store a note on amend'), _(b'TEXT')),
> > +     ] + walkopts + commitopts + commitopts2 + commitopts3 +
> interactiveopt,
> > +    _(b'[OPTION]... [FILE]...'),
> >       helpbasic=True)
> >   def amend(ui, repo, *pats, **opts):
> >       """combine a changeset with updates and replace it with a new one
> > @@ -127,34 +127,34 @@
> >       """
> >       _checknotesize(ui, opts)
> >       opts = opts.copy()
> > -    if opts.get('patch'):
> > +    if opts.get(b'patch'):
> >           return amendpatch(ui, repo, *pats, **opts)
> > -    if opts.get('extract'):
> > +    if opts.get(b'extract'):
> >           return uncommit(ui, repo, *pats, **opts)
> >       else:
> > -        if opts.pop('all', False):
> > +        if opts.pop(b'all', False):
> >               # add an include for all
> > -            include = list(opts.get('include'))
> > -            include.append('re:.*')
> > -        edit = opts.pop('edit', False)
> > -        log = opts.get('logfile')
> > -        opts['amend'] = True
> > +            include = list(opts.get(b'include'))
> > +            include.append(b're:.*')
> > +        edit = opts.pop(b'edit', False)
> > +        log = opts.get(b'logfile')
> > +        opts[b'amend'] = True
> >           _resolveoptions(ui, opts)
> > -        _alias, commitcmd = cmdutil.findcmd('commit', commands.table)
> > +        _alias, commitcmd = cmdutil.findcmd(b'commit', commands.table)
> >           with repo.wlock(), repo.lock():
> > -            if not (edit or opts['message'] or log):
> > -                opts['message'] = repo['.'].description()
> > -            rewriteutil.precheck(repo, [repo['.'].rev()],
> action='amend')
> > +            if not (edit or opts[b'message'] or log):
> > +                opts[b'message'] = repo[b'.'].description()
> > +            rewriteutil.precheck(repo, [repo[b'.'].rev()],
> action=b'amend')
> >               return commitcmd[0](ui, repo, *pats, **opts)
> >
> >   def amendpatch(ui, repo, *pats, **opts):
> >       """logic for --patch flag of `hg amend` command."""
> > -    with repo.wlock(), repo.lock(), repo.transaction('amend') as tr:
> > +    with repo.wlock(), repo.lock(), repo.transaction(b'amend') as tr:
> >           cmdutil.bailifchanged(repo)
> >           # first get the patch
> > -        old = repo['.']
> > +        old = repo[b'.']
> >           p1 = old.p1()
> > -        rewriteutil.precheck(repo, [old.rev()], 'amend')
> > +        rewriteutil.precheck(repo, [old.rev()], b'amend')
> >           diffopts = patch.difffeatureopts(repo.ui, whitespace=True)
> >           diffopts.nodates = True
> >           diffopts.git = True
> > @@ -167,12 +167,12 @@
> >               fp.write(chunk)
> >           newnode = _editandapply(ui, repo, pats, old, p1, fp, diffopts)
> >           if newnode == old.node():
> > -            raise error.Abort(_("nothing changed"))
> > +            raise error.Abort(_(b"nothing changed"))
> >           metadata = {}
> > -        if opts.get('note'):
> > -            metadata['note'] = opts['note']
> > +        if opts.get(b'note'):
> > +            metadata[b'note'] = opts[b'note']
> >           replacements = {old.node(): [newnode]}
> > -        scmutil.cleanupnodes(repo, replacements, operation='amend',
> > +        scmutil.cleanupnodes(repo, replacements, operation=b'amend',
> >                                metadata=metadata)
> >           phases.retractboundary(repo, tr, old.phase(), [newnode])
> >           hg.updaterepo(repo, newnode, True)
> > @@ -183,7 +183,7 @@
> >           fp.seek(0)
> >           previous_patch = fp.getvalue()
> >           if 5 <= len(ui.edit.im_func.func_defaults):
> > -            newpatch = ui.edit(fp.getvalue(), old.user(), action="diff")
> > +            newpatch = ui.edit(fp.getvalue(), old.user(),
> action=b"diff")
> >           else:
> >               newpatch = ui.edit(fp.getvalue(), old.user())
> >
> > @@ -191,7 +191,7 @@
> >           afp.write(newpatch)
> >           if pats:
> >               # write rest of the files in the patch
> > -            restmatcher = scmutil.match(old, [], opts={'exclude': pats})
> > +            restmatcher = scmutil.match(old, [], opts={b'exclude':
> pats})
> >               for chunk, label in patch.diffui(repo, p1.node(),
> old.node(),
> >                                                match=restmatcher,
> >                                                opts=diffopts):
> > @@ -199,21 +199,21 @@
> >
> >           user_patch = afp.getvalue()
> >           if not user_patch:
> > -            raise error.Abort(_("empty patch file, amend aborted"))
> > +            raise error.Abort(_(b"empty patch file, amend aborted"))
> >           if user_patch == previous_patch:
> > -            raise error.Abort(_("patch unchanged"))
> > +            raise error.Abort(_(b"patch unchanged"))
> >           afp.seek(0)
> >           # write the patch to repo a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20190702/771391df/attachment.html>


More information about the Mercurial-devel mailing list