[PATCH 2 of 2] templater: relax unquotestring() to fall back to bare string

Yuya Nishihara yuya at tcha.org
Sun Mar 27 04:52:01 EDT 2016


On Sat, 26 Mar 2016 21:51:08 -0700, Pierre-Yves David wrote:
> On 03/26/2016 09:07 AM, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya at tcha.org>
> > # Date 1458983532 -32400
> > #      Sat Mar 26 18:12:12 2016 +0900
> > # Node ID 4124288600c9eb8c229bcf98eb6902caf7fbbcad
> > # Parent  1c2157434cd147c37a08494ef54d4aa3d5999728
> > templater: relax unquotestring() to fall back to bare string
> >
> > This is convenient for our use case where quotes are optional except in
> > a map file.
> 
> I've pushed patch 1 (which is a great clean up),
> 
> However, I'm not clear about what is the effect of patch 2. Can you give 
> an example of what was previously invalid and now is ?

There were nothing wrong (except for the SyntaxError type and a few nits).
Previously we had to write try-catch:

  try:
      s = templater.unquotestring(t)
  except SyntaxError:
      s = t

Since it appears to be common for templater users, this patch makes
unquotestring() do that by default.

I don't know why unpaired quote is allowed, but it is for years. If I could
change the history, I would make it an error.

  [ui]
  logtemplate = "somehow unpaired quote works

BTW, I found any characters are taken as quotes if surrounded by the same
character. It is obviously a bug and should be fixed later.

  [ui]
  logtemplate = nthis is quoted by "n"\n


More information about the Mercurial-devel mailing list