changeset 4599:88fc92b0b821

patchbomb: page patchbomb messages only if PAGER is defined. Paging is complicated under win32. It is just better to avoid it by default.
author Patrick Mezard <pmezard@gmail.com>
date Sun, 17 Jun 2007 20:35:43 +0200
parents b25ee3f8f714
children 64c415d2553a
files hgext/patchbomb.py
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -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 @@ def patchbomb(ui, repo, *revs, **opts):
         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+')