[PATCH] py3: encode underlying error message during parse error of %include

Denis Laxalde denis at laxalde.org
Thu Oct 17 06:16:05 EDT 2019


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1571307042 -7200
#      Thu Oct 17 12:10:42 2019 +0200
# Node ID 8974165737bdc8d3553421d98eb23121bb5282a3
# Parent  733d4ffcd6675d457b60bafa9568115daebc0661
py3: encode underlying error message during parse error of %include

diff --git a/mercurial/config.py b/mercurial/config.py
index 36707ba..57fbd1c 100644
--- a/mercurial/config.py
+++ b/mercurial/config.py
@@ -13,6 +13,7 @@ import os
 from .i18n import _
 from .pycompat import getattr
 from . import (
+    encoding,
     error,
     pycompat,
     util,
@@ -173,7 +174,7 @@ class config(object):
                         if inst.errno != errno.ENOENT:
                             raise error.ParseError(
                                 _(b"cannot include %s (%s)")
-                                % (inc, inst.strerror),
+                                % (inc, encoding.strtolocal(inst.strerror)),
                                 b"%s:%d" % (src, line),
                             )
                 continue
diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t
index 614bbd0..c3dbd83 100644
--- a/tests/test-hgrc.t
+++ b/tests/test-hgrc.t
@@ -49,6 +49,18 @@ Issue1199: Can't use '%' in hgrc (eg url
   paths.default=$TESTTMP/foo%bar
   $ cd ..
 
+Check %include
+
+  $ echo '[section]' > $TESTTMP/included
+  $ echo 'option = value' >> $TESTTMP/included
+  $ echo '%include $TESTTMP/included' >> $HGRC
+  $ hg showconfig section
+  section.option=value
+  $ chmod u-r $TESTTMP/included
+  $ hg showconfig section
+  hg: parse error at $TESTTMP/hgrc:2: cannot include $TESTTMP/included (Permission denied)
+  [255]
+
 issue1829: wrong indentation
 
   $ echo '[foo]' > $HGRC


More information about the Mercurial-devel mailing list