mercurial/revset.py
changeset 26305 ade5c488d622
parent 26304 bca60842e22d
child 26306 d157e1f18e3f
--- a/mercurial/revset.py	Fri Sep 18 17:23:10 2015 -0700
+++ b/mercurial/revset.py	Sun Sep 20 19:27:53 2015 -0700
@@ -1387,10 +1387,14 @@
     Changeset with highest revision number in set.
     """
     os = getset(repo, fullreposet(repo), x)
-    if os:
+    try:
         m = os.max()
         if m in subset:
             return baseset([m])
+    except ValueError:
+        # os.max() throws a ValueError when the collection is empty.
+        # Same as python's max().
+        pass
     return baseset()
 
 def merge(repo, subset, x):
@@ -1426,10 +1430,14 @@
     Changeset with lowest revision number in set.
     """
     os = getset(repo, fullreposet(repo), x)
-    if os:
+    try:
         m = os.min()
         if m in subset:
             return baseset([m])
+    except ValueError:
+        # os.min() throws a ValueError when the collection is empty.
+        # Same as python's min().
+        pass
     return baseset()
 
 def modifies(repo, subset, x):