~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to weave.py

  • Committer: Martin Pool
  • Date: 2005-06-28 13:31:41 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mbp@sourcefrog.net-20050628133141-94b29d13e780312d
Fix weave line calculation when making deltas

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
                    raise NotImplementedError("can't handle replacing weave [%d:%d] yet"
155
155
                                              % (i1, i2))
156
156
 
157
 
                self._l.insert(i1 + offset, ('{', idx))
158
 
                i = i1 + offset + 1
159
 
                self._l[i:i] = newlines
160
 
                self._l.insert(i + 1, ('}', idx))
 
157
                i = i1 + offset
 
158
                self._l[i:i] = [('{', idx)] \
 
159
                               + newlines \
 
160
                               + [('}', idx)]
161
161
                offset += 2 + len(newlines)
162
162
 
163
163
            self._v.append(VerInfo(parents))
350
350
        ##print 'my lines:'
351
351
        ##pprint(self._l)
352
352
 
 
353
        # basis a list of (origin, lineno, line)
353
354
        basis = list(self._extract(included))
354
355
 
355
356
        # now make a parallel list with only the text, to pass to the differ
356
357
        basis_lines = [line for (origin, lineno, line) in basis]
357
358
 
358
359
        # add a sentinal, because we can also match against the final line
359
 
        basis.append((len(self._l), None))
 
360
        basis.append((None, len(self._l), None))
360
361
 
361
362
        # XXX: which line of the weave should we really consider matches the end of the file?
362
363
        # the current code says it's the last line of the weave?
375
376
 
376
377
            # i1,i2 are given in offsets within basis_lines; we need to map them
377
378
            # back to offsets within the entire weave
378
 
            real_i1 = basis[i1][0]
379
 
            real_i2 = basis[i2][0]
 
379
            real_i1 = basis[i1][1]
 
380
            real_i2 = basis[i2][1]
380
381
 
381
382
            assert 0 <= j1
382
383
            assert j1 <= j2