~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/multiparent.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:
57
57
            yield version_id
58
58
            seen.add(version_id)
59
59
        cur = next
60
 
    assert len(seen) == len(versions)
61
60
 
62
61
 
63
62
class MultiParent(object):
195
194
            elif cur_line[0] == '\n':
196
195
                hunks[-1].lines[-1] += '\n'
197
196
            else:
198
 
                assert cur_line[0] == 'c', cur_line[0]
 
197
                if not (cur_line[0] == 'c'):
 
198
                    raise AssertionError(cur_line[0])
199
199
                parent, parent_pos, child_pos, num_lines =\
200
200
                    [int(v) for v in cur_line.split(' ')[1:]]
201
201
                hunks.append(ParentText(parent, parent_pos, child_pos,
370
370
        :param single_parent: If true, omit all but one parent text, (but
371
371
            retain parent metadata).
372
372
        """
373
 
        assert no_cache or not verify
 
373
        if not (no_cache or not verify):
 
374
            raise ValueError()
374
375
        revisions = set(vf.versions())
375
376
        total = len(revisions)
376
377
        pb = ui.ui_factory.nested_progress_bar()
394
395
                        self.clear_cache()
395
396
                        vf.clear_cache()
396
397
                        if verify:
397
 
                            assert lines == self.get_line_list([revision])[0]
 
398
                            if not (lines == self.get_line_list([revision])[0]):
 
399
                                raise AssertionError()
398
400
                            self.clear_cache()
399
401
                    pb.update('Importing revisions',
400
402
                              (total - len(revisions)) + len(added), total)