# HG changeset patch # User timeless # Date 1451187189 0 # Node ID a67d2e059a51591b7e2080b408844dd7e2b0a63b # Parent a4f00861272700379b03b9606e1f194bcb8f2a1c histedit: use parse-error exception for parsing diff -r a4f008612727 -r a67d2e059a51 hgext/histedit.py --- a/hgext/histedit.py Fri Dec 11 07:08:36 2015 +0000 +++ b/hgext/histedit.py Sun Dec 27 03:33:09 2015 +0000 @@ -365,7 +365,7 @@ try: self.node = repo[ha].node() except error.RepoError: - raise error.Abort(_('unknown changeset %s listed') + raise error.ParseError(_('unknown changeset %s listed') % ha[:12]) def torule(self): @@ -509,7 +509,7 @@ return None for c in ctxs: if not c.mutable(): - raise error.Abort( + raise error.ParseError( _("cannot fold into public change %s") % node.short(c.node())) base = first.parents()[0] @@ -633,7 +633,7 @@ else: c = repo[prev.node] if not c.mutable(): - raise error.Abort( + raise error.ParseError( _("cannot fold into public change %s") % node.short(c.node())) @@ -1207,11 +1207,11 @@ actions = [] for r in rules: if ' ' not in r: - raise error.Abort(_('malformed line "%s"') % r) + raise error.ParseError(_('malformed line "%s"') % r) verb, rest = r.split(' ', 1) if verb not in actiontable: - raise error.Abort(_('unknown action "%s"') % verb) + raise error.ParseError(_('unknown action "%s"') % verb) action = actiontable[verb].fromrule(state, rest) actions.append(action) @@ -1220,7 +1220,7 @@ def warnverifyactions(ui, repo, actions, state, ctxs): try: verifyactions(actions, state, ctxs) - except error.Abort: + except error.ParseError: if repo.vfs.exists('histedit-last-edit.txt'): ui.warn(_('warning: histedit rules saved ' 'to: .hg/histedit-last-edit.txt\n')) @@ -1242,21 +1242,23 @@ constraints = action.constraints() for constraint in constraints: if constraint not in _constraints.known(): - raise error.Abort(_('unknown constraint "%s"') % constraint) + raise error.ParseError(_('unknown constraint "%s"') % + constraint) nodetoverify = action.nodetoverify() if nodetoverify is not None: ha = node.hex(nodetoverify) if _constraints.noother in constraints and ha not in expected: - raise error.Abort( + raise error.ParseError( _('may not use "%s" with changesets ' 'other than the ones listed') % action.verb) if _constraints.forceother in constraints and ha in expected: - raise error.Abort( + raise error.ParseError( _('may not use "%s" with changesets ' 'within the edited list') % action.verb) if _constraints.noduplicates in constraints and ha in seen: - raise error.Abort(_('duplicated command for changeset %s') % + raise error.ParseError(_( + 'duplicated command for changeset %s') % ha[:12]) seen.add(ha) missing = sorted(expected - seen) # sort to stabilize output @@ -1267,7 +1269,7 @@ # don't show in the edit-plan in the future actions[:0] = drops elif missing: - raise error.Abort(_('missing rules for changeset %s') % + raise error.ParseError(_('missing rules for changeset %s') % missing[0][:12], hint=_('use "drop %s" to discard, see also: ' '"hg help -e histedit.config"') % missing[0][:12]) diff -r a4f008612727 -r a67d2e059a51 tests/test-histedit-arguments.t --- a/tests/test-histedit-arguments.t Fri Dec 11 07:08:36 2015 +0000 +++ b/tests/test-histedit-arguments.t Sun Dec 27 03:33:09 2015 +0000 @@ -158,7 +158,7 @@ > pick eb57da33312f 2 three > pick 08d98a8350f3 4 five > EOF - abort: missing rules for changeset c8e68270e35a + hg: parse error: missing rules for changeset c8e68270e35a (use "drop c8e68270e35a" to discard, see also: "hg help -e histedit.config") [255] @@ -170,7 +170,7 @@ > pick c8e68270e35a 3 four > pick 08d98a8350f3 4 five > EOF - abort: may not use "pick" with changesets other than the ones listed + hg: parse error: may not use "pick" with changesets other than the ones listed [255] Test malformed line @@ -181,7 +181,7 @@ > pick c8e68270e35a 3 four > pick 08d98a8350f3 4 five > EOF - abort: malformed line "pickeb57da33312f2three" + hg: parse error: malformed line "pickeb57da33312f2three" [255] Test unknown changeset @@ -192,7 +192,7 @@ > pick c8e68270e35a 3 four > pick 08d98a8350f3 4 five > EOF - abort: unknown changeset 0123456789ab listed + hg: parse error: unknown changeset 0123456789ab listed [255] Test unknown command @@ -203,7 +203,7 @@ > pick c8e68270e35a 3 four > pick 08d98a8350f3 4 five > EOF - abort: unknown action "coin" + hg: parse error: unknown action "coin" [255] Test duplicated changeset @@ -216,7 +216,7 @@ > pick eb57da33312f 2 three > pick 08d98a8350f3 4 five > EOF - abort: duplicated command for changeset eb57da33312f + hg: parse error: duplicated command for changeset eb57da33312f [255] Test short version of command diff -r a4f008612727 -r a67d2e059a51 tests/test-histedit-base.t --- a/tests/test-histedit-base.t Fri Dec 11 07:08:36 2015 +0000 +++ b/tests/test-histedit-base.t Sun Dec 27 03:33:09 2015 +0000 @@ -229,7 +229,7 @@ > base d273e35dcdf2 B > pick b2f90fd8aa85 I > EOF - abort: may not use "base" with changesets within the edited list + hg: parse error: may not use "base" with changesets within the edited list $ hg --config experimental.histeditng=False histedit 5 --commands - 2>&1 << EOF | fixbundle > base cd010b8cd998 A @@ -238,7 +238,7 @@ > pick b2f90fd8aa85 I > pick e8c55b19d366 J > EOF - abort: unknown action "base" + hg: parse error: unknown action "base" $ hg tglog @ 8:e8c55b19d366b335626e805484110d1d5f6f2ea3:draft 'J' diff -r a4f008612727 -r a67d2e059a51 tests/test-histedit-commute.t --- a/tests/test-histedit-commute.t Fri Dec 11 07:08:36 2015 +0000 +++ b/tests/test-histedit-commute.t Sun Dec 27 03:33:09 2015 +0000 @@ -268,7 +268,7 @@ > pick de71b079d9ce e > pick 38b92f448761 c > EOF - abort: may not use "pick" with changesets other than the ones listed + hg: parse error: may not use "pick" with changesets other than the ones listed $ hg log --graph @ changeset: 7:803ef1c6fcfd | tag: tip diff -r a4f008612727 -r a67d2e059a51 tests/test-histedit-drop.t --- a/tests/test-histedit-drop.t Fri Dec 11 07:08:36 2015 +0000 +++ b/tests/test-histedit-drop.t Sun Dec 27 03:33:09 2015 +0000 @@ -152,7 +152,7 @@ > pick cb9a9f314b8b a > pick ee283cb5f2d5 e > EOF - abort: missing rules for changeset a4f7421b80f7 + hg: parse error: missing rules for changeset a4f7421b80f7 (use "drop a4f7421b80f7" to discard, see also: "hg help -e histedit.config") $ hg --config histedit.dropmissing=True histedit cb9a9f314b8b --commands - 2>&1 << EOF | fixbundle > pick cb9a9f314b8b a diff -r a4f008612727 -r a67d2e059a51 tests/test-histedit-edit.t --- a/tests/test-histedit-edit.t Fri Dec 11 07:08:36 2015 +0000 +++ b/tests/test-histedit-edit.t Sun Dec 27 03:33:09 2015 +0000 @@ -459,7 +459,7 @@ > EOF $ HGEDITOR="sh ../edit.sh" hg histedit 2 warning: histedit rules saved to: .hg/histedit-last-edit.txt - abort: cannot fold into public change 18aa70c8ad22 + hg: parse error: cannot fold into public change 18aa70c8ad22 [255] $ cat .hg/histedit-last-edit.txt fold 0012be4a27ea 2 extend a