# HG changeset patch # User Martin Geisler # Date 1336853574 -7200 # Node ID 48b1674ac1e7a1e9e913180a20b86546c17960ba # Parent 2fdd1902ed2d0862afd51f956379b0effac4e884 templater: handle SyntaxError when parsing ui.logtemplate Before, Mercurial would crash with a traceback ending with SyntaxError: unmatched quotes if you configured [ui] logtemplate = {rev}\n The SyntaxError is now catched and the string is re-parsed without requiring quotes. diff -r 2fdd1902ed2d -r 48b1674ac1e7 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Sat May 12 09:43:12 2012 +0200 +++ b/mercurial/cmdutil.py Sat May 12 22:12:54 2012 +0200 @@ -910,7 +910,10 @@ if not (tmpl or style): tmpl = ui.config('ui', 'logtemplate') if tmpl: - tmpl = templater.parsestring(tmpl) + try: + tmpl = templater.parsestring(tmpl) + except SyntaxError: + tmpl = templater.parsestring(tmpl, quoted=False) else: style = util.expandpath(ui.config('ui', 'style', '')) diff -r 2fdd1902ed2d -r 48b1674ac1e7 tests/test-command-template.t --- a/tests/test-command-template.t Sat May 12 09:43:12 2012 +0200 +++ b/tests/test-command-template.t Sat May 12 22:12:54 2012 +0200 @@ -45,6 +45,15 @@ $ hg mv second fourth $ hg commit -m third -d "2020-01-01 10:01" +Quoting for ui.logtemplate + + $ hg tip --config "ui.logtemplate={rev}\n" + 8 + $ hg tip --config "ui.logtemplate='{rev}\n'" + 8 + $ hg tip --config 'ui.logtemplate="{rev}\n"' + 8 + Make sure user/global hgrc does not affect tests $ echo '[ui]' > .hg/hgrc