Bug 5779 - The files command crashes with "-T ''{files}'"
Summary: The files command crashes with "-T ''{files}'"
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: templater (show other bugs)
Version: 4.4.2
Hardware: All All
: wish bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-31 18:30 UTC by Matt Harbison
Modified: 2018-03-11 00:00 UTC (History)
2 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Harbison 2018-01-31 18:30 UTC
AFAICT, it's not a valid keyword here, so not a big deal.  But other invalid keywords are silently dropped, so probably something isn't being handled here.

** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)]
** Mercurial Distributed SCM (version 4.5-rc)
** Extensions loaded: purge, schemes, strip, mq, blackbox, extdiff, rebase
Traceback (most recent call last):
  File "../hg", line 41, in <module>
    dispatch.run()
  File "e:\Projects\hg\mercurial\dispatch.py", line 88, in run
    status = (dispatch(req) or 0) & 255
  File "e:\Projects\hg\mercurial\dispatch.py", line 183, in dispatch
    ret = _runcatch(req)
  File "e:\Projects\hg\mercurial\dispatch.py", line 324, in _runcatch
    return _callcatch(ui, _runcatchfunc)
  File "e:\Projects\hg\mercurial\dispatch.py", line 332, in _callcatch
    return scmutil.callcatch(ui, func)
  File "e:\Projects\hg\mercurial\scmutil.py", line 154, in callcatch
    return func()
  File "e:\Projects\hg\mercurial\dispatch.py", line 314, in _runcatchfunc
    return _dispatch(req)
  File "e:\Projects\hg\mercurial\dispatch.py", line 918, in _dispatch
    cmdpats, cmdoptions)
  File "e:\Projects\hg\mercurial\dispatch.py", line 673, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "e:\Projects\hg\mercurial\dispatch.py", line 926, in _runcommand
    return cmdfunc()
  File "e:\Projects\hg\mercurial\dispatch.py", line 915, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
  File "e:\Projects\hg\mercurial\util.py", line 1195, in check
    return func(*args, **kwargs)
  File "e:\Projects\hg\mercurial\util.py", line 1195, in check
    return func(*args, **kwargs)
  File "e:\Projects\hg\hgext\mq.py", line 3583, in mqcommand
    return orig(ui, repo, *args, **kwargs)
  File "e:\Projects\hg\mercurial\util.py", line 1195, in check
    return func(*args, **kwargs)
  File "e:\Projects\hg\mercurial\commands.py", line 2028, in files
    return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
  File "e:\Projects\hg\mercurial\cmdutil.py", line 2914, in files
    fm.startitem()
  File "e:\Projects\hg\mercurial\formatter.py", line 173, in startitem
    self._showitem()
  File "e:\Projects\hg\mercurial\formatter.py", line 379, in _showitem
    self._renderitem(self._tref, item)
  File "e:\Projects\hg\mercurial\formatter.py", line 398, in _renderitem
    self._out.write(templater.stringify(g))
  File "e:\Projects\hg\mercurial\templatefilters.py", line 372, in stringify
    return "".join([stringify(t) for t in thing if t is not None])
  File "e:\Projects\hg\mercurial\util.py", line 1017, in increasingchunks
    for chunk in source:
  File "e:\Projects\hg\mercurial\templater.py", line 1272, in _flatten
    for i in thing:
  File "e:\Projects\hg\mercurial\templater.py", line 413, in runtemplate
    yield evalrawexp(context, mapping, arg)
  File "e:\Projects\hg\mercurial\templater.py", line 311, in evalrawexp
    return func(context, mapping, data)
  File "e:\Projects\hg\mercurial\templater.py", line 404, in runsymbol
    return v(**pycompat.strkwargs(props))
  File "e:\Projects\hg\mercurial\templatekw.py", line 528, in showfiles
    return showlist('file', args['ctx'].files(), args)
AttributeError: 'NoneType' object has no attribute 'files'

(I thought the log command would filter {files} down based on a fileset provided, but it doesn't seem to when --rev is given.  So I thought maybe files was the command I remembered, and forgot to clean up the template.  But that would be a nice feature, to be able to walk every revision, and print out files over a certain size, for example.)
Comment 1 Yuya Nishihara 2018-02-01 06:51 UTC
It's known issue of the formatter API, but it gets more visible since
I've moved keywords to the defaults table at 817a3d20dd01.

We'll need to make templatekw handle missing resources gracefully.

https://www.mercurial-scm.org/repo/hg/file/4.5-rc/mercurial/templater.py#l400
Comment 2 HG Bot 2018-03-03 15:20 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/121a20e5da56
Yuya Nishihara <yuya@tcha.org>
templatekw: switch most of showlist template keywords to new API (issue5779)

Non-trivial changes will follow.

(please test the fix)
Comment 3 Bugzilla 2018-03-11 00:00 UTC
Bug was set to TESTING for 7 days, resolving