236 unsynced = set([None]) |
236 unsynced = set([None]) |
237 else: |
237 else: |
238 unsynced = set() |
238 unsynced = set() |
239 return {None: (oldheads, newheads, unsynced)} |
239 return {None: (oldheads, newheads, unsynced)} |
240 |
240 |
|
241 def _nowarnheads(repo, remote, newbookmarks): |
|
242 # Compute newly pushed bookmarks. We don't warn about bookmarked heads. |
|
243 localbookmarks = repo._bookmarks |
|
244 remotebookmarks = remote.listkeys('bookmarks') |
|
245 bookmarkedheads = set() |
|
246 for bm in localbookmarks: |
|
247 rnode = remotebookmarks.get(bm) |
|
248 if rnode and rnode in repo: |
|
249 lctx, rctx = repo[bm], repo[rnode] |
|
250 if bookmarks.validdest(repo, rctx, lctx): |
|
251 bookmarkedheads.add(lctx.node()) |
|
252 else: |
|
253 if bm in newbookmarks and bm not in remotebookmarks: |
|
254 bookmarkedheads.add(repo[bm].node()) |
|
255 |
|
256 return bookmarkedheads |
|
257 |
241 def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False, |
258 def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False, |
242 newbookmarks=[]): |
259 newbookmarks=[]): |
243 """Check that a push won't add any outgoing head |
260 """Check that a push won't add any outgoing head |
244 |
261 |
245 raise Abort error and display ui message as needed. |
262 raise Abort error and display ui message as needed. |
266 raise error.Abort(_("push creates new remote branches: %s!") |
283 raise error.Abort(_("push creates new remote branches: %s!") |
267 % branchnames, |
284 % branchnames, |
268 hint=_("use 'hg push --new-branch' to create" |
285 hint=_("use 'hg push --new-branch' to create" |
269 " new remote branches")) |
286 " new remote branches")) |
270 |
287 |
271 # 2. Compute newly pushed bookmarks. We don't warn about bookmarked heads. |
288 # 2. Find heads that we need not warn about |
272 localbookmarks = repo._bookmarks |
289 nowarnheads = _nowarnheads(repo, remote, newbookmarks) |
273 remotebookmarks = remote.listkeys('bookmarks') |
|
274 bookmarkedheads = set() |
|
275 for bm in localbookmarks: |
|
276 rnode = remotebookmarks.get(bm) |
|
277 if rnode and rnode in repo: |
|
278 lctx, rctx = repo[bm], repo[rnode] |
|
279 if bookmarks.validdest(repo, rctx, lctx): |
|
280 bookmarkedheads.add(lctx.node()) |
|
281 else: |
|
282 if bm in newbookmarks and bm not in remotebookmarks: |
|
283 bookmarkedheads.add(repo[bm].node()) |
|
284 |
290 |
285 # 3. Check for new heads. |
291 # 3. Check for new heads. |
286 # If there are more heads after the push than before, a suitable |
292 # If there are more heads after the push than before, a suitable |
287 # error message, depending on unsynced status, is displayed. |
293 # error message, depending on unsynced status, is displayed. |
288 errormsg = None |
294 errormsg = None |
364 hint = _("merge or" |
370 hint = _("merge or" |
365 " see \"hg help push\" for details about" |
371 " see \"hg help push\" for details about" |
366 " pushing new heads") |
372 " pushing new heads") |
367 elif len(newhs) > len(oldhs): |
373 elif len(newhs) > len(oldhs): |
368 # remove bookmarked or existing remote heads from the new heads list |
374 # remove bookmarked or existing remote heads from the new heads list |
369 dhs = sorted(newhs - bookmarkedheads - oldhs) |
375 dhs = sorted(newhs - nowarnheads - oldhs) |
370 if dhs: |
376 if dhs: |
371 if errormsg is None: |
377 if errormsg is None: |
372 if branch not in ('default', None): |
378 if branch not in ('default', None): |
373 errormsg = _("push creates new remote head %s " |
379 errormsg = _("push creates new remote head %s " |
374 "on branch '%s'!") % (short(dhs[0]), branch) |
380 "on branch '%s'!") % (short(dhs[0]), branch) |