Patchwork [1,of,5,filtering,part,2] clfilter: ensure context raise RepoLookupError when the revision is filtered

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 4, 2012, 12:26 a.m.
Message ID <9ccccb02c2771df1b554.1354580814@yamac.lan>
Download mbox | patch
Permalink /patch/6/
State Superseded, archived
Commit ee3b5fb648c70f5595cca6cd396666dabcf803bb
Headers show

Comments

Pierre-Yves David - Dec. 4, 2012, 12:26 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1354489919 -3600
# Node ID 9ccccb02c2771df1b554c4424d144de5a4dd2e47
# Parent  9b05b31b413c55d750ca8be41330ff65fa9ed8c1
clfilter: ensure context raise RepoLookupError when the revision is filtered

Currently the code path of `changectx(filteredrepo, rev)` call
`filteredrepo.changelog.node(rev)`. When `rev` is filtered this raise an
unhandled `IndexError`. This case now raise a `RepoLookupError` as other
error case do.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -23,10 +23,15 @@  class changectx(object):
         if changeid == '':
             changeid = '.'
         self._repo = repo
 
         if isinstance(changeid, int):
+            try:
+                self._node = repo.changelog.node(changeid)
+            except IndexError:
+                raise error.RepoLookupError(
+                    _("unknown revision '%s'") % changeid)
             self._rev = changeid
             self._node = repo.changelog.node(changeid)
             return
         if isinstance(changeid, long):
             changeid = str(changeid)