[PATCH 2 of 5 V2] diff: use fctx.size() to test empty
Jun Wu
quark at fb.com
Fri May 5 21:27:19 EDT 2017
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1493875244 25200
# Wed May 03 22:20:44 2017 -0700
# Node ID 4f31a8ae3b30f6ca5fd8770a25b59f9638a48d6b
# Parent 1db00a094f91000d89bda7ee14771fb14498c9b1
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r 4f31a8ae3b30
diff: use fctx.size() to test empty
fctx.size() could have a fast path that does not require loading content.
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2509,4 +2509,7 @@ def trydiff(repo, revs, ctx1, ctx2, modi
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())
@@ -2547,7 +2550,7 @@ def trydiff(repo, revs, ctx1, ctx2, modi
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
More information about the Mercurial-devel
mailing list