Mercurial > public > mercurial-scm > hg-stable
diff hgext/histedit.py @ 24111:11d72683f3de
histedit: don't allow to strip nodes which are necessary to continue histedit
During histedit we don't want user to do any operation resulting in
stripping nodes needed to continue history editing. This patch
wraps the strip function to detect such situations.
author | Mateusz Kwapich <mitrandir@fb.com> |
---|---|
date | Fri, 30 Jan 2015 16:47:35 -0800 |
parents | 00d331763442 |
children | 5d5ec4fb7ada |
line wrap: on
line diff
--- a/hgext/histedit.py Fri Feb 06 16:09:43 2015 -0800 +++ b/hgext/histedit.py Fri Jan 30 16:47:35 2015 -0800 @@ -158,6 +158,7 @@ from mercurial import error from mercurial import copies from mercurial import context +from mercurial import extensions from mercurial import hg from mercurial import node from mercurial import repair @@ -674,6 +675,7 @@ actfunc = actiontable[action] state.parentctx, replacement_ = actfunc(ui, state, ha, opts) state.replacements.extend(replacement_) + state.write() hg.update(repo, state.parentctx.node()) @@ -971,6 +973,23 @@ finally: release(lock) +def stripwrapper(orig, ui, repo, nodelist, *args, **kwargs): + if isinstance(nodelist, str): + nodelist = [nodelist] + if os.path.exists(os.path.join(repo.path, 'histedit-state')): + state = histeditstate(repo) + state.read() + histedit_nodes = set([ctx for (action, ctx) in state.rules]) + strip_nodes = set([repo[n].hex() for n in nodelist]) + common_nodes = histedit_nodes & strip_nodes + if common_nodes: + raise util.Abort(_('unable to strip %s. Nodes are ' + 'used by history edit in progress.') + % ', '.join(common_nodes)) + return orig(ui, repo, nodelist, *args, **kwargs) + +extensions.wrapfunction(repair, 'strip', stripwrapper) + def summaryhook(ui, repo): if not os.path.exists(repo.join('histedit-state')): return