It is unused.
While a caller may want to ask the store to validate the hash of some
provided text, since there are no in-core consumers of this method,
let's drop it for now.
hg-reviewers |
It is unused.
While a caller may want to ask the store to validate the hash of some
provided text, since there are no in-core consumers of this method,
let's drop it for now.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/filelog.py (4 lines) | |||
M | mercurial/repository.py (6 lines) | |||
M | mercurial/testing/storage.py (32 lines) |
# Used by hgweb, children extension. | # Used by hgweb, children extension. | ||||
def children(self, node): | def children(self, node): | ||||
return self._revlog.children(node) | return self._revlog.children(node) | ||||
def iscensored(self, rev): | def iscensored(self, rev): | ||||
return self._revlog.iscensored(rev) | return self._revlog.iscensored(rev) | ||||
# Might be unused. | |||||
def checkhash(self, text, node, p1=None, p2=None, rev=None): | |||||
return self._revlog.checkhash(text, node, p1=p1, p2=p2, rev=rev) | |||||
def revision(self, node, _df=None, raw=False): | def revision(self, node, _df=None, raw=False): | ||||
return self._revlog.revision(node, _df=_df, raw=raw) | return self._revlog.revision(node, _df=_df, raw=raw) | ||||
def emitrevisions(self, nodes, nodesorder=None, | def emitrevisions(self, nodes, nodesorder=None, | ||||
revisiondata=False, assumehaveparentrevisions=False, | revisiondata=False, assumehaveparentrevisions=False, | ||||
deltaprevious=False): | deltaprevious=False): | ||||
return self._revlog.emitrevisions( | return self._revlog.emitrevisions( | ||||
nodes, nodesorder=nodesorder, revisiondata=revisiondata, | nodes, nodesorder=nodesorder, revisiondata=revisiondata, |
data for a tracked file. | data for a tracked file. | ||||
""" | """ | ||||
def size(rev): | def size(rev): | ||||
"""Obtain the fulltext size of file data. | """Obtain the fulltext size of file data. | ||||
Any metadata is excluded from size measurements. | Any metadata is excluded from size measurements. | ||||
""" | """ | ||||
def checkhash(fulltext, node, p1=None, p2=None, rev=None): | |||||
"""Validate the stored hash of a given fulltext and node. | |||||
Raises ``error.StorageError`` is hash validation fails. | |||||
""" | |||||
def revision(node, raw=False): | def revision(node, raw=False): | ||||
""""Obtain fulltext data for a node. | """"Obtain fulltext data for a node. | ||||
By default, any storage transformations are applied before the data | By default, any storage transformations are applied before the data | ||||
is returned. If ``raw`` is True, non-raw storage transformations | is returned. If ``raw`` is True, non-raw storage transformations | ||||
are not applied. | are not applied. | ||||
The fulltext data may contain a header containing metadata. Most | The fulltext data may contain a header containing metadata. Most |
for i in range(-5, 5): | for i in range(-5, 5): | ||||
if i == nullrev: | if i == nullrev: | ||||
continue | continue | ||||
with self.assertRaises(IndexError): | with self.assertRaises(IndexError): | ||||
f.size(i) | f.size(i) | ||||
with self.assertRaises(error.StorageError): | |||||
f.checkhash(b'', nullid) | |||||
with self.assertRaises(error.LookupError): | |||||
f.checkhash(b'', b'\x01' * 20) | |||||
self.assertEqual(f.revision(nullid), b'') | self.assertEqual(f.revision(nullid), b'') | ||||
self.assertEqual(f.revision(nullid, raw=True), b'') | self.assertEqual(f.revision(nullid, raw=True), b'') | ||||
with self.assertRaises(error.LookupError): | with self.assertRaises(error.LookupError): | ||||
f.revision(b'\x01' * 20) | f.revision(b'\x01' * 20) | ||||
self.assertEqual(f.read(nullid), b'') | self.assertEqual(f.read(nullid), b'') | ||||
self.assertEqual(f.storageinfo(revisionscount=True, trackedsize=True), | self.assertEqual(f.storageinfo(revisionscount=True, trackedsize=True), | ||||
{'revisionscount': 1, 'trackedsize': len(fulltext)}) | {'revisionscount': 1, 'trackedsize': len(fulltext)}) | ||||
self.assertEqual(f.size(0), len(fulltext)) | self.assertEqual(f.size(0), len(fulltext)) | ||||
with self.assertRaises(IndexError): | with self.assertRaises(IndexError): | ||||
f.size(1) | f.size(1) | ||||
f.checkhash(fulltext, node) | |||||
f.checkhash(fulltext, node, nullid, nullid) | |||||
with self.assertRaises(error.StorageError): | |||||
f.checkhash(fulltext + b'extra', node) | |||||
with self.assertRaises(error.StorageError): | |||||
f.checkhash(fulltext, node, b'\x01' * 20, nullid) | |||||
with self.assertRaises(error.StorageError): | |||||
f.checkhash(fulltext, node, nullid, b'\x01' * 20) | |||||
self.assertEqual(f.revision(node), fulltext) | self.assertEqual(f.revision(node), fulltext) | ||||
self.assertEqual(f.revision(node, raw=True), fulltext) | self.assertEqual(f.revision(node, raw=True), fulltext) | ||||
self.assertEqual(f.read(node), fulltext) | self.assertEqual(f.read(node), fulltext) | ||||
self.assertFalse(f.renamed(node)) | self.assertFalse(f.renamed(node)) | ||||
self.assertFalse(f.cmp(node, fulltext)) | self.assertFalse(f.cmp(node, fulltext)) | ||||
self.assertEqual(f.size(0), len(fulltext0)) | self.assertEqual(f.size(0), len(fulltext0)) | ||||
self.assertEqual(f.size(1), len(fulltext1)) | self.assertEqual(f.size(1), len(fulltext1)) | ||||
self.assertEqual(f.size(2), len(fulltext2)) | self.assertEqual(f.size(2), len(fulltext2)) | ||||
with self.assertRaises(IndexError): | with self.assertRaises(IndexError): | ||||
f.size(3) | f.size(3) | ||||
f.checkhash(fulltext0, node0) | |||||
f.checkhash(fulltext1, node1) | |||||
f.checkhash(fulltext1, node1, node0, nullid) | |||||
f.checkhash(fulltext2, node2, node1, nullid) | |||||
with self.assertRaises(error.StorageError): | |||||
f.checkhash(fulltext1, b'\x01' * 20) | |||||
with self.assertRaises(error.StorageError): | |||||
f.checkhash(fulltext1 + b'extra', node1, node0, nullid) | |||||
with self.assertRaises(error.StorageError): | |||||
f.checkhash(fulltext1, node1, node0, node0) | |||||
self.assertEqual(f.revision(node0), fulltext0) | self.assertEqual(f.revision(node0), fulltext0) | ||||
self.assertEqual(f.revision(node0, raw=True), fulltext0) | self.assertEqual(f.revision(node0, raw=True), fulltext0) | ||||
self.assertEqual(f.revision(node1), fulltext1) | self.assertEqual(f.revision(node1), fulltext1) | ||||
self.assertEqual(f.revision(node1, raw=True), fulltext1) | self.assertEqual(f.revision(node1, raw=True), fulltext1) | ||||
self.assertEqual(f.revision(node2), fulltext2) | self.assertEqual(f.revision(node2), fulltext2) | ||||
self.assertEqual(f.revision(node2, raw=True), fulltext2) | self.assertEqual(f.revision(node2, raw=True), fulltext2) | ||||
with self.assertRaises(error.LookupError): | with self.assertRaises(error.LookupError): |