91
91
self._revision_history_cache = None
92
92
self._revision_id_to_revno_cache = None
93
93
self._partial_revision_id_to_revno_cache = {}
94
self._partial_revision_history_cache = []
94
95
self._last_revision_info_cache = None
95
96
self._merge_sorted_revisions_cache = None
125
126
raise errors.UnstackableRepositoryFormat(self.repository._format,
126
127
self.repository.base)
129
def _extend_partial_history(self, stop_index=None, stop_revision=None):
130
"""Extend the partial history to include a given index
132
If a stop_index is supplied, stop when that index has been reached.
133
If a stop_revision is supplied, stop when that revision is
134
encountered. Otherwise, stop when the beginning of history is
137
:param stop_index: The index which should be present. When it is
138
present, history extension will stop.
139
:param revision_id: The revision id which should be present. When
140
it is encountered, history extension will stop.
142
repo = self.repository
143
if len(self._partial_revision_history_cache) == 0:
144
iterator = repo.iter_reverse_revision_history(self.last_revision())
146
start_revision = self._partial_revision_history_cache[-1]
147
iterator = repo.iter_reverse_revision_history(start_revision)
148
#skip the last revision in the list
149
next_revision = iterator.next()
150
for revision_id in iterator:
151
self._partial_revision_history_cache.append(revision_id)
152
if (stop_index is not None and
153
len(self._partial_revision_history_cache) > stop_index):
155
if revision_id == stop_revision:
129
159
def open(base, _unsupported=False, possible_transports=None):
130
160
"""Open the branch rooted at base.
698
728
self._revision_id_to_revno_cache = None
699
729
self._last_revision_info_cache = None
700
730
self._merge_sorted_revisions_cache = None
731
self._partial_revision_history_cache = []
732
self._partial_revision_id_to_revno_cache = {}
702
734
def _gen_revision_history(self):
703
735
"""Return sequence of revision hashes on to this branch.
831
863
except ValueError:
832
864
raise errors.NoSuchRevision(self, revision_id)
834
867
def get_rev_id(self, revno, history=None):
835
868
"""Find the revision id of the specified revno."""
837
870
return _mod_revision.NULL_REVISION
839
history = self.revision_history()
840
if revno <= 0 or revno > len(history):
871
last_revno, last_revid = self.last_revision_info()
872
if revno == last_revno:
874
if revno <= 0 or revno > last_revno:
841
875
raise errors.NoSuchRevision(self, revno)
842
return history[revno - 1]
876
distance_from_last = last_revno - revno
877
if len(self._partial_revision_history_cache) <= distance_from_last:
878
self._extend_partial_history(revno)
879
return self._partial_revision_history_cache[revno]
844
881
@needs_write_lock
845
882
def pull(self, source, overwrite=False, stop_revision=None,
2376
2413
self._ignore_fallbacks = kwargs.get('ignore_fallbacks', False)
2377
2414
super(BzrBranch8, self).__init__(*args, **kwargs)
2378
2415
self._last_revision_info_cache = None
2379
self._partial_revision_history_cache = []
2380
2416
self._reference_info = None
2382
2418
def _clear_cached_state(self):
2383
2419
super(BzrBranch8, self)._clear_cached_state()
2384
2420
self._last_revision_info_cache = None
2385
self._partial_revision_history_cache = []
2386
2421
self._reference_info = None
2388
2423
def _last_revision_info(self):
2444
2479
self._extend_partial_history(stop_index=last_revno-1)
2445
2480
return list(reversed(self._partial_revision_history_cache))
2447
def _extend_partial_history(self, stop_index=None, stop_revision=None):
2448
"""Extend the partial history to include a given index
2450
If a stop_index is supplied, stop when that index has been reached.
2451
If a stop_revision is supplied, stop when that revision is
2452
encountered. Otherwise, stop when the beginning of history is
2455
:param stop_index: The index which should be present. When it is
2456
present, history extension will stop.
2457
:param revision_id: The revision id which should be present. When
2458
it is encountered, history extension will stop.
2460
repo = self.repository
2461
if len(self._partial_revision_history_cache) == 0:
2462
iterator = repo.iter_reverse_revision_history(self.last_revision())
2464
start_revision = self._partial_revision_history_cache[-1]
2465
iterator = repo.iter_reverse_revision_history(start_revision)
2466
#skip the last revision in the list
2467
next_revision = iterator.next()
2468
for revision_id in iterator:
2469
self._partial_revision_history_cache.append(revision_id)
2470
if (stop_index is not None and
2471
len(self._partial_revision_history_cache) > stop_index):
2473
if revision_id == stop_revision:
2476
2482
def _write_revision_history(self, history):
2477
2483
"""Factored out of set_revision_history.