Show More
@@ -1429,42 +1429,97 b' class localrepository(repo.repository):' | |||||
1429 | else: |
|
1429 | else: | |
1430 | bases, heads = update, self.changelog.heads() |
|
1430 | bases, heads = update, self.changelog.heads() | |
1431 |
|
1431 | |||
|
1432 | def checkbranch(lheads, rheads, updatelh): | |||
|
1433 | ''' | |||
|
1434 | check whether there are more local heads than remote heads on | |||
|
1435 | a specific branch. | |||
|
1436 | ||||
|
1437 | lheads: local branch heads | |||
|
1438 | rheads: remote branch heads | |||
|
1439 | updatelh: outgoing local branch heads | |||
|
1440 | ''' | |||
|
1441 | ||||
|
1442 | warn = 0 | |||
|
1443 | ||||
|
1444 | if not revs and len(lheads) > len(rheads): | |||
|
1445 | warn = 1 | |||
|
1446 | else: | |||
|
1447 | updatelheads = [self.changelog.heads(x, lheads) | |||
|
1448 | for x in updatelh] | |||
|
1449 | newheads = set(sum(updatelheads, [])) & set(lheads) | |||
|
1450 | ||||
|
1451 | if not newheads: | |||
|
1452 | return True | |||
|
1453 | ||||
|
1454 | for r in rheads: | |||
|
1455 | if r in self.changelog.nodemap: | |||
|
1456 | desc = self.changelog.heads(r, heads) | |||
|
1457 | l = [h for h in heads if h in desc] | |||
|
1458 | if not l: | |||
|
1459 | newheads.add(r) | |||
|
1460 | else: | |||
|
1461 | newheads.add(r) | |||
|
1462 | if len(newheads) > len(rheads): | |||
|
1463 | warn = 1 | |||
|
1464 | ||||
|
1465 | if warn: | |||
|
1466 | if not rheads: # new branch requires --force | |||
|
1467 | self.ui.warn(_("abort: push creates new" | |||
|
1468 | " remote branch '%s'!\n" % | |||
|
1469 | self[updatelh[0]].branch())) | |||
|
1470 | else: | |||
|
1471 | self.ui.warn(_("abort: push creates new remote heads!\n")) | |||
|
1472 | ||||
|
1473 | self.ui.status(_("(did you forget to merge?" | |||
|
1474 | " use push -f to force)\n")) | |||
|
1475 | return False | |||
|
1476 | return True | |||
|
1477 | ||||
1432 | if not bases: |
|
1478 | if not bases: | |
1433 | self.ui.status(_("no changes found\n")) |
|
1479 | self.ui.status(_("no changes found\n")) | |
1434 | return None, 1 |
|
1480 | return None, 1 | |
1435 | elif not force: |
|
1481 | elif not force: | |
1436 |
# |
|
1482 | # Check for each named branch if we're creating new remote heads. | |
1437 |
# |
|
1483 | # To be a remote head after push, node must be either: | |
1438 | # - unknown locally |
|
1484 | # - unknown locally | |
1439 | # - a local outgoing head descended from update |
|
1485 | # - a local outgoing head descended from update | |
1440 | # - a remote head that's known locally and not |
|
1486 | # - a remote head that's known locally and not | |
1441 | # ancestral to an outgoing head |
|
1487 | # ancestral to an outgoing head | |
1442 |
|
1488 | # | ||
1443 | warn = 0 |
|
1489 | # New named branches cannot be created without --force. | |
1444 |
|
1490 | |||
1445 |
if remote_heads |
|
1491 | if remote_heads != [nullid]: | |
1446 | warn = 0 |
|
1492 | if remote.capable('branchmap'): | |
1447 | elif not revs and len(heads) > len(remote_heads): |
|
1493 | localhds = {} | |
1448 |
|
|
1494 | if not revs: | |
|
1495 | localhds = self.branchmap() | |||
|
1496 | else: | |||
|
1497 | for n in heads: | |||
|
1498 | branch = self[n].branch() | |||
|
1499 | if branch in localhds: | |||
|
1500 | localhds[branch].append(n) | |||
1449 | else: |
|
1501 | else: | |
1450 | newheads = list(heads) |
|
1502 | localhds[branch] = [n] | |
1451 | for r in remote_heads: |
|
1503 | ||
1452 | if r in self.changelog.nodemap: |
|
1504 | remotehds = remote.branchmap() | |
1453 | desc = self.changelog.heads(r, heads) |
|
1505 | ||
1454 |
|
|
1506 | for lh in localhds: | |
1455 |
if |
|
1507 | if lh in remotehds: | |
1456 |
|
|
1508 | rheads = remotehds[lh] | |
1457 | else: |
|
1509 | else: | |
1458 |
|
|
1510 | rheads = [] | |
1459 |
|
|
1511 | lheads = localhds[lh] | |
1460 | warn = 1 |
|
1512 | updatelh = [upd for upd in update | |
|
1513 | if self[upd].branch() == lh] | |||
|
1514 | if not updatelh: | |||
|
1515 | continue | |||
|
1516 | if not checkbranch(lheads, rheads, updatelh): | |||
|
1517 | return None, 0 | |||
|
1518 | else: | |||
|
1519 | if not checkbranch(heads, remote_heads, update): | |||
|
1520 | return None, 0 | |||
1461 |
|
1521 | |||
1462 |
if |
|
1522 | if inc: | |
1463 | self.ui.warn(_("abort: push creates new remote heads!\n")) |
|
|||
1464 | self.ui.status(_("(did you forget to merge?" |
|
|||
1465 | " use push -f to force)\n")) |
|
|||
1466 | return None, 0 |
|
|||
1467 | elif inc: |
|
|||
1468 | self.ui.warn(_("note: unsynced remote changes!\n")) |
|
1523 | self.ui.warn(_("note: unsynced remote changes!\n")) | |
1469 |
|
1524 | |||
1470 |
|
1525 |
@@ -42,6 +42,7 b' pretxnchangegroup.acl = python:hgext.acl' | |||||
42 | pushing to ../b |
|
42 | pushing to ../b | |
43 | searching for changes |
|
43 | searching for changes | |
44 | common changesets up to 6675d58eff77 |
|
44 | common changesets up to 6675d58eff77 | |
|
45 | invalidating branch cache (tip differs) | |||
45 | 3 changesets found |
|
46 | 3 changesets found | |
46 | list of changesets: |
|
47 | list of changesets: | |
47 | ef1ea85a6374b77d6da9dcda9541f498f2d17df7 |
|
48 | ef1ea85a6374b77d6da9dcda9541f498f2d17df7 | |
@@ -74,6 +75,7 b' sources = push' | |||||
74 | pushing to ../b |
|
75 | pushing to ../b | |
75 | searching for changes |
|
76 | searching for changes | |
76 | common changesets up to 6675d58eff77 |
|
77 | common changesets up to 6675d58eff77 | |
|
78 | invalidating branch cache (tip differs) | |||
77 | 3 changesets found |
|
79 | 3 changesets found | |
78 | list of changesets: |
|
80 | list of changesets: | |
79 | ef1ea85a6374b77d6da9dcda9541f498f2d17df7 |
|
81 | ef1ea85a6374b77d6da9dcda9541f498f2d17df7 | |
@@ -111,6 +113,7 b' sources = push' | |||||
111 | pushing to ../b |
|
113 | pushing to ../b | |
112 | searching for changes |
|
114 | searching for changes | |
113 | common changesets up to 6675d58eff77 |
|
115 | common changesets up to 6675d58eff77 | |
|
116 | invalidating branch cache (tip differs) | |||
114 | 3 changesets found |
|
117 | 3 changesets found | |
115 | list of changesets: |
|
118 | list of changesets: | |
116 | ef1ea85a6374b77d6da9dcda9541f498f2d17df7 |
|
119 | ef1ea85a6374b77d6da9dcda9541f498f2d17df7 | |
@@ -408,6 +411,7 b' foo/Bar/** = fred' | |||||
408 | pushing to ../b |
|
411 | pushing to ../b | |
409 | searching for changes |
|
412 | searching for changes | |
410 | common changesets up to 6675d58eff77 |
|
413 | common changesets up to 6675d58eff77 | |
|
414 | invalidating branch cache (tip differs) | |||
411 | 3 changesets found |
|
415 | 3 changesets found | |
412 | list of changesets: |
|
416 | list of changesets: | |
413 | ef1ea85a6374b77d6da9dcda9541f498f2d17df7 |
|
417 | ef1ea85a6374b77d6da9dcda9541f498f2d17df7 |
General Comments 0
You need to be logged in to leave comments.
Login now