Show More
@@ -1475,19 +1475,16 b' class localrepository(repo.repository):' | |||
|
1475 | 1475 | inc = self.findincoming(remote, common, remote_heads, force=force) |
|
1476 | 1476 | |
|
1477 | 1477 | update, updated_heads = self.findoutgoing(remote, common, remote_heads) |
|
1478 | if revs is not None: | |
|
1479 | msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) | |
|
1480 | else: | |
|
1481 | bases, heads = update, self.changelog.heads() | |
|
1478 | msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) | |
|
1482 | 1479 | |
|
1483 |
def checkbranch(lheads, rheads, updatel |
|
|
1480 | def checkbranch(lheads, rheads, updatelb): | |
|
1484 | 1481 | ''' |
|
1485 | 1482 | check whether there are more local heads than remote heads on |
|
1486 | 1483 | a specific branch. |
|
1487 | 1484 | |
|
1488 | 1485 | lheads: local branch heads |
|
1489 | 1486 | rheads: remote branch heads |
|
1490 |
updatel |
|
|
1487 | updatelb: outgoing local branch bases | |
|
1491 | 1488 | ''' |
|
1492 | 1489 | |
|
1493 | 1490 | warn = 0 |
@@ -1495,13 +1492,15 b' class localrepository(repo.repository):' | |||
|
1495 | 1492 | if not revs and len(lheads) > len(rheads): |
|
1496 | 1493 | warn = 1 |
|
1497 | 1494 | else: |
|
1495 | # add local heads involved in the push | |
|
1498 | 1496 | updatelheads = [self.changelog.heads(x, lheads) |
|
1499 |
for x in updatel |
|
|
1497 | for x in updatelb] | |
|
1500 | 1498 | newheads = set(sum(updatelheads, [])) & set(lheads) |
|
1501 | 1499 | |
|
1502 | 1500 | if not newheads: |
|
1503 | 1501 | return True |
|
1504 | 1502 | |
|
1503 | # add heads we don't have or that are not involved in the push | |
|
1505 | 1504 | for r in rheads: |
|
1506 | 1505 | if r in self.changelog.nodemap: |
|
1507 | 1506 | desc = self.changelog.heads(r, heads) |
@@ -1517,7 +1516,7 b' class localrepository(repo.repository):' | |||
|
1517 | 1516 | if not rheads: # new branch requires --force |
|
1518 | 1517 | self.ui.warn(_("abort: push creates new" |
|
1519 | 1518 | " remote branch '%s'!\n") % |
|
1520 |
self[updatel |
|
|
1519 | self[updatelb[0]].branch()) | |
|
1521 | 1520 | else: |
|
1522 | 1521 | self.ui.warn(_("abort: push creates new remote heads!\n")) |
|
1523 | 1522 | |
@@ -1560,11 +1559,11 b' class localrepository(repo.repository):' | |||
|
1560 | 1559 | else: |
|
1561 | 1560 | rheads = [] |
|
1562 | 1561 | lheads = localhds[lh] |
|
1563 |
updatel |
|
|
1562 | updatelb = [upd for upd in update | |
|
1564 | 1563 | if self[upd].branch() == lh] |
|
1565 |
if not updatel |
|
|
1564 | if not updatelb: | |
|
1566 | 1565 | continue |
|
1567 |
if not checkbranch(lheads, rheads, updatel |
|
|
1566 | if not checkbranch(lheads, rheads, updatelb): | |
|
1568 | 1567 | return None, 0 |
|
1569 | 1568 | else: |
|
1570 | 1569 | if not checkbranch(heads, remote_heads, update): |
@@ -14,7 +14,7 b' hide platform-specific details from the ' | |||
|
14 | 14 | """ |
|
15 | 15 | |
|
16 | 16 | from i18n import _ |
|
17 | import error, osutil | |
|
17 | import error, osutil, encoding | |
|
18 | 18 | import cStringIO, errno, re, shutil, sys, tempfile, traceback |
|
19 | 19 | import os, stat, time, calendar, random, textwrap |
|
20 | 20 | import imp |
@@ -1278,7 +1278,11 b' def wrap(line, hangindent, width=None):' | |||
|
1278 | 1278 | # adjust for weird terminal size |
|
1279 | 1279 | width = max(78, hangindent + 1) |
|
1280 | 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 | 1287 | def iterlines(iterator): |
|
1284 | 1288 | for chunk in iterator: |
@@ -123,4 +123,21 b' echo 11 > foo' | |||
|
123 | 123 | hg -q ci -d "1000000 0" -m 11 |
|
124 | 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 | 143 | exit 0 |
@@ -124,3 +124,20 b' adding manifests' | |||
|
124 | 124 | adding file changes |
|
125 | 125 | added 2 changesets with 2 changes to 1 files |
|
126 | 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