[PATCH 8 of 9 pager v2] annotate: migrate to modern pager API

Augie Fackler raf at durin42.com
Sun Feb 19 15:03:47 EST 2017


> On Feb 18, 2017, at 9:32 PM, Jun Wu <quark at fb.com> wrote:
> 
> Excerpts from Yuya Nishihara's message of 2017-02-19 11:04:19 +0900:
>> On Sat, 18 Feb 2017 15:39:08 -0500, Augie Fackler wrote:
>>> 
>>>> On Feb 18, 2017, at 3:11 PM, Martin von Zweigbergk <martinvonz at google.com> wrote:
>>>> 
>>>>>> --- a/mercurial/commands.py
>>>>>> +++ b/mercurial/commands.py
>>>>>> @@ -361,6 +361,7 @@ def annotate(ui, repo, *pats, **opts):
>>>>>> 
>>>>>>     Returns 0 on success.
>>>>>>     """
>>>>>> +    ui.pager('annotate')
>>>>>>     if not pats:
>>>>>>         raise error.Abort(_('at least one filename or pattern is required'))
>>>>> 
>>>>> Just to make sure. Do we plan to delay ui.pager() call so short error messages
>>>>> (and password prompt, etc.) won't be paged?
>>>>> 
>>>> I was wondering the same, but was hoping the pager would be configured to exit if the full text would fit. I have no idea if that's true for most systems out there, though. I don't believe I've manually configured mine that way, so I suspect it's that way be default on our custom Ubuntu. I guess pager on by default will be pretty annoying if that is not a common default configuration, so I really hope it is.
>>> 
>>> I don’t think that’s a safe assumption, sadly. I’ll do a follow-up to try and make sure that things are sane at least at a high level.
>> 
>> IIRC, "more" exits automatically, but "less" doesn't by default. Also, "less"
>> clears the paged contents on exit.
> 
> less can be configured to not clear the screen (-X), and exit automatically
> (-F). And another common flag is -R, which will allow colors.
> 
> git used to just hard-code LESS=FRX as the default in pager.c [1]. That got
> moved to an override-able build variable by [2].
> 
> I guess we could do the same, provide "LESS=FRX" as the default to be more
> user-friendly.

This is a great idea for built packages, but in the sources the default should be more(1) because that’s the only pager we can be sure to find.

(I expect our packages on debian would default to sensible-pager, packages on OS X would default to less with FRX set, etc)

> 
> [1]: https://github.com/git/git/blob/c3b1e8d85133e2a19d372b7c166d5b49fcbbfef2/pager.c#L70
> [2]: https://github.com/git/git/commit/995bc22d7f8c611e342095a211065f8585a08e65



More information about the Mercurial-devel mailing list