Patchwork [4,of,4] stream_in: write the remote branchcache for a usage as wide as possible

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 15, 2013, 11:20 p.m.
Message ID <ec59887cc09181f36aa0.1358292031@yamac.lan>
Download mbox | patch
Permalink /patch/635/
State Accepted
Commit ecf4f79cc6007c648ea458d0a4c71c3c69583280
Headers show

Comments

Pierre-Yves David - Jan. 15, 2013, 11:20 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1358291521 -3600
# Node ID ec59887cc09181f36aa0ebc0b3c9410b855aea29
# Parent  5175c9be5963aebd2a774015fd02050e924dbf63
stream_in: write the remote branchcache for a usage as wide as possible

Writing cache for unfiltered repo only is barely useful, Most repo user are now
at least use the `hidden` filter. This changeset now assigns the remote cache
for a filter as low as possible for a wider reuse as possible.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2475,12 +2475,18 @@  class localrepository(object):
                     rtiprev = max((int(self.changelog.rev(node))
                             for node in rbheads))
                     cache = branchmap.branchcache(rbranchmap,
                                                   self[rtiprev].node(),
                                                   rtiprev)
-                    self._branchcaches[None] = cache
-                    cache.write(self.unfiltered())
+                    # Try to stick it as low as possible
+                    # filter above served are unlikely to be fetch from a clone
+                    for candidate in ('base', 'immutable', 'served'):
+                        rview = self.filtered(candidate)
+                        if cache.validfor(rview):
+                            self._branchcaches[candidate] = cache
+                            cache.write(rview)
+                            break
             self.invalidate()
             return len(self.heads()) + 1
         finally:
             lock.release()