[PATCH 1 of 2] templates/filters: add 'stripquote' filter

Matt Mackall mpm at selenic.com
Mon Mar 5 16:48:43 CST 2012


On Mon, 2012-03-05 at 01:21 +0100, Yann E. MORIN wrote:
> Matt, All,
> 
> On Monday 05 March 2012 00:45:11 Matt Mackall wrote:
> > On Thu, 2012-03-01 at 00:39 +0100, Yann E. MORIN wrote:
> > > # HG changeset patch
> > > # User "Yann E. MORIN" <yann.morin.1998 at free.fr>
> > > # Date 1329262818 -3600
> > > # Node ID 03bbe66e40ad60efb9e9042cdd4d471d296941ff
> > > # Parent  a4413624d0146f1edaa712a32c36c3409209ed6a
> > > templates/filters: add 'stripquote' filter
> [--SNIP--]
> > > Given this author: "J. DOE" <john at doe.net>
> > >     {author|person}             : "J. DOE"
> > >     {author|person|stripquote}  : J. DOE
> > 
> > I would have guessed that the reason for not just fixing the person
> > filter would be to preserve backward compatibility.. but then you go and
> > change the stock command-line templates, which contradicts that goal.
> > 
> > Absent an argument as to why changing the command line output is safe
> > for all the stupid scripts in the world (could they already be doing
> > author = author[1:-1]?), you should avoid touching it. 
> > 
> > But if you do have such an argument, it should probably just be rolled
> > into the person filter.
> 
> On one hand, I believe the current behavior should not change, so as users
> do not get confused, and existing infrastructures do not break.
> 
> On the other hand, I think the current behavior is broken, because it is
> non-conformant to standards, so it should be fixed.
> 
> And I really can not decide which is the best. :-/

Let's consult the nearest available dataset:

$ hg log --template "{author|person}\n" | grep '"' | sort | uniq
"Andrei Vermel
"Aurelien Jacobs
"Daniel Santa Cruz
"Hidetaka Iwai
"Hiroshi Funai"
"Mathieu Clabaut
"Paul Moore
"Peter Arrenbrecht"
"Rafael Villar Burke
"Shun-ichi GOTO"
"Wallace, Eric S"
"Yann E. MORIN"
Josef "Jeff" Sipek
Radoslaw "AstralStorm" Szkodzinski

What a mess! We have matching quotes, unmatched quotes, and quotes in
the middle. So yes, the current behavior is busted. And it's hard to see
how anyone can do anything except l.strip('"') to fix the output, so I
think fixing person() is the right answer.

> > Please use a doctest for testing simple functions, it has orders of
> > magnitude less overhead per test:
> > 
> > http://mercurial.selenic.com/wiki/WritingTests#Writing_a_Python_doctest
> 
> You mean, instead of the tests in 'tests/test-command-template.t' ?

Yep.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list