Patchwork [4,of,5] trydiff: replace 'dodiff = False' by 'continue'

login
register
mail settings
Submitter Martin von Zweigbergk
Date Jan. 7, 2015, 7:53 p.m.
Message ID <dd66ac280e5bf951aaee.1420660399@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/7352/
State Accepted
Commit e30c6aa6f2a22f965ce62870610f3a9079a68466
Headers show

Comments

Martin von Zweigbergk - Jan. 7, 2015, 7:53 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1420657180 28800
#      Wed Jan 07 10:59:40 2015 -0800
# Node ID dd66ac280e5bf951aaee2958617ceaf038b441c7
# Parent  e5ae546bf7539d680cb65e7d5c7dbf96e3d322ae
trydiff: replace 'dodiff = False' by 'continue'

The 'dodiff' variable is initialized to True and may later be set to
either False or "binary". When it's set to False, we skip everything
after that point, so we can simplify by instead continue-ing (the
loop). We can then also drop the 'if dodiff', since it will always be
true.

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1849,7 +1849,7 @@ 
                          and copyto[copy[f]] == f) or
                         (f in copyto and copyto[f] in addedset
                          and copy[copyto[f]] == f)):
-                        dodiff = False
+                        continue
                     else:
                         header.append('deleted file mode %s\n' %
                                       gitmode[ctx1.flags(f)])
@@ -1869,21 +1869,20 @@ 
                 elif binary or nflag != oflag:
                     losedatafn(f)
 
-        if dodiff:
-            if opts.git or revs:
-                header.insert(0, diffline(join(a), join(b), revs))
-            if dodiff == 'binary' and not opts.nobinary:
-                text = mdiff.b85diff(to, tn)
-                if text and opts.git:
-                    addindexmeta(header, gitindex(to), gitindex(tn))
-            else:
-                text = mdiff.unidiff(to, date1,
-                                     tn, date2,
-                                     join(a), join(b), opts=opts)
-            if header and (text or len(header) > 1):
-                yield ''.join(header)
-            if text:
-                yield text
+        if opts.git or revs:
+            header.insert(0, diffline(join(a), join(b), revs))
+        if dodiff == 'binary' and not opts.nobinary:
+            text = mdiff.b85diff(to, tn)
+            if text and opts.git:
+                addindexmeta(header, gitindex(to), gitindex(tn))
+        else:
+            text = mdiff.unidiff(to, date1,
+                                 tn, date2,
+                                 join(a), join(b), opts=opts)
+        if header and (text or len(header) > 1):
+            yield ''.join(header)
+        if text:
+            yield text
 
 def diffstatsum(stats):
     maxfile, maxtotal, addtotal, removetotal, binary = 0, 0, 0, 0, False