[PATCH 1 of 7 clfilter part 1 V3] clfilter: ensure context raise RepoLookupError when the revision is filtered

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Mon Dec 17 10:50:10 CST 2012


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