cdatapack: fix empty revision reading

Summary:
The newly changed `LZ4_decompress_safe` is unhappy about empty buffer. So let's
check empty revision explicitly.

Test Plan: Added a test

Reviewers: #mercurial, ikostia

Reviewed By: ikostia

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4986277

Signature: t1:4986277:1493743735:be2ad6047bb0b983425c6e49b7c5ddf2c94d1c1a
This commit is contained in:
Jun Wu 2017-05-02 10:01:13 -07:00
parent 004e19698b
commit 488cf5ea26
3 changed files with 9 additions and 11 deletions

View File

@ -488,8 +488,8 @@ const get_delta_chain_link_result_t getdeltachainlink(
}
bool uncompressdeltachainlink(delta_chain_link_t *link) {
if (link->delta != NULL) {
// previously decompressed
if (link->delta != NULL || link->delta_sz == 0) {
// previously decompressed or no content to decompress
return true;
}

View File

@ -71,11 +71,10 @@ class datapacktestsbase(object):
path = packer.close()
return self.datapackreader(path)
def testAddSingle(self):
def _testAddSingle(self, content):
"""Test putting a simple blob into a pack and reading it out.
"""
filename = "foo"
content = "abcdef"
node = self.getHash(content)
revisions = [(filename, node, nullid, content)]
@ -86,6 +85,12 @@ class datapacktestsbase(object):
chain = pack.getdeltachain(filename, node)
self.assertEquals(content, chain[0][4])
def testAddSingle(self):
self._testAddSingle('')
def testAddSingleEmpty(self):
self._testAddSingle('abcdef')
def testAddMultiple(self):
"""Test putting multiple unrelated blobs into a pack and reading them
out.

View File

@ -1,7 +0,0 @@
Remotefilelog appears to have issues with specific (historical?) datapack
files, see https://phabricator.intern.facebook.com/P57361795.
This test is here only to ensure we don't push out a build with this bug.
$ echo FAIL
Please fix remotefilelog file parsing, see t17796162