~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mutabletree.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:
96
96
        TODO: Perhaps callback with the ids and paths as they're added.
97
97
        """
98
98
        if isinstance(files, basestring):
99
 
            assert(ids is None or isinstance(ids, basestring))
100
 
            assert(kinds is None or isinstance(kinds, basestring))
 
99
            # XXX: Passing a single string is inconsistent and should be
 
100
            # deprecated.
 
101
            if not (ids is None or isinstance(ids, basestring)):
 
102
                raise AssertionError()
 
103
            if not (kinds is None or isinstance(kinds, basestring)):
 
104
                raise AssertionError()
101
105
            files = [files]
102
106
            if ids is not None:
103
107
                ids = [ids]
109
113
        if ids is None:
110
114
            ids = [None] * len(files)
111
115
        else:
112
 
            assert(len(ids) == len(files))
 
116
            if not (len(ids) == len(files)):
 
117
                raise AssertionError()
113
118
        if kinds is None:
114
119
            kinds = [None] * len(files)
115
 
        else:
116
 
            assert(len(kinds) == len(files))
 
120
        elif not len(kinds) == len(files):
 
121
            raise AssertionError()
117
122
        for f in files:
118
123
            # generic constraint checks:
119
124
            if self.is_control_filename(f):
180
185
            revprops['branch-nick'] = self.branch.nick
181
186
        author = kwargs.pop('author', None)
182
187
        if author is not None:
183
 
            assert 'author' not in revprops
 
188
            if 'author' in revprops:
 
189
                # XXX: maybe we should just accept one of them?
 
190
                raise AssertionError('author property given twice')
184
191
            revprops['author'] = author
185
192
        # args for wt.commit start at message from the Commit.commit method,
186
193
        args = (message, ) + args
276
283
        # not in an inner loop; and we want to remove direct use of this,
277
284
        # so here as a reminder for now. RBC 20070703
278
285
        from bzrlib.inventory import InventoryEntry
279
 
        assert isinstance(recurse, bool)
280
286
        if action is None:
281
287
            action = add.AddAction()
282
288