~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/history.py

  • Committer: John Arbash Meinel
  • Date: 2011-03-16 12:39:56 UTC
  • mfrom: (432.2.8 authors-733015)
  • Revision ID: john@arbash-meinel.com-20110316123956-6jherozycdjmt9px
Fix bug #733015. Have a separate Author(s) line from Committer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd.
 
1
#
 
2
# Copyright (C) 2008, 2009 Canonical Ltd.
2
3
#                     (Authored by Martin Albisetti <argentina@gmail.com>)
3
4
# Copyright (C) 2006  Robey Pointer <robey@lag.net>
4
5
# Copyright (C) 2006  Goffredo Baroncelli <kreijack@inwind.it>
33
34
import re
34
35
import textwrap
35
36
import threading
36
 
import tarfile
37
37
 
38
38
from bzrlib import tag
39
39
import bzrlib.branch
45
45
from loggerhead import search
46
46
from loggerhead import util
47
47
from loggerhead.wholehistory import compute_whole_history_data
48
 
from bzrlib.export.tar_exporter import export_tarball
49
48
 
50
49
 
51
50
def is_branch(folder):
351
350
                r.add(self._rev_info[i][0][1])
352
351
                i += 1
353
352
            return r
354
 
        while revid_set:
 
353
        while True:
355
354
            if bzrlib.revision.is_null(revid):
356
355
                return
357
 
            rev_introduced = introduced_revisions(revid)
358
 
            matching = rev_introduced.intersection(revid_set)
359
 
            if matching:
360
 
                # We don't need to look for these anymore.
361
 
                revid_set.difference_update(matching)
 
356
            if introduced_revisions(revid) & revid_set:
362
357
                yield revid
363
358
            parents = self._rev_info[self._rev_indices[revid]][2]
364
359
            if len(parents) == 0:
479
474
        if revid is None:
480
475
            revid = self.last_revid
481
476
        if file_id is not None:
482
 
            revlist = list(
483
 
                self.get_short_revision_history_by_fileid(file_id))
484
 
            revlist = self.get_revids_from(revlist, revid)
 
477
            # since revid is 'start_revid', possibly should start the path
 
478
            # tracing from revid... FIXME
 
479
            revlist = list(self.get_short_revision_history_by_fileid(file_id))
 
480
            revlist = list(self.get_revids_from(revlist, revid))
485
481
        else:
486
 
            revlist = self.get_revids_from(None, revid)
 
482
            revlist = list(self.get_revids_from(None, revid))
487
483
        return revlist
488
484
 
489
 
    @staticmethod
490
 
    def _iterate_sufficiently(iterable, stop_at, extra_rev_count):
491
 
        """Return a list of iterable.
492
 
 
493
 
        If extra_rev_count is None, fully consume iterable.
494
 
        Otherwise, stop at 'stop_at' + extra_rev_count.
495
 
 
496
 
        Example:
497
 
          iterate until you find stop_at, then iterate 10 more times.
498
 
        """
499
 
        if extra_rev_count is None:
500
 
            return list(iterable)
501
 
        result = []
502
 
        found = False
503
 
        for n in iterable:
504
 
            result.append(n)
505
 
            if n == stop_at:
506
 
                found = True
507
 
                break
508
 
        if found:
509
 
            for count, n in enumerate(iterable):
510
 
                if count >= extra_rev_count:
511
 
                    break
512
 
                result.append(n)
513
 
        return result
514
 
 
515
 
    def get_view(self, revid, start_revid, file_id, query=None,
516
 
                 extra_rev_count=None):
 
485
    def get_view(self, revid, start_revid, file_id, query=None):
517
486
        """
518
487
        use the URL parameters (revid, start_revid, file_id, and query) to
519
488
        determine the revision list we're viewing (start_revid, file_id, query)
524
493
              file.
525
494
            - if a start_revid is given, we're viewing the branch from a
526
495
              specific revision up the tree.
527
 
            - if extra_rev_count is given, find the view from start_revid =>
528
 
              revid, and continue an additional 'extra_rev_count'. If not
529
 
              given, then revid_list will contain the full history of
530
 
              start_revid
531
496
 
532
497
        these may be combined to view revisions for a specific file, from
533
498
        a specific revision, with a specific search query.
546
511
 
547
512
        if query is None:
548
513
            revid_list = self.get_file_view(start_revid, file_id)
549
 
            revid_list = self._iterate_sufficiently(revid_list, revid,
550
 
                                                    extra_rev_count)
551
514
            if revid is None:
552
515
                revid = start_revid
553
516
            if revid not in revid_list:
554
517
                # if the given revid is not in the revlist, use a revlist that
555
518
                # starts at the given revid.
556
519
                revid_list = self.get_file_view(revid, file_id)
557
 
                revid_list = self._iterate_sufficiently(revid_list, revid,
558
 
                                                        extra_rev_count)
559
520
                start_revid = revid
560
521
            return revid, start_revid, revid_list
561
522
 
722
683
          # tag.sort_* functions expect (tag, data) pairs, so we generate them,
723
684
          # and then strip them
724
685
          tags = [(t, None) for t in self._branch_tags[revision.revision_id]]
725
 
          sort_func = getattr(tag, 'sort_natural', None)
726
 
          if sort_func is None:
727
 
              tags.sort()
728
 
          else:
729
 
              sort_func(self._branch, tags)
 
686
          tag.sort_natural(self._branch, tags)
730
687
          revtags = u', '.join([t[0] for t in tags])
731
688
 
732
689
        entry = {
744
701
            'tags': revtags,
745
702
        }
746
703
        if isinstance(revision, bzrlib.foreign.ForeignRevision):
747
 
            foreign_revid, mapping = (
748
 
                revision.foreign_revid, revision.mapping)
 
704
            foreign_revid, mapping = (rev.foreign_revid, rev.mapping)
749
705
        elif ":" in revision.revision_id:
750
706
            try:
751
707
                foreign_revid, mapping = \
818
774
            renamed=sorted(reporter.renamed, key=lambda x: x.new_filename),
819
775
            removed=sorted(reporter.removed, key=lambda x: x.filename),
820
776
            modified=sorted(reporter.modified, key=lambda x: x.filename),
821
 
            text_changes=sorted(reporter.text_changes,
822
 
                                key=lambda x: x.filename))
823
 
 
 
777
            text_changes=sorted(reporter.text_changes, key=lambda x: x.filename))