Patchwork py3: fix sorting of obsolete markers when building bundle

login
register
mail settings
Submitter Denis Laxalde
Date Oct. 10, 2019, 6:54 p.m.
Message ID <73c76732bc2febb0584f.1570733651@marimba>
Download mbox | patch
Permalink /patch/42192/
State Accepted
Headers show

Comments

Denis Laxalde - Oct. 10, 2019, 6:54 p.m.
# HG changeset patch
# User Denis Laxalde <denis@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().
Yuya Nishihara - Oct. 11, 2019, 11:40 a.m.
On Thu, 10 Oct 2019 20:54:11 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis@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

Queued, thanks.

Patch

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)