Patchwork [3,of,6,RFC] destutil: replace wc.branch() invocations by cached value for efficiency

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Feb. 24, 2016, 2:17 p.m.
Message ID <5c1d28233fd5ad7a419a.1456323431@feefifofum>
Download mbox | patch
Permalink /patch/13344/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Feb. 24, 2016, 2:17 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1456322433 -32400
#      Wed Feb 24 23:00:33 2016 +0900
# Node ID 5c1d28233fd5ad7a419a0e4fa6f15e5b3e47a3d2
# Parent  8938e21bbd1458d43b67697c941ba5eb66c75d76
destutil: replace wc.branch() invocations by cached value for efficiency
Pierre-Yves David - Feb. 25, 2016, 3:05 p.m.
On 02/24/2016 03:17 PM, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1456322433 -32400
> #      Wed Feb 24 23:00:33 2016 +0900
> # Node ID 5c1d28233fd5ad7a419a0e4fa6f15e5b3e47a3d2
> # Parent  8938e21bbd1458d43b67697c941ba5eb66c75d76
> destutil: replace wc.branch() invocations by cached value for efficiency

I've pushed patch 1-3 to the clowncopter as obvious improvement.
Patch 4 is also pushed as smart change.
Patch 5-6 needs further brain and discussion.

Patch

diff --git a/mercurial/destutil.py b/mercurial/destutil.py
--- a/mercurial/destutil.py
+++ b/mercurial/destutil.py
@@ -91,16 +91,17 @@  def _destupdatebranch(repo, clean, check
     """decide on an update destination from current branch"""
     wc = repo[None]
     movemark = node = None
+    currentbranch = wc.branch()
     try:
         node = repo.revs('max(.::(head() and branch(%s)))'
-                         , wc.branch()).first()
+                         , currentbranch).first()
         if bookmarks.isactivewdirparent(repo):
             movemark = repo['.'].node()
     except error.RepoLookupError:
-        if wc.branch() == 'default': # no default branch!
+        if currentbranch == 'default': # no default branch!
             node = repo.lookup('tip') # update to tip
         else:
-            raise error.Abort(_("branch %s not found") % wc.branch())
+            raise error.Abort(_("branch %s not found") % currentbranch)
     return node, movemark, None
 
 # order in which each step should be evalutated