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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Oct 16 04:30:07 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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:


More information about the Mercurial-devel mailing list