Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 24105:0f8baebcdbea
trydiff: read file data in only one place
This moves getfilectx() out of the initial block in the loop, leaving
that block to be only about finding pairs of filenames in ctx1 and
ctx2 to diff.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 22 Jan 2015 23:18:43 -0800 |
parents | b6f434729b97 |
children | 9cf9432a505b |
comparison
equal
deleted
inserted
replaced
24104:b6f434729b97 | 24105:0f8baebcdbea |
---|---|
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 content1 = None | |
1776 content2 = None | |
1777 copyop = None | 1775 copyop = None |
1778 if f not in addedset: | |
1779 content1 = getfilectx(f, ctx1).data() | |
1780 if f not in removedset: | |
1781 content2 = getfilectx(f, ctx2).data() | |
1782 f1, f2 = f, f | 1776 f1, f2 = f, f |
1783 if f in addedset: | 1777 if f in addedset: |
1784 f1 = None | 1778 f1 = None |
1785 if f in copy: | 1779 if f in copy: |
1786 if opts.git: | 1780 if opts.git: |
1788 if f1 in removedset and f1 not in gone: | 1782 if f1 in removedset and f1 not in gone: |
1789 copyop = 'rename' | 1783 copyop = 'rename' |
1790 gone.add(f1) | 1784 gone.add(f1) |
1791 else: | 1785 else: |
1792 copyop = 'copy' | 1786 copyop = 'copy' |
1793 content1 = getfilectx(f1, ctx1).data() | |
1794 elif f in removedset: | 1787 elif f in removedset: |
1795 f2 = None | 1788 f2 = None |
1796 if opts.git: | 1789 if opts.git: |
1797 # have we already reported a copy above? | 1790 # have we already reported a copy above? |
1798 if (f in copyto and copyto[f] in addedset | 1791 if (f in copyto and copyto[f] in addedset |
1799 and copy[copyto[f]] == f): | 1792 and copy[copyto[f]] == f): |
1800 continue | 1793 continue |
1801 | 1794 |
1795 content1 = None | |
1796 content2 = None | |
1797 if f1: | |
1798 content1 = getfilectx(f1, ctx1).data() | |
1799 if f2: | |
1800 content2 = getfilectx(f2, ctx2).data() | |
1802 flag1 = None | 1801 flag1 = None |
1803 flag2 = None | 1802 flag2 = None |
1804 binary = False | 1803 binary = False |
1805 if opts.git or losedatafn: | 1804 if opts.git or losedatafn: |
1806 if f1: | 1805 if f1: |