~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2005-05-05 23:28:03 UTC
  • Revision ID: mbp@sourcefrog.net-20050505232803-e7717bfd6c7cac69
- New Branch.enum_history method

Show diffs side-by-side

added added

removed removed

Lines of Context:
691
691
        return [l.rstrip('\r\n') for l in self.controlfile('revision-history', 'r').readlines()]
692
692
 
693
693
 
 
694
    def enum_history(self, direction):
 
695
        """Return (revno, revision_id) for history of branch.
 
696
 
 
697
        direction
 
698
            'forward' is from earliest to latest
 
699
            'reverse' is from latest to earliest
 
700
        """
 
701
        rh = self.revision_history()
 
702
        if direction == 'forward':
 
703
            i = 1
 
704
            for rid in rh:
 
705
                yield i, rid
 
706
                i += 1
 
707
        elif direction == 'reverse':
 
708
            i = len(rh)
 
709
            while i > 0:
 
710
                yield i, rh[i-1]
 
711
                i -= 1
 
712
        else:
 
713
            raise BzrError('invalid history direction %r' % direction)
 
714
 
 
715
 
694
716
    def revno(self):
695
717
        """Return current revision number for this branch.
696
718