views:

281

answers:

2

I'm trying to set the pager used for Mercurial but the output is empty, even if I specify the command in the [pager] section or as the PAGER environment variable.

I noticed that the command provided is launched with cmd.exe. Is this the cause of empty output, and if yes, what is the right syntax?

Environment: Mercurial 1.5, Mecurial 1.4.3

hgrc:

[extensions]
pager =

[pager]
pager = d:\tools\less\less.exe

Sample command lines (from Process Explorer):

hg diff
c:\windows\system32\cmd.exe /c "d:\tools\less\less.exe 2> NUL:"
d:\tools\less\less.exe

UPDATE

In pager.py, by replacing:

sys.stderr = sys.stdout = util.popen(p, "wb")

with

sys.stderr = sys.stdout = subprocess.Popen(p, stdin = subprocess.PIPE, shell=False).stdin

I managed to obtain the desired output for the hg status and diff.

BUT, I'm sure it's wrong (or at least incomplete), and I have no control over the pager app (less.exe): the output is shown in the cmd.exe window, I can see the less prompt (:) but any further input is fed into cmd.exe. It seems that the pager app is still active in the background: after typing exit in the cmd.exe window, I have control over the pager app, and I can terminate it normally.

Also, it makes no difference what I'm choosing as a pager app (more is behaving the same).

UPDATE 2

Issue1677 - [PATCH] pager for "hg help" output on windows

A: 

Did you enable the pager extension in your ~/.hgrc or mercurial.ini file?

  [extensions]
  pager =

It's came with your mercurial installation, but you still need to enable it.

Ry4an
Already did that, when it's not enabled the output is the expected one, when it's enabled there is no output.
alexandrul
Hrm, what do you see when you run with `--debug`?
Ry4an
the behavior is the same: no output
alexandrul
A: 

I have modified the pager extension to use a temporary file for storing the commands output, the resulting extension can be found on CodePlex and Bitbucket.

alexandrul