diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -408,7 +408,7 @@ raise error.ParseError("invalid changeset %s" % rulehash) return cls(state, rev) - def verify(self, prev, expected, seen): + def verify(self, prev, expected, seen, basenodes): """ Verifies semantic correctness of the rule""" repo = self.repo ha = node.hex(self.node) @@ -418,9 +418,9 @@ raise error.ParseError(_('unknown changeset %s listed') % ha[:12]) if self.node is not None: - self._verifynodeconstraints(prev, expected, seen) + self._verifynodeconstraints(prev, expected, seen, basenodes) - def _verifynodeconstraints(self, prev, expected, seen): + def _verifynodeconstraints(self, prev, expected, seen, basenodes): # by default command need a node in the edited list if self.node not in expected: raise error.ParseError(_('%s "%s" changeset was not a candidate') @@ -673,9 +673,9 @@ @action(['fold', 'f'], _('use commit, but combine it with the one above')) class fold(histeditaction): - def verify(self, prev, expected, seen): + def verify(self, prev, expected, seen, basenodes): """ Verifies semantic correctness of the fold rule""" - super(fold, self).verify(prev, expected, seen) + super(fold, self).verify(prev, expected, seen, basenodes) repo = self.repo if not prev: c = repo[self.node].parents()[0] @@ -808,7 +808,7 @@ basectx = self.repo['.'] return basectx, [] - def _verifynodeconstraints(self, prev, expected, seen): + def _verifynodeconstraints(self, prev, expected, seen, basenodes): # base can only be use with a node not in the edited set if self.node in expected: msg = _('%s "%s" changeset was an edited list candidate') @@ -1225,7 +1225,7 @@ actions = parserules(rules, state) ctxs = [repo[act.node] \ for act in state.actions if act.node] - warnverifyactions(ui, repo, actions, state, ctxs) + warnverifyactions(ui, repo, actions, state, ctxs, state.parentctxnode) state.actions = actions state.write() @@ -1264,9 +1264,8 @@ else: rules = _readfile(ui, rules) actions = parserules(rules, state) - warnverifyactions(ui, repo, actions, state, ctxs) - parentctxnode = repo[root].parents()[0].node() + warnverifyactions(ui, repo, actions, state, ctxs, parentctxnode) state.parentctxnode = parentctxnode state.actions = actions @@ -1398,16 +1397,16 @@ actions.append(action) return actions -def warnverifyactions(ui, repo, actions, state, ctxs): +def warnverifyactions(ui, repo, actions, state, ctxs, basenode): try: - verifyactions(actions, state, ctxs) + verifyactions(actions, state, ctxs, basenode) except error.ParseError: if repo.vfs.exists('histedit-last-edit.txt'): ui.warn(_('warning: histedit rules saved ' 'to: .hg/histedit-last-edit.txt\n')) raise -def verifyactions(actions, state, ctxs): +def verifyactions(actions, state, ctxs, basenode): """Verify that there exists exactly one action per given changeset and other constraints. @@ -1422,8 +1421,11 @@ raise error.ParseError(_('first changeset cannot use verb "%s"') % actions[0].verb) + basenodes = set([state.repo[node.hex(action.node)].node() + for action in actions if isinstance(action, base)]) + basenodes.add(basenode) for action in actions: - action.verify(prev, expected, seen) + action.verify(prev, expected, seen, basenodes) prev = action if action.node is not None: seen.add(action.node)