Patchwork [4,of,7] headssummary: ensure all returned lists are sorted

login
register
mail settings
Submitter Pierre-Yves David
Date June 3, 2017, 8:06 a.m.
Message ID <4c1f8363134c90034128.1496477187@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21150/
State Accepted
Headers show

Comments

Pierre-Yves David - June 3, 2017, 8:06 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1496028839 -7200
#      Mon May 29 05:33:59 2017 +0200
# Node ID 4c1f8363134c9003412863fd8a97dd8d3ed176fc
# Parent  3f9771a8f079d5698213d2038c077007ca4f3c5b
# EXP-Topic pushrace
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 4c1f8363134c
headssummary: ensure all returned lists are sorted

This is a simple step that will help to keep a stable output in coming
refactoring.

Patch

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -235,6 +235,10 @@  def _headssummary(repo, remote, outgoing
     newmap.update(repo, (ctx.rev() for ctx in missingctx))
     for branch, newheads in newmap.iteritems():
         headssum[branch][1][:] = newheads
+    for branch, items in headssum.iteritems():
+        for l in items:
+            if l is not None:
+                l.sort()
     return headssum
 
 def _oldheadssummary(repo, remoteheads, outgoing, inc=False):
@@ -244,14 +248,14 @@  def _oldheadssummary(repo, remoteheads, 
     # Construct {old,new}map with branch = None (topological branch).
     # (code based on update)
     knownnode = repo.changelog.hasnode # no nodemap until it is filtered
-    oldheads = list(h for h in remoteheads if knownnode(h))
+    oldheads = sorted(h for h in remoteheads if knownnode(h))
     # all nodes in outgoing.missing are children of either:
     # - an element of oldheads
     # - another element of outgoing.missing
     # - nullrev
     # This explains why the new head are very simple to compute.
     r = repo.set('heads(%ln + %ln)', oldheads, outgoing.missing)
-    newheads = list(c.node() for c in r)
+    newheads = sorted(c.node() for c in r)
     # set some unsynced head to issue the "unsynced changes" warning
     if inc:
         unsynced = [None]