mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
remotefilelog: implement nodemap
Summary: Core HG code uses revlog.nodemap to test node existence. We will hit some code path about LFS in the future. So let's add a nodemap to remotefilelog. Currently, the code path won't be hit. In the future, it should only be hit by `repo._filecommit` when a `remotefilectx` is used (which is an LFS fast path). That means, `nodemap` test won't connect remote server for missing nodes. In the future, we could add some "hints" to get/getmeta API to let it not look for the remote store. Test Plan: Real test will be added when we do can hit that code path. But the new code is short and looks fine. Reviewers: #mercurial, durham Reviewed By: durham Subscribers: durham, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D5061254 Signature: t1:5061254:1494869146:88a0e1d04d292e2a64f29fdf52660f48b906665c
This commit is contained in:
parent
a82574317b
commit
c10d3a3dff
@ -17,11 +17,26 @@ from mercurial.node import bin, nullid
|
||||
from mercurial import filelog, revlog, mdiff, ancestor, error
|
||||
from mercurial.i18n import _
|
||||
|
||||
class remotefilelognodemap(object):
|
||||
def __init__(self, filename, store):
|
||||
self._filename = filename
|
||||
self._store = store
|
||||
|
||||
def __contains__(self, node):
|
||||
missing = self._store.getmissing([(self._filename, node)])
|
||||
return not bool(missing)
|
||||
|
||||
def __get__(self, node):
|
||||
if node not in self:
|
||||
raise KeyError(node)
|
||||
return node
|
||||
|
||||
class remotefilelog(object):
|
||||
def __init__(self, opener, path, repo):
|
||||
self.opener = opener
|
||||
self.filename = path
|
||||
self.repo = repo
|
||||
self.nodemap = remotefilelognodemap(self.filename, repo.contentstore)
|
||||
|
||||
self.version = 1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user