# HG changeset patch # User Siddharth Agarwal # Date 2014-09-03 18:42:51 # Node ID 802dffd62de5a7649b83edfcde6960a8d92efedc # Parent 71227dc24311b6d83904c50bacf7b339b1454bec histedit: abort gracefully on --continue/--abort with no state Previously we'd print an ugly message saying that the histedit-state file doesn't exist in the repo. diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -147,6 +147,7 @@ try: pickle.dump # import now except ImportError: import pickle +import errno import os import sys @@ -741,7 +742,12 @@ def writestate(repo, parentnode, rules, def readstate(repo): """Returns a tuple of (parentnode, rules, keep, topmost, replacements). """ - fp = open(os.path.join(repo.path, 'histedit-state')) + try: + fp = open(os.path.join(repo.path, 'histedit-state')) + except IOError, err: + if err.errno != errno.ENOENT: + raise + raise util.Abort(_('no histedit in progress')) return pickle.load(fp) diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t --- a/tests/test-histedit-arguments.t +++ b/tests/test-histedit-arguments.t @@ -41,6 +41,16 @@ Repo setup. one +histedit --continue/--abort with no existing state +-------------------------------------------------- + + $ hg histedit --continue + abort: no histedit in progress + [255] + $ hg histedit --abort + abort: no histedit in progress + [255] + Run a dummy edit to make sure we get tip^^ correctly via revsingle. --------------------------------------------------------------------