##// END OF EJS Templates
push: added clear warning message when pushing closed branches(issue6080)...
Taapas Agrawal -
r42389:5997eabc default
parent child Browse files
Show More
@@ -340,13 +340,22 b' def checkheads(pushop):'
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)
@@ -791,3 +791,57 b' Test fail hook'
791 [255]
791 [255]
792
792
793 $ cd ..
793 $ cd ..
794
795 Test regarding pushing of closed branch/branches(Issue6080)
796
797 $ hg init x
798 $ cd x
799 $ hg -q branch a
800 $ echo 0 > foo
801 $ hg -q ci -Am 0
802 $ hg -q up 0
803 $ cd ..
804
805 $ hg -q clone x z
806 $ cd z
807
808 When there is a single closed branch
809
810 $ hg -q branch foo
811 $ echo 0 > foo
812 $ hg -q ci -Am 0
813 $ hg ci --close-branch -m 'closing branch foo'
814 $ hg -q up 0
815 $ hg push ../x
816 pushing to ../x
817 searching for changes
818 abort: push creates new remote branches: foo (1 closed)!
819 (use 'hg push --new-branch' to create new remote branches)
820 [255]
821
822 When there is more than one closed branches
823 $ hg -q branch bar
824 $ echo 0 > bar
825 $ hg -q ci -Am 0
826 $ hg ci --close-branch -m 'closing branch bar'
827 $ hg -q up 0
828 $ hg push ../x
829 pushing to ../x
830 searching for changes
831 abort: push creates new remote branches: bar, foo (2 closed)!
832 (use 'hg push --new-branch' to create new remote branches)
833 [255]
834
835 When there are more than one new branches and not all are closed
836 $ hg -q branch bar1
837 $ echo 0 > bar1
838 $ hg -q ci -Am 0
839 $ hg -q up 0
840 $ hg push ../x
841 pushing to ../x
842 searching for changes
843 abort: push creates new remote branches: bar, bar1, foo (2 closed)!
844 (use 'hg push --new-branch' to create new remote branches)
845 [255]
846
847 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now