Mercurial > hg-stable
comparison mercurial/discovery.py @ 42238:5997eabc7b85
push: added clear warning message when pushing closed branches(issue6080)
Differential Revision: https://phab.mercurial-scm.org/D6038
author | Taapas Agrawal <taapas2897@gmail.com> |
---|---|
date | Fri, 01 Mar 2019 05:56:18 +0530 |
parents | 19ccc6788a27 |
children | d0e773ad9077 |
comparison
equal
deleted
inserted
replaced
42237:8d14d91584f1 | 42238:5997eabc7b85 |
---|---|
338 else: | 338 else: |
339 headssum = _oldheadssummary(repo, remoteheads, outgoing, inc) | 339 headssum = _oldheadssummary(repo, remoteheads, outgoing, inc) |
340 pushop.pushbranchmap = headssum | 340 pushop.pushbranchmap = headssum |
341 newbranches = [branch for branch, heads in headssum.iteritems() | 341 newbranches = [branch for branch, heads in headssum.iteritems() |
342 if heads[0] is None] | 342 if heads[0] is None] |
343 # Makes a set of closed branches | |
344 closedbranches = set() | |
345 for tag, heads, tip, isclosed in repo.branchmap().iterbranches(): | |
346 if isclosed: | |
347 closedbranches.add(tag) | |
348 closedbranches = (closedbranches & set(newbranches)) | |
343 # 1. Check for new branches on the remote. | 349 # 1. Check for new branches on the remote. |
344 if newbranches and not newbranch: # new branch requires --new-branch | 350 if newbranches and not newbranch: # new branch requires --new-branch |
345 branchnames = ', '.join(sorted(newbranches)) | 351 branchnames = ', '.join(sorted(newbranches)) |
346 raise error.Abort(_("push creates new remote branches: %s!") | 352 if closedbranches: |
347 % branchnames, | 353 errmsg = (_("push creates new remote branches: %s (%d closed)!") |
348 hint=_("use 'hg push --new-branch' to create" | 354 % (branchnames, len(closedbranches))) |
349 " new remote branches")) | 355 else: |
356 errmsg = (_("push creates new remote branches: %s!")% branchnames) | |
357 hint=_("use 'hg push --new-branch' to create new remote branches") | |
358 raise error.Abort(errmsg, hint=hint) | |
350 | 359 |
351 # 2. Find heads that we need not warn about | 360 # 2. Find heads that we need not warn about |
352 nowarnheads = _nowarnheads(pushop) | 361 nowarnheads = _nowarnheads(pushop) |
353 | 362 |
354 # 3. Check for new heads. | 363 # 3. Check for new heads. |