[PATCH V2] mercurial: add debugextensions command (issue4676)
Yuya Nishihara
yuya at tcha.org
Wed Sep 23 03:40:28 UTC 2015
On Tue, 22 Sep 2015 21:37:20 +0200, Piotr Listkiewicz wrote:
> > This 'tested with' field will be overwritten by the subsequent condwrite().
> > We could
> > a) suppress it in machine-readable and templated output: use fm.plain()
> > b) or give different field name
>
> It won't, for verbose it will only be written by fm.condwrite , for
> normal(not verbose and not quiet) it will only be written in if stm and for
> quiet it will not be written.
It seems you missed the point of fm.condwrite(). It does
- print if condition met in plain output
- assign variable to JSON or templated formatter unconditionally, which
allows us to use that variable in template if we want
For details, see formatter.py, e8075329c5fb, the wiki page, etc.
https://mercurial.selenic.com/wiki/GenericTemplatingPlan
> It should be something like this:
> > fm.condwrite(ui.verbose and extbuglink, 'buglink',
> > _(' bug reporting: %s\n'), extbuglink)
> > because
> > - we probably don't want to see raw representation like "None" in plain
> > output
> > - plain output should be translated, so wrap it by _()
> > - field names are space-separated list, and they are used as template
> > keywords,
> > e.g. -T '{name} ({testedwith})\n <{buglink}>\n'
>
> So field names should not have space inside?
No whitespace, no uppercase letter, and perhaps no underscore. They should
look like template keywords.
> > Can we avoid raw list representation "['...']" ?
>
> How it should look like instead? I added in formatter._jsonifyobj case for
> showing the list same way at it shows tuple in this patch and from there it
> is not problem for changing how the list is shown. What would you suggest
> to do?
I think the simplest way is to print the original space-separated testedwith
string. If you don't like it, you can use fm.plain() and fm.data().
FWIW, I didn't add isinstance(v, list) to _jsonifyobj at 17eeda31e52b because
a list is mutable, but that isn't important.
Regards,
More information about the Mercurial-devel
mailing list