Patchwork [resend] pager: honour aliases (issue3532)

login
register
mail settings
Submitter David Soria Parra
Date Oct. 20, 2013, 9:39 p.m.
Message ID <de93db0ba5adadd8f90c.1382305195@achird.localdomain>
Download mbox | patch
Permalink /patch/2792/
State Superseded, archived
Headers show

Comments

David Soria Parra - Oct. 20, 2013, 9:39 p.m.
# HG changeset patch
# User David Soria Parra <dsp@experimentalworks.net>
# Date 1381629094 25200
#      Sat Oct 12 18:51:34 2013 -0700
# Node ID de93db0ba5adadd8f90c5046bb4466a0843d31c0
# Parent  ab2362e1672e341d13b0f2546b672122b2eb5ced
pager: honour aliases (issue3532)

If paging is configured for a command all it's aliases will be paged as
well. This will make attend=log cause 'hg history' to run the pager as
well as custom aliases defined with [alias].

Patch

diff --git a/hgext/pager.py b/hgext/pager.py
--- a/hgext/pager.py
+++ b/hgext/pager.py
@@ -48,7 +48,7 @@ 
 '''
 
 import atexit, sys, os, signal, subprocess, errno, shlex
-from mercurial import commands, dispatch, util, extensions
+from mercurial import commands, dispatch, util, extensions, cmdutil
 from mercurial.i18n import _
 
 testedwith = 'internal'
@@ -121,14 +121,22 @@ 
             attend = ui.configlist('pager', 'attend', attended)
             auto = options['pager'] == 'auto'
             always = util.parsebool(options['pager'])
-            if (always or auto and
-                (cmd in attend or
-                 (cmd not in ui.configlist('pager', 'ignore') and not attend))):
-                ui.setconfig('ui', 'formatted', ui.formatted())
-                ui.setconfig('ui', 'interactive', False)
-                if util.safehasattr(signal, "SIGPIPE"):
-                    signal.signal(signal.SIGPIPE, signal.SIG_DFL)
-                _runpager(ui, p)
+
+            cmds, (alias, _, _) = cmdutil.findcmd(cmd, commands.table)
+            if util.safehasattr(alias, 'cmdname'):
+                cmds.append(alias.cmdname)
+
+            ignore = ui.configlist('pager', 'ignore')
+            for cmd in cmds:
+                if (always or auto and
+                    (cmd in attend or
+                     (cmd not in ignore and not attend))):
+                    ui.setconfig('ui', 'formatted', ui.formatted())
+                    ui.setconfig('ui', 'interactive', False)
+                    if util.safehasattr(signal, "SIGPIPE"):
+                        signal.signal(signal.SIGPIPE, signal.SIG_DFL)
+                    _runpager(ui, p)
+                    break
         return orig(ui, options, cmd, cmdfunc)
 
     extensions.wrapfunction(dispatch, '_runcommand', pagecmd)