We can depend on the state object instead.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
We can depend on the state object instead.
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | hgext/histedit.py (10 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| Martin von Zweigbergk | Jul 25 2018, 1:51 AM |
| elif goal == 'abort': | elif goal == 'abort': | ||||
| if any((outg, revs, freeargs, rules, editplan)): | if any((outg, revs, freeargs, rules, editplan)): | ||||
| raise error.Abort(_('no arguments allowed with --abort')) | raise error.Abort(_('no arguments allowed with --abort')) | ||||
| elif goal == 'edit-plan': | elif goal == 'edit-plan': | ||||
| if any((outg, revs, freeargs)): | if any((outg, revs, freeargs)): | ||||
| raise error.Abort(_('only --commands argument allowed with ' | raise error.Abort(_('only --commands argument allowed with ' | ||||
| '--edit-plan')) | '--edit-plan')) | ||||
| else: | else: | ||||
| if os.path.exists(os.path.join(repo.path, 'histedit-state')): | if state.inprogress(): | ||||
| raise error.Abort(_('history edit already in progress, try ' | raise error.Abort(_('history edit already in progress, try ' | ||||
| '--continue or --abort')) | '--continue or --abort')) | ||||
| if outg: | if outg: | ||||
| if revs: | if revs: | ||||
| raise error.Abort(_('no revisions allowed with --outgoing')) | raise error.Abort(_('no revisions allowed with --outgoing')) | ||||
| if len(freeargs) > 1: | if len(freeargs) > 1: | ||||
| raise error.Abort( | raise error.Abort( | ||||
| _('only one repo argument allowed with --outgoing')) | _('only one repo argument allowed with --outgoing')) | ||||
| roots = [c.node() for c in repo.set("roots(%ln)", nodes)] | roots = [c.node() for c in repo.set("roots(%ln)", nodes)] | ||||
| if roots: | if roots: | ||||
| backup = not nobackup | backup = not nobackup | ||||
| repair.strip(ui, repo, roots, backup=backup) | repair.strip(ui, repo, roots, backup=backup) | ||||
| def stripwrapper(orig, ui, repo, nodelist, *args, **kwargs): | def stripwrapper(orig, ui, repo, nodelist, *args, **kwargs): | ||||
| if isinstance(nodelist, str): | if isinstance(nodelist, str): | ||||
| nodelist = [nodelist] | nodelist = [nodelist] | ||||
| if os.path.exists(os.path.join(repo.path, 'histedit-state')): | |||||
| state = histeditstate(repo) | state = histeditstate(repo) | ||||
| if state.inprogress(): | |||||
| state.read() | state.read() | ||||
| histedit_nodes = {action.node for action | histedit_nodes = {action.node for action | ||||
| in state.actions if action.node} | in state.actions if action.node} | ||||
| common_nodes = histedit_nodes & set(nodelist) | common_nodes = histedit_nodes & set(nodelist) | ||||
| if common_nodes: | if common_nodes: | ||||
| raise error.Abort(_("histedit in progress, can't strip %s") | raise error.Abort(_("histedit in progress, can't strip %s") | ||||
| % ', '.join(node.short(x) for x in common_nodes)) | % ', '.join(node.short(x) for x in common_nodes)) | ||||
| return orig(ui, repo, nodelist, *args, **kwargs) | return orig(ui, repo, nodelist, *args, **kwargs) | ||||
| extensions.wrapfunction(repair, 'strip', stripwrapper) | extensions.wrapfunction(repair, 'strip', stripwrapper) | ||||
| def summaryhook(ui, repo): | def summaryhook(ui, repo): | ||||
| if not os.path.exists(repo.vfs.join('histedit-state')): | |||||
| return | |||||
| state = histeditstate(repo) | state = histeditstate(repo) | ||||
| if not state.inprogress(): | |||||
| return | |||||
| state.read() | state.read() | ||||
| if state.actions: | if state.actions: | ||||
| # i18n: column positioning for "hg summary" | # i18n: column positioning for "hg summary" | ||||
| ui.write(_('hist: %s (histedit --continue)\n') % | ui.write(_('hist: %s (histedit --continue)\n') % | ||||
| (ui.label(_('%d remaining'), 'histedit.remaining') % | (ui.label(_('%d remaining'), 'histedit.remaining') % | ||||
| len(state.actions))) | len(state.actions))) | ||||
| def extsetup(ui): | def extsetup(ui): | ||||
| cmdutil.summaryhooks.add('histedit', summaryhook) | cmdutil.summaryhooks.add('histedit', summaryhook) | ||||
| cmdutil.unfinishedstates.append( | cmdutil.unfinishedstates.append( | ||||
| ['histedit-state', False, True, _('histedit in progress'), | ['histedit-state', False, True, _('histedit in progress'), | ||||
| _("use 'hg histedit --continue' or 'hg histedit --abort'")]) | _("use 'hg histedit --continue' or 'hg histedit --abort'")]) | ||||
| cmdutil.afterresolvedstates.append( | cmdutil.afterresolvedstates.append( | ||||
| ['histedit-state', _('hg histedit --continue')]) | ['histedit-state', _('hg histedit --continue')]) | ||||