Differences between revisions 7 and 8
Revision 7 as of 2016-09-22 19:42:53
Size: 1796
Editor: AugieFackler
Comment: rewrite to conform to style, add some thoughts
Revision 8 as of 2016-09-22 19:54:21
Size: 1830
Comment: make link to git's diff.c stable
Deletions are marked like this. Additions are marked like this.
Line 18: Line 18:
It [[https://github.com/git/git/blob/master/builtin/diff.c#L367|looks like]] git just hard-codes which commands use the pager. We could probably do something similar by having a paged context manager on ui, eg: It [[https://github.com/git/git/blob/6fe1b1407ed91823daa5d487abe457ff37463349/builtin/diff.c#L370|looks like]] git just hard-codes which commands use the pager. We could probably do something similar by having a paged context manager on ui, eg:

Moving Pager to Core

Note:

This page is primarily intended for developers of Mercurial.

Pager is currently a hacky extension, and breaks some things in odd ways. Given a concerted refactor, it could be much less fragile by moving it into core hg.

1. Current Problems

  1. Pager only applies to a handful of whitelisted commands, and aliases using those commands don't get paged
  2. Pager breaks interactivity of commands
  3. Sometimes surprising things get paged.
  4. We don't know what the default pager configuration be?

    1. Probably less, and probably set LESS=FSRX if LESS isn't already set?

2. Proposal

It looks like git just hard-codes which commands use the pager. We could probably do something similar by having a paged context manager on ui, eg:

  with ui.paged:
    # all ui prints here go to the pager

or we could have a function to page the output, since I [augie] think that starting the pager isn't reversible:

  ui.pager()
  # all subsequent output goes to the pager

That'd solve the problem of [alias] entries not getting paged, and would avoid multi-mode commands (eg shelve) from always being paged. We could also have ui.interactive() produce a developer warning ('tried to use ui.interactive() after enabling the pager') to prevent interactive-with-pager-running problems.

3. Handling errors

If you use --traceback, currently the error is paged. This doesn't seem ideal, but there doesn't appear to be a good solution other than always emitting the error on stderr and terminating output to the pager as soon as an error occurs.


CategoryDeveloper CategoryNewFeatures

PagerInCorePlan (last edited 2017-12-06 21:37:58 by AugieFackler)