revlog: raise WdirUnsupported when wdirrev is passed
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 19 May 2017 19:12:06 +0530
changeset 32403 a28c76e1cea9
parent 32402 c8e10565a113
child 32404 e8c043375b53
revlog: raise WdirUnsupported when wdirrev is passed revlog.parentrevs() is called while evaluating ^ operator in revsets. When wdir is passed, it raises IndexError. This patch raises WdirUnsupported if wdir is passed in the function. The error will be caugth in future patches.
mercurial/revlog.py
--- a/mercurial/revlog.py	Fri May 19 19:10:37 2017 +0530
+++ b/mercurial/revlog.py	Fri May 19 19:12:06 2017 +0530
@@ -26,6 +26,7 @@
     hex,
     nullid,
     nullrev,
+    wdirrev,
 )
 from .i18n import _
 from . import (
@@ -481,7 +482,12 @@
         return self.index[rev][4]
 
     def parentrevs(self, rev):
-        return self.index[rev][5:7]
+        try:
+            return self.index[rev][5:7]
+        except IndexError:
+            if rev == wdirrev:
+                raise error.WdirUnsupported
+            raise
 
     def node(self, rev):
         return self.index[rev][7]