[PATCH 1 of 2] context: fix repo[n] not to make invalid changectx if n is out of range

Yuya Nishihara yuya at tcha.org
Mon Feb 2 08:15:39 CST 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1420883783 -32400
#      Sat Jan 10 18:56:23 2015 +0900
# Node ID 184aa519a7a72ab10361d91f66455e3cea8f4f50
# Parent  3667bc21b8773715d9472a3b4e034b77e62c6451
context: fix repo[n] not to make invalid changectx if n is out of range

This problem was spotted by ba89f7b542c9 (and eb763217152a), so it uses
fullreposet(repo) instead. This fix is necessary to rewrite "rev()" revset
without using fullreposet.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -371,6 +371,8 @@ class changectx(basectx):
 
         try:
             if isinstance(changeid, int):
+                if changeid < nullrev or changeid >= len(repo.changelog):
+                    raise IndexError
                 self._node = repo.changelog.node(changeid)
                 self._rev = changeid
                 return


More information about the Mercurial-devel mailing list