~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/patches.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:
220
220
            return self.shift_to_mod_lines(pos)
221
221
 
222
222
    def shift_to_mod_lines(self, pos):
223
 
        assert (pos >= self.orig_pos-1 and pos <= self.orig_pos+self.orig_range)
224
223
        position = self.orig_pos-1
225
224
        shift = 0
226
225
        for line in self.lines:
355
354
    last_line = None
356
355
    for line in iter_lines:
357
356
        if line == NO_NL:
358
 
            assert last_line.endswith('\n')
 
357
            if not last_line.endswith('\n'):
 
358
                raise AssertionError()
359
359
            last_line = last_line[:-1]
360
360
            line = None
361
361
        if last_line is not None:
415
415
                if isinstance(hunk_line, ContextLine):
416
416
                    yield orig_line
417
417
                else:
418
 
                    assert isinstance(hunk_line, RemoveLine)
 
418
                    if not isinstance(hunk_line, RemoveLine):
 
419
                        raise AssertionError(hunk_line)
419
420
                line_no += 1
420
421
    if orig_lines is not None:
421
422
        for line in orig_lines: