Patchwork [2,of,6] changectx: move `IndexError` handling in the top level try except

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 16, 2014, 9:30 a.m.
Message ID <1e638fa45fbcdaa23e1b.1413451807@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6320/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 16, 2014, 9:30 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# 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.

Patch

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: