[issue2986] basename filter should support files keyword in output templates

jamesbroadhead bugs at mercurial.selenic.com
Tue Sep 6 11:36:51 CDT 2011


New submission from jamesbroadhead <jamesbroadhead at gmail.com>:

The basename filter should be improved to support the files keyword in 
output templates. 

Current output: 
hg log . --template "{files}\n" :
foo/bar/baz.jarb foo/bar/bag.feh foo/bar/foo.bzg

hg log . --template "{files|basename}\n" :
... Exception traceback ... (see attachments)
File "/usr/lib64/python2.7/site-packages/mercurial/templater.py", line 149, 
in runfilter
    return filt(func(context, mapping, data))
  File "/usr/lib64/python2.7/site-packages/mercurial/templatefilters.py", 
line 63, in basename
    return os.path.basename(path)
  File "/usr/lib64/python2.7/posixpath.py", line 112, in basename
    i = p.rfind('/') + 1
AttributeError: 'generator' object has no attribute 'rfind'


Desired functionality:
hg log . --template "{files|basename}\n" :
baz.jarb bag.feh foo.bzg

This has been brought up before on the mailing list and elsewhere. In fact, 
the hg book even suggests using it(!) See the 'basename' section; 
http://hgbook.red-bean.com/read/customizing-the-output-of-mercurial.html

If backwards compatibility is desirable, perhaps a 'basenames' filter could 
be created to iterate through a space-separated list of paths. 

Related: Issue 2159

----------
files: traceback.log
messages: 17305
nosy: jamesbroadhead
priority: feature
status: unread
title: basename filter should support files keyword in output templates

____________________________________________________
Mercurial issue tracker <bugs at mercurial.selenic.com>
<http://mercurial.selenic.com/bts/issue2986>
____________________________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: traceback.log
Type: text/x-log
Size: 3097 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20110906/8bf39195/attachment.bin>


More information about the Mercurial-devel mailing list