~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__groupcompress.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-06-05 04:50:30 UTC
  • mfrom: (4398.6.3 1.16-no-first-delta-index)
  • Revision ID: pqm@pqm.ubuntu.com-20090605045030-yj7sm39ao623zoqo
(jam) Delay generating a delta index until we call make_delta()
        [saves a lot of memory during commit of large files.]

Show diffs side-by-side

added added

removed removed

Lines of Context:
272
272
        di = self._gc_module.DeltaIndex('test text\n')
273
273
        self.assertEqual('DeltaIndex(1, 10)', repr(di))
274
274
 
 
275
    def test_first_add_source_doesnt_index_until_make_delta(self):
 
276
        di = self._gc_module.DeltaIndex()
 
277
        self.assertFalse(di._has_index())
 
278
        di.add_source(_text1, 0)
 
279
        self.assertFalse(di._has_index())
 
280
        # However, asking to make a delta will trigger the index to be
 
281
        # generated, and will generate a proper delta
 
282
        delta = di.make_delta(_text2)
 
283
        self.assertTrue(di._has_index())
 
284
        self.assertEqual('N\x90/\x1fdiffer from\nagainst other text\n', delta)
 
285
 
 
286
    def test_second_add_source_triggers_make_index(self):
 
287
        di = self._gc_module.DeltaIndex()
 
288
        self.assertFalse(di._has_index())
 
289
        di.add_source(_text1, 0)
 
290
        self.assertFalse(di._has_index())
 
291
        di.add_source(_text2, 0)
 
292
        self.assertTrue(di._has_index())
 
293
 
275
294
    def test_make_delta(self):
276
295
        di = self._gc_module.DeltaIndex(_text1)
277
296
        delta = di.make_delta(_text2)