Show More
@@ -1475,19 +1475,16 b' class localrepository(repo.repository):' | |||||
1475 | inc = self.findincoming(remote, common, remote_heads, force=force) |
|
1475 | inc = self.findincoming(remote, common, remote_heads, force=force) | |
1476 |
|
1476 | |||
1477 | update, updated_heads = self.findoutgoing(remote, common, remote_heads) |
|
1477 | update, updated_heads = self.findoutgoing(remote, common, remote_heads) | |
1478 | if revs is not None: |
|
1478 | msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) | |
1479 | msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) |
|
|||
1480 | else: |
|
|||
1481 | bases, heads = update, self.changelog.heads() |
|
|||
1482 |
|
1479 | |||
1483 |
def checkbranch(lheads, rheads, updatel |
|
1480 | def checkbranch(lheads, rheads, updatelb): | |
1484 | ''' |
|
1481 | ''' | |
1485 | check whether there are more local heads than remote heads on |
|
1482 | check whether there are more local heads than remote heads on | |
1486 | a specific branch. |
|
1483 | a specific branch. | |
1487 |
|
1484 | |||
1488 | lheads: local branch heads |
|
1485 | lheads: local branch heads | |
1489 | rheads: remote branch heads |
|
1486 | rheads: remote branch heads | |
1490 |
updatel |
|
1487 | updatelb: outgoing local branch bases | |
1491 | ''' |
|
1488 | ''' | |
1492 |
|
1489 | |||
1493 | warn = 0 |
|
1490 | warn = 0 | |
@@ -1495,13 +1492,15 b' class localrepository(repo.repository):' | |||||
1495 | if not revs and len(lheads) > len(rheads): |
|
1492 | if not revs and len(lheads) > len(rheads): | |
1496 | warn = 1 |
|
1493 | warn = 1 | |
1497 | else: |
|
1494 | else: | |
|
1495 | # add local heads involved in the push | |||
1498 | updatelheads = [self.changelog.heads(x, lheads) |
|
1496 | updatelheads = [self.changelog.heads(x, lheads) | |
1499 |
for x in updatel |
|
1497 | for x in updatelb] | |
1500 | newheads = set(sum(updatelheads, [])) & set(lheads) |
|
1498 | newheads = set(sum(updatelheads, [])) & set(lheads) | |
1501 |
|
1499 | |||
1502 | if not newheads: |
|
1500 | if not newheads: | |
1503 | return True |
|
1501 | return True | |
1504 |
|
1502 | |||
|
1503 | # add heads we don't have or that are not involved in the push | |||
1505 | for r in rheads: |
|
1504 | for r in rheads: | |
1506 | if r in self.changelog.nodemap: |
|
1505 | if r in self.changelog.nodemap: | |
1507 | desc = self.changelog.heads(r, heads) |
|
1506 | desc = self.changelog.heads(r, heads) | |
@@ -1517,7 +1516,7 b' class localrepository(repo.repository):' | |||||
1517 | if not rheads: # new branch requires --force |
|
1516 | if not rheads: # new branch requires --force | |
1518 | self.ui.warn(_("abort: push creates new" |
|
1517 | self.ui.warn(_("abort: push creates new" | |
1519 | " remote branch '%s'!\n") % |
|
1518 | " remote branch '%s'!\n") % | |
1520 |
self[updatel |
|
1519 | self[updatelb[0]].branch()) | |
1521 | else: |
|
1520 | else: | |
1522 | self.ui.warn(_("abort: push creates new remote heads!\n")) |
|
1521 | self.ui.warn(_("abort: push creates new remote heads!\n")) | |
1523 |
|
1522 | |||
@@ -1560,11 +1559,11 b' class localrepository(repo.repository):' | |||||
1560 | else: |
|
1559 | else: | |
1561 | rheads = [] |
|
1560 | rheads = [] | |
1562 | lheads = localhds[lh] |
|
1561 | lheads = localhds[lh] | |
1563 |
updatel |
|
1562 | updatelb = [upd for upd in update | |
1564 | if self[upd].branch() == lh] |
|
1563 | if self[upd].branch() == lh] | |
1565 |
if not updatel |
|
1564 | if not updatelb: | |
1566 | continue |
|
1565 | continue | |
1567 |
if not checkbranch(lheads, rheads, updatel |
|
1566 | if not checkbranch(lheads, rheads, updatelb): | |
1568 | return None, 0 |
|
1567 | return None, 0 | |
1569 | else: |
|
1568 | else: | |
1570 | if not checkbranch(heads, remote_heads, update): |
|
1569 | if not checkbranch(heads, remote_heads, update): |
@@ -14,7 +14,7 b' hide platform-specific details from the ' | |||||
14 | """ |
|
14 | """ | |
15 |
|
15 | |||
16 | from i18n import _ |
|
16 | from i18n import _ | |
17 | import error, osutil |
|
17 | import error, osutil, encoding | |
18 | import cStringIO, errno, re, shutil, sys, tempfile, traceback |
|
18 | import cStringIO, errno, re, shutil, sys, tempfile, traceback | |
19 | import os, stat, time, calendar, random, textwrap |
|
19 | import os, stat, time, calendar, random, textwrap | |
20 | import imp |
|
20 | import imp | |
@@ -1278,7 +1278,11 b' def wrap(line, hangindent, width=None):' | |||||
1278 | # adjust for weird terminal size |
|
1278 | # adjust for weird terminal size | |
1279 | width = max(78, hangindent + 1) |
|
1279 | width = max(78, hangindent + 1) | |
1280 | padding = '\n' + ' ' * hangindent |
|
1280 | padding = '\n' + ' ' * hangindent | |
1281 | return padding.join(textwrap.wrap(line, width=width - hangindent)) |
|
1281 | # To avoid corrupting multi-byte characters in line, we must wrap | |
|
1282 | # a Unicode string instead of a bytestring. | |||
|
1283 | u = line.decode(encoding.encoding) | |||
|
1284 | w = padding.join(textwrap.wrap(u, width=width - hangindent)) | |||
|
1285 | return w.encode(encoding.encoding) | |||
1282 |
|
1286 | |||
1283 | def iterlines(iterator): |
|
1287 | def iterlines(iterator): | |
1284 | for chunk in iterator: |
|
1288 | for chunk in iterator: |
@@ -123,4 +123,21 b' echo 11 > foo' | |||||
123 | hg -q ci -d "1000000 0" -m 11 |
|
123 | hg -q ci -d "1000000 0" -m 11 | |
124 | hg push -r 10 -r 11 ../f; echo $? |
|
124 | hg push -r 10 -r 11 ../f; echo $? | |
125 |
|
125 | |||
|
126 | echo % checking prepush logic does not allow silently pushing multiple new heads | |||
|
127 | cd .. | |||
|
128 | hg init g | |||
|
129 | echo init > g/init | |||
|
130 | hg -R g ci -Am init | |||
|
131 | echo a > g/a | |||
|
132 | hg -R g ci -Am a | |||
|
133 | hg clone g h | |||
|
134 | hg -R g up 0 | |||
|
135 | echo b > g/b | |||
|
136 | hg -R g ci -Am b | |||
|
137 | hg -R h up 0 | |||
|
138 | echo c > h/c | |||
|
139 | hg -R h ci -Am c | |||
|
140 | hg -R h push g | |||
|
141 | echo | |||
|
142 | ||||
126 | exit 0 |
|
143 | exit 0 |
@@ -124,3 +124,20 b' adding manifests' | |||||
124 | adding file changes |
|
124 | adding file changes | |
125 | added 2 changesets with 2 changes to 1 files |
|
125 | added 2 changesets with 2 changes to 1 files | |
126 | 0 |
|
126 | 0 | |
|
127 | % checking prepush logic does not allow silently pushing multiple new heads | |||
|
128 | abort: repository g already exists! | |||
|
129 | adding init | |||
|
130 | adding a | |||
|
131 | updating working directory | |||
|
132 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
133 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved | |||
|
134 | adding b | |||
|
135 | created new head | |||
|
136 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved | |||
|
137 | adding c | |||
|
138 | created new head | |||
|
139 | pushing to g | |||
|
140 | searching for changes | |||
|
141 | abort: push creates new remote heads! | |||
|
142 | (did you forget to merge? use push -f to force) | |||
|
143 |
General Comments 0
You need to be logged in to leave comments.
Login now