comparison mercurial/discovery.py @ 20184:a14d93b2fb1b

bookmarks: allow push -B to create a new remote head (issue2372) Push is currently allowed to create a new head if there is a remote bookmark that will be updated to point to the new head. If the bookmark is not known remotely then push aborts, even if a -B argument is about to push the bookmark. This change allows push to continue in this case. This does not require a wireproto force.
author Stephen Lee <sphen.lee@gmail.com>
date Mon, 11 Nov 2013 21:16:54 +1100
parents b988b3b19303
children d2704c48f417
comparison
equal deleted inserted replaced
20183:de7e6c489412 20184:a14d93b2fb1b
217 r = repo.set('heads(%ln + %ln)', oldheads, outgoing.missing) 217 r = repo.set('heads(%ln + %ln)', oldheads, outgoing.missing)
218 newheads = list(c.node() for c in r) 218 newheads = list(c.node() for c in r)
219 unsynced = inc and set([None]) or set() 219 unsynced = inc and set([None]) or set()
220 return {None: (oldheads, newheads, unsynced)} 220 return {None: (oldheads, newheads, unsynced)}
221 221
222 def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False): 222 def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False,
223 newbookmarks=[]):
223 """Check that a push won't add any outgoing head 224 """Check that a push won't add any outgoing head
224 225
225 raise Abort error and display ui message as needed. 226 raise Abort error and display ui message as needed.
226 """ 227 """
227 # Check for each named branch if we're creating new remote heads. 228 # Check for each named branch if we're creating new remote heads.
257 rnode = remotebookmarks.get(bm) 258 rnode = remotebookmarks.get(bm)
258 if rnode and rnode in repo: 259 if rnode and rnode in repo:
259 lctx, rctx = repo[bm], repo[rnode] 260 lctx, rctx = repo[bm], repo[rnode]
260 if bookmarks.validdest(repo, rctx, lctx): 261 if bookmarks.validdest(repo, rctx, lctx):
261 bookmarkedheads.add(lctx.node()) 262 bookmarkedheads.add(lctx.node())
263 else:
264 if bm in newbookmarks:
265 bookmarkedheads.add(repo[bm].node())
262 266
263 # 3. Check for new heads. 267 # 3. Check for new heads.
264 # If there are more heads after the push than before, a suitable 268 # If there are more heads after the push than before, a suitable
265 # error message, depending on unsynced status, is displayed. 269 # error message, depending on unsynced status, is displayed.
266 error = None 270 error = None