# HG changeset patch # User Thomas Arendsen Hein # Date 1318756379 -7200 # Node ID 2ed335669e186192ddcd735984c7829b3f4203c0 # Parent 8a7f1722b28e50f8e1690870b0caa38e6a6def59 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 diff -r 8a7f1722b28e -r 2ed335669e18 mercurial/commands.py --- 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()