comparison mercurial/destutil.py @ 28103:7d852bb47b0a

merge: give priority to "not at head" failures for bare 'hg merge' We refuse to pick a destination for a bare 'hg merge' if the working copy is not at head. This is meant to prevent strange merge from user who forget to update. (Moreover, such merge does not reduce actually the number of heads) However, we were doing that as the last possible failure type. So user were recommended to merge with an explicit head (from this bad location) if the branch had too many heads. We now make "not on branch heads" class of failure the first things to check and fail on. The one test that change was actually trying to check for these failure (and did not). The new test output is correct.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 08 Feb 2016 14:55:58 +0100
parents bd74b5e0d2c0
children 96f8baddbd6a
comparison
equal deleted inserted replaced
28102:bd74b5e0d2c0 28103:7d852bb47b0a
191 return node 191 return node
192 192
193 def _destmergebranch(repo): 193 def _destmergebranch(repo):
194 """find merge destination based on branch heads""" 194 """find merge destination based on branch heads"""
195 node = None 195 node = None
196 parent = repo.dirstate.p1()
196 branch = repo[None].branch() 197 branch = repo[None].branch()
197 bheads = repo.branchheads(branch) 198 bheads = repo.branchheads(branch)
198 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()] 199 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
199 200
201 if parent not in bheads:
202 if len(repo.heads()) <= 1:
203 msg, hint = msgdestmerge['nootherheadsbehind']
204 else:
205 msg, hint = msgdestmerge['notatheads']
206 raise error.Abort(msg, hint=hint)
207
200 if len(nbhs) > 2: 208 if len(nbhs) > 2:
201 msg, hint = msgdestmerge['toomanyheads'] 209 msg, hint = msgdestmerge['toomanyheads']
202 msg %= (branch, len(bheads)) 210 msg %= (branch, len(bheads))
203 raise error.Abort(msg, hint=hint) 211 raise error.Abort(msg, hint=hint)
204 212
205 parent = repo.dirstate.p1()
206 if len(nbhs) <= 1: 213 if len(nbhs) <= 1:
207 if len(bheads) > 1: 214 if len(bheads) > 1:
208 msg, hint = msgdestmerge['bookmarkedheads'] 215 msg, hint = msgdestmerge['bookmarkedheads']
209 elif len(repo.heads()) > 1: 216 elif len(repo.heads()) > 1:
210 msg, hint = msgdestmerge['nootherbranchheads'] 217 msg, hint = msgdestmerge['nootherbranchheads']
211 msg %= branch 218 msg %= branch
212 elif parent != repo.lookup(branch):
213 msg, hint = msgdestmerge['nootherheadsbehind']
214 else: 219 else:
215 msg, hint = msgdestmerge['nootherheads'] 220 msg, hint = msgdestmerge['nootherheads']
216 raise error.Abort(msg, hint=hint) 221 raise error.Abort(msg, hint=hint)
217 222
218 if parent not in bheads:
219 msg, hint = msgdestmerge['notatheads']
220 raise error.Abort(msg, hint=hint)
221 if parent == nbhs[0]: 223 if parent == nbhs[0]:
222 node = nbhs[-1] 224 node = nbhs[-1]
223 else: 225 else:
224 node = nbhs[0] 226 node = nbhs[0]
225 assert node is not None 227 assert node is not None