[PATCH] templates/filters: extracting the user portion of an email address

Greg Ward greg at gerg.ca
Wed Apr 4 08:17:36 CDT 2012


On 28 March 2012, Matteo Capobianco said:
> # HG changeset patch
> # User Matteo Capobianco <m.capobianco at gmail.com>
> # Date 1332943580 -7200
> # Node ID 8fe5ec2993cb73aa4fa4aa3638a4824440598f61
> # Parent  ba42eb722bb39e702c54b7a6fa7a703d4ba2cec3
> templates/filters: extracting the user portion of an email address
> 
> Currently, the 'user' filter is using util.shortuser(text) (which clearly
> doesn't extract only the user portion of an email address, even though the
> help text says it does).

You're more likely to get some feedback here if you explain *how* the
current 'user' filter is broken. (Specifically, it turns
"joe.blow at example.com" into "joe", when it should return "joe.blow".
At least that's the obvious bug I found in 5 minutes, given your
hint.)

Offhand, I can't imagine why the current behaviour of shortuser() is
desirable. Maybe it would be better to fix the bug rather than
introduce a new filter.

OTOH, the current behaviour was deliberately introduced here:

  changeset:   3533:bb44489b901f
  user:        Matt Mackall <mpm at selenic.com>
  date:        Fri Oct 27 11:30:20 2006 -0500
  files:       mercurial/util.py
  description:
  shortname: truncate at '.' too

Does anyone remember why Matt made this change? Makes no sense to me.

       Greg
-- 
Greg Ward                                http://www.gerg.ca/
I can never remember how to spell "mnemonic".


More information about the Mercurial-devel mailing list