Mercurial > public > mercurial-scm > hg
comparison mercurial/filemerge.py @ 50920:c642c03969ff
dynamic-import: use sysstr for importing extension and others
This logic is used by extensions, and python hooks and merge-tools. All this
logic eventually deals with native string (unicode in Python 3). This patch
makes it handle `str` directly instead of relying on some pycompat low lever
layer to do the conversion at the last minutes.
We adjust the Python version filtering of a test as the output seems to be present with Python 3.7 too.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 31 Aug 2023 02:41:33 +0200 |
parents | 2282d8ac0fa9 |
children | 18c8c18993f0 |
comparison
equal
deleted
inserted
replaced
50919:0e6cea0c3113 | 50920:c642c03969ff |
---|---|
832 r = 0 | 832 r = 0 |
833 try: | 833 try: |
834 # avoid cycle cmdutil->merge->filemerge->extensions->cmdutil | 834 # avoid cycle cmdutil->merge->filemerge->extensions->cmdutil |
835 from . import extensions | 835 from . import extensions |
836 | 836 |
837 mod = extensions.loadpath(toolpath, b'hgmerge.%s' % tool) | 837 mod_name = 'hgmerge.%s' % pycompat.sysstr(tool) |
838 mod = extensions.loadpath(toolpath, mod_name) | |
838 except Exception: | 839 except Exception: |
839 raise error.Abort( | 840 raise error.Abort( |
840 _(b"loading python merge script failed: %s") % toolpath | 841 _(b"loading python merge script failed: %s") % toolpath |
841 ) | 842 ) |
842 mergefn = getattr(mod, scriptfn, None) | 843 mergefn = getattr(mod, pycompat.sysstr(scriptfn), None) |
843 if mergefn is None: | 844 if mergefn is None: |
844 raise error.Abort( | 845 raise error.Abort( |
845 _(b"%s does not have function: %s") % (toolpath, scriptfn) | 846 _(b"%s does not have function: %s") % (toolpath, scriptfn) |
846 ) | 847 ) |
847 argslist = procutil.shellsplit(args) | 848 argslist = procutil.shellsplit(args) |