~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to knit.py

  • Committer: Martin Pool
  • Date: 2005-06-27 08:27:15 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mbp@sourcefrog.net-20050627082715-900eed098cccef9e
Fix insertion of multiple regions, calculating the right line offset as we go.

Add test for this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
            parents = frozenset(parents)
78
78
            delta = self._delta(parents, text)
79
79
 
 
80
            # offset gives the number of lines that have been inserted
 
81
            # into the weave up to the current point; if the original edit instruction
 
82
            # says to change line A then we actually change (A+offset)
 
83
            offset = 0
 
84
 
80
85
            for i1, i2, newlines in delta:
81
86
                assert 0 <= i1
82
87
                assert i1 <= i2
92
97
                for line in newlines:
93
98
                    to_insert.append((idx, line))
94
99
                
95
 
                self._l[i1:i1] = to_insert
 
100
                self._l[(i1+offset):(i1+offset)] = to_insert
 
101
 
 
102
                offset += len(newlines)
96
103
 
97
104
            self._v.append(VerInfo(parents))
98
105
        else: