comparison mercurial/localrepo.py @ 9567:02c43e8e0835

Merge with hg-i18n-stable
author Martin Geisler <mg@lazybytes.net>
date Wed, 30 Sep 2009 21:14:24 +0200
parents 1c4e4004f3a6 f3569d95c2ab
children ceb0f59e1327
comparison
equal deleted inserted replaced
9565:08914fd0fddb 9567:02c43e8e0835
1157 # sort the output in rev descending order 1157 # sort the output in rev descending order
1158 heads = [(-self.changelog.rev(h), h) for h in heads] 1158 heads = [(-self.changelog.rev(h), h) for h in heads]
1159 return [n for (r, n) in sorted(heads)] 1159 return [n for (r, n) in sorted(heads)]
1160 1160
1161 def branchheads(self, branch=None, start=None, closed=False): 1161 def branchheads(self, branch=None, start=None, closed=False):
1162 '''return a (possibly filtered) list of heads for the given branch
1163
1164 Heads are returned in topological order, from newest to oldest.
1165 If branch is None, use the dirstate branch.
1166 If start is not None, return only heads reachable from start.
1167 If closed is True, return heads that are marked as closed as well.
1168 '''
1162 if branch is None: 1169 if branch is None:
1163 branch = self[None].branch() 1170 branch = self[None].branch()
1164 branches = self.branchmap() 1171 branches = self.branchmap()
1165 if branch not in branches: 1172 if branch not in branches:
1166 return [] 1173 return []
1167 bheads = branches[branch]
1168 # the cache returns heads ordered lowest to highest 1174 # the cache returns heads ordered lowest to highest
1169 bheads.reverse() 1175 bheads = list(reversed(branches[branch]))
1170 if start is not None: 1176 if start is not None:
1171 # filter out the heads that cannot be reached from startrev 1177 # filter out the heads that cannot be reached from startrev
1172 bheads = self.changelog.nodesbetween([start], bheads)[2] 1178 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
1179 bheads = [h for h in bheads if h in fbheads]
1173 if not closed: 1180 if not closed:
1174 bheads = [h for h in bheads if 1181 bheads = [h for h in bheads if
1175 ('close' not in self.changelog.read(h)[5])] 1182 ('close' not in self.changelog.read(h)[5])]
1176 return bheads 1183 return bheads
1177 1184
1466 common = {} 1473 common = {}
1467 remote_heads = remote.heads() 1474 remote_heads = remote.heads()
1468 inc = self.findincoming(remote, common, remote_heads, force=force) 1475 inc = self.findincoming(remote, common, remote_heads, force=force)
1469 1476
1470 update, updated_heads = self.findoutgoing(remote, common, remote_heads) 1477 update, updated_heads = self.findoutgoing(remote, common, remote_heads)
1471 if revs is not None: 1478 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
1472 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) 1479
1473 else: 1480 def checkbranch(lheads, rheads, updatelb):
1474 bases, heads = update, self.changelog.heads()
1475
1476 def checkbranch(lheads, rheads, updatelh):
1477 ''' 1481 '''
1478 check whether there are more local heads than remote heads on 1482 check whether there are more local heads than remote heads on
1479 a specific branch. 1483 a specific branch.
1480 1484
1481 lheads: local branch heads 1485 lheads: local branch heads
1482 rheads: remote branch heads 1486 rheads: remote branch heads
1483 updatelh: outgoing local branch heads 1487 updatelb: outgoing local branch bases
1484 ''' 1488 '''
1485 1489
1486 warn = 0 1490 warn = 0
1487 1491
1488 if not revs and len(lheads) > len(rheads): 1492 if not revs and len(lheads) > len(rheads):
1489 warn = 1 1493 warn = 1
1490 else: 1494 else:
1495 # add local heads involved in the push
1491 updatelheads = [self.changelog.heads(x, lheads) 1496 updatelheads = [self.changelog.heads(x, lheads)
1492 for x in updatelh] 1497 for x in updatelb]
1493 newheads = set(sum(updatelheads, [])) & set(lheads) 1498 newheads = set(sum(updatelheads, [])) & set(lheads)
1494 1499
1495 if not newheads: 1500 if not newheads:
1496 return True 1501 return True
1497 1502
1503 # add heads we don't have or that are not involved in the push
1498 for r in rheads: 1504 for r in rheads:
1499 if r in self.changelog.nodemap: 1505 if r in self.changelog.nodemap:
1500 desc = self.changelog.heads(r, heads) 1506 desc = self.changelog.heads(r, heads)
1501 l = [h for h in heads if h in desc] 1507 l = [h for h in heads if h in desc]
1502 if not l: 1508 if not l:
1508 1514
1509 if warn: 1515 if warn:
1510 if not rheads: # new branch requires --force 1516 if not rheads: # new branch requires --force
1511 self.ui.warn(_("abort: push creates new" 1517 self.ui.warn(_("abort: push creates new"
1512 " remote branch '%s'!\n") % 1518 " remote branch '%s'!\n") %
1513 self[updatelh[0]].branch()) 1519 self[updatelb[0]].branch())
1514 else: 1520 else:
1515 self.ui.warn(_("abort: push creates new remote heads!\n")) 1521 self.ui.warn(_("abort: push creates new remote heads!\n"))
1516 1522
1517 self.ui.status(_("(did you forget to merge?" 1523 self.ui.status(_("(did you forget to merge?"
1518 " use push -f to force)\n")) 1524 " use push -f to force)\n"))
1551 if lh in remotehds: 1557 if lh in remotehds:
1552 rheads = remotehds[lh] 1558 rheads = remotehds[lh]
1553 else: 1559 else:
1554 rheads = [] 1560 rheads = []
1555 lheads = localhds[lh] 1561 lheads = localhds[lh]
1556 updatelh = [upd for upd in update 1562 updatelb = [upd for upd in update
1557 if self[upd].branch() == lh] 1563 if self[upd].branch() == lh]
1558 if not updatelh: 1564 if not updatelb:
1559 continue 1565 continue
1560 if not checkbranch(lheads, rheads, updatelh): 1566 if not checkbranch(lheads, rheads, updatelb):
1561 return None, 0 1567 return None, 0
1562 else: 1568 else:
1563 if not checkbranch(heads, remote_heads, update): 1569 if not checkbranch(heads, remote_heads, update):
1564 return None, 0 1570 return None, 0
1565 1571