Show More
@@ -2577,7 +2577,8 b' def reposetup(ui, repo):' | |||||
2577 | start = lrev + 1 |
|
2577 | start = lrev + 1 | |
2578 | if start < qbase: |
|
2578 | if start < qbase: | |
2579 | # update the cache (excluding the patches) and save it |
|
2579 | # update the cache (excluding the patches) and save it | |
2580 |
self |
|
2580 | ctxgen = (self[r] for r in xrange(lrev + 1, qbase)) | |
|
2581 | self._updatebranchcache(partial, ctxgen) | |||
2581 | self._writebranchcache(partial, cl.node(qbase - 1), qbase - 1) |
|
2582 | self._writebranchcache(partial, cl.node(qbase - 1), qbase - 1) | |
2582 | start = qbase |
|
2583 | start = qbase | |
2583 | # if start = qbase, the cache is as updated as it should be. |
|
2584 | # if start = qbase, the cache is as updated as it should be. | |
@@ -2585,7 +2586,8 b' def reposetup(ui, repo):' | |||||
2585 | # we might as well use it, but we won't save it. |
|
2586 | # we might as well use it, but we won't save it. | |
2586 |
|
2587 | |||
2587 | # update the cache up to the tip |
|
2588 | # update the cache up to the tip | |
2588 | self._updatebranchcache(partial, start, len(cl)) |
|
2589 | ctxgen = (self[r] for r in xrange(start, len(cl))) | |
|
2590 | self._updatebranchcache(partial, ctxgen) | |||
2589 |
|
2591 | |||
2590 | return partial |
|
2592 | return partial | |
2591 |
|
2593 |
@@ -320,7 +320,8 b' class localrepository(repo.repository):' | |||||
320 | # TODO: rename this function? |
|
320 | # TODO: rename this function? | |
321 | tiprev = len(self) - 1 |
|
321 | tiprev = len(self) - 1 | |
322 | if lrev != tiprev: |
|
322 | if lrev != tiprev: | |
323 |
self |
|
323 | ctxgen = (self[r] for r in xrange(lrev + 1, tiprev + 1)) | |
|
324 | self._updatebranchcache(partial, ctxgen) | |||
324 | self._writebranchcache(partial, self.changelog.tip(), tiprev) |
|
325 | self._writebranchcache(partial, self.changelog.tip(), tiprev) | |
325 |
|
326 | |||
326 | return partial |
|
327 | return partial | |
@@ -398,11 +399,10 b' class localrepository(repo.repository):' | |||||
398 | except (IOError, OSError): |
|
399 | except (IOError, OSError): | |
399 | pass |
|
400 | pass | |
400 |
|
401 | |||
401 |
def _updatebranchcache(self, partial, |
|
402 | def _updatebranchcache(self, partial, ctxgen): | |
402 | # collect new branch entries |
|
403 | # collect new branch entries | |
403 | newbranches = {} |
|
404 | newbranches = {} | |
404 |
for |
|
405 | for c in ctxgen: | |
405 | c = self[r] |
|
|||
406 | newbranches.setdefault(c.branch(), []).append(c.node()) |
|
406 | newbranches.setdefault(c.branch(), []).append(c.node()) | |
407 | # if older branchheads are reachable from new ones, they aren't |
|
407 | # if older branchheads are reachable from new ones, they aren't | |
408 | # really branchheads. Note checking parents is insufficient: |
|
408 | # really branchheads. Note checking parents is insufficient: | |
@@ -1503,30 +1503,22 b' class localrepository(repo.repository):' | |||||
1503 | update, updated_heads = self.findoutgoing(remote, common, remote_heads) |
|
1503 | update, updated_heads = self.findoutgoing(remote, common, remote_heads) | |
1504 | msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) |
|
1504 | msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) | |
1505 |
|
1505 | |||
1506 |
def checkbranch(lheads, rheads, |
|
1506 | def checkbranch(lheads, rheads, branchname=None): | |
1507 | ''' |
|
1507 | ''' | |
1508 | check whether there are more local heads than remote heads on |
|
1508 | check whether there are more local heads than remote heads on | |
1509 | a specific branch. |
|
1509 | a specific branch. | |
1510 |
|
1510 | |||
1511 | lheads: local branch heads |
|
1511 | lheads: local branch heads | |
1512 | rheads: remote branch heads |
|
1512 | rheads: remote branch heads | |
1513 | updatelb: outgoing local branch bases |
|
|||
1514 | ''' |
|
1513 | ''' | |
1515 |
|
1514 | |||
1516 | warn = 0 |
|
1515 | warn = 0 | |
1517 |
|
1516 | |||
1518 |
if |
|
1517 | if len(lheads) > len(rheads): | |
1519 | warn = 1 |
|
1518 | warn = 1 | |
1520 | else: |
|
1519 | else: | |
1521 | # add local heads involved in the push |
|
|||
1522 | updatelheads = [self.changelog.heads(x, lheads) |
|
|||
1523 | for x in updatelb] |
|
|||
1524 | newheads = set(sum(updatelheads, [])) & set(lheads) |
|
|||
1525 |
|
||||
1526 | if not newheads: |
|
|||
1527 | return True |
|
|||
1528 |
|
||||
1529 | # add heads we don't have or that are not involved in the push |
|
1520 | # add heads we don't have or that are not involved in the push | |
|
1521 | newheads = set(lheads) | |||
1530 | for r in rheads: |
|
1522 | for r in rheads: | |
1531 | if r in self.changelog.nodemap: |
|
1523 | if r in self.changelog.nodemap: | |
1532 | desc = self.changelog.heads(r, heads) |
|
1524 | desc = self.changelog.heads(r, heads) | |
@@ -1575,9 +1567,8 b' class localrepository(repo.repository):' | |||||
1575 | localbrheads = self.branchmap() |
|
1567 | localbrheads = self.branchmap() | |
1576 | else: |
|
1568 | else: | |
1577 | localbrheads = {} |
|
1569 | localbrheads = {} | |
1578 |
for n in |
|
1570 | ctxgen = (self[n] for n in msng_cl) | |
1579 |
|
|
1571 | self._updatebranchcache(localbrheads, ctxgen) | |
1580 | localbrheads.setdefault(branch, []).append(n) |
|
|||
1581 |
|
1572 | |||
1582 | newbranches = list(set(localbrheads) - set(remotebrheads)) |
|
1573 | newbranches = list(set(localbrheads) - set(remotebrheads)) | |
1583 | if newbranches: # new branch requires --force |
|
1574 | if newbranches: # new branch requires --force | |
@@ -1591,10 +1582,10 b' class localrepository(repo.repository):' | |||||
1591 | for branch, lheads in localbrheads.iteritems(): |
|
1582 | for branch, lheads in localbrheads.iteritems(): | |
1592 | if branch in remotebrheads: |
|
1583 | if branch in remotebrheads: | |
1593 | rheads = remotebrheads[branch] |
|
1584 | rheads = remotebrheads[branch] | |
1594 |
if not checkbranch(lheads, rheads, |
|
1585 | if not checkbranch(lheads, rheads, branch): | |
1595 | return None, 0 |
|
1586 | return None, 0 | |
1596 | else: |
|
1587 | else: | |
1597 |
if not checkbranch(heads, remote_heads |
|
1588 | if not checkbranch(heads, remote_heads): | |
1598 | return None, 0 |
|
1589 | return None, 0 | |
1599 |
|
1590 | |||
1600 | if inc: |
|
1591 | if inc: |
@@ -166,4 +166,32 b' hg -R k ci -m merge' | |||||
166 | hg -R k push -r a j |
|
166 | hg -R k push -r a j | |
167 | echo |
|
167 | echo | |
168 |
|
168 | |||
|
169 | echo % prepush -r should not allow you to sneak in new heads | |||
|
170 | hg init l | |||
|
171 | cd l | |||
|
172 | echo a >> foo | |||
|
173 | hg -q add foo | |||
|
174 | hg -q branch a | |||
|
175 | hg -q ci -d '0 0' -ma | |||
|
176 | hg -q up null | |||
|
177 | echo a >> foo | |||
|
178 | hg -q add foo | |||
|
179 | hg -q branch b | |||
|
180 | hg -q ci -d '0 0' -mb | |||
|
181 | cd .. | |||
|
182 | hg -q clone l m -u a | |||
|
183 | cd m | |||
|
184 | hg -q merge b | |||
|
185 | hg -q ci -d '0 0' -mmb | |||
|
186 | hg -q up 0 | |||
|
187 | echo a >> foo | |||
|
188 | hg -q ci -ma2 | |||
|
189 | hg -q up 2 | |||
|
190 | echo a >> foo | |||
|
191 | hg -q branch -f b | |||
|
192 | hg -q ci -d '0 0' -mb2 | |||
|
193 | hg -q merge 3 | |||
|
194 | hg -q ci -d '0 0' -mma | |||
|
195 | hg push ../l -b b | |||
|
196 | ||||
169 | exit 0 |
|
197 | exit 0 |
@@ -100,7 +100,7 b' abort: push creates new remote branches:' | |||||
100 | 1 |
|
100 | 1 | |
101 | pushing to ../f |
|
101 | pushing to ../f | |
102 | searching for changes |
|
102 | searching for changes | |
103 | abort: push creates new remote branches: d! |
|
103 | abort: push creates new remote branches: c, d! | |
104 | (use 'hg push -f' to force) |
|
104 | (use 'hg push -f' to force) | |
105 | 1 |
|
105 | 1 | |
106 | % fail on multiple head push |
|
106 | % fail on multiple head push | |
@@ -167,6 +167,11 b' 1 files updated, 0 files merged, 0 files' | |||||
167 | (branch merge, don't forget to commit) |
|
167 | (branch merge, don't forget to commit) | |
168 | pushing to j |
|
168 | pushing to j | |
169 | searching for changes |
|
169 | searching for changes | |
|
170 | abort: push creates new remote branches: b! | |||
|
171 | (use 'hg push -f' to force) | |||
|
172 | ||||
|
173 | % prepush -r should not allow you to sneak in new heads | |||
|
174 | pushing to ../l | |||
|
175 | searching for changes | |||
170 | abort: push creates new remote heads on branch 'a'! |
|
176 | abort: push creates new remote heads on branch 'a'! | |
171 |
( |
|
177 | (did you forget to merge? use push -f to force) | |
172 |
|
General Comments 0
You need to be logged in to leave comments.
Login now