Mercurial > hg
comparison hgext/rebase.py @ 38672:0f8599afb92f
rebase: avoid converting from nodes to revnums twice
In the case where the node has successors, but none of them is an
ancestor of the destination, we would iterate over the successor nodes
twice, check if they're in the repo and convert them to revnums. I
doubt it's a measureable cost, but it gets simpler this way too.
Differential Revision: https://phab.mercurial-scm.org/D3941
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 11 Jul 2018 15:01:47 -0700 |
parents | 99ed6e2f6606 |
children | 20a30bb8f276 |
comparison
equal
deleted
inserted
replaced
38671:99ed6e2f6606 | 38672:0f8599afb92f |
---|---|
1867 obsoleteextinctsuccessors.add(srcrev) | 1867 obsoleteextinctsuccessors.add(srcrev) |
1868 if not successors: | 1868 if not successors: |
1869 # no successor | 1869 # no successor |
1870 obsoletenotrebased[srcrev] = None | 1870 obsoletenotrebased[srcrev] = None |
1871 else: | 1871 else: |
1872 destnode = cl.node(destmap[srcrev]) | 1872 dstrev = destmap[srcrev] |
1873 for succnode in successors: | 1873 succrevs = [nodemap[s] for s in successors if s in nodemap] |
1874 if succnode not in nodemap: | 1874 for succrev in succrevs: |
1875 continue | 1875 if cl.isancestorrev(succrev, dstrev): |
1876 if cl.isancestor(succnode, destnode): | 1876 obsoletenotrebased[srcrev] = succrev |
1877 obsoletenotrebased[srcrev] = nodemap[succnode] | |
1878 break | 1877 break |
1879 else: | 1878 else: |
1880 # If 'srcrev' has a successor in rebase set but none in | 1879 # If 'srcrev' has a successor in rebase set but none in |
1881 # destination (which would be catched above), we shall skip it | 1880 # destination (which would be catched above), we shall skip it |
1882 # and its descendants to avoid divergence. | 1881 # and its descendants to avoid divergence. |
1883 if any(nodemap[s] in destmap for s in successors | 1882 if any(s in destmap for s in succrevs): |
1884 if s in nodemap): | |
1885 obsoletewithoutsuccessorindestination.add(srcrev) | 1883 obsoletewithoutsuccessorindestination.add(srcrev) |
1886 | 1884 |
1887 return ( | 1885 return ( |
1888 obsoletenotrebased, | 1886 obsoletenotrebased, |
1889 obsoletewithoutsuccessorindestination, | 1887 obsoletewithoutsuccessorindestination, |