stream_in: write the remote branchcache for a usage as wide as possible
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Wed, 16 Jan 2013 00:12:01 +0100
changeset 18397 ecf4f79cc600
parent 18396 dd3fd3353e23
child 18398 1a00c8451640
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.
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Tue Jan 15 23:33:07 2013 +0100
+++ b/mercurial/localrepo.py	Wed Jan 16 00:12:01 2013 +0100
@@ -2477,8 +2477,14 @@
                     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: