From patchwork Thu Oct 16 09:30:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 6] changectx: move `IndexError` handling in the top level try except From: Pierre-Yves David X-Patchwork-Id: 6320 Message-Id: <1e638fa45fbcdaa23e1b.1413451807@marginatus.alto.octopoid.net> To: mercurial-devel@selenic.com Cc: Pierre-Yves David Date: Thu, 16 Oct 2014 02:30:07 -0700 # HG changeset patch # User Pierre-Yves David # Date 1413414890 25200 # Wed Oct 15 16:14:50 2014 -0700 # Node ID 1e638fa45fbcdaa23e1b89f6be9cd1658adf62a3 # Parent a1bcac476a03416f95a0a3c5d9176dc59b1e53e2 changectx: move `IndexError` handling in the top level try except This one can be handled by the top level catching. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -376,15 +376,11 @@ class changectx(basectx): changeid = '.' self._repo = repo try: if isinstance(changeid, int): - try: - self._node = repo.changelog.node(changeid) - except IndexError: - raise error.RepoLookupError( - _("unknown revision '%s'") % changeid) + self._node = repo.changelog.node(changeid) self._rev = changeid return if isinstance(changeid, long): changeid = str(changeid) if changeid == '.': @@ -461,12 +457,12 @@ class changectx(basectx): try: if len(changeid) == 20: changeid = hex(changeid) except TypeError: pass - except Exception: - raise + except IndexError: + pass raise error.RepoLookupError( _("unknown revision '%s'") % changeid) def __hash__(self): try: