changeset 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 245689e7f869
children bae76e97f91a
files mercurial/sshserver.py
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/sshserver.py	Sat Nov 07 03:22:03 2009 +0100
+++ b/mercurial/sshserver.py	Sat Nov 07 13:25:25 2009 +0100
@@ -181,11 +181,9 @@
         self.respond('')
 
         # write bundle data to temporary file because it can be big
-        tempname = fp = None
+        fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-')
+        fp = os.fdopen(fd, 'wb+')
         try:
-            fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-')
-            fp = os.fdopen(fd, 'wb+')
-
             count = int(self.fin.readline())
             while count:
                 fp.write(self.fin.read(count))
@@ -212,10 +210,8 @@
                     self.lock.release()
                     self.lock = None
         finally:
-            if fp is not None:
-                fp.close()
-            if tempname is not None:
-                os.unlink(tempname)
+            fp.close()
+            os.unlink(tempname)
 
     def do_stream_out(self):
         try: