# HG changeset patch # User Martin von Zweigbergk # Date 2015-01-23 07:01:00 # 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 --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1772,8 +1772,6 @@ def trydiff(repo, revs, ctx1, ctx2, modi 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 @@ def trydiff(repo, revs, ctx1, ctx2, modi 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 @@ def trydiff(repo, revs, ctx1, ctx2, modi 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: