##// END OF EJS Templates
Merge with stable...
Merge with stable Simplify the copy search algorithm

File last commit:

r6840:80e51429 default
r6876:077f1e63 merge default
Show More
streamclone.py
51 lines | 1.8 KiB | text/x-python | PythonLexer
Vadim Gelfer
add support for streaming clone....
r2612 # streamclone.py - streaming clone server support for mercurial
#
# Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
Adrian Buehlmann
introduce store classes...
r6840 import util, lock
Vadim Gelfer
add support for streaming clone....
r2612
# if server supports streaming clone, it advertises "stream"
# capability with value that is version+flags of repo it is serving.
# client only streams if it can read that repo format.
# stream file format is simple.
#
# server writes out line that says how many files, how many total
# bytes. separator is ascii space, byte counts are strings.
#
# then for each file:
#
# server writes out line that says file name, how many bytes in
# file. separator is ascii nul, byte count is string.
#
# server writes out raw file data.
Dirkjan Ochtman
Backed out changeset b9d6ab187523 (doesn't work on Python 2.3/2.4)
r6794 def stream_out(repo, fileobj, untrusted=False):
Vadim Gelfer
add support for streaming clone....
r2612 '''stream out all metadata files in repository.
writes to file-like object, must support write() and optional flush().'''
Vadim Gelfer
clone: disable stream support on server side by default....
r2621
Edouard Gomez
Fix inconsistency for the stream_out capability in hgweb...
r4834 if not repo.ui.configbool('server', 'uncompressed', untrusted=untrusted):
Dirkjan Ochtman
Backed out changeset b9d6ab187523 (doesn't work on Python 2.3/2.4)
r6794 fileobj.write('1\n')
Vadim Gelfer
clone: disable stream support on server side by default....
r2621 return
Thomas Arendsen Hein
Handle locking exceptions if streaming clone can't lock the repo. (Issue324)
r3687 try:
Adrian Buehlmann
introduce store classes...
r6840 entries, total_bytes = repo.storefiles()
except (lock.LockHeld, lock.LockUnavailable), inst:
repo.ui.warn('locking the repository failed: %s\n' % (inst,))
fileobj.write('2\n')
return
Thomas Arendsen Hein
Handle locking exceptions if streaming clone can't lock the repo. (Issue324)
r3687
Adrian Buehlmann
introduce store classes...
r6840 fileobj.write('0\n')
Vadim Gelfer
add support for streaming clone....
r2612 repo.ui.debug('%d files, %d bytes to transfer\n' %
(len(entries), total_bytes))
Dirkjan Ochtman
Backed out changeset b9d6ab187523 (doesn't work on Python 2.3/2.4)
r6794 fileobj.write('%d %d\n' % (len(entries), total_bytes))
Vadim Gelfer
add support for streaming clone....
r2612 for name, size in entries:
repo.ui.debug('sending %s (%d bytes)\n' % (name, size))
Dirkjan Ochtman
Backed out changeset b9d6ab187523 (doesn't work on Python 2.3/2.4)
r6794 fileobj.write('%s\0%d\n' % (name, size))
Benoit Boissinot
introduce localrepo.spath for the store path, sopener fixes
r3791 for chunk in util.filechunkiter(repo.sopener(name), limit=size):
Dirkjan Ochtman
Backed out changeset b9d6ab187523 (doesn't work on Python 2.3/2.4)
r6794 fileobj.write(chunk)
flush = getattr(fileobj, 'flush', None)
if flush: flush()