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

Martin von Zweigbergk martinvonz at google.com
Wed Jul 3 03:37:54 EDT 2019


On Sun, Jun 30, 2019 at 10:42 PM Ludovic Chabant <ludovic at chabant.com>
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
> - 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'])
>

Should opts[x], opts.get(x), etc really use bytes? They usually get passed
as **opts, which means their keys are str, I think.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20190703/1a31e6d1/attachment.html>


More information about the Mercurial-devel mailing list