rebase: use a direct reference to repo.changelog
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 14 Oct 2015 23:42:15 +0100
changeset 26674 fd4a38bd7e49
parent 26673 ab1af5e7d734
child 26675 b73eb98c0243
rebase: use a direct reference to repo.changelog Accessing 'repo.changelog' have a small overhead because we double check that the filtering did not changed. As we make multiple use of this into loops, we should avoid doing the lookup/check every time. This also make the code tidier.
hgext/rebase.py
--- a/hgext/rebase.py	Wed Oct 14 22:21:05 2015 -0400
+++ b/hgext/rebase.py	Wed Oct 14 23:42:15 2015 +0100
@@ -1161,19 +1161,20 @@
     # Build a mapping succesor => obsolete nodes for the obsolete
     # nodes to be rebased
     allsuccessors = {}
+    cl = repo.changelog
     for r in rebasesetrevs:
         n = repo[r]
         if n.obsolete():
-            node = repo.changelog.node(r)
+            node = cl.node(r)
             for s in obsolete.allsuccessors(repo.obsstore, [node]):
-                allsuccessors[repo.changelog.rev(s)] = repo.changelog.rev(node)
+                allsuccessors[cl.rev(s)] = cl.rev(node)
 
     if allsuccessors:
         # Look for successors of obsolete nodes to be rebased among
         # the ancestors of dest
-        ancs = repo.changelog.ancestors([repo[dest].rev()],
-                                        stoprev=min(allsuccessors),
-                                        inclusive=True)
+        ancs = cl.ancestors([repo[dest].rev()],
+                            stoprev=min(allsuccessors),
+                            inclusive=True)
         for s in allsuccessors:
             if s in ancs:
                 obsoletenotrebased[allsuccessors[s]] = s