# HG changeset patch # User Bryan O'Sullivan # Date 1452534579 28800 # Node ID 60268a5f731ab83f5f21033ad85163e86b1f777f # Parent 14f5ea7cc4c23a549be95a53a7f3b18d6eea2512 commands: get rid of empty try/finally block from import_ This diff is purely an indentation change to clean up a block that was kept in place to make 713b09fc9fbb easier to read. diff -r 14f5ea7cc4c2 -r 60268a5f731a mercurial/commands.py --- a/mercurial/commands.py Sat Jan 02 15:09:58 2016 -0800 +++ b/mercurial/commands.py Mon Jan 11 09:49:39 2016 -0800 @@ -4735,63 +4735,58 @@ try: - try: - wlock = repo.wlock() - - if update: - cmdutil.checkunfinished(repo) - if (exact or not opts.get('force')): - cmdutil.bailifchanged(repo) - - if not opts.get('no_commit'): - lock = repo.lock() - tr = repo.transaction('import') + wlock = repo.wlock() + + if update: + cmdutil.checkunfinished(repo) + if (exact or not opts.get('force')): + cmdutil.bailifchanged(repo) + + if not opts.get('no_commit'): + lock = repo.lock() + tr = repo.transaction('import') + else: + dsguard = cmdutil.dirstateguard(repo, 'import') + parents = repo[None].parents() + for patchurl in patches: + if patchurl == '-': + ui.status(_('applying patch from stdin\n')) + patchfile = ui.fin + patchurl = 'stdin' # for error message else: - dsguard = cmdutil.dirstateguard(repo, 'import') - parents = repo[None].parents() - for patchurl in patches: - if patchurl == '-': - ui.status(_('applying patch from stdin\n')) - patchfile = ui.fin - patchurl = 'stdin' # for error message + patchurl = os.path.join(base, patchurl) + ui.status(_('applying %s\n') % patchurl) + patchfile = hg.openpath(ui, patchurl) + + haspatch = False + for hunk in patch.split(patchfile): + (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk, + parents, opts, + msgs, hg.clean) + if msg: + haspatch = True + ui.note(msg + '\n') + if update or exact: + parents = repo[None].parents() else: - patchurl = os.path.join(base, patchurl) - ui.status(_('applying %s\n') % patchurl) - patchfile = hg.openpath(ui, patchurl) - - haspatch = False - for hunk in patch.split(patchfile): - (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk, - parents, opts, - msgs, hg.clean) - if msg: - haspatch = True - ui.note(msg + '\n') - if update or exact: - parents = repo[None].parents() - else: - parents = [repo[node]] - if rej: - ui.write_err(_("patch applied partially\n")) - ui.write_err(_("(fix the .rej files and run " - "`hg commit --amend`)\n")) - ret = 1 - break - - if not haspatch: - raise error.Abort(_('%s: no diffs found') % patchurl) - - if tr: - tr.close() - if msgs: - repo.savecommitmessage('\n* * *\n'.join(msgs)) - if dsguard: - dsguard.close() - return ret - finally: - # TODO: get rid of this meaningless try/finally enclosing. - # this is kept only to reduce changes in a patch. - pass + parents = [repo[node]] + if rej: + ui.write_err(_("patch applied partially\n")) + ui.write_err(_("(fix the .rej files and run " + "`hg commit --amend`)\n")) + ret = 1 + break + + if not haspatch: + raise error.Abort(_('%s: no diffs found') % patchurl) + + if tr: + tr.close() + if msgs: + repo.savecommitmessage('\n* * *\n'.join(msgs)) + if dsguard: + dsguard.close() + return ret finally: if tr: tr.release()