~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge3.py

  • Committer: Martin Pool
  • Date: 2008-05-08 04:16:03 UTC
  • mto: This revision was merged to the branch mainline in revision 3415.
  • Revision ID: mbp@sourcefrog.net-20080508041603-bspsqou83t7p4l10
Restore some assertions as comments

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    >>> intersect((0, 9), (7, 15))
37
37
    (7, 9)
38
38
    """
 
39
    # preconditions: (ra[0] <= ra[1]) and (rb[0] <= rb[1])
 
40
    
39
41
    sa = max(ra[0], rb[0])
40
42
    sb = min(ra[1], rb[1])
41
43
    if sa < sb:
220
222
        
221
223
        for zmatch, zend, amatch, aend, bmatch, bend in self.find_sync_regions():
222
224
            matchlen = zend - zmatch
 
225
            # invariants:
 
226
            #   matchlen >= 0
 
227
            #   matchlen == (aend - amatch)
 
228
            #   matchlen == (bend - bmatch)
223
229
            len_a = amatch - ia
224
230
            len_b = bmatch - ib
225
231
            len_base = zmatch - iz
 
232
            # invariants:
 
233
            # assert len_a >= 0
 
234
            # assert len_b >= 0
 
235
            # assert len_base >= 0
 
236
 
226
237
            #print 'unmatched a=%d, b=%d' % (len_a, len_b)
227
238
 
228
239
            if len_a or len_b:
260
271
            # that's OK, we can just skip it.
261
272
 
262
273
            if matchlen > 0:
 
274
                # invariants:
 
275
                # assert ia == amatch
 
276
                # assert ib == bmatch
 
277
                # assert iz == zmatch
 
278
                
263
279
                yield 'unchanged', zmatch, zend
264
280
                iz = zend
265
281
                ia = aend
369
385
                intbase = i[0]
370
386
                intend = i[1]
371
387
                intlen = intend - intbase
 
388
 
 
389
                # found a match of base[i[0], i[1]]; this may be less than
 
390
                # the region that matches in either one
 
391
                # assert intlen <= alen
 
392
                # assert intlen <= blen
 
393
                # assert abase <= intbase
 
394
                # assert bbase <= intbase
 
395
 
372
396
                asub = amatch + (intbase - abase)
373
397
                bsub = bmatch + (intbase - bbase)
374
398
                aend = asub + intlen
375
399
                bend = bsub + intlen
 
400
 
 
401
                # assert self.base[intbase:intend] == self.a[asub:aend], \
 
402
                #       (self.base[intbase:intend], self.a[asub:aend])
 
403
                # assert self.base[intbase:intend] == self.b[bsub:bend]
 
404
 
376
405
                sl.append((intbase, intend,
377
406
                           asub, aend,
378
407
                           bsub, bend))