~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to groupcompress.py

  • Committer: John Arbash Meinel
  • Date: 2009-02-27 20:40:02 UTC
  • mto: (0.23.23 groupcompress_rabin)
  • mto: This revision was merged to the branch mainline in revision 4280.
  • Revision ID: john@arbash-meinel.com-20090227204002-fdzk52zc3frd4ddi
Insert a fulltext if the delta is more than half the total size.
Also, gcr deltas are more pithy, they probably are approx the same after
compression, but decrease the range limits since the copy instructions are
effectively pre-compressed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
        input_len = len(target_text)
143
143
        new_chunks = ['label: %s\nsha1: %s\n' % (label, sha1)]
144
144
        source_text = ''.join(self.lines)
 
145
        # XXX: We have a few possibilities here. We could consider a few
 
146
        #      different 'previous' windows, such as only the initial text, we
 
147
        #      could do something with the 'just inserted' text
 
148
        #      we could try a delta against whatever the last delta we
 
149
        #      computed, (the idea being we just computed the delta_index, so
 
150
        #      we re-use it here, and see if that is good enough, etc)
145
151
        delta = _groupcompress_c.make_delta(source_text, target_text)
146
 
        if delta is None:
 
152
        if (delta is None
 
153
            or len(delta) > len(target_text) / 2):
147
154
            # We can't delta (perhaps source_text is empty)
148
155
            # so mark this as an insert
149
156
            new_chunks.insert(0, 'fulltext\n')
558
565
                prefix = record.key[0]
559
566
                if (last_prefix is not None and prefix != last_prefix):
560
567
                    soft = True
561
 
                    if basis_end > 1024 * 1024 * 4:
 
568
                    if basis_end > 1024 * 1024 * 2:
562
569
                        flush()
563
570
                        self._compressor = GroupCompressor(self._delta)
564
571
                        self._unadded_refs = {}
577
584
            keys_to_add.append((key, '%d %d' % (basis_end, end_point),
578
585
                (record.parents,)))
579
586
            basis_end = end_point
580
 
            if basis_end > 1024 * 1024 * 8:
 
587
            if basis_end > 1024 * 1024 * 4:
581
588
                flush()
582
589
                self._compressor = GroupCompressor(self._delta)
583
590
                self._unadded_refs = {}