changeset 32188:776127b29a5c

diff: use fctx.size() to test empty fctx.size() could have a fast path that does not require loading content.
author Jun Wu <quark@fb.com>
date Wed, 03 May 2017 22:20:44 -0700
parents e62cf13e0858
children 15f10ee778f8
files mercurial/patch.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Wed May 03 22:16:54 2017 -0700
+++ b/mercurial/patch.py	Wed May 03 22:20:44 2017 -0700
@@ -2508,6 +2508,9 @@
         revinfo = ' '.join(["-r %s" % rev for rev in revs])
         return 'diff %s %s' % (revinfo, f)
 
+    def isempty(fctx):
+        return fctx is None or fctx.size() == 0
+
     date1 = util.datestr(ctx1.date())
     date2 = util.datestr(ctx2.date())
 
@@ -2546,9 +2549,9 @@
                 # copy/rename
                 f2 in copy or
                 # empty file creation
-                (not f1 and not content2) or
+                (not f1 and isempty(fctx2)) or
                 # empty file deletion
-                (not content1 and not f2) or
+                (isempty(fctx1) and not f2) or
                 # create with flags
                 (not f1 and flag2) or
                 # change flags