patchbomb: page patchbomb messages only if PAGER is defined.
authorPatrick Mezard <pmezard@gmail.com>
Sun, 17 Jun 2007 20:35:43 +0200
changeset 4599 88fc92b0b821
parent 4598 b25ee3f8f714
child 4600 64c415d2553a
patchbomb: page patchbomb messages only if PAGER is defined. Paging is complicated under win32. It is just better to avoid it by default.
hgext/patchbomb.py
--- a/hgext/patchbomb.py	Sun Jun 17 20:35:32 2007 +0200
+++ b/hgext/patchbomb.py	Sun Jun 17 20:35:43 2007 +0200
@@ -44,7 +44,8 @@
 # the "email" command with the "-n" option (test only).  You will be
 # prompted for an email recipient address, a subject an an introductory
 # message describing the patches of your patchbomb.  Then when all is
-# done, your pager will be fired up once for each patchbomb message, so
+# done, patchbomb messages are displayed. If PAGER environment variable
+# is set, your pager will be fired up once for each patchbomb message, so
 # you can verify everything is alright.
 #
 # The "-m" (mbox) option is also very useful.  Instead of previewing
@@ -381,14 +382,18 @@
         if opts['test']:
             ui.status('Displaying ', m['Subject'], ' ...\n')
             ui.flush()
-            fp = os.popen(os.getenv('PAGER', 'more'), 'w')
+            if 'PAGER' in os.environ:
+                fp = os.popen(os['PAGER'], 'w')
+            else:
+                fp = ui
             try:
                 fp.write(m.as_string(0))
                 fp.write('\n')
             except IOError, inst:
                 if inst.errno != errno.EPIPE:
                     raise
-            fp.close()
+            if fp is not ui:
+                fp.close()
         elif opts['mbox']:
             ui.status('Writing ', m['Subject'], ' ...\n')
             fp = open(opts['mbox'], m.has_key('In-Reply-To') and 'ab+' or 'wb+')