##// END OF EJS Templates
httppeer: expose API descriptor on httpv2peer...
httppeer: expose API descriptor on httpv2peer The API descriptor in wireprotov2 is much more expressive than space-delimited tokens and it will be difficult to define methods to query it in all of the ways we'll want to query it. So let's just declare defeat and expose the API descriptor on the peer instance. As part of this, we define a new interface for version 2 peers, fulfilling a TODO in the process. Differential Revision: https://phab.mercurial-scm.org/D4974

File last commit:

r39989:a3a9b93b default
r40207:dac438b7 default
Show More
test-storage.py
73 lines | 2.4 KiB | text/x-python | PythonLexer
Gregory Szorc
testing: add interface unit tests for file storage...
r39808 # This test verifies the conformance of various classes to various
# storage interfaces.
from __future__ import absolute_import
import silenttestrunner
from mercurial import (
Gregory Szorc
testing: add file storage integration for bad hashes and censoring...
r40087 error,
Gregory Szorc
testing: add interface unit tests for file storage...
r39808 filelog,
Gregory Szorc
testing: add file storage integration for bad hashes and censoring...
r40087 revlog,
Gregory Szorc
testing: add interface unit tests for file storage...
r39808 transaction,
ui as uimod,
vfs as vfsmod,
)
from mercurial.testing import (
storage as storagetesting,
)
STATE = {
'lastindex': 0,
'ui': uimod.ui(),
'vfs': vfsmod.vfs(b'.', realpath=True),
}
def makefilefn(self):
"""Factory for filelog instances."""
Gregory Szorc
py3: byteify test-storage.py...
r39989 fl = filelog.filelog(STATE['vfs'], b'filelog-%d' % STATE['lastindex'])
Gregory Szorc
testing: add interface unit tests for file storage...
r39808 STATE['lastindex'] += 1
return fl
def maketransaction(self):
Gregory Szorc
revlog: rewrite censoring logic...
r40092 vfsmap = {'plain': STATE['vfs'], 'store': STATE['vfs']}
Gregory Szorc
testing: add interface unit tests for file storage...
r39808
return transaction.transaction(STATE['ui'].warn, STATE['vfs'], vfsmap,
Gregory Szorc
py3: byteify test-storage.py...
r39989 b'journal', b'undo')
Gregory Szorc
testing: add interface unit tests for file storage...
r39808
Gregory Szorc
testing: add file storage integration for bad hashes and censoring...
r40087 def addrawrevision(self, fl, tr, node, p1, p2, linkrev, rawtext=None,
delta=None, censored=False, ellipsis=False, extstored=False):
flags = 0
if censored:
flags |= revlog.REVIDX_ISCENSORED
if ellipsis:
flags |= revlog.REVIDX_ELLIPSIS
if extstored:
flags |= revlog.REVIDX_EXTSTORED
if rawtext is not None:
fl._revlog.addrawrevision(rawtext, tr, linkrev, p1, p2, node, flags)
elif delta is not None:
raise error.Abort('support for storing raw deltas not yet supported')
else:
raise error.Abort('must supply rawtext or delta arguments')
# We may insert bad data. Clear caches to prevent e.g. cache hits to
# bypass hash verification.
fl._revlog.clearcaches()
Gregory Szorc
testing: add interface unit tests for file storage...
r39808 # Assigning module-level attributes that inherit from unittest.TestCase
# is all that is needed to register tests.
filelogindextests = storagetesting.makeifileindextests(makefilefn,
Gregory Szorc
testing: add file storage integration for bad hashes and censoring...
r40087 maketransaction,
addrawrevision)
Gregory Szorc
testing: add interface unit tests for file storage...
r39808 filelogdatatests = storagetesting.makeifiledatatests(makefilefn,
Gregory Szorc
testing: add file storage integration for bad hashes and censoring...
r40087 maketransaction,
addrawrevision)
Gregory Szorc
testing: add interface unit tests for file storage...
r39808 filelogmutationtests = storagetesting.makeifilemutationtests(makefilefn,
Gregory Szorc
testing: add file storage integration for bad hashes and censoring...
r40087 maketransaction,
addrawrevision)
Gregory Szorc
testing: add interface unit tests for file storage...
r39808
if __name__ == '__main__':
silenttestrunner.main(__name__)