diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -25,8 +25,12 @@ class changectx(object): 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)