[Pkg-bazaar-commits] ./bzr/unstable r385: - New Branch.enum_history method
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 07:43:41 UTC 2009
------------------------------------------------------------
revno: 385
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Fri 2005-05-06 09:28:03 +1000
message:
- New Branch.enum_history method
modified:
bzrlib/branch.py
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2005-05-05 06:59:12 +0000
+++ b/bzrlib/branch.py 2005-05-05 23:28:03 +0000
@@ -691,6 +691,28 @@
return [l.rstrip('\r\n') for l in self.controlfile('revision-history', 'r').readlines()]
+ def enum_history(self, direction):
+ """Return (revno, revision_id) for history of branch.
+
+ direction
+ 'forward' is from earliest to latest
+ 'reverse' is from latest to earliest
+ """
+ rh = self.revision_history()
+ if direction == 'forward':
+ i = 1
+ for rid in rh:
+ yield i, rid
+ i += 1
+ elif direction == 'reverse':
+ i = len(rh)
+ while i > 0:
+ yield i, rh[i-1]
+ i -= 1
+ else:
+ raise BzrError('invalid history direction %r' % direction)
+
+
def revno(self):
"""Return current revision number for this branch.
More information about the Pkg-bazaar-commits
mailing list