# HG changeset patch # User Pierre-Yves David # Date 1496029933 -7200 # Node ID 90cb4ec8df6401a1b2b74572c3749a2bb46519b9 # Parent 32c8f98aebf40cf2051eaaf3addcf2f3c9ad0115 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. diff -r 32c8f98aebf4 -r 90cb4ec8df64 mercurial/discovery.py --- 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()