~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/util/_bencode_py.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
        return (r, f + 1)
87
87
 
88
88
    def bdecode(self, x):
 
89
        if type(x) != str:
 
90
            raise TypeError
89
91
        try:
90
92
            r, l = self.decode_func[x[0]](x, 0)
91
 
        except (IndexError, KeyError):
92
 
            raise ValueError
 
93
        except (IndexError, KeyError, OverflowError), e:
 
94
            import sys
 
95
            raise ValueError, ValueError(str(e)), sys.exc_info()[2]
93
96
        if l != len(x):
94
97
            raise ValueError
95
98
        return r
152
155
        encode_int(int(x), r)
153
156
    encode_func[BooleanType] = encode_bool
154
157
 
 
158
from bzrlib._static_tuple_py import StaticTuple
 
159
encode_func[StaticTuple] = encode_list
 
160
try:
 
161
    from bzrlib._static_tuple_c import StaticTuple
 
162
except ImportError:
 
163
    pass
 
164
else:
 
165
    encode_func[StaticTuple] = encode_list
 
166
 
155
167
 
156
168
def bencode(x):
157
169
    r = []