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

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 10, 2012, 5:30 p.m.
Message ID <9280d7beadd6f38c8623.1355160621@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/40/
State Superseded, archived
Commit ee3b5fb648c70f5595cca6cd396666dabcf803bb
Headers show

Comments

Pierre-Yves David - Dec. 10, 2012, 5:30 p.m.
# 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.

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)