Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 23754:ed645dc672e5
trydiff: replace dodiff=True/'binary' by binarydiff=False/True
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 07 Jan 2015 11:02:10 -0800 |
parents | e30c6aa6f2a2 |
children | 0db6810e84e8 |
comparison
equal
deleted
inserted
replaced
23753:e30c6aa6f2a2 | 23754:ed645dc672e5 |
---|---|
1796 addedset.add(f) | 1796 addedset.add(f) |
1797 modifiedset.remove(f) | 1797 modifiedset.remove(f) |
1798 for f in sorted(modified + added + removed): | 1798 for f in sorted(modified + added + removed): |
1799 to = None | 1799 to = None |
1800 tn = None | 1800 tn = None |
1801 dodiff = True | 1801 binarydiff = False |
1802 header = [] | 1802 header = [] |
1803 if f not in addedset: | 1803 if f not in addedset: |
1804 to = getfilectx(f, ctx1).data() | 1804 to = getfilectx(f, ctx1).data() |
1805 if f not in removedset: | 1805 if f not in removedset: |
1806 tn = getfilectx(f, ctx2).data() | 1806 tn = getfilectx(f, ctx2).data() |
1834 # In theory, if tn was copied or renamed we should check | 1834 # In theory, if tn was copied or renamed we should check |
1835 # if the source is binary too but the copy record already | 1835 # if the source is binary too but the copy record already |
1836 # forces git mode. | 1836 # forces git mode. |
1837 if util.binary(tn): | 1837 if util.binary(tn): |
1838 if opts.git: | 1838 if opts.git: |
1839 dodiff = 'binary' | 1839 binarydiff = True |
1840 else: | 1840 else: |
1841 losedatafn(f) | 1841 losedatafn(f) |
1842 if not opts.git and not tn: | 1842 if not opts.git and not tn: |
1843 # regular diffs cannot represent new empty file | 1843 # regular diffs cannot represent new empty file |
1844 losedatafn(f) | 1844 losedatafn(f) |
1852 continue | 1852 continue |
1853 else: | 1853 else: |
1854 header.append('deleted file mode %s\n' % | 1854 header.append('deleted file mode %s\n' % |
1855 gitmode[ctx1.flags(f)]) | 1855 gitmode[ctx1.flags(f)]) |
1856 if util.binary(to): | 1856 if util.binary(to): |
1857 dodiff = 'binary' | 1857 binarydiff = True |
1858 elif not to or util.binary(to): | 1858 elif not to or util.binary(to): |
1859 # regular diffs cannot represent empty file deletion | 1859 # regular diffs cannot represent empty file deletion |
1860 losedatafn(f) | 1860 losedatafn(f) |
1861 else: | 1861 else: |
1862 oflag = ctx1.flags(f) | 1862 oflag = ctx1.flags(f) |
1863 nflag = ctx2.flags(f) | 1863 nflag = ctx2.flags(f) |
1864 binary = util.binary(to) or util.binary(tn) | 1864 binary = util.binary(to) or util.binary(tn) |
1865 if opts.git: | 1865 if opts.git: |
1866 addmodehdr(header, gitmode[oflag], gitmode[nflag]) | 1866 addmodehdr(header, gitmode[oflag], gitmode[nflag]) |
1867 if binary: | 1867 if binary: |
1868 dodiff = 'binary' | 1868 binarydiff = True |
1869 elif binary or nflag != oflag: | 1869 elif binary or nflag != oflag: |
1870 losedatafn(f) | 1870 losedatafn(f) |
1871 | 1871 |
1872 if opts.git or revs: | 1872 if opts.git or revs: |
1873 header.insert(0, diffline(join(a), join(b), revs)) | 1873 header.insert(0, diffline(join(a), join(b), revs)) |
1874 if dodiff == 'binary' and not opts.nobinary: | 1874 if binarydiff and not opts.nobinary: |
1875 text = mdiff.b85diff(to, tn) | 1875 text = mdiff.b85diff(to, tn) |
1876 if text and opts.git: | 1876 if text and opts.git: |
1877 addindexmeta(header, gitindex(to), gitindex(tn)) | 1877 addindexmeta(header, gitindex(to), gitindex(tn)) |
1878 else: | 1878 else: |
1879 text = mdiff.unidiff(to, date1, | 1879 text = mdiff.unidiff(to, date1, |