author | Matt Mackall <mpm@selenic.com> |
Mon, 23 Jul 2007 20:44:08 -0500 | |
changeset 4993 | 4205f626dc05 |
parent 4635 | 63b9d2deed48 |
permissions | -rw-r--r-- |
2399 | 1 |
# sshserver.py - ssh protocol server support for mercurial |
2396 | 2 |
# |
4635
63b9d2deed48
Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4267
diff
changeset
|
3 |
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
2858 | 4 |
# Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> |
2396 | 5 |
# |
6 |
# This software may be used and distributed according to the terms |
|
7 |
# of the GNU General Public License, incorporated herein by reference. |
|
8 |
||
3893 | 9 |
from i18n import _ |
2396 | 10 |
from node import * |
3886
abaee83ce0a6
Replace demandload with new demandimport
Matt Mackall <mpm@selenic.com>
parents:
3447
diff
changeset
|
11 |
import os, streamclone, sys, tempfile, util |
2396 | 12 |
|
13 |
class sshserver(object): |
|
14 |
def __init__(self, ui, repo): |
|
15 |
self.ui = ui |
|
16 |
self.repo = repo |
|
17 |
self.lock = None |
|
18 |
self.fin = sys.stdin |
|
19 |
self.fout = sys.stdout |
|
20 |
||
21 |
sys.stdout = sys.stderr |
|
22 |
||
23 |
# Prevent insertion/deletion of CRs |
|
24 |
util.set_binary(self.fin) |
|
25 |
util.set_binary(self.fout) |
|
26 |
||
27 |
def getarg(self): |
|
28 |
argline = self.fin.readline()[:-1] |
|
29 |
arg, l = argline.split() |
|
30 |
val = self.fin.read(int(l)) |
|
31 |
return arg, val |
|
32 |
||
33 |
def respond(self, v): |
|
34 |
self.fout.write("%d\n" % len(v)) |
|
35 |
self.fout.write(v) |
|
36 |
self.fout.flush() |
|
37 |
||
38 |
def serve_forever(self): |
|
39 |
while self.serve_one(): pass |
|
40 |
sys.exit(0) |
|
41 |
||
42 |
def serve_one(self): |
|
43 |
cmd = self.fin.readline()[:-1] |
|
44 |
if cmd: |
|
45 |
impl = getattr(self, 'do_' + cmd, None) |
|
46 |
if impl: impl() |
|
2397
e9d402506514
merge change to ssh protocol.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2396
diff
changeset
|
47 |
else: self.respond("") |
2396 | 48 |
return cmd != '' |
49 |
||
3446
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
50 |
def do_lookup(self): |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
51 |
arg, key = self.getarg() |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
52 |
assert arg == 'key' |
3447
ef1032c223e7
sshrepo: add passing of lookup exceptions
Eric Hopper <hopper@omnifarious.org>
parents:
3446
diff
changeset
|
53 |
try: |
ef1032c223e7
sshrepo: add passing of lookup exceptions
Eric Hopper <hopper@omnifarious.org>
parents:
3446
diff
changeset
|
54 |
r = hex(self.repo.lookup(key)) |
ef1032c223e7
sshrepo: add passing of lookup exceptions
Eric Hopper <hopper@omnifarious.org>
parents:
3446
diff
changeset
|
55 |
success = 1 |
ef1032c223e7
sshrepo: add passing of lookup exceptions
Eric Hopper <hopper@omnifarious.org>
parents:
3446
diff
changeset
|
56 |
except Exception,inst: |
ef1032c223e7
sshrepo: add passing of lookup exceptions
Eric Hopper <hopper@omnifarious.org>
parents:
3446
diff
changeset
|
57 |
r = str(inst) |
ef1032c223e7
sshrepo: add passing of lookup exceptions
Eric Hopper <hopper@omnifarious.org>
parents:
3446
diff
changeset
|
58 |
success = 0 |
ef1032c223e7
sshrepo: add passing of lookup exceptions
Eric Hopper <hopper@omnifarious.org>
parents:
3446
diff
changeset
|
59 |
self.respond("%s %s\n" % (success, r)) |
3446
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
60 |
|
2396 | 61 |
def do_heads(self): |
62 |
h = self.repo.heads() |
|
63 |
self.respond(" ".join(map(hex, h)) + "\n") |
|
64 |
||
2419
b17eebc911ae
Initial implementation of hello command for ssh
Matt Mackall <mpm@selenic.com>
parents:
2399
diff
changeset
|
65 |
def do_hello(self): |
b17eebc911ae
Initial implementation of hello command for ssh
Matt Mackall <mpm@selenic.com>
parents:
2399
diff
changeset
|
66 |
'''the hello command returns a set of lines describing various |
b17eebc911ae
Initial implementation of hello command for ssh
Matt Mackall <mpm@selenic.com>
parents:
2399
diff
changeset
|
67 |
interesting things about the server, in an RFC822-like format. |
b17eebc911ae
Initial implementation of hello command for ssh
Matt Mackall <mpm@selenic.com>
parents:
2399
diff
changeset
|
68 |
Currently the only one defined is "capabilities", which |
b17eebc911ae
Initial implementation of hello command for ssh
Matt Mackall <mpm@selenic.com>
parents:
2399
diff
changeset
|
69 |
consists of a line in the form: |
b17eebc911ae
Initial implementation of hello command for ssh
Matt Mackall <mpm@selenic.com>
parents:
2399
diff
changeset
|
70 |
|
b17eebc911ae
Initial implementation of hello command for ssh
Matt Mackall <mpm@selenic.com>
parents:
2399
diff
changeset
|
71 |
capabilities: space separated list of tokens |
b17eebc911ae
Initial implementation of hello command for ssh
Matt Mackall <mpm@selenic.com>
parents:
2399
diff
changeset
|
72 |
''' |
b17eebc911ae
Initial implementation of hello command for ssh
Matt Mackall <mpm@selenic.com>
parents:
2399
diff
changeset
|
73 |
|
3446
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
74 |
caps = ['unbundle', 'lookup', 'changegroupsubset'] |
2622
064aef9162cc
rename stream hgrc option to compressed.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2621
diff
changeset
|
75 |
if self.ui.configbool('server', 'uncompressed'): |
4267
b11a2fb59cf5
revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents:
3893
diff
changeset
|
76 |
caps.append('stream=%d' % self.repo.changelog.version) |
2621
5a5852a417b1
clone: disable stream support on server side by default.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2612
diff
changeset
|
77 |
self.respond("capabilities: %s\n" % (' '.join(caps),)) |
2419
b17eebc911ae
Initial implementation of hello command for ssh
Matt Mackall <mpm@selenic.com>
parents:
2399
diff
changeset
|
78 |
|
2396 | 79 |
def do_lock(self): |
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
80 |
'''DEPRECATED - allowing remote client to lock repo is not safe''' |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
81 |
|
2396 | 82 |
self.lock = self.repo.lock() |
83 |
self.respond("") |
|
84 |
||
85 |
def do_unlock(self): |
|
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
86 |
'''DEPRECATED''' |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
87 |
|
2396 | 88 |
if self.lock: |
89 |
self.lock.release() |
|
90 |
self.lock = None |
|
91 |
self.respond("") |
|
92 |
||
93 |
def do_branches(self): |
|
94 |
arg, nodes = self.getarg() |
|
95 |
nodes = map(bin, nodes.split(" ")) |
|
96 |
r = [] |
|
97 |
for b in self.repo.branches(nodes): |
|
98 |
r.append(" ".join(map(hex, b)) + "\n") |
|
99 |
self.respond("".join(r)) |
|
100 |
||
101 |
def do_between(self): |
|
102 |
arg, pairs = self.getarg() |
|
103 |
pairs = [map(bin, p.split("-")) for p in pairs.split(" ")] |
|
104 |
r = [] |
|
105 |
for b in self.repo.between(pairs): |
|
106 |
r.append(" ".join(map(hex, b)) + "\n") |
|
107 |
self.respond("".join(r)) |
|
108 |
||
109 |
def do_changegroup(self): |
|
110 |
nodes = [] |
|
111 |
arg, roots = self.getarg() |
|
112 |
nodes = map(bin, roots.split(" ")) |
|
113 |
||
114 |
cg = self.repo.changegroup(nodes, 'serve') |
|
115 |
while True: |
|
116 |
d = cg.read(4096) |
|
117 |
if not d: |
|
118 |
break |
|
119 |
self.fout.write(d) |
|
120 |
||
121 |
self.fout.flush() |
|
122 |
||
3446
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
123 |
def do_changegroupsubset(self): |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
124 |
bases = [] |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
125 |
heads = [] |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
126 |
argmap = dict([self.getarg(), self.getarg()]) |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
127 |
bases = [bin(n) for n in argmap['bases'].split(' ')] |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
128 |
heads = [bin(n) for n in argmap['heads'].split(' ')] |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
129 |
|
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
130 |
cg = self.repo.changegroupsubset(bases, heads, 'serve') |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
131 |
while True: |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
132 |
d = cg.read(4096) |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
133 |
if not d: |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
134 |
break |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
135 |
self.fout.write(d) |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
136 |
|
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
137 |
self.fout.flush() |
0b450267cf47
Adding changegroupsubset and lookup to ssh protocol so pull -r and
Eric Hopper <hopper@omnifarious.org>
parents:
3215
diff
changeset
|
138 |
|
2396 | 139 |
def do_addchangegroup(self): |
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
140 |
'''DEPRECATED''' |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
141 |
|
2396 | 142 |
if not self.lock: |
143 |
self.respond("not locked") |
|
144 |
return |
|
145 |
||
146 |
self.respond("") |
|
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2622
diff
changeset
|
147 |
r = self.repo.addchangegroup(self.fin, 'serve', self.client_url()) |
2396 | 148 |
self.respond(str(r)) |
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
149 |
|
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2622
diff
changeset
|
150 |
def client_url(self): |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2622
diff
changeset
|
151 |
client = os.environ.get('SSH_CLIENT', '').split(' ', 1)[0] |
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2622
diff
changeset
|
152 |
return 'remote:ssh:' + client |
3215
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2858
diff
changeset
|
153 |
|
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
154 |
def do_unbundle(self): |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
155 |
their_heads = self.getarg()[1].split() |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
156 |
|
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
157 |
def check_heads(): |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
158 |
heads = map(hex, self.repo.heads()) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
159 |
return their_heads == [hex('force')] or their_heads == heads |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
160 |
|
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
161 |
# fail early if possible |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
162 |
if not check_heads(): |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
163 |
self.respond(_('unsynced changes')) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
164 |
return |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
165 |
|
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
166 |
self.respond('') |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
167 |
|
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
168 |
# write bundle data to temporary file because it can be big |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
169 |
|
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
170 |
try: |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
171 |
fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-') |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
172 |
fp = os.fdopen(fd, 'wb+') |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
173 |
|
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
174 |
count = int(self.fin.readline()) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
175 |
while count: |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
176 |
fp.write(self.fin.read(count)) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
177 |
count = int(self.fin.readline()) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
178 |
|
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
179 |
was_locked = self.lock is not None |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
180 |
if not was_locked: |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
181 |
self.lock = self.repo.lock() |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
182 |
try: |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
183 |
if not check_heads(): |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
184 |
# someone else committed/pushed/unbundled while we |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
185 |
# were transferring data |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
186 |
self.respond(_('unsynced changes')) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
187 |
return |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
188 |
self.respond('') |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
189 |
|
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
190 |
# push can proceed |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
191 |
|
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
192 |
fp.seek(0) |
2673
109a22f5434a
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2622
diff
changeset
|
193 |
r = self.repo.addchangegroup(fp, 'serve', self.client_url()) |
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
194 |
self.respond(str(r)) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
195 |
finally: |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
196 |
if not was_locked: |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
197 |
self.lock.release() |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
198 |
self.lock = None |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
199 |
finally: |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
200 |
fp.close() |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
201 |
os.unlink(tempname) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2419
diff
changeset
|
202 |
|
2612
ffb895f16925
add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
203 |
def do_stream_out(self): |
ffb895f16925
add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2439
diff
changeset
|
204 |
streamclone.stream_out(self.repo, self.fout) |