Comments
Patch
@@ -3475,11 +3475,11 @@ def reposetup(ui, repo):
else:
tags[patch[1]] = patch[0]
return result
- def _branchtags(self, partial, lrev):
+ def _cacheabletip(self):
q = self.mq
cl = self.changelog
qbase = None
if not q.applied:
if getattr(self, '_committingpatch', False):
@@ -3490,29 +3490,14 @@ def reposetup(ui, repo):
try:
qbase = self.unfiltered().changelog.rev(qbasenode)
except error.LookupError:
self.ui.warn(_('mq status file refers to unknown node %s\n')
% short(qbasenode))
- if qbase is None:
- return super(mqrepo, self)._branchtags(partial, lrev)
-
- start = lrev + 1
- if start < qbase:
- # update the cache (excluding the patches) and save it
- ctxgen = (self[r] for r in xrange(lrev + 1, qbase))
- self._updatebranchcache(partial, ctxgen)
- self._writebranchcache(partial, cl.node(qbase - 1), qbase - 1)
- start = qbase
- # if start = qbase, the cache is as updated as it should be.
- # if start > qbase, the cache includes (part of) the patches.
- # we might as well use it, but we won't save it.
-
- # update the cache up to the tip
- ctxgen = (self[r] for r in xrange(start, len(cl)))
- self._updatebranchcache(partial, ctxgen)
-
- return partial
+ ret = super(mqrepo, self)._cacheabletip()
+ if qbase is not None:
+ ret = min(qbase - 1, ret)
+ return ret
if repo.local():
repo.__class__ = mqrepo
repo._phasedefaults.append(mqphasedefaults)
@@ -630,18 +630,41 @@ 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 _branchtags(self, partial, lrev):
# TODO: rename this function?
+ cl = self.changelog
+ catip = self._cacheabletip()
+ # if lrev == catip: cache is already up to date
+ # if lrev > catip: we have uncachable element in `partial` can't write
+ # on disk
+ if lrev < catip:
+ ctxgen = (self[r] for r in cl.revs(lrev + 1, catip))
+ self._updatebranchcache(partial, ctxgen)
+ self._writebranchcache(partial, cl.node(catip), catip)
+ lrev = catip
+ # 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 = len(self) - 1
- if lrev != tiprev:
- ctxgen = (self[r] for r in self.changelog.revs(lrev + 1, tiprev))
+ if lrev < tiprev:
+ ctxgen = (self[r] for r in cl.revs(lrev + 1, tiprev))
self._updatebranchcache(partial, ctxgen)
- self._writebranchcache(partial, self.changelog.tip(), tiprev)
-
return partial
@unfilteredmethod # Until we get a smarter cache management
def updatebranchcache(self):
tip = self.changelog.tip()