~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:13:13 UTC
  • mfrom: (6614.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201191313-wdfvmfff1djde6oq
(vila) Release 2.7.0 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
 
18
 
 
19
17
"""Code to show logs of changes.
20
18
 
21
19
Various flavors of log can be produced:
49
47
all the changes since the previous revision that touched hello.c.
50
48
"""
51
49
 
 
50
from __future__ import absolute_import
 
51
 
52
52
import codecs
53
53
from cStringIO import StringIO
54
54
from itertools import (
138
138
        revno += 1
139
139
 
140
140
 
141
 
def _enumerate_history(branch):
142
 
    rh = []
143
 
    revno = 1
144
 
    for rev_id in branch.revision_history():
145
 
        rh.append((revno, rev_id))
146
 
        revno += 1
147
 
    return rh
148
 
 
149
 
 
150
141
def show_log(branch,
151
142
             lf,
152
143
             specific_fileid=None,
343
334
    gpg_strategy = gpg.GPGStrategy(None)
344
335
    result = repo.verify_revision_signature(rev_id, gpg_strategy)
345
336
    if result[0] == gpg.SIGNATURE_VALID:
346
 
        return "valid signature from {0}".format(result[1])
 
337
        return u"valid signature from {0}".format(result[1])
347
338
    if result[0] == gpg.SIGNATURE_KEY_MISSING:
348
339
        return "unknown key {0}".format(result[1])
349
340
    if result[0] == gpg.SIGNATURE_NOT_VALID:
580
571
        and (not generate_merge_revisions
581
572
             or not _has_merges(branch, end_rev_id))):
582
573
        # If a single revision is requested, check we can handle it
583
 
        iter_revs = _generate_one_revision(branch, end_rev_id, br_rev_id,
584
 
                                           br_revno)
585
 
    elif not generate_merge_revisions:
586
 
        # If we only want to see linear revisions, we can iterate ...
587
 
        iter_revs = _generate_flat_revisions(branch, start_rev_id, end_rev_id,
588
 
                                             direction, exclude_common_ancestry)
589
 
        if direction == 'forward':
590
 
            iter_revs = reversed(iter_revs)
591
 
    else:
592
 
        iter_revs = _generate_all_revisions(branch, start_rev_id, end_rev_id,
593
 
                                            direction, delayed_graph_generation,
594
 
                                            exclude_common_ancestry)
595
 
        if direction == 'forward':
596
 
            iter_revs = _rebase_merge_depth(reverse_by_depth(list(iter_revs)))
 
574
        return  _generate_one_revision(branch, end_rev_id, br_rev_id,
 
575
                                       br_revno)
 
576
    if not generate_merge_revisions:
 
577
        try:
 
578
            # If we only want to see linear revisions, we can iterate ...
 
579
            iter_revs = _linear_view_revisions(
 
580
                branch, start_rev_id, end_rev_id,
 
581
                exclude_common_ancestry=exclude_common_ancestry)
 
582
            # If a start limit was given and it's not obviously an
 
583
            # ancestor of the end limit, check it before outputting anything
 
584
            if (direction == 'forward'
 
585
                or (start_rev_id and not _is_obvious_ancestor(
 
586
                        branch, start_rev_id, end_rev_id))):
 
587
                    iter_revs = list(iter_revs)
 
588
            if direction == 'forward':
 
589
                iter_revs = reversed(iter_revs)
 
590
            return iter_revs
 
591
        except _StartNotLinearAncestor:
 
592
            # Switch to the slower implementation that may be able to find a
 
593
            # non-obvious ancestor out of the left-hand history.
 
594
            pass
 
595
    iter_revs = _generate_all_revisions(branch, start_rev_id, end_rev_id,
 
596
                                        direction, delayed_graph_generation,
 
597
                                        exclude_common_ancestry)
 
598
    if direction == 'forward':
 
599
        iter_revs = _rebase_merge_depth(reverse_by_depth(list(iter_revs)))
597
600
    return iter_revs
598
601
 
599
602
 
606
609
        return [(rev_id, revno_str, 0)]
607
610
 
608
611
 
609
 
def _generate_flat_revisions(branch, start_rev_id, end_rev_id, direction,
610
 
                             exclude_common_ancestry=False):
611
 
    result = _linear_view_revisions(
612
 
        branch, start_rev_id, end_rev_id,
613
 
        exclude_common_ancestry=exclude_common_ancestry)
614
 
    # If a start limit was given and it's not obviously an
615
 
    # ancestor of the end limit, check it before outputting anything
616
 
    if direction == 'forward' or (start_rev_id
617
 
        and not _is_obvious_ancestor(branch, start_rev_id, end_rev_id)):
618
 
        try:
619
 
            result = list(result)
620
 
        except _StartNotLinearAncestor:
621
 
            raise errors.BzrCommandError(gettext('Start revision not found in'
622
 
                ' left-hand history of end revision.'))
623
 
    return result
624
 
 
625
 
 
626
612
def _generate_all_revisions(branch, start_rev_id, end_rev_id, direction,
627
613
                            delayed_graph_generation,
628
614
                            exclude_common_ancestry=False):
2028
2014
      kind is one of values 'directory', 'file', 'symlink', 'tree-reference'.
2029
2015
      branch will be read-locked.
2030
2016
    """
2031
 
    from builtins import _get_revision_range
 
2017
    from bzrlib.builtins import _get_revision_range
2032
2018
    tree, b, path = controldir.ControlDir.open_containing_tree_or_branch(
2033
2019
        file_list[0])
2034
2020
    add_cleanup(b.lock_read().unlock)