/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/log.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
    range,
90
90
    zip,
91
91
    )
92
 
from .tree import InterTree
 
92
from .tree import find_previous_path
93
93
 
94
94
 
95
95
def find_touching_revisions(repository, last_revision, last_tree, last_path):
109
109
    revno = len(history)
110
110
    for revision_id in history:
111
111
        this_tree = repository.revision_tree(revision_id)
112
 
        this_intertree = InterTree.get(this_tree, last_tree)
113
 
        this_path = this_intertree.find_source_path(last_path)
 
112
        this_path = find_previous_path(last_tree, this_tree, last_path)
114
113
 
115
114
        # now we know how it was last time, and how it is in this revision.
116
115
        # are those two states effectively the same or not?
137
136
 
138
137
def show_log(branch,
139
138
             lf,
 
139
             specific_fileid=None,
140
140
             verbose=False,
141
141
             direction='reverse',
142
142
             start_revision=None,
154
154
 
155
155
    :param lf: The LogFormatter object showing the output.
156
156
 
 
157
    :param specific_fileid: If not None, list only the commits affecting the
 
158
        specified file, rather than all commits.
 
159
 
157
160
    :param verbose: If True show added/changed/deleted/renamed files.
158
161
 
159
162
    :param direction: 'reverse' (default) is latest to earliest; 'forward' is
174
177
    :param match: Dictionary of search lists to use when matching revision
175
178
      properties.
176
179
    """
 
180
    # Convert old-style parameters to new-style parameters
 
181
    if specific_fileid is not None:
 
182
        file_ids = [specific_fileid]
 
183
    else:
 
184
        file_ids = None
177
185
    if verbose:
178
 
        delta_type = 'full'
 
186
        if file_ids:
 
187
            delta_type = 'partial'
 
188
        else:
 
189
            delta_type = 'full'
179
190
    else:
180
191
        delta_type = None
181
192
    if show_diff:
182
 
        diff_type = 'full'
 
193
        if file_ids:
 
194
            diff_type = 'partial'
 
195
        else:
 
196
            diff_type = 'full'
183
197
    else:
184
198
        diff_type = None
185
199
 
199
213
        raise errors.InvalidRevisionNumber(end_revision.revno)
200
214
 
201
215
    # Build the request and execute it
202
 
    rqst = make_log_request_dict(
203
 
        direction=direction,
204
 
        start_revision=start_revision, end_revision=end_revision,
205
 
        limit=limit, message_search=search,
206
 
        delta_type=delta_type, diff_type=diff_type)
 
216
    rqst = make_log_request_dict(direction=direction, specific_fileids=file_ids,
 
217
                                 start_revision=start_revision, end_revision=end_revision,
 
218
                                 limit=limit, message_search=search,
 
219
                                 delta_type=delta_type, diff_type=diff_type)
207
220
    Logger(branch, rqst).show(lf)
208
221
 
209
222
 
734
747
    repo = branch.repository
735
748
    graph = repo.get_graph()
736
749
    if start_rev_id is None and end_rev_id is None:
737
 
        if branch._format.stores_revno() or \
738
 
                config.GlobalStack().get('calculate_revnos'):
739
 
            try:
740
 
                br_revno, br_rev_id = branch.last_revision_info()
741
 
            except errors.GhostRevisionsHaveNoRevno:
742
 
                br_rev_id = branch.last_revision()
743
 
                cur_revno = None
744
 
            else:
745
 
                cur_revno = br_revno
746
 
        else:
 
750
        try:
 
751
            br_revno, br_rev_id = branch.last_revision_info()
 
752
        except errors.GhostRevisionsHaveNoRevno:
747
753
            br_rev_id = branch.last_revision()
748
754
            cur_revno = None
749
 
 
 
755
        else:
 
756
            cur_revno = br_revno
750
757
        graph_iter = graph.iter_lefthand_ancestry(br_rev_id,
751
758
                                                  (_mod_revision.NULL_REVISION,))
752
759
        while True:
1017
1024
      fileids set once their add or remove entry is detected respectively
1018
1025
    """
1019
1026
    if stop_on == 'add':
1020
 
        for item in delta.added + delta.copied:
1021
 
            if item.file_id in fileids:
1022
 
                fileids.remove(item.file_id)
 
1027
        for item in delta.added:
 
1028
            if item[1] in fileids:
 
1029
                fileids.remove(item[1])
1023
1030
    elif stop_on == 'delete':
1024
1031
        for item in delta.removed:
1025
 
            if item.file_id in fileids:
1026
 
                fileids.remove(item.file_id)
 
1032
            if item[1] in fileids:
 
1033
                fileids.remove(item[1])
1027
1034
 
1028
1035
 
1029
1036
def _make_revision_objects(branch, generate_delta, search, log_rev_iterator):
1098
1105
            raise TypeError(start_revision)
1099
1106
        end_rev_id = end_revision.rev_id
1100
1107
        end_revno = end_revision.revno
 
1108
    if end_revno is None:
 
1109
        try:
 
1110
            end_revno = branch.revno()
 
1111
        except errors.GhostRevisionsHaveNoRevno:
 
1112
            end_revno = None
1101
1113
 
1102
1114
    if branch.last_revision() != _mod_revision.NULL_REVISION:
1103
1115
        if (start_rev_id == _mod_revision.NULL_REVISION
1795
1807
 
1796
1808
        if revision.delta is not None and revision.delta.has_changed():
1797
1809
            for c in revision.delta.added + revision.delta.removed + revision.delta.modified:
1798
 
                if c.path[0] is None:
1799
 
                    path = c.path[1]
1800
 
                else:
1801
 
                    path = c.path[0]
 
1810
                path, = c[:1]
1802
1811
                to_file.write('\t* %s:\n' % (path,))
1803
 
            for c in revision.delta.renamed + revision.delta.copied:
 
1812
            for c in revision.delta.renamed:
 
1813
                oldpath, newpath = c[:2]
1804
1814
                # For renamed files, show both the old and the new path
1805
 
                to_file.write('\t* %s:\n\t* %s:\n' % (c.path[0], c.path[1]))
 
1815
                to_file.write('\t* %s:\n\t* %s:\n' % (oldpath, newpath))
1806
1816
            to_file.write('\n')
1807
1817
 
1808
1818
        if not revision.rev.message:
1939
1949
        to_file.write('Added Revisions:\n')
1940
1950
        show_log(branch,
1941
1951
                 lf,
 
1952
                 None,
1942
1953
                 verbose=False,
1943
1954
                 direction='forward',
1944
1955
                 start_revision=base_idx + 1,
2023
2034
    if new_history != []:
2024
2035
        output.write('Added Revisions:\n')
2025
2036
        start_revno = new_revno - len(new_history) + 1
2026
 
        show_log(branch, lf, verbose=False, direction='forward',
 
2037
        show_log(branch, lf, None, verbose=False, direction='forward',
2027
2038
                 start_revision=start_revno)
2028
2039
 
2029
2040
 
2041
2052
        lf.log_revision(lr)
2042
2053
 
2043
2054
 
2044
 
def _get_info_for_log_files(revisionspec_list, file_list, exit_stack):
 
2055
def _get_info_for_log_files(revisionspec_list, file_list, add_cleanup):
2045
2056
    """Find file-ids and kinds given a list of files and a revision range.
2046
2057
 
2047
2058
    We search for files at the end of the range. If not found there,
2051
2062
    :param file_list: the list of paths given on the command line;
2052
2063
      the first of these can be a branch location or a file path,
2053
2064
      the remainder must be file paths
2054
 
    :param exit_stack: When the branch returned is read locked,
2055
 
      an unlock call will be queued to the exit stack.
 
2065
    :param add_cleanup: When the branch returned is read locked,
 
2066
      an unlock call will be queued to the cleanup.
2056
2067
    :return: (branch, info_list, start_rev_info, end_rev_info) where
2057
2068
      info_list is a list of (relative_path, file_id, kind) tuples where
2058
2069
      kind is one of values 'directory', 'file', 'symlink', 'tree-reference'.
2061
2072
    from breezy.builtins import _get_revision_range
2062
2073
    tree, b, path = controldir.ControlDir.open_containing_tree_or_branch(
2063
2074
        file_list[0])
2064
 
    exit_stack.enter_context(b.lock_read())
 
2075
    add_cleanup(b.lock_read().unlock)
2065
2076
    # XXX: It's damn messy converting a list of paths to relative paths when
2066
2077
    # those paths might be deleted ones, they might be on a case-insensitive
2067
2078
    # filesystem and/or they might be in silly locations (like another branch).