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

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Mon Dec 10 11:30:21 CST 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1354489919 -3600
# Node ID 9280d7beadd6f38c8623ea3137f2028c57cc349c
# Parent  40374059d227850ec2f5fb4f21a1b619136e2a6a
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.

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)


More information about the Mercurial-devel mailing list