Patchwork [02,of,10] branchmap: factorise access to changelog in updatebranchcache

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 19, 2012, 1:53 p.m.
Message ID <f8e00dbbb6bb0c871278.1355925198@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/189/
State Superseded, archived
Commit da1714bd0250ff87ac7b73657769208ddc4b61dc
Headers show

Comments

Pierre-Yves David - Dec. 19, 2012, 1:53 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1355916586 -3600
# Node ID f8e00dbbb6bb0c871278d61fb979179162d3cdd4
# Parent  56c016dea0622854146f52acb9b3d5c9258636b9
branchmap: factorise access to changelog in updatebranchcache

This prepares merge of `updatebranchcache` and `_branchtags`.
Laurens Holst - Dec. 19, 2012, 2:11 p.m.
Op 19-12-12 14:53, pierre-yves.david at logilab.fr schreef:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1355916586 -3600
> # Node ID f8e00dbbb6bb0c871278d61fb979179162d3cdd4
> # Parent  56c016dea0622854146f52acb9b3d5c9258636b9
> branchmap: factorise access to changelog in updatebranchcache
>
> This prepares merge of `updatebranchcache` and `_branchtags`.
>
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -662,20 +662,21 @@ class localrepository(object):
>               self._updatebranchcache(partial, ctxgen)
>           return partial
>   
>       @unfilteredmethod # Until we get a smarter cache management
>       def updatebranchcache(self):
> -        tip = self.changelog.tip()
> +        cl = self.changelog
> +        tip = cl.tip()
>           if self._branchcache is not None and self._branchcachetip == tip:
>               return
>   
>           oldtip = self._branchcachetip
>           self._branchcachetip = tip
> -        if oldtip is None or oldtip not in self.changelog.nodemap:
> +        if oldtip is None or oldtip not in cl.nodemap:
>               partial, last, lrev = self._readbranchcache()
>           else:
> -            lrev = self.changelog.rev(oldtip)
> +            lrev = self.cl.rev(oldtip)

As cl is a local variable, remove self. ?

~Laurens
Pierre-Yves David - Dec. 19, 2012, 5:21 p.m.
On Wed, Dec 19, 2012 at 03:11:04PM +0100, Laurens Holst wrote:
> Op 19-12-12 14:53, pierre-yves.david at logilab.fr schreef:
> ># HG changeset patch
> ># User Pierre-Yves David <pierre-yves.david at logilab.fr>
> ># Date 1355916586 -3600
> ># Node ID f8e00dbbb6bb0c871278d61fb979179162d3cdd4
> ># Parent  56c016dea0622854146f52acb9b3d5c9258636b9
> >branchmap: factorise access to changelog in updatebranchcache
> >
> >This prepares merge of `updatebranchcache` and `_branchtags`.
> >
> >diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> >--- a/mercurial/localrepo.py
> >+++ b/mercurial/localrepo.py
> >@@ -662,20 +662,21 @@ class localrepository(object):
> >              self._updatebranchcache(partial, ctxgen)
> >          return partial
> >      @unfilteredmethod # Until we get a smarter cache management
> >      def updatebranchcache(self):
> >-        tip = self.changelog.tip()
> >+        cl = self.changelog
> >+        tip = cl.tip()
> >          if self._branchcache is not None and self._branchcachetip == tip:
> >              return
> >          oldtip = self._branchcachetip
> >          self._branchcachetip = tip
> >-        if oldtip is None or oldtip not in self.changelog.nodemap:
> >+        if oldtip is None or oldtip not in cl.nodemap:
> >              partial, last, lrev = self._readbranchcache()
> >          else:
> >-            lrev = self.changelog.rev(oldtip)
> >+            lrev = self.cl.rev(oldtip)
> 
> As cl is a local variable, remove self. ?

oops, this is silently fixed by the next patch and I did not caught it when running the tests.

fixed version pullable from here:

hg pull -r d68f836a210f http://hg-lab.logilab.org/wip/hg/

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -662,20 +662,21 @@  class localrepository(object):
             self._updatebranchcache(partial, ctxgen)
         return partial
 
     @unfilteredmethod # Until we get a smarter cache management
     def updatebranchcache(self):
-        tip = self.changelog.tip()
+        cl = self.changelog
+        tip = cl.tip()
         if self._branchcache is not None and self._branchcachetip == tip:
             return
 
         oldtip = self._branchcachetip
         self._branchcachetip = tip
-        if oldtip is None or oldtip not in self.changelog.nodemap:
+        if oldtip is None or oldtip not in cl.nodemap:
             partial, last, lrev = self._readbranchcache()
         else:
-            lrev = self.changelog.rev(oldtip)
+            lrev = self.cl.rev(oldtip)
             partial = self._branchcache
 
         self._branchtags(partial, lrev)
         # this private cache holds all heads (not just the branch tips)
         self._branchcache = partial