77
77
compressor = groupcompress.GroupCompressor(True)
78
78
sha1_1, _ = compressor.compress(('label',),
79
79
['strange\n', 'common\n'], None)
80
expected_lines = list(compressor.lines)
80
81
sha1_2, end_point = compressor.compress(('newlabel',),
81
82
['common\n', 'different\n'], None)
82
83
self.assertEqual(sha_strings(['common\n', 'different\n']), sha1_2)
85
'sha1: %s\n' % sha1_1,
84
expected_lines.extend([
90
85
'label: newlabel\n',
91
86
'sha1: %s\n' % sha1_2,
92
# Delete what we don't want. Perhaps we want an implicit
93
# delete all to keep from bloating with useless delete
87
# copy the line common
89
# add the line different
92
# copy the line \n. Note that when we filter on encoding-overhead
93
# this will become a fresh insert instead
100
96
self.assertEqual(expected_lines, compressor.lines)
101
97
self.assertEqual(sum(map(len, expected_lines)), end_point)
108
104
['strange\n', 'common\n'], None)
109
105
sha1_2, _ = compressor.compress(('newlabel',),
110
106
['common\n', 'different\n', 'moredifferent\n'], None)
107
expected_lines = list(compressor.lines)
111
108
sha1_3, end_point = compressor.compress(('label3',),
112
109
['new\n', 'common\n', 'different\n', 'moredifferent\n'], None)
113
110
self.assertEqual(
114
111
sha_strings(['new\n', 'common\n', 'different\n', 'moredifferent\n']),
118
'sha1: %s\n' % sha1_1,
124
'sha1: %s\n' % sha1_2,
125
# Delete what we don't want. Perhaps we want an implicit
126
# delete all to keep from bloating with useless delete
113
expected_lines.extend([
133
114
'label: label3\n',
134
115
'sha1: %s\n' % sha1_3,
135
# Delete what we don't want. Perhaps we want an implicit
136
# delete all to keep from bloating with useless delete
138
# replace 'strange' with 'new'
141
# delete from after common up to differnet
119
# copy the line common
121
# copy the lines different, moredifferent
123
# copy the line \n. Note that when we filter on encoding-overhead
124
# this will become a fresh insert instead
147
127
self.assertEqualDiff(''.join(expected_lines), ''.join(compressor.lines))
148
128
self.assertEqual(sum(map(len, expected_lines)), end_point)