~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to weave.py

  • Committer: Martin Pool
  • Date: 2005-06-30 09:43:08 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mbp@sourcefrog.net-20050630094308-eef09d8efbc4737f
Refactor Weave._delta to calculate less unused information

Show diffs side-by-side

added added

removed removed

Lines of Context:
427
427
        ##pprint(self._l)
428
428
 
429
429
        # basis a list of (origin, lineno, line)
430
 
        basis = []
 
430
        basis_lineno = []
431
431
        basis_lines = []
432
 
        for t in self._extract(included):
433
 
            basis.append(t)
434
 
            basis_lines.append(t[2])
 
432
        for origin, lineno, line in self._extract(included):
 
433
            basis_lineno.append(lineno)
 
434
            basis_lines.append(line)
435
435
 
436
436
        # add a sentinal, because we can also match against the final line
437
 
        basis.append((None, len(self._l), None))
 
437
        basis_lineno.append(len(self._l))
438
438
 
439
439
        # XXX: which line of the weave should we really consider
440
440
        # matches the end of the file?  the current code says it's the
443
443
        from difflib import SequenceMatcher
444
444
        s = SequenceMatcher(None, basis_lines, lines)
445
445
 
446
 
        ##print 'basis sequence:'
447
 
        ##pprint(basis)
448
 
 
449
446
        # TODO: Perhaps return line numbers from composed weave as well?
450
447
 
451
448
        for tag, i1, i2, j1, j2 in s.get_opcodes():
456
453
 
457
454
            # i1,i2 are given in offsets within basis_lines; we need to map them
458
455
            # back to offsets within the entire weave
459
 
            real_i1 = basis[i1][1]
460
 
            real_i2 = basis[i2][1]
 
456
            real_i1 = basis_lineno[i1]
 
457
            real_i2 = basis_lineno[i2]
461
458
 
462
459
            assert 0 <= j1
463
460
            assert j1 <= j2