[PATCH] py3: fix sorting of obsolete markers when building bundle

Denis Laxalde denis at laxalde.org
Thu Oct 10 18:54:11 UTC 2019


# HG changeset patch
# User Denis Laxalde <denis at laxalde.org>
# Date 1570732054 -7200
#      Thu Oct 10 20:27:34 2019 +0200
# Node ID 73c76732bc2febb0584f68e8253f3c727e1ddaeb
# Parent  a5b04863dbff8c9a0966ee47c8a27675bdcdf2b8
py3: fix sorting of obsolete markers when building bundle

Last item of marker tuple (parents) is either None or tuple. Comparison
thus fails on Python 3 with:

  TypeError: '<' not supported between instances of 'tuple' and 'NoneType'

Fixing this by coercing None to the empty tuple when sorting markers in
exchange._getbundleobsmarkerpart().

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
index 4850348..ae5e9e8 100644
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -2567,7 +2567,8 @@ def _getbundleobsmarkerpart(
             heads = repo.heads()
         subset = [c.node() for c in repo.set(b'::%ln', heads)]
         markers = repo.obsstore.relevantmarkers(subset)
-        markers = sorted(markers)
+        # last item of marker tuple ('parents') may be None or a tuple
+        markers = sorted(markers, key=lambda m: m[:-1] + (m[-1] or (),))
         bundle2.buildobsmarkerspart(bundler, markers)
 
 


More information about the Mercurial-devel mailing list