# HG changeset patch # User Denis Laxalde # Date 2019-11-09 09:31:58 # Node ID e513e87b0476cc9a6eb31abe420448877fa9c902 # Parent be0f77fd274dfeaf47a2104b178039894532c425 py3: fix sorting of obsolete markers in obsutil (issue6217) This is similar to 01e8eefd9434 and others. We move the sortedmarkers() function from exchange module to obsutil. diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -28,6 +28,7 @@ from . import ( logexchange, narrowspec, obsolete, + obsutil, phases, pushkey, pycompat, @@ -99,11 +100,6 @@ 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. @@ -1140,7 +1136,7 @@ def _pushb2obsmarkers(pushop, bundler): return pushop.stepsdone.add(b'obsmarkers') if pushop.outobsmarkers: - markers = _sortedmarkers(pushop.outobsmarkers) + markers = obsutil.sortedmarkers(pushop.outobsmarkers) bundle2.buildobsmarkerspart(bundler, markers) @@ -1475,7 +1471,7 @@ def _pushobsolete(pushop): if pushop.outobsmarkers: pushop.ui.debug(b'try to push obsolete markers to remote\n') rslts = [] - markers = _sortedmarkers(pushop.outobsmarkers) + markers = obsutil.sortedmarkers(pushop.outobsmarkers) remotedata = obsolete._pushkeyescape(markers) for key in sorted(remotedata, reverse=True): # reverse sort to ensure we end with dump0 @@ -2573,7 +2569,7 @@ def _getbundleobsmarkerpart( heads = repo.heads() subset = [c.node() for c in repo.set(b'::%ln', heads)] markers = repo.obsstore.relevantmarkers(subset) - markers = _sortedmarkers(markers) + markers = obsutil.sortedmarkers(markers) bundle2.buildobsmarkerspart(bundler, markers) diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py --- a/mercurial/obsutil.py +++ b/mercurial/obsutil.py @@ -112,6 +112,11 @@ def getmarkers(repo, nodes=None, exclusi yield marker(repo, markerdata) +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 closestpredecessors(repo, nodeid): """yield the list of next predecessors pointing on visible changectx nodes @@ -675,7 +680,7 @@ def successorssets(repo, initialnode, cl # Having none means pruned node, multiple successors means split, # single successors are standard replacement. # - for mark in sorted(succmarkers[current]): + for mark in sortedmarkers(succmarkers[current]): for suc in mark[1]: if suc not in cache: if suc in stackedset: @@ -712,7 +717,7 @@ def successorssets(repo, initialnode, cl # duplicated entry and successors set that are strict subset of # another one. succssets = [] - for mark in sorted(succmarkers[current]): + for mark in sortedmarkers(succmarkers[current]): # successors sets contributed by this marker base = _succs() base.markers.add(mark)