# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2017-05-31 18:18:52 # Node ID a8262b7784f91d762a0f3dfedddbe2c92722aa1a # Parent 954489932c4f5e6ec33b57ebaaf4333f881e3010 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. diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -801,7 +801,7 @@ def manifestmerge(repo, wctx, p2, pa, br # 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)