Patchwork D11820: extensions: refactor handling of loading error make it reusable

login
register
mail settings
Submitter phabricator
Date Nov. 29, 2021, 4:51 p.m.
Message ID <differential-rev-PHID-DREV-f3xgvwvpklfr5m22ukrm-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50145/
State Superseded
Headers show

Comments

phabricator - Nov. 29, 2021, 4:51 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We will need this in the next patch.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11820

AFFECTED FILES
  mercurial/extensions.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -307,15 +307,12 @@ 
             except Exception as inst:
                 msg = stringutil.forcebytestr(inst)
                 if path:
-                    ui.warn(
-                        _(b"*** failed to import extension %s from %s: %s\n")
-                        % (name, path, msg)
-                    )
+                    error_msg = _(b"failed to import extension %s from %s: %s")
+                    error_msg %= (name, path, msg)
                 else:
-                    ui.warn(
-                        _(b"*** failed to import extension %s: %s\n")
-                        % (name, msg)
-                    )
+                    error_msg = _(b"failed to import extension %s: %s")
+                    error_msg %= (name, msg)
+                ui.warn((b"*** %s\n") % error_msg)
                 if isinstance(inst, error.Hint) and inst.hint:
                     ui.warn(_(b"*** (%s)\n") % inst.hint)
                 ui.traceback()