diff --git a/hgext/pager.py b/hgext/pager.py
index dfc6663f97ca49aa6cbd8744b6bb565872b3f7c1_aGdleHQvcGFnZXIucHk=..e12553cfd0a4d3714802392efdc8dbcf72410488_aGdleHQvcGFnZXIucHk= 100644
--- a/hgext/pager.py
+++ b/hgext/pager.py
@@ -115,9 +115,6 @@
         pager.wait()
 
 def uisetup(ui):
-    if '--debugger' in sys.argv or not ui.formatted():
-        return
-
     class pagerui(ui.__class__):
         def _runpager(self, pagercmd):
             _runpager(self, pagercmd)
@@ -130,7 +127,7 @@
         always = util.parsebool(options['pager'])
         auto = options['pager'] == 'auto'
 
-        if not p:
+        if not p or '--debugger' in sys.argv or not ui.formatted():
             pass
         elif always:
             usepager = True
diff --git a/tests/test-chg.t b/tests/test-chg.t
index dfc6663f97ca49aa6cbd8744b6bb565872b3f7c1_dGVzdHMvdGVzdC1jaGcudA==..e12553cfd0a4d3714802392efdc8dbcf72410488_dGVzdHMvdGVzdC1jaGcudA== 100644
--- a/tests/test-chg.t
+++ b/tests/test-chg.t
@@ -32,6 +32,38 @@
 
   $ cd ..
 
+pager
+-----
+
+  $ cat >> fakepager.py <<EOF
+  > import sys
+  > for line in sys.stdin:
+  >     sys.stdout.write('paged! %r\n' % line)
+  > EOF
+
+enable pager extension globally, but spawns the master server with no tty:
+
+  $ chg init pager
+  $ cd pager
+  $ cat >> $HGRCPATH <<EOF
+  > [extensions]
+  > pager =
+  > [pager]
+  > pager = python $TESTTMP/fakepager.py
+  > EOF
+  $ chg version > /dev/null
+  $ touch foo
+  $ chg ci -qAm foo
+
+pager should be enabled if the attached client has a tty:
+
+  $ chg log -l1 -q --config ui.formatted=True
+  paged! '0:1f7b0de80e11\n'
+  $ chg log -l1 -q --config ui.formatted=False
+  0:1f7b0de80e11
+
+  $ cd ..
+
 server lifecycle
 ----------------
 
diff --git a/tests/test-pager.t b/tests/test-pager.t
index dfc6663f97ca49aa6cbd8744b6bb565872b3f7c1_dGVzdHMvdGVzdC1wYWdlci50..e12553cfd0a4d3714802392efdc8dbcf72410488_dGVzdHMvdGVzdC1wYWdlci50 100644
--- a/tests/test-pager.t
+++ b/tests/test-pager.t
@@ -152,6 +152,11 @@
   summary:     modify a 9
   
 
+Pager should not start if stdout is not a tty.
+
+  $ hg log -l1 -q --config ui.formatted=False
+  10:46106edeeb38
+
 Pager with color enabled allows colors to come through by default,
 even though stdout is no longer a tty.
   $ cat >> $HGRCPATH <<EOF