272
272
# TODO: Could split this into two functions, one that updates
273
273
# the stack and the other that processes the results -- but
274
274
# I'm not sure it's really needed.
276
WFE = WeaveFormatError
276
278
for l in self._l:
277
279
if isinstance(l, tuple):
280
282
if istack and (istack[-1] >= v):
281
raise WeaveFormatError("improperly nested insertions %d>=%d on line %d"
282
% (istack[-1], v, lineno))
283
raise WFE("improperly nested insertions %d>=%d on line %d"
284
% (istack[-1], v, lineno))
286
288
oldv = istack.pop()
287
289
except IndexError:
288
raise WeaveFormatError("unmatched close of insertion %d on line %d"
290
raise WFE("unmatched close of insertion %d on line %d"
291
raise WeaveFormatError("mismatched close of insertion %d!=%d on line %d"
293
raise WFE("mismatched close of insertion %d!=%d on line %d"
294
296
# block deleted in v
296
raise WeaveFormatError("repeated deletion marker for version %d on line %d"
298
raise WFE("repeated deletion marker for version %d on line %d"
299
301
if istack[-1] == v:
300
raise WeaveFormatError("version %d deletes own text on line %d"
302
raise WFE("version %d deletes own text on line %d"
307
raise WeaveFormatError("unmatched close of deletion %d on line %d"
309
raise WFE("unmatched close of deletion %d on line %d"
310
raise WeaveFormatError("invalid processing instruction %r on line %d"
312
raise WFE("invalid processing instruction %r on line %d"
313
315
assert isinstance(l, basestring)
315
raise WeaveFormatError("literal at top level on line %d"
317
raise WFE("literal at top level on line %d"
317
319
isactive = (istack[-1] in included) \
318
320
and not included.intersection(dset)
325
raise WeaveFormatError("unclosed insertion blocks at end of weave",
327
raise WFE("unclosed insertion blocks at end of weave",
328
raise WeaveFormatError("unclosed deletion blocks at end of weave",
330
raise WFE("unclosed deletion blocks at end of weave",
401
403
# add a sentinal, because we can also match against the final line
402
404
basis.append((None, len(self._l), None))
404
# XXX: which line of the weave should we really consider matches the end of the file?
405
# the current code says it's the last line of the weave?
406
# XXX: which line of the weave should we really consider
407
# matches the end of the file? the current code says it's the
408
# last line of the weave?
407
410
from difflib import SequenceMatcher
408
411
s = SequenceMatcher(None, basis_lines, lines)