Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 24000:82e3324c4df9
trydiff: inline sole addmodehdr() call
Now that there is only a single call to addmodehdr() left, and there
is other similar code (for new/deleted files) around that call site,
let's inline the function there. That also makes it clearer under what
circumstances the header is actually written (when modes differ).
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 16 Jan 2015 14:53:37 -0800 |
parents | e02888efc5aa |
children | f610c3bd03d3 |
comparison
equal
deleted
inserted
replaced
23999:e02888efc5aa | 24000:82e3324c4df9 |
---|---|
1737 return difflabel(diff, *args, **kw) | 1737 return difflabel(diff, *args, **kw) |
1738 | 1738 |
1739 def trydiff(repo, revs, ctx1, ctx2, modified, added, removed, | 1739 def trydiff(repo, revs, ctx1, ctx2, modified, added, removed, |
1740 copy, getfilectx, opts, losedatafn, prefix): | 1740 copy, getfilectx, opts, losedatafn, prefix): |
1741 | 1741 |
1742 def addmodehdr(header, mode1, mode2): | |
1743 if mode1 != mode2: | |
1744 header.append('old mode %s\n' % mode1) | |
1745 header.append('new mode %s\n' % mode2) | |
1746 | |
1747 def addindexmeta(meta, index1, index2): | 1742 def addindexmeta(meta, index1, index2): |
1748 meta.append('index %s..%s\n' % (index1, index2)) | 1743 meta.append('index %s..%s\n' % (index1, index2)) |
1749 | 1744 |
1750 def gitindex(text): | 1745 def gitindex(text): |
1751 if not text: | 1746 if not text: |
1859 if content1 is None: # added | 1854 if content1 is None: # added |
1860 header.append('new file mode %s\n' % gitmode[flag2]) | 1855 header.append('new file mode %s\n' % gitmode[flag2]) |
1861 elif content2 is None: # removed | 1856 elif content2 is None: # removed |
1862 header.append('deleted file mode %s\n' % gitmode[flag1]) | 1857 header.append('deleted file mode %s\n' % gitmode[flag1]) |
1863 else: # modified/copied/renamed | 1858 else: # modified/copied/renamed |
1864 addmodehdr(header, gitmode[flag1], gitmode[flag2]) | 1859 mode1, mode2 = gitmode[flag1], gitmode[flag2] |
1860 if mode1 != mode2: | |
1861 header.append('old mode %s\n' % mode1) | |
1862 header.append('new mode %s\n' % mode2) | |
1865 if op is not None: | 1863 if op is not None: |
1866 header.append('%s from %s\n' % (op, path1)) | 1864 header.append('%s from %s\n' % (op, path1)) |
1867 header.append('%s to %s\n' % (op, path2)) | 1865 header.append('%s to %s\n' % (op, path2)) |
1868 | 1866 |
1869 if opts.git or revs: | 1867 if opts.git or revs: |