[PATCH RFC] formatter: convert identify command

David M. Carr david at carrclan.us
Sat Sep 15 21:55:40 CDT 2012


On Sat, Sep 15, 2012 at 1:41 PM, David M. Carr <david at carrclan.us> wrote:
> On Sat, Sep 15, 2012 at 12:41 PM, Matt Mackall <mpm at selenic.com> wrote:
>> On Tue, 2012-09-11 at 21:26 -0400, David Carr wrote:
>>> # HG changeset patch
>>> # User David M. Carr  <david at carrclan.us>
>>> # Date 1347413070 14400
>>> # Node ID f16835267ff0075424d56db9aa210ef60fd578f8
>>> # Parent  ba61e84ff4ce474366294df7cd3a1d6b8b5132d5
>>> formatter: convert identify command
>>>
>>> This is an attempt at converting the identify command to use the formatter,
>>> towards "generic templating".  It was based on mpm's example in 68007f0557de.
>>> After this change, identify should produce identical output unless a non-default
>>> formatter is used.
>>
>> Thanks for looking into this!
>>
>> There's one philosophical point I don't think I've spelled out
>> elsewhere: much like revsets obsolete most of the option switches in log
>> (and many other places), display switches are obsoleted by generic
>> templating. In other words, a template should have potential access to
>> all the relevant data, regardless of the display switches.
>>
>> That means when something isn't shown in the plain view (because it's
>> either off by default or the verbosity is too low or a switch turned it
>> off), you should pass that field to formatter anyway (with data()).
>
> Thanks for the feedback.  I had wondered how this should provide data
> that wasn't desired to be displayed by the current UI switches, but
> somehow missed data().  I'm going to work on a second iteration that
> incorporates this (always including all relevant data, even if it
> won't be displayed with the given display switches)
>
>>
>>>          elif default and not ui.quiet:
>>>              # multiple bookmarks for a single parent separated by '/'
>>>              bm = '/'.join(getbms())
>>>              if bm:
>>> -                output.append(bm)
>>> +                fields.append('bookmarks')
>>> +                fieldvalues.append(bm)
>>
>> Hmmm. I think we want to present this sort of thing as a list.
>
> I'm not understanding what you meant by this.  I assume that you don't
> mean that we should change the output when doing plain formatting, as
> that would (I believe) break the compatibility rules.  Did you mean
> that we should pass the multiple bookmarks to the formatter as a list,
> but maintain the same plain formatting?  Could you give an example of
> what this might look like?
>
>>
>> --
>> Mathematics is the supreme nostalgia of our time.
>>
>>
>
> --
> David M. Carr
> david at carrclan.us

Actually, I think I worked out how to have the bookmarks data be in a
list, while have the plain output the same.  The key is to use the
data() and plain() methods together instead of the write() method.
I'll be sending my revised patches shortly.

-- 
David M. Carr
david at carrclan.us


More information about the Mercurial-devel mailing list