[PATCH 1 of 2] patchbomb: add linebreaks after colons (coding style)

Christian Ebert blacktrash at gmx.net
Sun Dec 30 07:45:06 CST 2007


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1199021043 -3600
# Node ID 4e97d4e8442ad9dc446f2385362dbaa6e0704610
# Parent  0145f9afb0e7b154f16cff287a1c2543799226cc
patchbomb: add linebreaks after colons (coding style)

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -117,13 +117,17 @@ def patchbomb(ui, repo, *revs, **opts):
     def prompt(prompt, default = None, rest = ': ', empty_ok = False):
         if not ui.interactive:
             return default
-        if default: prompt += ' [%s]' % default
+        if default:
+            prompt += ' [%s]' % default
         prompt += rest
         while True:
             r = ui.prompt(prompt, default=default)
-            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, denial):
@@ -149,27 +153,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
@@ -315,7 +325,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
 
             body = getdescription(body, sender)
             msg = email.MIMEText.MIMEText(body)
@@ -383,8 +394,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')
             ui.flush()


More information about the Mercurial-devel mailing list