Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 23661:dbd60f8d88d5
trydiff: use sets, not lists, for containment checks
This only has a noticeable effect on diffs touching A LOT of
files. For example, it takes
hg diff -r FIREFOX_AURORA_30_BASE -r FIREFOX_AURORA_35_BASE
from 1m55.465s to 1m32.354s. That diff has over 50k files.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 23 Dec 2014 10:41:45 -0800 |
parents | 60300a4c0ae5 |
children | bc7d90c966d2 |
comparison
equal
deleted
inserted
replaced
23660:1ec6dbb9b216 | 23661:dbd60f8d88d5 |
---|---|
1792 copyto = dict([(v, k) for k, v in copy.items()]) | 1792 copyto = dict([(v, k) for k, v in copy.items()]) |
1793 | 1793 |
1794 if opts.git: | 1794 if opts.git: |
1795 revs = None | 1795 revs = None |
1796 | 1796 |
1797 modifiedset, addedset, removedset = set(modified), set(added), set(removed) | |
1797 for f in sorted(modified + added + removed): | 1798 for f in sorted(modified + added + removed): |
1798 to = None | 1799 to = None |
1799 tn = None | 1800 tn = None |
1800 dodiff = True | 1801 dodiff = True |
1801 header = [] | 1802 header = [] |
1802 if f in man1: | 1803 if f in man1: |
1803 to = getfilectx(f, ctx1).data() | 1804 to = getfilectx(f, ctx1).data() |
1804 if f not in removed: | 1805 if f not in removedset: |
1805 tn = getfilectx(f, ctx2).data() | 1806 tn = getfilectx(f, ctx2).data() |
1806 a, b = f, f | 1807 a, b = f, f |
1807 if opts.git or losedatafn: | 1808 if opts.git or losedatafn: |
1808 if f in added or (f in modified and to is None): | 1809 if f in addedset or (f in modifiedset and to is None): |
1809 mode = gitmode[ctx2.flags(f)] | 1810 mode = gitmode[ctx2.flags(f)] |
1810 if f in copy or f in copyto: | 1811 if f in copy or f in copyto: |
1811 if opts.git: | 1812 if opts.git: |
1812 if f in copy: | 1813 if f in copy: |
1813 a = copy[f] | 1814 a = copy[f] |
1814 else: | 1815 else: |
1815 a = copyto[f] | 1816 a = copyto[f] |
1816 omode = gitmode[man1.flags(a)] | 1817 omode = gitmode[man1.flags(a)] |
1817 addmodehdr(header, omode, mode) | 1818 addmodehdr(header, omode, mode) |
1818 if a in removed and a not in gone: | 1819 if a in removedset and a not in gone: |
1819 op = 'rename' | 1820 op = 'rename' |
1820 gone.add(a) | 1821 gone.add(a) |
1821 else: | 1822 else: |
1822 op = 'copy' | 1823 op = 'copy' |
1823 header.append('%s from %s\n' % (op, join(a))) | 1824 header.append('%s from %s\n' % (op, join(a))) |
1839 else: | 1840 else: |
1840 losedatafn(f) | 1841 losedatafn(f) |
1841 if not opts.git and not tn: | 1842 if not opts.git and not tn: |
1842 # regular diffs cannot represent new empty file | 1843 # regular diffs cannot represent new empty file |
1843 losedatafn(f) | 1844 losedatafn(f) |
1844 elif f in removed or (f in modified and tn is None): | 1845 elif f in removedset or (f in modifiedset and tn is None): |
1845 if opts.git: | 1846 if opts.git: |
1846 # have we already reported a copy above? | 1847 # have we already reported a copy above? |
1847 if ((f in copy and copy[f] in added | 1848 if ((f in copy and copy[f] in addedset |
1848 and copyto[copy[f]] == f) or | 1849 and copyto[copy[f]] == f) or |
1849 (f in copyto and copyto[f] in added | 1850 (f in copyto and copyto[f] in addedset |
1850 and copy[copyto[f]] == f)): | 1851 and copy[copyto[f]] == f)): |
1851 dodiff = False | 1852 dodiff = False |
1852 else: | 1853 else: |
1853 header.append('deleted file mode %s\n' % | 1854 header.append('deleted file mode %s\n' % |
1854 gitmode[man1.flags(f)]) | 1855 gitmode[man1.flags(f)]) |