Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/sshserver.py @ 9742:0c84afa1d622
sshrepo: move mkstemp() out of the try block, we don't use the exception
simpler fix for 3b6f18851d87
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sat, 07 Nov 2009 13:25:25 +0100 |
parents | d193cc97c4e8 |
children | 25e572394f5c |
comparison
equal
deleted
inserted
replaced
9741:245689e7f869 | 9742:0c84afa1d622 |
---|---|
179 return | 179 return |
180 | 180 |
181 self.respond('') | 181 self.respond('') |
182 | 182 |
183 # write bundle data to temporary file because it can be big | 183 # write bundle data to temporary file because it can be big |
184 tempname = fp = None | 184 fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-') |
185 try: | 185 fp = os.fdopen(fd, 'wb+') |
186 fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-') | 186 try: |
187 fp = os.fdopen(fd, 'wb+') | |
188 | |
189 count = int(self.fin.readline()) | 187 count = int(self.fin.readline()) |
190 while count: | 188 while count: |
191 fp.write(self.fin.read(count)) | 189 fp.write(self.fin.read(count)) |
192 count = int(self.fin.readline()) | 190 count = int(self.fin.readline()) |
193 | 191 |
210 finally: | 208 finally: |
211 if not was_locked: | 209 if not was_locked: |
212 self.lock.release() | 210 self.lock.release() |
213 self.lock = None | 211 self.lock = None |
214 finally: | 212 finally: |
215 if fp is not None: | 213 fp.close() |
216 fp.close() | 214 os.unlink(tempname) |
217 if tempname is not None: | |
218 os.unlink(tempname) | |
219 | 215 |
220 def do_stream_out(self): | 216 def do_stream_out(self): |
221 try: | 217 try: |
222 for chunk in streamclone.stream_out(self.repo): | 218 for chunk in streamclone.stream_out(self.repo): |
223 self.fout.write(chunk) | 219 self.fout.write(chunk) |