comparison mercurial/patch.py @ 32234: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
comparison
equal deleted inserted replaced
32233:e62cf13e0858 32234:776127b29a5c
2506 2506
2507 def diffline(f, revs): 2507 def diffline(f, revs):
2508 revinfo = ' '.join(["-r %s" % rev for rev in revs]) 2508 revinfo = ' '.join(["-r %s" % rev for rev in revs])
2509 return 'diff %s %s' % (revinfo, f) 2509 return 'diff %s %s' % (revinfo, f)
2510 2510
2511 def isempty(fctx):
2512 return fctx is None or fctx.size() == 0
2513
2511 date1 = util.datestr(ctx1.date()) 2514 date1 = util.datestr(ctx1.date())
2512 date2 = util.datestr(ctx2.date()) 2515 date2 = util.datestr(ctx2.date())
2513 2516
2514 gitmode = {'l': '120000', 'x': '100755', '': '100644'} 2517 gitmode = {'l': '120000', 'x': '100755', '': '100644'}
2515 2518
2544 if losedatafn and not opts.git: 2547 if losedatafn and not opts.git:
2545 if (binary or 2548 if (binary or
2546 # copy/rename 2549 # copy/rename
2547 f2 in copy or 2550 f2 in copy or
2548 # empty file creation 2551 # empty file creation
2549 (not f1 and not content2) or 2552 (not f1 and isempty(fctx2)) or
2550 # empty file deletion 2553 # empty file deletion
2551 (not content1 and not f2) or 2554 (isempty(fctx1) and not f2) or
2552 # create with flags 2555 # create with flags
2553 (not f1 and flag2) or 2556 (not f1 and flag2) or
2554 # change flags 2557 # change flags
2555 (f1 and f2 and flag1 != flag2)): 2558 (f1 and f2 and flag1 != flag2)):
2556 losedatafn(f2 or f1) 2559 losedatafn(f2 or f1)