##// END OF EJS Templates
hgweb: escape REMOTE_HOST when passing url for addchangegroup...
hgweb: escape REMOTE_HOST when passing url for addchangegroup If DNS lookups are turned off on the web server, REMOTE_HOST may be populated with REMOTE_ADDR, which, if the remote is an IPv6 hosts will contain colons, thus interfering with the separator character. This is solved by URL quoting the REMOTE_HOST string.

File last commit:

r8761:0289f384 default
r8845:296767ac default
Show More
streamclone.py
67 lines | 2.2 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>
#
Martin Geisler
updated license to be explicit about GPL version 2
r8225 # This software may be used and distributed according to the terms of the
# GNU General Public License version 2, incorporated herein by reference.
Vadim Gelfer
add support for streaming clone....
r2612
Matt Mackall
error: move lock errors...
r7640 import util, error
Martin Geisler
i18n: mark strings for translation in Mercurial
r6953 from i18n import _
Vadim Gelfer
add support for streaming clone....
r2612
Benoit Boissinot
filelog encoding: move the encoding/decoding into store...
r8531 from mercurial import store
Dirkjan Ochtman
make streamclone.stream_out() a generator
r6925 class StreamException(Exception):
def __init__(self, code):
Exception.__init__(self)
self.code = code
def __str__(self):
return '%i\n' % self.code
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:
#
timeless
Generally replace "file name" with "filename" in help and comments.
r8761 # server writes out line that says filename, how many bytes in
Vadim Gelfer
add support for streaming clone....
r2612 # file. separator is ascii nul, byte count is string.
#
# server writes out raw file data.
Dirkjan Ochtman
make streamclone.stream_out() a generator
r6925 def stream_out(repo, 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
make streamclone.stream_out() a generator
r6925 raise StreamException(1)
Vadim Gelfer
clone: disable stream support on server side by default....
r2621
Matt Mackall
streamclone: fold in localrepo.storefiles
r6901 entries = []
total_bytes = 0
Thomas Arendsen Hein
Handle locking exceptions if streaming clone can't lock the repo. (Issue324)
r3687 try:
Ronny Pfannschmidt
switch lock releasing in the core from gc to explicit
r8109 # get consistent snapshot of repo, lock during scan
lock = repo.lock()
Matt Mackall
streamclone: fold in localrepo.storefiles
r6901 try:
Martin Geisler
i18n: mark strings for translation in Mercurial
r6953 repo.ui.debug(_('scanning\n'))
Matt Mackall
streamclone: fold in localrepo.storefiles
r6901 for name, ename, size in repo.store.walk():
Benoit Boissinot
filelog encoding: move the encoding/decoding into store...
r8531 # for backwards compat, name was partially encoded
entries.append((store.encodedir(name), size))
Matt Mackall
streamclone: fold in localrepo.storefiles
r6901 total_bytes += size
finally:
Ronny Pfannschmidt
switch lock releasing in the core from gc to explicit
r8109 lock.release()
Matt Mackall
error: move lock errors...
r7640 except error.LockError:
Dirkjan Ochtman
make streamclone.stream_out() a generator
r6925 raise StreamException(2)
Thomas Arendsen Hein
Handle locking exceptions if streaming clone can't lock the repo. (Issue324)
r3687
Dirkjan Ochtman
make streamclone.stream_out() a generator
r6925 yield '0\n'
Martin Geisler
i18n: mark strings for translation in Mercurial
r6953 repo.ui.debug(_('%d files, %d bytes to transfer\n') %
Vadim Gelfer
add support for streaming clone....
r2612 (len(entries), total_bytes))
Dirkjan Ochtman
make streamclone.stream_out() a generator
r6925 yield '%d %d\n' % (len(entries), total_bytes)
Vadim Gelfer
add support for streaming clone....
r2612 for name, size in entries:
Martin Geisler
i18n: mark strings for translation in Mercurial
r6953 repo.ui.debug(_('sending %s (%d bytes)\n') % (name, size))
Dirkjan Ochtman
make streamclone.stream_out() a generator
r6925 yield '%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
make streamclone.stream_out() a generator
r6925 yield chunk