2
# Copyright (C) 2008, 2009 Canonical Ltd.
1
# Copyright (C) 2006-2011 Canonical Ltd.
3
2
# (Authored by Martin Albisetti <argentina@gmail.com>)
4
3
# Copyright (C) 2006 Robey Pointer <robey@lag.net>
5
4
# Copyright (C) 2006 Goffredo Baroncelli <kreijack@inwind.it>
327
327
revid in revid_list.
329
329
if revid_list is None:
330
revid_list = [r[0][1] for r in self._rev_info]
330
# Just yield the mainline, starting at start_revid
332
is_null = bzrlib.revision.is_null
333
while not is_null(revid):
335
parents = self._rev_info[self._rev_indices[revid]][2]
331
340
revid_set = set(revid_list)
332
341
revid = start_revid
340
349
r.add(self._rev_info[i][0][1])
344
353
if bzrlib.revision.is_null(revid):
346
if introduced_revisions(revid) & revid_set:
355
rev_introduced = introduced_revisions(revid)
356
matching = rev_introduced.intersection(revid_set)
358
# We don't need to look for these anymore.
359
revid_set.difference_update(matching)
348
361
parents = self._rev_info[self._rev_indices[revid]][2]
349
362
if len(parents) == 0:
464
477
if revid is None:
465
478
revid = self.last_revid
466
479
if file_id is not None:
467
# since revid is 'start_revid', possibly should start the path
468
# tracing from revid... FIXME
469
revlist = list(self.get_short_revision_history_by_fileid(file_id))
470
revlist = list(self.get_revids_from(revlist, revid))
481
self.get_short_revision_history_by_fileid(file_id))
482
revlist = self.get_revids_from(revlist, revid)
472
revlist = list(self.get_revids_from(None, revid))
484
revlist = self.get_revids_from(None, revid)
475
def get_view(self, revid, start_revid, file_id, query=None):
488
def _iterate_sufficiently(iterable, stop_at, extra_rev_count):
489
"""Return a list of iterable.
491
If extra_rev_count is None, fully consume iterable.
492
Otherwise, stop at 'stop_at' + extra_rev_count.
495
iterate until you find stop_at, then iterate 10 more times.
497
if extra_rev_count is None:
498
return list(iterable)
507
for count, n in enumerate(iterable):
508
if count >= extra_rev_count:
513
def get_view(self, revid, start_revid, file_id, query=None,
514
extra_rev_count=None):
477
516
use the URL parameters (revid, start_revid, file_id, and query) to
478
517
determine the revision list we're viewing (start_revid, file_id, query)
484
523
- if a start_revid is given, we're viewing the branch from a
485
524
specific revision up the tree.
525
- if extra_rev_count is given, find the view from start_revid =>
526
revid, and continue an additional 'extra_rev_count'. If not
527
given, then revid_list will contain the full history of
487
530
these may be combined to view revisions for a specific file, from
488
531
a specific revision, with a specific search query.
502
545
if query is None:
503
546
revid_list = self.get_file_view(start_revid, file_id)
547
revid_list = self._iterate_sufficiently(revid_list, revid,
504
549
if revid is None:
505
550
revid = start_revid
506
551
if revid not in revid_list:
507
552
# if the given revid is not in the revlist, use a revlist that
508
553
# starts at the given revid.
509
554
revid_list = self.get_file_view(revid, file_id)
555
revid_list = self._iterate_sufficiently(revid_list, revid,
510
557
start_revid = revid
511
558
return revid, start_revid, revid_list
672
719
if revision.revision_id in self._branch_tags:
673
revtags = ', '.join(self._branch_tags[revision.revision_id])
720
# tag.sort_* functions expect (tag, data) pairs, so we generate them,
721
# and then strip them
722
tags = [(t, None) for t in self._branch_tags[revision.revision_id]]
723
sort_func = getattr(tag, 'sort_natural', None)
724
if sort_func is None:
727
sort_func(self._branch, tags)
728
revtags = u', '.join([t[0] for t in tags])
676
731
'revid': revision.revision_id,
677
732
'date': datetime.datetime.fromtimestamp(revision.timestamp),
678
733
'utc_date': datetime.datetime.utcfromtimestamp(revision.timestamp),
734
'committer': revision.committer,
679
735
'authors': revision.get_apparent_authors(),
680
736
'branch_nick': revision.properties.get('branch-nick', None),
681
737
'short_comment': short_message,
688
744
if isinstance(revision, bzrlib.foreign.ForeignRevision):
689
foreign_revid, mapping = (rev.foreign_revid, rev.mapping)
745
foreign_revid, mapping = (
746
revision.foreign_revid, revision.mapping)
690
747
elif ":" in revision.revision_id:
692
749
foreign_revid, mapping = \