505 def branchmap(self): |
505 def branchmap(self): |
506 '''returns a dictionary {branch: [branchheads]}''' |
506 '''returns a dictionary {branch: [branchheads]}''' |
507 self.updatebranchcache() |
507 self.updatebranchcache() |
508 return self._branchcache |
508 return self._branchcache |
509 |
509 |
|
510 def _branchtip(self, heads): |
|
511 '''return the tipmost branch head in heads''' |
|
512 tip = heads[-1] |
|
513 for h in reversed(heads): |
|
514 if 'close' not in self.changelog.read(h)[5]: |
|
515 tip = h |
|
516 break |
|
517 return tip |
|
518 |
|
519 def branchtip(self, branch): |
|
520 '''return the tip node for a given branch''' |
|
521 if branch not in self.branchmap(): |
|
522 raise error.RepoLookupError(_("unknown branch '%s'") % branch) |
|
523 return self._branchtip(self.branchmap()[branch]) |
|
524 |
510 def branchtags(self): |
525 def branchtags(self): |
511 '''return a dict where branch names map to the tipmost head of |
526 '''return a dict where branch names map to the tipmost head of |
512 the branch, open heads come before closed''' |
527 the branch, open heads come before closed''' |
513 bt = {} |
528 bt = {} |
514 for bn, heads in self.branchmap().iteritems(): |
529 for bn, heads in self.branchmap().iteritems(): |
515 tip = heads[-1] |
530 bt[bn] = self._branchtip(heads) |
516 for h in reversed(heads): |
|
517 if 'close' not in self.changelog.read(h)[5]: |
|
518 tip = h |
|
519 break |
|
520 bt[bn] = tip |
|
521 return bt |
531 return bt |
522 |
532 |
523 def _readbranchcache(self): |
533 def _readbranchcache(self): |
524 partial = {} |
534 partial = {} |
525 try: |
535 try: |