mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
simplecache: fix for hggit
Summary: When used with hggit, simplecache would treat all hggit overlayctxs as having the `nullid` node. This is used in the cache key for the result of `status()`; this caused the return value of all hggit's changectxs' `status()` to be intermingled. There are arguably two issues here: - hggit's `overlaychangectx` simply implemented `node()` and didn't set a `_node` like changectx does. Changectx refers to this property internally (and other external callers might do so too) so we should probably set it. - simplecache was reading the `changectx._node` property instead of the more public `changectx.node()`. This returned `nullid` because of the above. Either change would fix it but I sent both to be safe. I look forward to tightening the context class interfaces in the future. (Note: this ignores all push blocking failures!) Reviewed By: quark-zju Differential Revision: D6788335 fbshipit-source-id: eb4b3cebc1b6ee6011405cdb7d702cdf5cac0904
This commit is contained in:
parent
511a0a046f
commit
c97e746105
@ -213,12 +213,13 @@ class overlaychangectx(context.changectx):
|
||||
self.commit = repo.handler.git.get_object(_maybehex(sha))
|
||||
self._overlay = getattr(repo, 'gitoverlay', repo)
|
||||
self._rev = self._overlay.rev(bin(self.commit.id))
|
||||
self._node = bin(self.commit.id)
|
||||
|
||||
def repo(self):
|
||||
return self._hgrepo
|
||||
|
||||
def node(self):
|
||||
return bin(self.commit.id)
|
||||
return self._node
|
||||
|
||||
def rev(self):
|
||||
return self._rev
|
||||
|
@ -28,10 +28,21 @@ from mercurial import (
|
||||
extensions,
|
||||
node,
|
||||
)
|
||||
from mercurial.node import (
|
||||
nullid,
|
||||
wdirid
|
||||
)
|
||||
from mercurial.scmutil import status
|
||||
|
||||
testedwith = 'ships-with-fb-hgext'
|
||||
|
||||
# context nodes that are special and should not be cached.
|
||||
UNCACHEABLE_NODES = [
|
||||
None, # repo[None].node() returns this
|
||||
nullid,
|
||||
wdirid
|
||||
]
|
||||
|
||||
def extsetup(ui):
|
||||
extensions.wrapfunction(copies, 'pathcopies', pathcopiesui(ui))
|
||||
extensions.wrapfunction(context.basectx, '_buildstatus', buildstatusui(ui))
|
||||
@ -155,10 +166,11 @@ def buildstatusui(ui):
|
||||
return func()
|
||||
if ignored or clean or unknown:
|
||||
return func()
|
||||
if self._node is None or other._node is None:
|
||||
if (self.node() in UNCACHEABLE_NODES or
|
||||
other.node() in UNCACHEABLE_NODES):
|
||||
return func()
|
||||
key = 'buildstatus:%s:%s' % (
|
||||
node.hex(self._node), node.hex(other._node))
|
||||
node.hex(self.node()), node.hex(other.node()))
|
||||
return memoize(func, key, buildstatusserializer, ui)
|
||||
|
||||
return buildstatus
|
||||
|
Loading…
Reference in New Issue
Block a user