293
293
def iter_merge_sorted_revisions(self, start_revision_id=None,
294
stop_revision_id=None, direction='reverse'):
294
stop_revision_id=None, stop_rule='exclude', direction='reverse'):
295
295
"""Walk the revisions for a branch in merge sorted order.
297
297
Merge sorted order is the output from a merge-aware,
301
301
:param start_revision_id: the revision_id to begin walking from.
302
302
If None, the branch tip is used.
303
303
:param stop_revision_id: the revision_id to terminate the walk
304
after (i.e. the range is inclusive). If None, the rest of
304
after. If None, the rest of history is included.
305
:param stop_rule: if stop_revision_id is not None, the precise rule
306
to use for termination:
307
* 'exclude' - leave the stop revision out of the result (default)
308
* 'include' - the stop revision is the last item in the result
309
* 'with-merges' - include the stop revision and all of its
310
merged revisions in the result
306
311
:param direction: either 'reverse' or 'forward':
307
312
* reverse means return the start_revision_id first, i.e.
308
313
start at the most recent revision and go backwards in history
342
347
filtered = self._filter_merge_sorted_revisions(
343
348
self._merge_sorted_revisions_cache, start_revision_id,
349
stop_revision_id, stop_rule)
345
350
if direction == 'reverse':
347
352
if direction == 'forward':
350
355
raise ValueError('invalid direction %r' % direction)
352
357
def _filter_merge_sorted_revisions(self, merge_sorted_revisions,
353
start_revision_id, stop_revision_id):
358
start_revision_id, stop_revision_id, stop_rule):
354
359
"""Iterate over an inclusive range of sorted revisions."""
355
360
rev_iter = iter(merge_sorted_revisions)
356
361
if start_revision_id is not None:
358
363
if rev_id != start_revision_id:
361
yield rev_id, depth, revno, end_of_merge
366
# The decision to include the start or not
367
# depends on the stop_rule if a stop is provided
369
iter([(rev_id, depth, revno, end_of_merge)]),
363
for rev_id, depth, revno, end_of_merge in rev_iter:
364
yield rev_id, depth, revno, end_of_merge
365
if stop_revision_id is not None and rev_id == stop_revision_id:
372
if stop_revision_id is None:
373
for rev_id, depth, revno, end_of_merge in rev_iter:
374
yield rev_id, depth, revno, end_of_merge
375
elif stop_rule == 'exclude':
376
for rev_id, depth, revno, end_of_merge in rev_iter:
377
if rev_id == stop_revision_id:
379
yield rev_id, depth, revno, end_of_merge
380
elif stop_rule == 'include':
381
for rev_id, depth, revno, end_of_merge in rev_iter:
382
yield rev_id, depth, revno, end_of_merge
383
if rev_id == stop_revision_id:
385
elif stop_rule == 'with-merges':
386
stop_rev = self.repository.get_revision(stop_revision_id)
387
if stop_rev.parent_ids:
388
left_parent = stop_rev.parent_ids[0]
390
left_parent = _mod_revision.NULL_REVISION
391
for rev_id, depth, revno, end_of_merge in rev_iter:
392
if rev_id == left_parent:
394
yield rev_id, depth, revno, end_of_merge
396
raise ValueError('invalid stop_rule %r' % stop_rule)
368
398
def leave_lock_in_place(self):
369
399
"""Tell this branch object not to release the physical lock when this