Patchwork [09,of,10] revlog: raise error.WdirUnsupported from revlog.node() if wdirrev is passed

login
register
mail settings
Submitter Pulkit Goyal
Date May 22, 2017, 8:52 p.m.
Message ID <db4b48c60495338c7c2c.1495486339@workspace>
Download mbox | patch
Permalink /patch/20850/
State Accepted
Headers show

Comments

Pulkit Goyal - May 22, 2017, 8:52 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1495483236 -19800
#      Tue May 23 01:30:36 2017 +0530
# Node ID db4b48c60495338c7c2ce659c73b0ecb9ae84c7b
# Parent  5a8f18940f9961debfde65c7c7fd66964580734d
revlog: raise error.WdirUnsupported from revlog.node() if wdirrev is passed

When we try to run, 'hg debugrevspec 'branch(wdir())'', it throws an index error
and blows up. Lets raise the WdirUnsupported if wdir() is passed so that we can
catch that later.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -490,7 +490,12 @@ 
             raise
 
     def node(self, rev):
-        return self.index[rev][7]
+        try:
+            return self.index[rev][7]
+        except IndexError:
+            if rev == wdirrev:
+                raise error.WdirUnsupported
+            raise
 
     # Derived from index values.