changeset 43277:48b9fbfb00b9

exchange: extract a function to sort obsolete markers Follows up on changeset 01e8eefd9434, several other occurrences of sorted() need to be fixed. The _sortedmarkers() handles sorting obsmarkers with a None value as last element on Python 3.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Thu, 17 Oct 2019 13:30:58 +0200
parents d201a637c971
children 2c70dd03b743
files mercurial/exchange.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Thu Oct 17 12:10:42 2019 +0200
+++ b/mercurial/exchange.py	Thu Oct 17 13:30:58 2019 +0200
@@ -99,6 +99,11 @@
     contentopts = attr.ib()
 
 
+def _sortedmarkers(markers):
+    # last item of marker tuple ('parents') may be None or a tuple
+    return sorted(markers, key=lambda m: m[:-1] + (m[-1] or (),))
+
+
 def parsebundlespec(repo, spec, strict=True):
     """Parse a bundle string specification into parts.
 
@@ -2567,8 +2572,7 @@
             heads = repo.heads()
         subset = [c.node() for c in repo.set(b'::%ln', heads)]
         markers = repo.obsstore.relevantmarkers(subset)
-        # last item of marker tuple ('parents') may be None or a tuple
-        markers = sorted(markers, key=lambda m: m[:-1] + (m[-1] or (),))
+        markers = _sortedmarkers(markers)
         bundle2.buildobsmarkerspart(bundler, markers)