~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/util/bencode.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-17 07:05:37 UTC
  • mfrom: (4152.1.2 branch.stacked.streams)
  • Revision ID: pqm@pqm.ubuntu.com-20090317070537-zaud24vjs2szna87
(robertc) Add client-side streaming from stacked branches (over
        bzr:// protocols) when the sort order is compatible with doing
        that. (Robert Collins, 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
91
89
        try:
92
90
            r, l = self.decode_func[x[0]](x, 0)
93
 
        except (IndexError, KeyError, OverflowError), e:
94
 
            import sys
95
 
            raise ValueError, ValueError(str(e)), sys.exc_info()[2]
 
91
        except (IndexError, KeyError):
 
92
            raise ValueError
96
93
        if l != len(x):
97
94
            raise ValueError
98
95
        return r
155
152
        encode_int(int(x), r)
156
153
    encode_func[BooleanType] = encode_bool
157
154
 
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
 
 
167
155
 
168
156
def bencode(x):
169
157
    r = []