[PATCH 1 of 2] patchbomb: use modern pager to display -n/--test result (BC)

Yuya Nishihara yuya at tcha.org
Sat Mar 18 07:47:31 UTC 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1488011268 -32400
#      Sat Feb 25 17:27:48 2017 +0900
# Node ID dc2eb4ca2186d50e036f20b11e52000ef11f67fe
# Parent  6d6c4d50c59b87e01936095f34720e79b812d05b
patchbomb: use modern pager to display -n/--test result (BC)

This should provide more consistent UX, but is a BC because the pager will
no longer be fired up for each message.

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -83,7 +83,6 @@ from mercurial.i18n import _
 from mercurial import (
     cmdutil,
     commands,
-    encoding,
     error,
     formatter,
     hg,
@@ -498,9 +497,7 @@ def email(ui, repo, *revs, **opts):
     With -n/--test, all steps will run, but mail will not be sent.
     You will be prompted for an email recipient address, a subject and
     an introductory message describing the patches of your patchbomb.
-    Then when all is done, patchbomb messages are displayed. If the
-    PAGER environment variable is set, your pager will be fired up once
-    for each patchbomb message, so you can verify everything is alright.
+    Then when all is done, patchbomb messages are displayed.
 
     In case email sending fails, you will find a backup of your series
     introductory message in ``.hg/last-email.txt``.
@@ -719,19 +716,14 @@ def email(ui, repo, *revs, **opts):
         if opts.get('test'):
             ui.status(_('displaying '), subj, ' ...\n')
             ui.flush()
-            if 'PAGER' in encoding.environ and not ui.plain():
-                fp = util.popen(encoding.environ['PAGER'], 'w')
-            else:
-                fp = ui
-            generator = emailmod.Generator.Generator(fp, mangle_from_=False)
+            ui.pager('email')
+            generator = emailmod.Generator.Generator(ui, mangle_from_=False)
             try:
                 generator.flatten(m, 0)
-                fp.write('\n')
+                ui.write('\n')
             except IOError as inst:
                 if inst.errno != errno.EPIPE:
                     raise
-            if fp is not ui:
-                fp.close()
         else:
             if not sendmail:
                 sendmail = mail.connect(ui, mbox=mbox)
diff --git a/tests/test-patchbomb-tls.t b/tests/test-patchbomb-tls.t
--- a/tests/test-patchbomb-tls.t
+++ b/tests/test-patchbomb-tls.t
@@ -10,10 +10,6 @@ Set up SMTP server:
   listening at localhost:$HGPORT
   $ cat a.pid >> $DAEMON_PIDS
 
-Ensure hg email output is sent to stdout:
-
-  $ unset PAGER
-
 Set up repository:
 
   $ hg init t
diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t
--- a/tests/test-patchbomb.t
+++ b/tests/test-patchbomb.t
@@ -28,9 +28,6 @@ Mercurial-patchbomb/.* -> Mercurial-patc
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "patchbomb=" >> $HGRCPATH
 
-Ensure hg email output is sent to stdout
-  $ unset PAGER
-
   $ hg init t
   $ cd t
   $ echo a > a


More information about the Mercurial-devel mailing list