repo: remove the last few "pass" statements in localrepo.__getitem__
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 04 Oct 2018 16:06:36 -0700
changeset 40064 f84d7ed3bb35
parent 40063 b6c2543e1dd8
child 40065 5c3585a58845
repo: remove the last few "pass" statements in localrepo.__getitem__ In case of IndexError or LookupError, we used "pass" statements and fell through to the end of localrepo.__getitem__. I find the pass statements easy to miss. Consistently raising and catching exceptions seems easier to follow. Oh -- and I didn't plan this before I wrote the above -- that probably also lets us reuse the "return context.changectx(self, rev, node)" in a later patch. Differential Revision: https://phab.mercurial-scm.org/D4884
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Thu Oct 04 10:38:55 2018 -0700
+++ b/mercurial/localrepo.py	Thu Oct 04 16:06:36 2018 -0700
@@ -1255,16 +1255,12 @@
                         msg = _("working directory has unknown parent '%s'!")
                         raise error.Abort(msg % short(changeid))
                     changeid = hex(changeid) # for the error message
+                    raise
 
             elif len(changeid) == 40:
-                try:
-                    node = bin(changeid)
-                    rev = self.changelog.rev(node)
-                    return context.changectx(self, rev, node)
-                except error.FilteredLookupError:
-                    raise
-                except LookupError:
-                    pass
+                node = bin(changeid)
+                rev = self.changelog.rev(node)
+                return context.changectx(self, rev, node)
             else:
                 raise error.ProgrammingError(
                         "unsupported changeid '%s' of type %s" %
@@ -1273,12 +1269,10 @@
         except (error.FilteredIndexError, error.FilteredLookupError):
             raise error.FilteredRepoLookupError(_("filtered revision '%s'")
                                                 % pycompat.bytestr(changeid))
-        except IndexError:
-            pass
+        except (IndexError, LookupError):
+            raise error.RepoLookupError(_("unknown revision '%s'") % changeid)
         except error.WdirUnsupported:
             return context.workingctx(self)
-        raise error.RepoLookupError(
-            _("unknown revision '%s'") % changeid)
 
     def __contains__(self, changeid):
         """True if the given changeid exists