|
@@ -119,3 +119,32 @@ class TestPack(PackTests):
|
|
|
# (new_blob_2), so let's verify that actually happens:
|
|
|
self.assertIn('chain length = 2', output)
|
|
|
|
|
|
+ # This test is SUPER slow: over 80 seconds on a 2012-era
|
|
|
+ # laptop. This is because SequenceMatcher is worst-case quadratic
|
|
|
+ # on the input size. It's impractical to produce deltas for
|
|
|
+ # objects this large, but it's still worth doing the right thing
|
|
|
+ # when it happens.
|
|
|
+ def test_delta_large_object(self):
|
|
|
+ # This tests an object set that will have a copy operation
|
|
|
+ # 2**25 in size. This is a copy large enough that it requires
|
|
|
+ # two copy operations in git's binary delta format.
|
|
|
+ orig_pack = self.get_pack(pack1_sha)
|
|
|
+ orig_blob = orig_pack[a_sha]
|
|
|
+ new_blob = Blob()
|
|
|
+ new_blob.data = 'big blob' + ('x' * 2 ** 25)
|
|
|
+ new_blob_2 = Blob()
|
|
|
+ new_blob_2.data = new_blob.data + 'y'
|
|
|
+ all_to_pack = list(orig_pack.pack_tuples()) + [(new_blob, None),
|
|
|
+ (new_blob_2, None)]
|
|
|
+ pack_path = os.path.join(self._tempdir, "pack_with_deltas")
|
|
|
+ write_pack(pack_path, all_to_pack, deltify=True)
|
|
|
+ output = run_git_or_fail(['verify-pack', '-v', pack_path])
|
|
|
+ self.assertEqual(set(x[0].id for x in all_to_pack),
|
|
|
+ _git_verify_pack_object_list(output))
|
|
|
+ # We specifically made a new blob that should be a delta
|
|
|
+ # against the blob a_sha, so make sure we really got only 4
|
|
|
+ # non-delta objects:
|
|
|
+ got_non_delta = int(_NON_DELTA_RE.search(output).group('non_delta'))
|
|
|
+ self.assertEqual(
|
|
|
+ 4, got_non_delta,
|
|
|
+ 'Expected 4 non-delta objects, got %d' % got_non_delta)
|