Mercurial > hg
changeset 28130:47317570ab8c
histedit: break _histedit function into smaller pieces (add _abortaction)
This is a part of bigger effort to refactor histedit. Initial steps are to
break _histedit function into smaller pieces which will supposedly be more
understandable. After this is done, I will have a better understanding
of how histedit works and apply that to fix issue4800.
author | Kostia Balytskyi <ikostia@fb.com> |
---|---|
date | Mon, 01 Feb 2016 12:51:20 +0000 |
parents | 7c40b4b7f8f1 |
children | 5a2fb2680a39 |
files | hgext/histedit.py |
diffstat | 1 files changed, 38 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/histedit.py Mon Feb 08 13:52:51 2016 +0000 +++ b/hgext/histedit.py Mon Feb 01 12:51:20 2016 +0000 @@ -1064,41 +1064,7 @@ state.write() return elif goal == 'abort': - try: - state.read() - tmpnodes, leafs = newnodestoabort(state) - ui.debug('restore wc to old parent %s\n' - % node.short(state.topmost)) - - # Recover our old commits if necessary - if not state.topmost in repo and state.backupfile: - backupfile = repo.join(state.backupfile) - f = hg.openpath(ui, backupfile) - gen = exchange.readbundle(ui, f, backupfile) - with repo.transaction('histedit.abort') as tr: - if not isinstance(gen, bundle2.unbundle20): - gen.apply(repo, 'histedit', 'bundle:' + backupfile) - if isinstance(gen, bundle2.unbundle20): - bundle2.applybundle(repo, gen, tr, - source='histedit', - url='bundle:' + backupfile) - - os.remove(backupfile) - - # check whether we should update away - if repo.unfiltered().revs('parents() and (%n or %ln::)', - state.parentctxnode, leafs | tmpnodes): - hg.clean(repo, state.topmost, show_stats=True, quietempty=True) - cleanupnode(ui, repo, 'created', tmpnodes) - cleanupnode(ui, repo, 'temp', leafs) - except Exception: - if state.inprogress(): - ui.warn(_('warning: encountered an exception during histedit ' - '--abort; the repository may not have been completely ' - 'cleaned up\n')) - raise - finally: - state.clear() + _abortaction(ui, repo, state) return else: cmdutil.checkunfinished(repo) @@ -1222,6 +1188,43 @@ if repo.vfs.exists('histedit-last-edit.txt'): repo.vfs.unlink('histedit-last-edit.txt') +def _abortaction(ui, repo, state): + try: + state.read() + tmpnodes, leafs = newnodestoabort(state) + ui.debug('restore wc to old parent %s\n' + % node.short(state.topmost)) + + # Recover our old commits if necessary + if not state.topmost in repo and state.backupfile: + backupfile = repo.join(state.backupfile) + f = hg.openpath(ui, backupfile) + gen = exchange.readbundle(ui, f, backupfile) + with repo.transaction('histedit.abort') as tr: + if not isinstance(gen, bundle2.unbundle20): + gen.apply(repo, 'histedit', 'bundle:' + backupfile) + if isinstance(gen, bundle2.unbundle20): + bundle2.applybundle(repo, gen, tr, + source='histedit', + url='bundle:' + backupfile) + + os.remove(backupfile) + + # check whether we should update away + if repo.unfiltered().revs('parents() and (%n or %ln::)', + state.parentctxnode, leafs | tmpnodes): + hg.clean(repo, state.topmost, show_stats=True, quietempty=True) + cleanupnode(ui, repo, 'created', tmpnodes) + cleanupnode(ui, repo, 'temp', leafs) + except Exception: + if state.inprogress(): + ui.warn(_('warning: encountered an exception during histedit ' + '--abort; the repository may not have been completely ' + 'cleaned up\n')) + raise + finally: + state.clear() + def bootstrapcontinue(ui, state, opts): repo = state.repo if state.actions: