Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master-1, master-0, and 0.9.4

Add some tests for deltification.

Changeset 63d8732b59ac

Parent 0d8a2187d53d

by Jelmer Vernooij

Changes to 2 files · Browse files at 63d8732b59ac Showing diff from parent 0d8a2187d53d Diff from another changeset...

Change 1 of 1 Show Entire File dulwich/​pack.py Stacked
 
1167
1168
1169
 
 
1170
1171
1172
 
1167
1168
1169
1170
1171
1172
1173
1174
@@ -1167,6 +1167,8 @@
    :param objects: Objects to deltify   :param window: Window size + :return: Iterator over type_num, object id, delta_base, content + delta_base is None for full text entries   """   # Build a list of objects ordered by the magic Linus heuristic   # This helps us find good objects to diff against us
 
33
34
35
 
36
37
38
 
44
45
46
 
47
48
49
 
536
537
538
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
34
35
36
37
38
39
 
45
46
47
48
49
50
51
 
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
@@ -33,6 +33,7 @@
  GitFile,   )  from dulwich.objects import ( + Blob,   hex_to_sha,   sha_to_hex,   Tree, @@ -44,6 +45,7 @@
  ThinPackData,   apply_delta,   create_delta, + deltify_pack_objects,   load_pack_index,   read_zlib_chunks,   write_pack_header, @@ -536,3 +538,25 @@
    def test_decompress_buffer_size_4(self):   self._do_decompress_test(4) + + +class DeltifyTests(TestCase): + + def test_empty(self): + self.assertEquals([], list(deltify_pack_objects([]))) + + def test_single(self): + b = Blob.from_string("foo") + self.assertEquals( + [(b.type_num, b.sha().digest(), None, b.as_raw_string())], + list(deltify_pack_objects([(b, "")]))) + + def test_simple_delta(self): + b1 = Blob.from_string("a" * 101) + b2 = Blob.from_string("a" * 100) + delta = create_delta(b1.as_raw_string(), b2.as_raw_string()) + self.assertEquals([ + (b1.type_num, b1.sha().digest(), None, b1.as_raw_string()), + (b2.type_num, b2.sha().digest(), b1.sha().digest(), delta) + ], + list(deltify_pack_objects([(b1, ""), (b2, "")])))