Patchwork [1,of,2] exchange: extract a function to sort obsolete markers

login
register
mail settings
Submitter Denis Laxalde
Date Oct. 17, 2019, 11:48 a.m.
Message ID <4371ba5facb375010160.1571312932@steppe.local>
Download mbox | patch
Permalink /patch/42449/
State Accepted
Headers show

Comments

Denis Laxalde - Oct. 17, 2019, 11:48 a.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1571311858 -7200
#      Thu Oct 17 13:30:58 2019 +0200
# Node ID 4371ba5facb3750101608a38cdbf6c7646ff5fd1
# Parent  733d4ffcd6675d457b60bafa9568115daebc0661
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.
Yuya Nishihara - Oct. 17, 2019, 12:08 p.m.
On Thu, 17 Oct 2019 13:48:52 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1571311858 -7200
> #      Thu Oct 17 13:30:58 2019 +0200
> # Node ID 4371ba5facb3750101608a38cdbf6c7646ff5fd1
> # Parent  733d4ffcd6675d457b60bafa9568115daebc0661
> exchange: extract a function to sort obsolete markers

Queued, thanks.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
index 6a84c39..dfa679b 100644
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -99,6 +99,11 @@  class bundlespec(object):
     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 @@  def _getbundleobsmarkerpart(
             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)