comparison mercurial/destutil.py @ 28029:72072cfc7e91

update: warn about other topological heads on bare update A concern around the user experience of Mercurial is user getting stuck on there own topological branch forever. For example, someone pulling another topological branch, missing that message in pull asking them to merge and getting stuck on there own local branch. The current way to "address" this concern was for bare 'hg update' to target the tipmost (also latest pulled) changesets and complain when the update was not linear. That way, failure to merge newly pulled changesets would result in some kind of failure. Yet the failure was quite obscure, not working in all cases (eg: commit right after pull) and the behavior was very impractical in the common case (eg: issue4673). To be able to change that behavior, we need to provide other ways to alert a user stucks on one of many topological head. We do so with an extra message after bare update: 1 other heads for branch "default" Bookmark get its own special version: 1 other divergent bookmarks for "foobar" There is significant room to improve the message itself, and we should augment it with hint about how to see theses other heads or handle the situation (see in-line comment). But having "a" message is already a significant improvement compared to the existing situation. Once we have it we can iterate on a better version of it. As having such message is an important step toward changing the default destination for update and other nicety, I would like to move forward quickly on getting such message. This was discussed during London - October 2015 Sprint.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 02 Feb 2016 14:49:02 +0000
parents d13bcc9fd656
children 6b1fc09c699a
comparison
equal deleted inserted replaced
28028:ac49ecb2a897 28029:72072cfc7e91
216 # take the first revision. So do this manually. 216 # take the first revision. So do this manually.
217 revs.sort() 217 revs.sort()
218 return revs.first() 218 return revs.first()
219 219
220 return None 220 return None
221
222 def _statusotherbook(ui, repo):
223 bmheads = repo.bookmarkheads(repo._activebookmark)
224 curhead = repo[repo._activebookmark].node()
225 if repo.revs('%n and parents()', curhead):
226 # we are on the active bookmark
227 bmheads = [b for b in bmheads if curhead != b]
228 if bmheads:
229 msg = _('%i other divergent bookmarks for "%s"\n')
230 ui.status(msg % (len(bmheads), repo._activebookmark))
231
232 def _statusotherbranchheads(ui, repo):
233 currentbranch = repo.dirstate.branch()
234 heads = repo.branchheads(currentbranch)
235 l = len(heads)
236 if repo.revs('%ln and parents()', heads):
237 # we are on a head
238 heads = repo.revs('%ln - parents()', heads)
239 if heads and l != len(heads):
240 ui.status(_('%i other heads for branch "%s"\n') %
241 (len(heads), currentbranch))
242
243 def statusotherdests(ui, repo):
244 """Print message about other head"""
245 # XXX we should probably include a hint:
246 # - about what to do
247 # - how to see such heads
248 if repo._activebookmark:
249 _statusotherbook(ui, repo)
250 else:
251 _statusotherbranchheads(ui, repo)