Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 24022:da63f557d0dc
trydiff: make 'revs' ignored if opts.git is set
Instead of setting revs=None to prevent the call to diffline() when
opts.git is set, explicitly do not call the function in the git case.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 16 Jan 2015 15:19:57 -0800 |
parents | f51a822dcf3b |
children | 163e25931f65 |
comparison
equal
deleted
inserted
replaced
24021:f51a822dcf3b | 24022:da63f557d0dc |
---|---|
1770 gone = set() | 1770 gone = set() |
1771 gitmode = {'l': '120000', 'x': '100755', '': '100644'} | 1771 gitmode = {'l': '120000', 'x': '100755', '': '100644'} |
1772 | 1772 |
1773 copyto = dict([(v, k) for k, v in copy.items()]) | 1773 copyto = dict([(v, k) for k, v in copy.items()]) |
1774 | 1774 |
1775 if opts.git: | |
1776 revs = None | |
1777 | |
1778 addedset, removedset = set(added), set(removed) | 1775 addedset, removedset = set(added), set(removed) |
1779 # Fix up added, since merged-in additions appear as | 1776 # Fix up added, since merged-in additions appear as |
1780 # modifications during merges | 1777 # modifications during merges |
1781 for f in modified: | 1778 for f in modified: |
1782 if f not in ctx1: | 1779 if f not in ctx1: |
1843 losedatafn(f) | 1840 losedatafn(f) |
1844 | 1841 |
1845 path1 = posixpath.join(prefix, f1) | 1842 path1 = posixpath.join(prefix, f1) |
1846 path2 = posixpath.join(prefix, f2) | 1843 path2 = posixpath.join(prefix, f2) |
1847 header = [] | 1844 header = [] |
1848 if revs: | 1845 if opts.git: |
1849 header.append(diffline(path1, revs)) | |
1850 elif opts.git: | |
1851 header.append('diff --git %s%s %s%s\n' % | 1846 header.append('diff --git %s%s %s%s\n' % |
1852 (aprefix, path1, bprefix, path2)) | 1847 (aprefix, path1, bprefix, path2)) |
1853 if content1 is None: # added | 1848 if content1 is None: # added |
1854 header.append('new file mode %s\n' % gitmode[flag2]) | 1849 header.append('new file mode %s\n' % gitmode[flag2]) |
1855 elif content2 is None: # removed | 1850 elif content2 is None: # removed |
1860 header.append('old mode %s\n' % mode1) | 1855 header.append('old mode %s\n' % mode1) |
1861 header.append('new mode %s\n' % mode2) | 1856 header.append('new mode %s\n' % mode2) |
1862 if op is not None: | 1857 if op is not None: |
1863 header.append('%s from %s\n' % (op, path1)) | 1858 header.append('%s from %s\n' % (op, path1)) |
1864 header.append('%s to %s\n' % (op, path2)) | 1859 header.append('%s to %s\n' % (op, path2)) |
1860 elif revs: | |
1861 header.append(diffline(path1, revs)) | |
1865 | 1862 |
1866 if binarydiff and not opts.nobinary: | 1863 if binarydiff and not opts.nobinary: |
1867 text = mdiff.b85diff(content1, content2) | 1864 text = mdiff.b85diff(content1, content2) |
1868 if text and opts.git: | 1865 if text and opts.git: |
1869 header.append('index %s..%s\n' % | 1866 header.append('index %s..%s\n' % |