Best way to get list of return separated file names in template?

Nicolas Dumazet nicdumz at gmail.com
Thu Jul 8 18:55:02 CDT 2010


2010/7/8 Jason Harris <jason at jasonfharris.com>:
>
> On Jul 8, 2010, at 3:41 PM, Matt Mackall wrote:
>
>> On Thu, 2010-07-08 at 15:40 +0200, Christian Ebert wrote:
>>> * Jason Harris on Thursday, July 08, 2010 at 15:10:59 +0200
>>>> Question:
>>>>
>>>> In some commands like "hg log --template "{file_mods} {date}"
>>>> the list of files that come back is space separated. However,
>>>> some files have spaces in their names. Thus programmatically
>>>> determining Thus I would like to add / change / modify things
>>>> so I can get log to yield a list of file names which are return
>>>> separated.
>>>>
>>>> I could of course add my own file_mods_separated to the code in
>>>> templatekw.py but I am asking what would the preferred way to
>>>> modify the code to achieve this?
>>>>
>>>> Should a new keyword be added, or should this be done in some
>>>> other manner?
>>>
>>> Perhaps you can tweak this --style:
>>>
>>> http://hgbook.red-bean.com/read/customizing-the-output-of-mercurial.html#id417978
>>
>> That or hg st -n -0 --change
>
> Thanks all.
>
> Actually right now in MacHg when I need the full details of a changeset, I currently do the log command and then I do a second mercurial command: status to get the separate files (just as Matt noted). This has been the situation since before the first public release of MacHg. However some people have commented that they would like less of a delay in looking at the full details when scrolling through the list and looking at a particular item.
>
> So since most of the delay is starting the mercurial command, and then reading the result, ie there is a lot of overhead in just sending and receiving the command, I could basically halve the delay time if I can issue a single mercurial command. Thus I would like a way to do this from within a single log command.
>
> I am about to add a new keyword file_mods_multiline to templatekw.py, or something like that but thought it best to ask if there are other approaches...

Well. The "proper" way might be to add a multiline filter in templatefilters.py
This way you would write {file_mods|multiline} and it could work for
{file_adds|multiline} and so on.

Perhaps it's not perfect:
* until now, most filters could apply to both item lists, and single
items; and multiline is cleary list-oriented
* Templating code might or might not get broken if you start using
multiline items (in glog maybe)

But it seems like the reasonable (tm) approach if you _really_ need to
extend templates to do this. Otherwise you'll have to add one
*_multiline keyword for all applicable keyword, and it's uglier.

>
> Thanks,
>  Jas
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>



-- 
Nicolas Dumazet — NicDumZ


More information about the Mercurial-devel mailing list