Patchwork [06,of,16] branchmap: drop all remains of `_cacheabletip`

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 2, 2013, 1:09 a.m.
Message ID <42d39c8232de6b32d6e4.1357088968@yamac.lan>
Download mbox | patch
Permalink /patch/352/
State Superseded, archived
Headers show

Comments

Pierre-Yves David - Jan. 2, 2013, 1:09 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1356660678 -3600
# Node ID 42d39c8232de6b32d6e489329bf10656960ae8a7
# Parent  0e12b59cb6494470d08837d26d6b2753a34d8fea
branchmap: drop all remains of `_cacheabletip`

It does not have any user left.
Kevin Bullock - Jan. 3, 2013, 11:04 p.m.
On Jan 1, 2013, at 7:09 PM, Pierre-Yves David wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1356660678 -3600
> # Node ID 42d39c8232de6b32d6e489329bf10656960ae8a7
> # Parent  0e12b59cb6494470d08837d26d6b2753a34d8fea
> branchmap: drop all remains of `_cacheabletip`
> 
> It does not have any user left.

...after you remove the last user of it in the same patch. One change per patch. As it is, I can't tell what the change in branchmap is doing or why it's correct.

pacem in terris / ??? / ?????? / ????????? / ??
Kevin R. Bullock

> diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
> --- a/mercurial/branchmap.py
> +++ b/mercurial/branchmap.py
> @@ -66,25 +66,15 @@ def updatecache(repo):
>     if partial is None or not partial.validfor(repo):
>         partial = read(repo)
>         if partial is None:
>             partial = branchcache()
> 
> -    catip = repo._cacheabletip()
> -    # if partial.tiprev == catip: cache is already up to date
> -    # if partial.tiprev >  catip: we have uncachable element in `partial` can't
> -    #                             write on disk
> -    if partial.tiprev < catip:
> -        ctxgen = (repo[r] for r in cl.revs(partial.tiprev + 1, catip))
> +    revs = list(cl.revs(start=partial.tiprev +1))
> +    if revs:
> +        ctxgen = (repo[r] for r in revs)
>         partial.update(repo, ctxgen)
>         partial.write(repo)
> -    # If cacheable tip were lower than actual tip, we need to update the
> -    # cache up to tip. This update (from cacheable to actual tip) is not
> -    # written to disk since it's not cacheable.
> -    tiprev = cl.rev(cl.tip())
> -    if partial.tiprev < tiprev:
> -        ctxgen = (repo[r] for r in cl.revs(partial.tiprev + 1, tiprev))
> -        partial.update(repo, ctxgen)
>     repo._branchcaches[repo.filtername] = partial
> 
> class branchcache(dict):
>     """A dict like object that hold branches heads cache"""
> 
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -648,22 +648,10 @@ class localrepository(object):
>         for bookmark, n in self._bookmarks.iteritems():
>             if n == node:
>                 marks.append(bookmark)
>         return sorted(marks)
> 
> -    def _cacheabletip(self):
> -        """tip-most revision stable enought to used in persistent cache
> -
> -        This function is overwritten by MQ to ensure we do not write cache for
> -        a part of the history that will likely change.
> -
> -        Efficient handling of filtered revision in branchcache should offer a
> -        better alternative. But we are using this approach until it is ready.
> -        """
> -        cl = self.changelog
> -        return cl.rev(cl.tip())
> -
>     def branchmap(self):
>         '''returns a dictionary {branch: [branchheads]}'''
>         if self.filtername and not self.changelog.filteredrevs:
>             return self.unfiltered().branchmap()
>         branchmap.updatecache(self)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -66,25 +66,15 @@  def updatecache(repo):
     if partial is None or not partial.validfor(repo):
         partial = read(repo)
         if partial is None:
             partial = branchcache()
 
-    catip = repo._cacheabletip()
-    # if partial.tiprev == catip: cache is already up to date
-    # if partial.tiprev >  catip: we have uncachable element in `partial` can't
-    #                             write on disk
-    if partial.tiprev < catip:
-        ctxgen = (repo[r] for r in cl.revs(partial.tiprev + 1, catip))
+    revs = list(cl.revs(start=partial.tiprev +1))
+    if revs:
+        ctxgen = (repo[r] for r in revs)
         partial.update(repo, ctxgen)
         partial.write(repo)
-    # If cacheable tip were lower than actual tip, we need to update the
-    # cache up to tip. This update (from cacheable to actual tip) is not
-    # written to disk since it's not cacheable.
-    tiprev = cl.rev(cl.tip())
-    if partial.tiprev < tiprev:
-        ctxgen = (repo[r] for r in cl.revs(partial.tiprev + 1, tiprev))
-        partial.update(repo, ctxgen)
     repo._branchcaches[repo.filtername] = partial
 
 class branchcache(dict):
     """A dict like object that hold branches heads cache"""
 
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -648,22 +648,10 @@  class localrepository(object):
         for bookmark, n in self._bookmarks.iteritems():
             if n == node:
                 marks.append(bookmark)
         return sorted(marks)
 
-    def _cacheabletip(self):
-        """tip-most revision stable enought to used in persistent cache
-
-        This function is overwritten by MQ to ensure we do not write cache for
-        a part of the history that will likely change.
-
-        Efficient handling of filtered revision in branchcache should offer a
-        better alternative. But we are using this approach until it is ready.
-        """
-        cl = self.changelog
-        return cl.rev(cl.tip())
-
     def branchmap(self):
         '''returns a dictionary {branch: [branchheads]}'''
         if self.filtername and not self.changelog.filteredrevs:
             return self.unfiltered().branchmap()
         branchmap.updatecache(self)