changeset 15278:2ed335669e18 stable

commands: use separate try/except and try/finally as needed for python2.4 62dc0e7ab092 introduced a try/except/finally block, which breaks compatibility with python2.4
author Thomas Arendsen Hein <thomas@intevation.de>
date Sun, 16 Oct 2011 11:12:59 +0200
parents 8a7f1722b28e
children 018608160299
files mercurial/commands.py
diffstat 1 files changed, 37 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Oct 15 14:31:29 2011 -0500
+++ b/mercurial/commands.py	Sun Oct 16 11:12:59 2011 +0200
@@ -3543,43 +3543,44 @@
             os.unlink(tmpname)
 
     try:
-        wlock = repo.wlock()
-        lock = repo.lock()
-        tr = repo.transaction('import')
-        parents = repo.parents()
-        for patchurl in patches:
-            if patchurl == '-':
-                ui.status(_('applying patch from stdin\n'))
-                patchfile = ui.fin
-                patchurl = 'stdin'      # for error message
-            else:
-                patchurl = os.path.join(base, patchurl)
-                ui.status(_('applying %s\n') % patchurl)
-                patchfile = url.open(ui, patchurl)
-
-            haspatch = False
-            for hunk in patch.split(patchfile):
-                (msg, node) = tryone(ui, hunk, parents)
-                if msg:
-                    haspatch = True
-                    ui.note(msg + '\n')
-                if update or opts.get('exact'):
-                    parents = repo.parents()
+        try:
+            wlock = repo.wlock()
+            lock = repo.lock()
+            tr = repo.transaction('import')
+            parents = repo.parents()
+            for patchurl in patches:
+                if patchurl == '-':
+                    ui.status(_('applying patch from stdin\n'))
+                    patchfile = ui.fin
+                    patchurl = 'stdin'      # for error message
                 else:
-                    parents = [repo[node]]
-
-            if not haspatch:
-                raise util.Abort(_('%s: no diffs found') % patchurl)
-
-        tr.close()
-        if msgs:
-            repo.savecommitmessage('\n* * *\n'.join(msgs))
-    except:
-        # wlock.release() indirectly calls dirstate.write(): since
-        # we're crashing, we do not want to change the working dir
-        # parent after all, so make sure it writes nothing
-        repo.dirstate.invalidate()
-        raise
+                    patchurl = os.path.join(base, patchurl)
+                    ui.status(_('applying %s\n') % patchurl)
+                    patchfile = url.open(ui, patchurl)
+
+                haspatch = False
+                for hunk in patch.split(patchfile):
+                    (msg, node) = tryone(ui, hunk, parents)
+                    if msg:
+                        haspatch = True
+                        ui.note(msg + '\n')
+                    if update or opts.get('exact'):
+                        parents = repo.parents()
+                    else:
+                        parents = [repo[node]]
+
+                if not haspatch:
+                    raise util.Abort(_('%s: no diffs found') % patchurl)
+
+            tr.close()
+            if msgs:
+                repo.savecommitmessage('\n* * *\n'.join(msgs))
+        except:
+            # wlock.release() indirectly calls dirstate.write(): since
+            # we're crashing, we do not want to change the working dir
+            # parent after all, so make sure it writes nothing
+            repo.dirstate.invalidate()
+            raise
     finally:
         if tr:
             tr.release()