From patchwork Thu Sep 4 14:54:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: histedit: abort gracefully on --continue/--abort with no state From: Siddharth Agarwal X-Patchwork-Id: 5696 Message-Id: <7b84fe4163b556e233cf.1409842445@devbig136.prn2.facebook.com> To: Date: Thu, 4 Sep 2014 07:54:05 -0700 # HG changeset patch # User Siddharth Agarwal # Date 1409769771 -7200 # Wed Sep 03 20:42:51 2014 +0200 # Node ID 7b84fe4163b556e233cfbd35750728c43bc6ea1a # Parent b21f3e34b117f72011f06cfb69d9114388258b50 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 @@ -149,6 +149,7 @@ pickle.dump # import now except ImportError: import pickle +import errno import os import sys @@ -761,7 +762,12 @@ 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 @@ 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. --------------------------------------------------------------------