If I enter the code:
b = Branch.open('directory containing repository')
r1 = 1010 #input revision number
r2 = r1-5 #last revision number that I want to sort to
r1 = b.dotted_revno_to_revision_id((r1,), _cache_reverse=False) #revision ids of r1 and r2
r2 = b.dotted_revno_to_revision_id((r2,), _cache_reverse=False)
test = b.iter_merge_sorted_revisions(start_revision_id=r1, stop_revision_id=r2, stop_rule='include', direction = 'reverse')
for i in test:
print i[0]
The iter_merge_sorted_revisions is supposed to return an iterator over (revision_id, depth, revno, end_of_merge) tuples.
So when I print all of the i[0] it should return to me all of the revision_ids between r1 and r2.
And it DOES return them to me all the way up to r2. But I keep on getting an error that stops the rest of my code from running once that for loop finishes.
The error code is as follows:
Traceback (most recent call last):
File "log.py", line 60, in <module>
for i in revisions:
File "/usr/lib/python2.7/dist-packages/bzrlib/branch.py", line 634, in _filter_start_non_ancestors
pmap = self.repository.get_parent_map([rev_id])
File "/usr/lib/python2.7/dist-packages/bzrlib/vf_repository.py", line 1882, in get_parent_map
self.revisions.get_parent_map(query_keys).iteritems():
File "/usr/lib/python2.7/dist-packages/bzrlib/groupcompress.py", line 1356, in get_parent_map
return self._get_parent_map_with_sources(keys)[0]
File "/usr/lib/python2.7/dist-packages/bzrlib/groupcompress.py", line 1375, in _get_parent_map_with_sources
new_result = source.get_parent_map(missing)
File "/usr/lib/python2.7/dist-packages/bzrlib/groupcompress.py", line 2093, in get_parent_map
self._check_read()
File "/usr/lib/python2.7/dist-packages/bzrlib/groupcompress.py", line 2051, in _check_read
raise errors.ObjectNotLocked(self)
bzrlib.errors.ObjectNotLocked: <bzrlib.groupcompress._GCGraphIndex object at 0x7fd55e846390> is not locked
I do not know what is going wrong because the for loop is completed since it does return to me the last revision that I want. I don't know if I need to somehow manually end the loop, but any ideas are appreciated!
You need to take a read lock on the branch before you can access it: