/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Martin Pool
  • Date: 2008-04-24 07:22:53 UTC
  • mto: This revision was merged to the branch mainline in revision 3415.
  • Revision ID: mbp@sourcefrog.net-20080424072253-opmjij7xfy38w27f
Remove every assert statement from bzrlib!

Depending on the context they are:

 * turned into an explicit if/raise of either AssertionError 
   or something more specific -- particularly where they protect
   programming interfaces, complex invariants, or data file integrity
 * removed, if they're redundant with a later check, not protecting
   a meaningful invariant
 * turned into a selftest method on tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
312
312
 
313
313
        :param nostore_sha: See VersionedFile.add_lines.
314
314
        """
315
 
        assert isinstance(version_id, basestring)
316
315
        self._check_lines_not_unicode(lines)
317
316
        self._check_lines_are_lines(lines)
318
317
        if not sha1:
393
392
            #print 'raw match', tag, i1, i2, j1, j2
394
393
            if tag == 'equal':
395
394
                continue
396
 
 
397
395
            i1 = basis_lineno[i1]
398
396
            i2 = basis_lineno[i2]
399
 
 
400
 
            assert 0 <= j1 <= j2 <= len(lines)
401
 
 
402
 
            #print tag, i1, i2, j1, j2
403
 
 
404
397
            # the deletion and insertion are handled separately.
405
398
            # first delete the region.
406
399
            if i1 != i2:
507
500
                elif c == '}':
508
501
                    istack.pop()
509
502
                elif c == '[':
510
 
                    assert self._names[v] not in dset
511
503
                    dset.add(self._names[v])
512
504
                elif c == ']':
513
505
                    dset.remove(self._names[v])
514
506
                else:
515
507
                    raise WeaveFormatError('unexpected instruction %r' % v)
516
508
            else:
517
 
                assert l.__class__ in (str, unicode)
518
 
                assert istack
519
509
                yield lineno, istack[-1], frozenset(dset), l
520
510
            lineno += 1
521
511
 
631
621
                c, v = l
632
622
                isactive = None
633
623
                if c == '{':
634
 
                    assert v not in iset
635
624
                    istack.append(v)
636
625
                    iset.add(v)
637
626
                elif c == '}':
638
627
                    iset.remove(istack.pop())
639
628
                elif c == '[':
640
629
                    if v in included:
641
 
                        assert v not in dset
642
630
                        dset.add(v)
643
 
                else:
644
 
                    assert c == ']'
 
631
                elif c == ']':
645
632
                    if v in included:
646
 
                        assert v in dset
647
633
                        dset.remove(v)
 
634
                else:
 
635
                    raise AssertionError()
648
636
            else:
649
 
                assert l.__class__ in (str, unicode)
650
637
                if isactive is None:
651
638
                    isactive = (not dset) and istack and (istack[-1] in included)
652
639
                if isactive:
690
677
    def num_versions(self):
691
678
        """How many versions are in this weave?"""
692
679
        l = len(self._parents)
693
 
        assert l == len(self._sha1s)
694
680
        return l
695
681
 
696
682
    __len__ = num_versions
722
708
            for p in self._parents[i]:
723
709
                new_inc.update(inclusions[self._idx_to_name(p)])
724
710
 
725
 
            assert set(new_inc) == set(self.get_ancestry(name)), \
726
 
                'failed %s != %s' % (set(new_inc), set(self.get_ancestry(name)))
 
711
            if set(new_inc) != set(self.get_ancestry(name)):
 
712
                raise AssertionError(
 
713
                    'failed %s != %s' 
 
714
                    % (set(new_inc), set(self.get_ancestry(name))))
727
715
            inclusions[name] = new_inc
728
716
 
729
717
        nlines = len(self._weave)