[PATCH 1 of 4] Clean up patchbomb indent to follow standards

John Goerzen jgoerzen at complete.org
Wed Mar 21 22:59:06 CDT 2007


# HG changeset patch
# User John Goerzen <jgoerzen at complete.org>
# Date 1174535734 18000
# Node ID 60ec27d55e7ca3a4b1037fc69b8e0a616848e09d
# Parent  fe0fe0b4d73b32f9197f386140f2eb9363a13f7f
Clean up patchbomb indent to follow standards

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -73,7 +73,8 @@ try:
     # readline gives raw_input editing capabilities, but is not
     # present on windows
     import readline
-except ImportError: pass
+except ImportError:
+    pass
 
 def patchbomb(ui, repo, *revs, **opts):
     '''send changesets as a series of patch emails
@@ -88,13 +89,17 @@ def patchbomb(ui, repo, *revs, **opts):
     program is installed, the result of running diffstat on the patch.
     Finally, the patch itself, as generated by "hg export".'''
     def prompt(prompt, default = None, rest = ': ', empty_ok = False):
-        if default: prompt += ' [%s]' % default
+        if default:
+            prompt += ' [%s]' % default
         prompt += rest
         while True:
             r = raw_input(prompt)
-            if r: return r
-            if default is not None: return default
-            if empty_ok: return r
+            if r:
+                return r
+            if default is not None:
+                return default
+            if empty_ok:
+                return r
             ui.warn(_('Please enter a valid value.\n'))
 
     def confirm(s):
@@ -116,27 +121,33 @@ def patchbomb(ui, repo, *revs, **opts):
         body = ''
         for line in patch:
             if line.startswith('#'):
-                if line.startswith('# Node ID'): node = line.split()[-1]
+                if line.startswith('# Node ID'):
+                    node = line.split()[-1]
                 continue
             if (line.startswith('diff -r')
                 or line.startswith('diff --git')):
                 break
             desc.append(line)
-        if not node: raise ValueError
+        if not node:
+            raise ValueError
 
         #body = ('\n'.join(desc[1:]).strip() or
         #        'Patch subject is complete summary.')
         #body += '\n\n\n'
 
         if opts['plain']:
-            while patch and patch[0].startswith('# '): patch.pop(0)
-            if patch: patch.pop(0)
-            while patch and not patch[0].strip(): patch.pop(0)
+            while patch and patch[0].startswith('# '):
+                patch.pop(0)
+            if patch:
+                patch.pop(0)
+            while patch and not patch[0].strip():
+                patch.pop(0)
         if opts['diffstat']:
             body += cdiffstat('\n'.join(desc), patch) + '\n\n'
         if opts['attach']:
             msg = email.MIMEMultipart.MIMEMultipart()
-            if body: msg.attach(email.MIMEText.MIMEText(body, 'plain'))
+            if body:
+                msg.attach(email.MIMEText.MIMEText(body, 'plain'))
             p = email.MIMEText.MIMEText('\n'.join(patch), 'x-patch')
             binnode = bin(node)
             # if node is mq patch, it will have patch file name as tag
@@ -228,7 +239,8 @@ def patchbomb(ui, repo, *revs, **opts):
         body = ''
         if opts['diffstat']:
             d = cdiffstat(_('Final summary:\n'), jumbo)
-            if d: body = '\n' + d
+            if d:
+                body = '\n' + d
 
         ui.write(_('\nWrite the introductory message for the patch series.\n\n'))
         body = ui.edit(body, sender)
@@ -260,8 +272,10 @@ def patchbomb(ui, repo, *revs, **opts):
         start_time = (start_time[0] + 1, start_time[1])
         m['From'] = sender
         m['To'] = ', '.join(to)
-        if cc: m['Cc']  = ', '.join(cc)
-        if bcc: m['Bcc'] = ', '.join(bcc)
+        if cc:
+            m['Cc']  = ', '.join(cc)
+        if bcc:
+            m['Bcc'] = ', '.join(bcc)
         if opts['test']:
             ui.status('Displaying ', m['Subject'], ' ...\n')
             fp = os.popen(os.getenv('PAGER', 'more'), 'w')


More information about the Mercurial-devel mailing list