Patchwork D9352: config: clean up message about ignored untrusted config

login
register
mail settings
Submitter phabricator
Date Nov. 21, 2020, 12:26 a.m.
Message ID <differential-rev-PHID-DREV-dsxc577m4vjerdpmsgy5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47631/
State Superseded
Headers show

Comments

phabricator - Nov. 21, 2020, 12:26 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The error message relied on Python's default formatting of arguments
  to an Exception's constructor. Let's try to make it a little more
  readable for users.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/ui.py
  tests/test-trusted.py.out

CHANGE DETAILS




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

Patch

diff --git a/tests/test-trusted.py.out b/tests/test-trusted.py.out
--- a/tests/test-trusted.py.out
+++ b/tests/test-trusted.py.out
@@ -174,7 +174,7 @@ 
 # parse error
 # different user, different group
 not trusting file .hg/hgrc from untrusted user abc, group def
-ignored: ('foo', '.hg/hgrc:1')
+ignored .hg/hgrc:1: foo
 # same user, same group
 hg: parse error at .hg/hgrc:1: foo
 
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -469,7 +469,9 @@ 
             except error.ParseError as inst:
                 if trusted:
                     raise
-                self.warn(_(b'ignored: %s\n') % stringutil.forcebytestr(inst))
+                self.warn(
+                    _(b'ignored %s: %s\n') % (inst.location, inst.message)
+                )
 
         self._applyconfig(cfg, trusted, root)