changeset 27900:27572a5cc409

diff: move status fixup earlier, out of _filepairs() This prepares for future patches, and it also lets us remove the ugly "ctx1" argument to _filepairs() (ugly because of its assymmetry -- there's no "ctx2" argument).
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 14 Jan 2016 10:02:34 -0800
parents 78b9fdb844c1
children 29c8e35d3283
files mercurial/patch.py
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Sun Jan 17 19:33:02 2016 +0100
+++ b/mercurial/patch.py	Thu Jan 14 10:02:34 2016 -0800
@@ -2256,6 +2256,17 @@
                      if dst.startswith(relroot)
                      and src.startswith(relroot)))
 
+    modifiedset = set(modified)
+    addedset = set(added)
+    for f in modified:
+        if f not in ctx1:
+            # Fix up added, since merged-in additions appear as
+            # modifications during merges
+            modifiedset.remove(f)
+            addedset.add(f)
+    modified = sorted(modifiedset)
+    added = sorted(addedset)
+
     def difffn(opts, losedata):
         return trydiff(repo, revs, ctx1, ctx2, modified, added, removed,
                        copy, getfilectx, opts, losedata, prefix, relroot)
@@ -2327,7 +2338,7 @@
     '''like diff(), but yields 2-tuples of (output, label) for ui.write()'''
     return difflabel(diff, *args, **kw)
 
-def _filepairs(ctx1, modified, added, removed, copy, opts):
+def _filepairs(modified, added, removed, copy, opts):
     '''generates tuples (f1, f2, copyop), where f1 is the name of the file
     before and f2 is the the name after. For added files, f1 will be None,
     and for removed files, f2 will be None. copyop may be set to None, 'copy'
@@ -2337,11 +2348,6 @@
     copyto = dict([(v, k) for k, v in copy.items()])
 
     addedset, removedset = set(added), set(removed)
-    # Fix up  added, since merged-in additions appear as
-    # modifications during merges
-    for f in modified:
-        if f not in ctx1:
-            addedset.add(f)
 
     for f in sorted(modified + added + removed):
         copyop = None
@@ -2407,8 +2413,7 @@
                 raise AssertionError(
                     "file %s doesn't start with relroot %s" % (f, relroot))
 
-    for f1, f2, copyop in _filepairs(
-            ctx1, modified, added, removed, copy, opts):
+    for f1, f2, copyop in _filepairs(modified, added, removed, copy, opts):
         content1 = None
         content2 = None
         flag1 = None