Mercurial > hg-stable
comparison mercurial/patch.py @ 24103:c666c85f71ba
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.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 22 Jan 2015 23:01:00 -0800 |
parents | 00280a2b8b9a |
children | b6f434729b97 |
comparison
equal
deleted
inserted
replaced
24102:00280a2b8b9a | 24103:c666c85f71ba |
---|---|
1770 # modifications during merges | 1770 # modifications during merges |
1771 for f in modified: | 1771 for f in modified: |
1772 if f not in ctx1: | 1772 if f not in ctx1: |
1773 addedset.add(f) | 1773 addedset.add(f) |
1774 for f in sorted(modified + added + removed): | 1774 for f in sorted(modified + added + removed): |
1775 flag1 = None | |
1776 flag2 = None | |
1777 content1 = None | 1775 content1 = None |
1778 content2 = None | 1776 content2 = None |
1779 copyop = None | 1777 copyop = None |
1780 if f not in addedset: | 1778 if f not in addedset: |
1781 content1 = getfilectx(f, ctx1).data() | 1779 content1 = getfilectx(f, ctx1).data() |
1783 content2 = getfilectx(f, ctx2).data() | 1781 content2 = getfilectx(f, ctx2).data() |
1784 f1, f2 = f, f | 1782 f1, f2 = f, f |
1785 if opts.git or losedatafn: | 1783 if opts.git or losedatafn: |
1786 if f in addedset: | 1784 if f in addedset: |
1787 f1 = None | 1785 f1 = None |
1788 flag2 = ctx2.flags(f) | |
1789 if f in copy: | 1786 if f in copy: |
1790 if opts.git: | 1787 if opts.git: |
1791 f1 = copy[f] | 1788 f1 = copy[f] |
1792 flag1 = ctx1.flags(f1) | |
1793 if f1 in removedset and f1 not in gone: | 1789 if f1 in removedset and f1 not in gone: |
1794 copyop = 'rename' | 1790 copyop = 'rename' |
1795 gone.add(f1) | 1791 gone.add(f1) |
1796 else: | 1792 else: |
1797 copyop = 'copy' | 1793 copyop = 'copy' |
1801 if opts.git: | 1797 if opts.git: |
1802 # have we already reported a copy above? | 1798 # have we already reported a copy above? |
1803 if (f in copyto and copyto[f] in addedset | 1799 if (f in copyto and copyto[f] in addedset |
1804 and copy[copyto[f]] == f): | 1800 and copy[copyto[f]] == f): |
1805 continue | 1801 continue |
1806 else: | 1802 |
1807 flag1 = ctx1.flags(f) | 1803 flag1 = None |
1808 else: | 1804 flag2 = None |
1809 flag1 = ctx1.flags(f) | |
1810 flag2 = ctx2.flags(f) | |
1811 | |
1812 binary = False | 1805 binary = False |
1813 if opts.git or losedatafn: | 1806 if opts.git or losedatafn: |
1807 if f1: | |
1808 flag1 = ctx1.flags(f1) | |
1809 if f2: | |
1810 flag2 = ctx2.flags(f2) | |
1814 binary = util.binary(content1) or util.binary(content2) | 1811 binary = util.binary(content1) or util.binary(content2) |
1815 | 1812 |
1816 if losedatafn and not opts.git: | 1813 if losedatafn and not opts.git: |
1817 if (binary or | 1814 if (binary or |
1818 # copy/rename | 1815 # copy/rename |