##// END OF EJS Templates
prepush: warn about every new outgoing named branch, not just the first
Benoit Boissinot -
r10354:844d83da default
parent child Browse files
Show More
@@ -1531,13 +1531,7 b' class localrepository(repo.repository):'
1531 1531 warn = 1
1532 1532
1533 1533 if warn:
1534 if not rheads: # new branch requires --force
1535 self.ui.warn(_("abort: push creates new"
1536 " remote branch '%s'!\n") %
1537 self[lheads[0]].branch())
1538 else:
1539 self.ui.warn(_("abort: push creates new remote heads!\n"))
1540
1534 self.ui.warn(_("abort: push creates new remote heads!\n"))
1541 1535 self.ui.status(_("(did you forget to merge?"
1542 1536 " use push -f to force)\n"))
1543 1537 return False
@@ -1568,10 +1562,20 b' class localrepository(repo.repository):'
1568 1562 branch = self[n].branch()
1569 1563 localbrheads.setdefault(branch, []).append(n)
1570 1564
1565 newbranches = list(set(localbrheads) - set(remotebrheads))
1566 if newbranches: # new branch requires --force
1567 branchnames = ', '.join("'%s'" % b for b in newbranches)
1568 self.ui.warn(_("abort: push creates "
1569 "new remote branches: %s!\n")
1570 % branchnames)
1571 # propose 'push -b .' in the msg too?
1572 self.ui.status(_("(use 'hg push -f' to force)\n"))
1573 return None, 0
1571 1574 for branch, lheads in localbrheads.iteritems():
1572 rheads = remotebrheads.get(branch, [])
1573 if not checkbranch(lheads, rheads, update):
1574 return None, 0
1575 if branch in remotebrheads:
1576 rheads = remotebrheads[branch]
1577 if not checkbranch(lheads, rheads, update):
1578 return None, 0
1575 1579 else:
1576 1580 if not checkbranch(heads, remote_heads, update):
1577 1581 return None, 0
@@ -90,38 +90,47 b' hg -q up 0'
90 90 echo 5 > foo
91 91 hg -q branch c
92 92 hg -q ci -d "1000000 0" -m 5
93 hg push ../f; echo $?
93 94 hg push -r 4 -r 5 ../f; echo $?
94 95
96 echo % multiple new branches
97 hg -q branch d
98 echo 6 > foo
99 hg -q ci -d "1000000 0" -m 6
100 hg push ../f; echo $?
101 hg push -r 4 -r 6 ../f; echo $?
102 cd ../g
103
95 104 echo % fail on multiple head push
96 105 hg -q up 1
97 echo 6 > foo
98 hg -q ci -d "1000000 0" -m 6
99 hg push -r 4 -r 6 ../f; echo $?
106 echo 7 > foo
107 hg -q ci -d "1000000 0" -m 7
108 hg push -r 4 -r 7 ../f; echo $?
100 109
101 110 echo % push replacement head on existing branches
102 111 hg -q up 3
103 echo 7 > foo
104 hg -q ci -d "1000000 0" -m 7
105 hg push -r 6 -r 7 ../f; echo $?
112 echo 8 > foo
113 hg -q ci -d "1000000 0" -m 8
114 hg push -r 7 -r 8 ../f; echo $?
106 115
107 116 echo % merge of branch a to other branch b followed by unrelated push on branch a
108 hg -q up 6
109 HGMERGE=true hg -q merge 7
110 hg -q ci -d "1000000 0" -m 8
111 117 hg -q up 7
112 echo 9 > foo
118 HGMERGE=true hg -q merge 8
113 119 hg -q ci -d "1000000 0" -m 9
114 hg push -r 8 ../f; echo $?
120 hg -q up 8
121 echo 10 > foo
122 hg -q ci -d "1000000 0" -m 10
115 123 hg push -r 9 ../f; echo $?
124 hg push -r 10 ../f; echo $?
116 125
117 126 echo % cheating the counting algorithm
118 hg -q up 8
127 hg -q up 9
119 128 HGMERGE=true hg -q merge 2
120 hg -q ci -d "1000000 0" -m 10
129 hg -q ci -d "1000000 0" -m 11
121 130 hg -q up 1
122 echo 11 > foo
123 hg -q ci -d "1000000 0" -m 11
124 hg push -r 10 -r 11 ../f; echo $?
131 echo 12 > foo
132 hg -q ci -d "1000000 0" -m 12
133 hg push -r 11 -r 12 ../f; echo $?
125 134
126 135 echo % checking prepush logic does not allow silently pushing multiple new heads
127 136 cd ..
@@ -84,8 +84,24 b' 0'
84 84 % push on existing branch and new branch
85 85 pushing to ../f
86 86 searching for changes
87 abort: push creates new remote branch 'c'!
88 (did you forget to merge? use push -f to force)
87 abort: push creates new remote branches: 'c'!
88 (use 'hg push -f' to force)
89 1
90 pushing to ../f
91 searching for changes
92 abort: push creates new remote branches: 'c'!
93 (use 'hg push -f' to force)
94 1
95 % multiple new branches
96 pushing to ../f
97 searching for changes
98 abort: push creates new remote branches: 'c', 'd'!
99 (use 'hg push -f' to force)
100 1
101 pushing to ../f
102 searching for changes
103 abort: push creates new remote branches: 'd'!
104 (use 'hg push -f' to force)
89 105 1
90 106 % fail on multiple head push
91 107 pushing to ../f
General Comments 0
You need to be logged in to leave comments. Login now