changeset 37525:a7de62adcf03

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
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 10 Apr 2018 19:21:16 +0530
parents 5d81f1b7051b
children f5ffcac66c02
files hgext/mq.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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)