Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 24058:d1fcff9400c9
trydiff: call util.binary in only one place
It's practically free to call util.binary on empty or None content. By
relying on that, we can replace the current four call sites by one.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 22 Jan 2015 22:22:09 -0800 |
parents | 696d0fd77d94 |
children | 1ea90d140ee3 |
comparison
equal
deleted
inserted
replaced
24057:696d0fd77d94 | 24058:d1fcff9400c9 |
---|---|
1794 copyop = 'rename' | 1794 copyop = 'rename' |
1795 gone.add(f1) | 1795 gone.add(f1) |
1796 else: | 1796 else: |
1797 copyop = 'copy' | 1797 copyop = 'copy' |
1798 content1 = getfilectx(f1, ctx1).data() | 1798 content1 = getfilectx(f1, ctx1).data() |
1799 binary = util.binary(content1) or util.binary(content2) | |
1800 elif f in removedset: | 1799 elif f in removedset: |
1801 if opts.git: | 1800 if opts.git: |
1802 # have we already reported a copy above? | 1801 # have we already reported a copy above? |
1803 if (f in copyto and copyto[f] in addedset | 1802 if (f in copyto and copyto[f] in addedset |
1804 and copy[copyto[f]] == f): | 1803 and copy[copyto[f]] == f): |
1805 continue | 1804 continue |
1806 else: | 1805 else: |
1807 flag1 = ctx1.flags(f) | 1806 flag1 = ctx1.flags(f) |
1808 binary = util.binary(content1) | |
1809 else: | |
1810 binary = util.binary(content1) | |
1811 else: | 1807 else: |
1812 flag1 = ctx1.flags(f) | 1808 flag1 = ctx1.flags(f) |
1813 flag2 = ctx2.flags(f) | 1809 flag2 = ctx2.flags(f) |
1814 binary = util.binary(content1) or util.binary(content2) | 1810 |
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 |
1819 f in copy or | 1816 f in copy or |