changeset 32708:90cb4ec8df64

headsummary: expose the 'discardedheads' set in the headssummary That information will be useful to detect push race on related part of the history. See next changeset for details.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 29 May 2017 05:52:13 +0200
parents 32c8f98aebf4
children 16ada4cbb1a9
files mercurial/discovery.py
diffstat 1 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/discovery.py	Mon May 29 05:47:27 2017 +0200
+++ b/mercurial/discovery.py	Mon May 29 05:52:13 2017 +0200
@@ -185,13 +185,15 @@
 def _headssummary(pushop):
     """compute a summary of branch and heads status before and after push
 
-    return {'branch': ([remoteheads], [newheads], [unsyncedheads])} mapping
+    return {'branch': ([remoteheads], [newheads],
+                       [unsyncedheads], [discardedheads])} mapping
 
-    - branch: the branch name
+    - branch: the branch name,
     - remoteheads: the list of remote heads known locally
-                   None if the branch is new
-    - newheads: the new remote heads (known locally) with outgoing pushed
-    - unsyncedheads: the list of remote heads unknown locally.
+                   None if the branch is new,
+    - newheads: the new remote heads (known locally) with outgoing pushed,
+    - unsyncedheads: the list of remote heads unknown locally,
+    - discardedheads: the list of heads made obsolete by the push.
     """
     repo = pushop.repo.unfiltered()
     remote = pushop.remote
@@ -242,6 +244,8 @@
         for l in items:
             if l is not None:
                 l.sort()
+        headssum[branch] = items + ([],)
+
     # If there are no obsstore, no post processing are needed.
     if repo.obsstore:
         allmissing = set(outgoing.missing)
@@ -249,10 +253,10 @@
         allfuturecommon = set(c.node() for c in cctx)
         allfuturecommon.update(allmissing)
         for branch, heads in sorted(headssum.iteritems()):
-            remoteheads, newheads, unsyncedheads = heads
+            remoteheads, newheads, unsyncedheads, placeholder = heads
             result = _postprocessobsolete(pushop, allfuturecommon, newheads)
-            newheads = sorted(result[0])
-            headssum[branch] = (remoteheads, newheads, unsyncedheads)
+            headssum[branch] = (remoteheads, sorted(result[0]), unsyncedheads,
+                                sorted(result[1]))
     return headssum
 
 def _oldheadssummary(repo, remoteheads, outgoing, inc=False):
@@ -275,7 +279,7 @@
         unsynced = [None]
     else:
         unsynced = []
-    return {None: (oldheads, newheads, unsynced)}
+    return {None: (oldheads, newheads, unsynced, [])}
 
 def _nowarnheads(pushop):
     # Compute newly pushed bookmarks. We don't warn about bookmarked heads.
@@ -346,7 +350,7 @@
     # error message, depending on unsynced status, is displayed.
     errormsg = None
     for branch, heads in sorted(headssum.iteritems()):
-        remoteheads, newheads, unsyncedheads = heads
+        remoteheads, newheads, unsyncedheads, discardedheads = heads
         # add unsynced data
         if remoteheads is None:
             oldhs = set()