[issue3255] Templates: traceback using template filter addbreaks

Jason Harris bugs at mercurial.selenic.com
Wed Feb 8 07:56:55 CST 2012


New submission from Jason Harris <jason at jasonfharris.com>:

Background: It's very handy for Mercurial GUI clients to be able to get the list of files using log --template ... since currently in MacHg I need to do 
this through status on individual changesets, but unfortunately without line breaks you can't tell if a file name has a space in it or if it's a new file 
so you can't currently use the filters file_adds, file_copies, file_dels, etc.

-----

So While taking a look to see if the situation had been changed where a client could easily get a list of file names with line breaks during say a log 
operation with a template, I noticed the new filter addbreaks. This looked promising, so with a quick experiment I found the following traceback:

(I also tried this in (version 2.1-rc+18-db3e73933a0f) and it gave the same result.)

[salt:/Development/MacHgDev/MacHgClone26] MacHgClone26 1016(1016) ⌘ rhg log --rev 1014 --template "{rev}{file_mods|stringify|addbreaks}"
1014Classes/DifferencesView/JointSplitView.m Classes/FilesView/FSNodeInfo.m Classes/FilesView/FSViewerBrowser.m Classes/General/Common.h 
Classes/General/Common.m Classes/PatchesModel/PatchData.h Classes/PatchesModel/PatchData.m[salt:/Development/MacHgDev/MacHgClone26] MacHgClone26 
1016(1016) ⌘ hg log --rev 1014 --template "{rev}{file_mods|addbreaks}"
** unknown exception encountered, please report by visiting
**  http://mercurial.selenic.com/wiki/BugTracker
** Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)]
** Mercurial Distributed SCM (version 2.0.2+20120104)
** Extensions loaded: prompt
Traceback (most recent call last):
  File "/usr/local/bin/hg", line 38, in <module>
    mercurial.dispatch.run()
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 27, in run
    sys.exit(dispatch(request(sys.argv[1:])))
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 64, in dispatch
    return _runcatch(req)
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 87, in _runcatch
    return _dispatch(req)
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 684, in _dispatch
    cmdpats, cmdoptions)
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 466, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 738, in _runcommand
    return checkargs()
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 692, in checkargs
    return cmdfunc()
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 681, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/Library/Python/2.7/site-packages/mercurial/util.py", line 458, in check
    return func(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/mercurial/commands.py", line 3899, in log
    for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
  File "/Library/Python/2.7/site-packages/mercurial/cmdutil.py", line 1157, in iterate
    prepare(ctx, fns)
  File "/Library/Python/2.7/site-packages/mercurial/commands.py", line 3897, in prep
    displayer.show(ctx, copies=copies, matchfn=revmatchfn)
  File "/Library/Python/2.7/site-packages/mercurial/cmdutil.py", line 638, in show
    self._show(ctx, copies, matchfn, props)
  File "/Library/Python/2.7/site-packages/mercurial/cmdutil.py", line 849, in _show
    self.ui.write(templater.stringify(self.t(key, **props)))
  File "/Library/Python/2.7/site-packages/mercurial/templatefilters.py", line 292, in stringify
    return "".join([stringify(t) for t in thing if t is not None])
  File "/Library/Python/2.7/site-packages/mercurial/util.py", line 317, in increasingchunks
    for chunk in source:
  File "/Library/Python/2.7/site-packages/mercurial/templater.py", line 210, in _flatten
    for i in thing:
  File "/Library/Python/2.7/site-packages/mercurial/templater.py", line 266, in <genexpr>
    return _flatten(func(self, mapping, data) for func, data in
  File "/Library/Python/2.7/site-packages/mercurial/templater.py", line 149, in runfilter
    return filt(func(context, mapping, data))
  File "/Library/Python/2.7/site-packages/mercurial/templatefilters.py", line 16, in addbreaks
    return text.replace('\n', '<br/>\n')
AttributeError: 'generator' object has no attribute 'replace'
[salt:/Development/MacHgDev/MacHgClone26] MacHgClone26 1016(1016) ⌘

----------
messages: 19003
nosy: Jason Harris
priority: bug
status: unread
title: Templates: traceback using template filter addbreaks

____________________________________________________
Mercurial issue tracker <bugs at mercurial.selenic.com>
<http://mercurial.selenic.com/bts/issue3255>
____________________________________________________


More information about the Mercurial-devel mailing list