comparison mercurial/merge.py @ 32612:a8262b7784f9

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 "<stdin>", line 1, in <module> 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.
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 31 May 2017 23:48:52 +0530
parents bd56bea5ecf8
children 49e1e5acb8ff
comparison
equal deleted inserted replaced
32611:954489932c4f 32612:a8262b7784f9
799 799
800 copy, movewithdir, diverge, renamedelete, dirmove = {}, {}, {}, {}, {} 800 copy, movewithdir, diverge, renamedelete, dirmove = {}, {}, {}, {}, {}
801 801
802 # manifests fetched in order are going to be faster, so prime the caches 802 # manifests fetched in order are going to be faster, so prime the caches
803 [x.manifest() for x in 803 [x.manifest() for x in
804 sorted(wctx.parents() + [p2, pa], key=lambda x: x.rev())] 804 sorted(wctx.parents() + [p2, pa], key=lambda x: x.rev() or -1)]
805 805
806 if followcopies: 806 if followcopies:
807 ret = copies.mergecopies(repo, wctx, p2, pa) 807 ret = copies.mergecopies(repo, wctx, p2, pa)
808 copy, movewithdir, diverge, renamedelete, dirmove = ret 808 copy, movewithdir, diverge, renamedelete, dirmove = ret
809 809