Patchwork D3219: py3: workaround comparing NoneType and integers

login
register
mail settings
Submitter phabricator
Date April 10, 2018, 2:16 p.m.
Message ID <differential-rev-PHID-DREV-a4fcq22rdw3vola5vomo-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30629/
State Superseded
Headers show

Comments

phabricator - April 10, 2018, 2:16 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3219

AFFECTED FILES
  hgext/mq.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -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)