changeset 24103:c666c85f71ba

trydiff: read flags in one place Now that we can trust f1/f2 to indicate whether that side of the diff exists, we can move the calls to ctx.flag() to a single place.
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 22 Jan 2015 23:01:00 -0800
parents 00280a2b8b9a
children b6f434729b97
files mercurial/patch.py
diffstat 1 files changed, 6 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Fri Feb 06 15:21:56 2015 -0800
+++ b/mercurial/patch.py	Thu Jan 22 23:01:00 2015 -0800
@@ -1772,8 +1772,6 @@
         if f not in ctx1:
             addedset.add(f)
     for f in sorted(modified + added + removed):
-        flag1 = None
-        flag2 = None
         content1 = None
         content2 = None
         copyop = None
@@ -1785,11 +1783,9 @@
         if opts.git or losedatafn:
             if f in addedset:
                 f1 = None
-                flag2 = ctx2.flags(f)
                 if f in copy:
                     if opts.git:
                         f1 = copy[f]
-                        flag1 = ctx1.flags(f1)
                         if f1 in removedset and f1 not in gone:
                             copyop = 'rename'
                             gone.add(f1)
@@ -1803,14 +1799,15 @@
                     if (f in copyto and copyto[f] in addedset
                         and copy[copyto[f]] == f):
                         continue
-                    else:
-                        flag1 = ctx1.flags(f)
-            else:
-                flag1 = ctx1.flags(f)
-                flag2 = ctx2.flags(f)
 
+        flag1 = None
+        flag2 = None
         binary = False
         if opts.git or losedatafn:
+            if f1:
+                flag1 = ctx1.flags(f1)
+            if f2:
+                flag2 = ctx2.flags(f2)
             binary = util.binary(content1) or util.binary(content2)
 
         if losedatafn and not opts.git: