equal
deleted
inserted
replaced
1774 for f in sorted(modified + added + removed): |
1774 for f in sorted(modified + added + removed): |
1775 flag1 = None |
1775 flag1 = None |
1776 flag2 = None |
1776 flag2 = None |
1777 content1 = None |
1777 content1 = None |
1778 content2 = None |
1778 content2 = None |
1779 binarydiff = False |
1779 binary = False |
1780 copyop = None |
1780 copyop = None |
1781 if f not in addedset: |
1781 if f not in addedset: |
1782 content1 = getfilectx(f, ctx1).data() |
1782 content1 = getfilectx(f, ctx1).data() |
1783 if f not in removedset: |
1783 if f not in removedset: |
1784 content2 = getfilectx(f, ctx2).data() |
1784 content2 = getfilectx(f, ctx2).data() |
1799 else: |
1799 else: |
1800 losedatafn(f) |
1800 losedatafn(f) |
1801 else: |
1801 else: |
1802 if not opts.git and flag2: |
1802 if not opts.git and flag2: |
1803 losedatafn(f) |
1803 losedatafn(f) |
1804 if util.binary(content1) or util.binary(content2): |
1804 binary = util.binary(content1) or util.binary(content2) |
1805 if opts.git: |
1805 if not opts.git and binary: |
1806 binarydiff = True |
1806 losedatafn(f) |
1807 else: |
|
1808 losedatafn(f) |
|
1809 if not opts.git and not content2: |
1807 if not opts.git and not content2: |
1810 # regular diffs cannot represent new empty file |
1808 # regular diffs cannot represent new empty file |
1811 losedatafn(f) |
1809 losedatafn(f) |
1812 elif f in removedset: |
1810 elif f in removedset: |
1813 if opts.git: |
1811 if opts.git: |
1815 if (f in copyto and copyto[f] in addedset |
1813 if (f in copyto and copyto[f] in addedset |
1816 and copy[copyto[f]] == f): |
1814 and copy[copyto[f]] == f): |
1817 continue |
1815 continue |
1818 else: |
1816 else: |
1819 flag1 = ctx1.flags(f) |
1817 flag1 = ctx1.flags(f) |
1820 if util.binary(content1): |
1818 binary = util.binary(content1) |
1821 binarydiff = True |
1819 else: |
1822 elif not content1 or util.binary(content1): |
1820 binary = util.binary(content1) |
1823 # regular diffs cannot represent empty file deletion |
1821 if not content1 or binary: |
1824 losedatafn(f) |
1822 # regular diffs cannot represent empty file deletion |
|
1823 losedatafn(f) |
1825 else: |
1824 else: |
1826 flag1 = ctx1.flags(f) |
1825 flag1 = ctx1.flags(f) |
1827 flag2 = ctx2.flags(f) |
1826 flag2 = ctx2.flags(f) |
1828 binary = util.binary(content1) or util.binary(content2) |
1827 binary = util.binary(content1) or util.binary(content2) |
1829 if opts.git: |
1828 if not opts.git and (binary or flag2 != flag1): |
1830 if binary: |
|
1831 binarydiff = True |
|
1832 elif binary or flag2 != flag1: |
|
1833 losedatafn(f) |
1829 losedatafn(f) |
1834 |
1830 |
1835 path1 = posixpath.join(prefix, f1) |
1831 path1 = posixpath.join(prefix, f1) |
1836 path2 = posixpath.join(prefix, f2) |
1832 path2 = posixpath.join(prefix, f2) |
1837 header = [] |
1833 header = [] |
1851 header.append('%s from %s' % (copyop, path1)) |
1847 header.append('%s from %s' % (copyop, path1)) |
1852 header.append('%s to %s' % (copyop, path2)) |
1848 header.append('%s to %s' % (copyop, path2)) |
1853 elif revs and not repo.ui.quiet: |
1849 elif revs and not repo.ui.quiet: |
1854 header.append(diffline(path1, revs)) |
1850 header.append(diffline(path1, revs)) |
1855 |
1851 |
1856 if binarydiff and not opts.nobinary: |
1852 if binary and opts.git and not opts.nobinary: |
1857 text = mdiff.b85diff(content1, content2) |
1853 text = mdiff.b85diff(content1, content2) |
1858 if text and opts.git: |
1854 if text: |
1859 header.append('index %s..%s' % |
1855 header.append('index %s..%s' % |
1860 (gitindex(content1), gitindex(content2))) |
1856 (gitindex(content1), gitindex(content2))) |
1861 else: |
1857 else: |
1862 text = mdiff.unidiff(content1, date1, |
1858 text = mdiff.unidiff(content1, date1, |
1863 content2, date2, |
1859 content2, date2, |