diff --git a/mercurial/config.py b/mercurial/config.py --- a/mercurial/config.py +++ b/mercurial/config.py @@ -200,7 +200,10 @@ self._unset.append((section, name)) continue - raise error.ParseError(l.rstrip(), (b"%s:%d" % (src, line))) + message = l.rstrip() + if l.startswith(b' '): + message = b"unexpected leading whitespace: %s" % message + raise error.ParseError(message, (b"%s:%d" % (src, line))) def read(self, path, fp=None, sections=None, remap=None): if not fp: diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -248,8 +248,6 @@ _(b"hg: parse error at %s: %s\n") % (pycompat.bytestr(inst.location), inst.message) ) - if inst.message.startswith(b' '): - write(_(b"unexpected leading whitespace\n")) else: write(_(b"hg: parse error: %s\n") % inst.message) _reportsimilar(write, similar) diff --git a/tests/test-config.t b/tests/test-config.t --- a/tests/test-config.t +++ b/tests/test-config.t @@ -25,8 +25,7 @@ > key=value > EOF $ hg showconfig - hg: parse error at $TESTTMP/.hg/hgrc:1: key=value - unexpected leading whitespace + hg: parse error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: key=value [255] $ cat > .hg/hgrc << EOF @@ -34,8 +33,7 @@ > key=value > EOF $ hg showconfig - hg: parse error at $TESTTMP/.hg/hgrc:1: [section] - unexpected leading whitespace + hg: parse error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace: [section] [255] Reset hgrc diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t --- a/tests/test-hgrc.t +++ b/tests/test-hgrc.t @@ -68,8 +68,7 @@ $ echo '[foo]' > $HGRC $ echo ' x = y' >> $HGRC $ hg version - hg: parse error at $TESTTMP/hgrc:2: x = y - unexpected leading whitespace + hg: parse error at $TESTTMP/hgrc:2: unexpected leading whitespace: x = y [255] $ "$PYTHON" -c "from __future__ import print_function; print('[foo]\nbar = a\n b\n c \n de\n fg \nbaz = bif cb \n')" \