# HG changeset patch # User Yuya Nishihara # Date 2016-03-27 08:42:19 # Node ID 29c249dfb4ef9b5bfcd312072a7c0ad175c3f0f1 # Parent b212e01fead0a51bee4b9bea5e026a433eb1e8f3 templater: do not strip non-quote characters from template config Before this patch, the first and last characters were stripped from ui.logtemplate and template.* if they were the same. It could lead to a strange result as quotes are optional. See the test for example. diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -868,7 +868,7 @@ def _flatten(thing): def unquotestring(s): '''unwrap quotes if any; otherwise returns unmodified string''' - if len(s) < 2 or s[0] != s[-1]: + if len(s) < 2 or s[0] not in "'\"" or s[0] != s[-1]: return s return s[1:-1] diff --git a/tests/test-command-template.t b/tests/test-command-template.t --- a/tests/test-command-template.t +++ b/tests/test-command-template.t @@ -71,6 +71,8 @@ Quoting for ui.logtemplate 8 $ hg tip --config 'ui.logtemplate="{rev}\n"' 8 + $ hg tip --config 'ui.logtemplate=n{rev}\n' + n8 Make sure user/global hgrc does not affect tests