# HG changeset patch # User Martin von Zweigbergk # Date 1421996460 28800 # Node ID c666c85f71ba2a78ae9a1cad4e390285eff6d954 # Parent 00280a2b8b9ab734a30ca0a87d42479438ac97e0 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. diff -r 00280a2b8b9a -r c666c85f71ba mercurial/patch.py --- 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: