~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_dirstate_helpers_py.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:
200
200
    fields = text.split('\0')
201
201
    # Remove the last blank entry
202
202
    trailing = fields.pop()
203
 
    assert trailing == ''
 
203
    if trailing != '':
 
204
        raise AssertionError("dirtstate line %r has trailing garbage: %r" 
 
205
            % (trailing,))
204
206
    # consider turning fields into a tuple.
205
207
 
206
208
    # skip the first field which is the trailing null from the header.
217
219
    expected_field_count = entry_size * state._num_entries
218
220
    field_count = len(fields)
219
221
    # this checks our adjustment, and also catches file too short.
220
 
    assert field_count - cur == expected_field_count, \
221
 
        'field count incorrect %s != %s, entry_size=%s, '\
222
 
        'num_entries=%s fields=%r' % (
 
222
    if field_count - cur != expected_field_count:
 
223
        raise AssertionError(
 
224
            'field count incorrect %s != %s, entry_size=%s, '\
 
225
            'num_entries=%s fields=%r' % (
223
226
            field_count - cur, expected_field_count, entry_size,
224
 
            state._num_entries, fields)
 
227
            state._num_entries, fields))
225
228
 
226
229
    if num_present_parents == 1:
227
230
        # Bind external functions to local names
269
272
                     ),
270
273
                     ])
271
274
            trailing = next()
272
 
            assert trailing == '\n'
 
275
            if trailing != '\n':
 
276
                raise ValueError("trailing garbage in dirstate: %r" % trailing)
273
277
            # append the entry to the current block
274
278
            append_entry(entry)
275
279
        state._split_root_dirblock_into_contents()