py3: workaround comparing NoneType and integers
authorPulkit Goyal <7895pulkit@gmail.com>
Tue, 10 Apr 2018 19:21:16 +0530
changeset 37525 a7de62adcf03
parent 37524 5d81f1b7051b
child 37526 f5ffcac66c02
py3: workaround comparing NoneType and integers Comparing None with integers was fine in Python 2 but returns error in Python 3 which is nice. This patch replaces None with -1 where sorting is done and some related logic. Differential Revision: https://phab.mercurial-scm.org/D3219
hgext/mq.py
--- a/hgext/mq.py	Tue Apr 10 18:57:56 2018 +0530
+++ b/hgext/mq.py	Tue Apr 10 19:21:16 2018 +0530
@@ -1022,9 +1022,17 @@
 
         unknown = []
 
-        for (i, p) in sorted([(self.findseries(p), p) for p in patches],
-                             reverse=True):
-            if i is not None:
+        sortedseries = []
+        for p in patches:
+            idx = self.findseries(p)
+            if idx is None:
+                sortedseries.append((-1, p))
+            else:
+                sortedseries.append((idx, p))
+
+        sortedseries.sort(reverse=True)
+        for (i, p) in sortedseries:
+            if i != -1:
                 del self.fullseries[i]
             else:
                 unknown.append(p)