From 4e870f314a59fbc97e1f6092a5c8e6f3e3c3b175 Mon Sep 17 00:00:00 2001 From: Pulkit Goyal <7895pulkit@gmail.com> Date: Wed, 31 May 2017 23:48:52 +0530 Subject: [PATCH] py3: replace None with -1 to sort an integer array In Python 2: >>> ls = [4, 2, None] >>> sorted(ls) [None, 2, 4] In Python 3: >>> ls = [4, 2, None] >>> sorted(ls) Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: NoneType() < int() Therefore we replaced None with -1, and the safe part is that, None and -1 are only the keys which are used for sorting so we don't need to convert the -1's back to None. --- mercurial/merge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mercurial/merge.py b/mercurial/merge.py index ae57a5fc00..9ac9ae34bb 100644 --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -801,7 +801,7 @@ def manifestmerge(repo, wctx, p2, pa, branchmerge, force, matcher, # manifests fetched in order are going to be faster, so prime the caches [x.manifest() for x in - sorted(wctx.parents() + [p2, pa], key=lambda x: x.rev())] + sorted(wctx.parents() + [p2, pa], key=lambda x: x.rev() or -1)] if followcopies: ret = copies.mergecopies(repo, wctx, p2, pa)