Mercurial > hg
changeset 27708:60268a5f731a
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.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Mon, 11 Jan 2016 09:49:39 -0800 |
parents | 14f5ea7cc4c2 |
children | da6b457e668c |
files | mercurial/commands.py |
diffstat | 1 files changed, 50 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- 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()