From patchwork Mon Feb 2 14:15:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 2] context: fix repo[n] not to make invalid changectx if n is out of range From: Yuya Nishihara X-Patchwork-Id: 7592 Message-Id: <184aa519a7a72ab10361.1422886539@mimosa> To: mercurial-devel@selenic.com Date: Mon, 02 Feb 2015 23:15:39 +0900 # HG changeset patch # User Yuya Nishihara # 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