Patchwork [1,of,2,fix] rebase: use a direct reference to repo.changelog

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 14, 2015, 11:57 p.m.
Message ID <d2dd179568f5aa46ffc5.1444867055@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/11088/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 14, 2015, 11:57 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1444862535 -3600
#      Wed Oct 14 23:42:15 2015 +0100
# Node ID d2dd179568f5aa46ffc597a393f2df663a4893af
# Parent  07db7e95c464537aeb2dd7aba39de0813eaffd04
# EXP-Topic reb.skip
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r d2dd179568f5
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.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1156,23 +1156,24 @@  def _computeobsoletenotrebased(repo, reb
     obsoletenotrebased = {}
 
     # 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
     return obsoletenotrebased