~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.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:
440
440
 
441
441
    def version_file(self, file_id, trans_id):
442
442
        """Schedule a file to become versioned."""
443
 
        assert file_id is not None
 
443
        if file_id is None:
 
444
            raise ValueError()
444
445
        unique_add(self._new_id, trans_id, file_id)
445
446
        unique_add(self._r_new_id, file_id, trans_id)
446
447
 
510
511
        applied.
511
512
        """
512
513
        try:
513
 
            # there is a new id for this file
514
 
            assert self._new_id[trans_id] is not None
515
514
            return self._new_id[trans_id]
516
515
        except KeyError:
517
516
            if trans_id in self._removed_id:
1242
1241
                        file_id = self._tree.get_root_id()
1243
1242
                    else:
1244
1243
                        file_id = self.tree_file_id(trans_id)
1245
 
                    assert file_id is not None
1246
1244
                    # File-id isn't really being deleted, just moved
1247
1245
                    if file_id in self._r_new_id:
1248
1246
                        continue
1664
1662
    new_conflicts = set()
1665
1663
    for c_type, conflict in ((c[0], c) for c in conflicts):
1666
1664
        # Anything but a 'duplicate' would indicate programmer error
1667
 
        assert c_type == 'duplicate', c_type
 
1665
        if c_type != 'duplicate':
 
1666
            raise AssertionError(c_type)
1668
1667
        # Now figure out which is new and which is old
1669
1668
        if tt.new_contents(conflict[1]):
1670
1669
            new_file = conflict[1]
1942
1941
                    # preserve the execute bit when backing up
1943
1942
                    if keep_content and executable[0] == executable[1]:
1944
1943
                        tt.set_executability(executable[1], trans_id)
1945
 
                else:
1946
 
                    assert kind[1] is None
 
1944
                elif kind[1] != None:
 
1945
                    raise AssertionError(kind[1])
1947
1946
            if versioned == (False, True):
1948
1947
                tt.version_file(file_id, trans_id)
1949
1948
            if versioned == (True, False):