##// END OF EJS Templates
protocol: convert StreamException to generated error code...
Dirkjan Ochtman -
r11624:67260651 default
parent child Browse files
Show More
@@ -6,16 +6,8 b''
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 import util, error
8 import util, error
9
10 from mercurial import store
9 from mercurial import store
11
10
12 class StreamException(Exception):
13 def __init__(self, code):
14 Exception.__init__(self)
15 self.code = code
16 def __str__(self):
17 return '%i\n' % self.code
18
19 # if server supports streaming clone, it advertises "stream"
11 # if server supports streaming clone, it advertises "stream"
20 # capability with value that is version+flags of repo it is serving.
12 # capability with value that is version+flags of repo it is serving.
21 # client only streams if it can read that repo format.
13 # client only streams if it can read that repo format.
@@ -40,7 +32,8 b' def stream_out(repo):'
40 writes to file-like object, must support write() and optional flush().'''
32 writes to file-like object, must support write() and optional flush().'''
41
33
42 if not allowed(repo.ui):
34 if not allowed(repo.ui):
43 raise StreamException(1)
35 yield '1\n' # error: 1
36 return
44
37
45 entries = []
38 entries = []
46 total_bytes = 0
39 total_bytes = 0
@@ -55,9 +48,10 b' def stream_out(repo):'
55 finally:
48 finally:
56 lock.release()
49 lock.release()
57 except error.LockError:
50 except error.LockError:
58 raise StreamException(2)
51 yield '2\n' # error: 2
52 return
59
53
60 yield '0\n'
54 yield '0\n' # success
61 repo.ui.debug('%d files, %d bytes to transfer\n' %
55 repo.ui.debug('%d files, %d bytes to transfer\n' %
62 (len(entries), total_bytes))
56 (len(entries), total_bytes))
63 yield '%d %d\n' % (len(entries), total_bytes)
57 yield '%d %d\n' % (len(entries), total_bytes)
General Comments 0
You need to be logged in to leave comments. Login now