Show More
@@ -49,9 +49,27 b' To ignore global commands like :hg:`vers' | |||
|
49 | 49 | to specify them in the global .hgrc |
|
50 | 50 | ''' |
|
51 | 51 | |
|
52 | import sys, os, signal | |
|
52 | import sys, os, signal, shlex | |
|
53 | 53 | from mercurial import dispatch, util, extensions |
|
54 | 54 | |
|
55 | def _runpager(p): | |
|
56 | if not hasattr(os, 'fork'): | |
|
57 | sys.stderr = sys.stdout = util.popen(p, 'wb') | |
|
58 | return | |
|
59 | fdin, fdout = os.pipe() | |
|
60 | pid = os.fork() | |
|
61 | if pid == 0: | |
|
62 | os.close(fdin) | |
|
63 | os.dup2(fdout, sys.stdout.fileno()) | |
|
64 | os.dup2(fdout, sys.stderr.fileno()) | |
|
65 | os.close(fdout) | |
|
66 | return | |
|
67 | os.dup2(fdin, sys.stdin.fileno()) | |
|
68 | os.close(fdin) | |
|
69 | os.close(fdout) | |
|
70 | args = shlex.split(p) | |
|
71 | os.execvp(args[0], args) | |
|
72 | ||
|
55 | 73 | def uisetup(ui): |
|
56 | 74 | def pagecmd(orig, ui, options, cmd, cmdfunc): |
|
57 | 75 | p = ui.config("pager", "pager", os.environ.get("PAGER")) |
@@ -60,7 +78,7 b' def uisetup(ui):' | |||
|
60 | 78 | if (cmd in attend or |
|
61 | 79 | (cmd not in ui.configlist('pager', 'ignore') and not attend)): |
|
62 | 80 | ui.setconfig('ui', 'interactive', False) |
|
63 | sys.stderr = sys.stdout = util.popen(p, "wb") | |
|
81 | _runpager(p) | |
|
64 | 82 | if ui.configbool('pager', 'quiet'): |
|
65 | 83 | signal.signal(signal.SIGPIPE, signal.SIG_DFL) |
|
66 | 84 | return orig(ui, options, cmd, cmdfunc) |
General Comments 0
You need to be logged in to leave comments.
Login now