Mercurial > public > mercurial-scm > hg
comparison mercurial/patch.py @ 23753:e30c6aa6f2a2
trydiff: replace 'dodiff = False' by 'continue'
The 'dodiff' variable is initialized to True and may later be set to
either False or "binary". When it's set to False, we skip everything
after that point, so we can simplify by instead continue-ing (the
loop). We can then also drop the 'if dodiff', since it will always be
true.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 07 Jan 2015 10:59:40 -0800 |
parents | 70d8be6299ab |
children | ed645dc672e5 |
comparison
equal
deleted
inserted
replaced
23752:70d8be6299ab | 23753:e30c6aa6f2a2 |
---|---|
1847 # have we already reported a copy above? | 1847 # have we already reported a copy above? |
1848 if ((f in copy and copy[f] in addedset | 1848 if ((f in copy and copy[f] in addedset |
1849 and copyto[copy[f]] == f) or | 1849 and copyto[copy[f]] == f) or |
1850 (f in copyto and copyto[f] in addedset | 1850 (f in copyto and copyto[f] in addedset |
1851 and copy[copyto[f]] == f)): | 1851 and copy[copyto[f]] == f)): |
1852 dodiff = False | 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 dodiff = 'binary' |
1867 if binary: | 1867 if binary: |
1868 dodiff = 'binary' | 1868 dodiff = 'binary' |
1869 elif binary or nflag != oflag: | 1869 elif binary or nflag != oflag: |
1870 losedatafn(f) | 1870 losedatafn(f) |
1871 | 1871 |
1872 if dodiff: | 1872 if opts.git or revs: |
1873 if opts.git or revs: | 1873 header.insert(0, diffline(join(a), join(b), revs)) |
1874 header.insert(0, diffline(join(a), join(b), revs)) | 1874 if dodiff == 'binary' and not opts.nobinary: |
1875 if dodiff == 'binary' and not opts.nobinary: | 1875 text = mdiff.b85diff(to, tn) |
1876 text = mdiff.b85diff(to, tn) | 1876 if text and opts.git: |
1877 if text and opts.git: | 1877 addindexmeta(header, gitindex(to), gitindex(tn)) |
1878 addindexmeta(header, gitindex(to), gitindex(tn)) | 1878 else: |
1879 else: | 1879 text = mdiff.unidiff(to, date1, |
1880 text = mdiff.unidiff(to, date1, | 1880 tn, date2, |
1881 tn, date2, | 1881 join(a), join(b), opts=opts) |
1882 join(a), join(b), opts=opts) | 1882 if header and (text or len(header) > 1): |
1883 if header and (text or len(header) > 1): | 1883 yield ''.join(header) |
1884 yield ''.join(header) | 1884 if text: |
1885 if text: | 1885 yield text |
1886 yield text | |
1887 | 1886 |
1888 def diffstatsum(stats): | 1887 def diffstatsum(stats): |
1889 maxfile, maxtotal, addtotal, removetotal, binary = 0, 0, 0, 0, False | 1888 maxfile, maxtotal, addtotal, removetotal, binary = 0, 0, 0, 0, False |
1890 for f, a, r, b in stats: | 1889 for f, a, r, b in stats: |
1891 maxfile = max(maxfile, encoding.colwidth(f)) | 1890 maxfile = max(maxfile, encoding.colwidth(f)) |