Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 24005:2c166f6b5d10
trydiff: inline indexmeta()
The function is trivial and is only called in one place.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 16 Jan 2015 15:40:59 -0800 |
parents | f610c3bd03d3 |
children | cc81e6da0757 |
comparison
equal
deleted
inserted
replaced
24004:8a5267cd5286 | 24005:2c166f6b5d10 |
---|---|
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 addindexmeta(meta, index1, index2): | |
1743 meta.append('index %s..%s\n' % (index1, index2)) | |
1744 | |
1745 def gitindex(text): | 1742 def gitindex(text): |
1746 if not text: | 1743 if not text: |
1747 text = "" | 1744 text = "" |
1748 l = len(text) | 1745 l = len(text) |
1749 s = util.sha1('blob %d\0' % l) | 1746 s = util.sha1('blob %d\0' % l) |
1867 header.append('%s to %s\n' % (op, path2)) | 1864 header.append('%s to %s\n' % (op, path2)) |
1868 | 1865 |
1869 if binarydiff and not opts.nobinary: | 1866 if binarydiff and not opts.nobinary: |
1870 text = mdiff.b85diff(content1, content2) | 1867 text = mdiff.b85diff(content1, content2) |
1871 if text and opts.git: | 1868 if text and opts.git: |
1872 addindexmeta(header, gitindex(content1), gitindex(content2)) | 1869 header.append('index %s..%s\n' % |
1870 (gitindex(content1), gitindex(content2))) | |
1873 else: | 1871 else: |
1874 text = mdiff.unidiff(content1, date1, | 1872 text = mdiff.unidiff(content1, date1, |
1875 content2, date2, | 1873 content2, date2, |
1876 path1, path2, opts=opts) | 1874 path1, path2, opts=opts) |
1877 if header and (text or len(header) > 1): | 1875 if header and (text or len(header) > 1): |