85
84
for prefix, factory_list in transport_list_registry.items():
86
85
for factory in factory_list:
87
if hasattr(factory, "_module_name"):
88
modules.add(factory._module_name)
90
modules.add(factory._obj.__module__)
86
modules.add(factory.get_module())
91
87
# Add chroot and pathfilter directly, because there is no handler
92
88
# registered for it.
93
89
modules.add('bzrlib.transport.chroot')
677
673
This uses _coalesce_offsets to issue larger reads and fewer seeks.
679
:param fp: A file-like object that supports seek() and read(size)
675
:param fp: A file-like object that supports seek() and read(size).
676
Note that implementations are allowed to call .close() on this file
677
handle, so don't trust that you can use it for other work.
680
678
:param offsets: A list of offsets to be read from the given file.
681
679
:return: yield (pos, data) tuples for each request
694
692
# Cache the results, but only until they have been fulfilled
696
for c_offset in coalesced:
697
# TODO: jam 20060724 it might be faster to not issue seek if
698
# we are already at the right location. This should be
700
fp.seek(c_offset.start)
701
data = fp.read(c_offset.length)
702
if len(data) < c_offset.length:
703
raise errors.ShortReadvError(relpath, c_offset.start,
704
c_offset.length, actual=len(data))
705
for suboffset, subsize in c_offset.ranges:
706
key = (c_offset.start+suboffset, subsize)
707
data_map[key] = data[suboffset:suboffset+subsize]
695
for c_offset in coalesced:
696
# TODO: jam 20060724 it might be faster to not issue seek if
697
# we are already at the right location. This should be
699
fp.seek(c_offset.start)
700
data = fp.read(c_offset.length)
701
if len(data) < c_offset.length:
702
raise errors.ShortReadvError(relpath, c_offset.start,
703
c_offset.length, actual=len(data))
704
for suboffset, subsize in c_offset.ranges:
705
key = (c_offset.start+suboffset, subsize)
706
data_map[key] = data[suboffset:suboffset+subsize]
709
# Now that we've read some data, see if we can yield anything back
710
while cur_offset_and_size in data_map:
711
this_data = data_map.pop(cur_offset_and_size)
712
this_offset = cur_offset_and_size[0]
714
cur_offset_and_size = offset_stack.next()
715
except StopIteration:
716
# Close the file handle as there will be no more data
717
# The handle would normally be cleaned up as this code goes
718
# out of scope, but as we are a generator, not all code
719
# will re-enter once we have consumed all the expected
721
# zip(range(len(requests)), readv(foo, requests))
722
# Will stop because the range is done, and not run the
723
# cleanup code for the readv().
725
cur_offset_and_size = None
726
yield this_offset, this_data
708
# Now that we've read some data, see if we can yield anything back
709
while cur_offset_and_size in data_map:
710
this_data = data_map.pop(cur_offset_and_size)
711
this_offset = cur_offset_and_size[0]
713
cur_offset_and_size = offset_stack.next()
714
except StopIteration:
715
cur_offset_and_size = None
716
yield this_offset, this_data
728
722
def _sort_expand_and_combine(self, offsets, upper_limit):
729
723
"""Helper for readv.
1813
1804
register_lazy_transport('nosmart+', 'bzrlib.transport.nosmart',
1814
1805
'NoSmartTransportDecorator')
1816
# These two schemes were registered, but don't seem to have an actual transport
1817
# protocol registered
1818
for scheme in ['ssh', 'bzr+loopback']:
1819
register_urlparse_netloc_protocol(scheme)
1822
1807
register_transport_proto('bzr://',
1823
1808
help="Fast access using the Bazaar smart server.",
1824
1809
register_netloc=True)