/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: 2018-03-24 17:48:04 UTC
  • mfrom: (6921 work)
  • mto: This revision was merged to the branch mainline in revision 6923.
  • Revision ID: jelmer@jelmer.uk-20180324174804-xf22o05byoj12x1q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
    config,
65
65
    controldir,
66
66
    diff,
67
 
    errors,
68
67
    foreign,
69
68
    repository as _mod_repository,
70
69
    revision as _mod_revision,
74
73
""")
75
74
 
76
75
from . import (
 
76
    errors,
77
77
    lazy_regex,
78
78
    registry,
79
79
    revisionspec,
85
85
    get_terminal_encoding,
86
86
    terminal_width,
87
87
    )
88
 
from breezy.sixish import (
 
88
from .sixish import (
89
89
    BytesIO,
90
90
    range,
91
91
    zip,
92
92
    )
93
 
 
94
 
 
95
 
def find_touching_revisions(branch, file_id):
 
93
from .tree import find_previous_path
 
94
 
 
95
 
 
96
def find_touching_revisions(repository, last_revision, last_tree, last_path):
96
97
    """Yield a description of revisions which affect the file_id.
97
98
 
98
99
    Each returned element is (revno, revision_id, description)
103
104
    TODO: Perhaps some way to limit this to only particular revisions,
104
105
    or to traverse a non-mainline set of revisions?
105
106
    """
106
 
    last_verifier = None
107
 
    last_path = None
108
 
    revno = 1
109
 
    graph = branch.repository.get_graph()
110
 
    history = list(graph.iter_lefthand_ancestry(branch.last_revision(),
111
 
        [_mod_revision.NULL_REVISION]))
112
 
    for revision_id in reversed(history):
113
 
        this_tree = branch.repository.revision_tree(revision_id)
114
 
        try:
115
 
            this_path = this_tree.id2path(file_id)
116
 
        except errors.NoSuchId:
117
 
            this_verifier = this_path = None
118
 
        else:
119
 
            this_verifier = this_tree.get_file_verifier(this_path, file_id)
 
107
    last_verifier = last_tree.get_file_verifier(last_path)
 
108
    graph = repository.get_graph()
 
109
    history = list(graph.iter_lefthand_ancestry(last_revision, []))
 
110
    revno = len(history)
 
111
    for revision_id in history:
 
112
        this_tree = repository.revision_tree(revision_id)
 
113
        this_path = find_previous_path(last_tree, this_tree, last_path)
120
114
 
121
115
        # now we know how it was last time, and how it is in this revision.
122
116
        # are those two states effectively the same or not?
123
 
 
124
 
        if not this_verifier and not last_verifier:
125
 
            # not present in either
126
 
            pass
127
 
        elif this_verifier and not last_verifier:
128
 
            yield revno, revision_id, "added " + this_path
129
 
        elif not this_verifier and last_verifier:
130
 
            # deleted here
131
 
            yield revno, revision_id, "deleted " + last_path
 
117
        if this_path is not None and last_path is None:
 
118
            yield revno, revision_id, "deleted " + this_path
 
119
            this_verifier = this_tree.get_file_verifier(this_path)
 
120
        elif this_path is None and last_path is not None:
 
121
            yield revno, revision_id, "added " + last_path
132
122
        elif this_path != last_path:
133
 
            yield revno, revision_id, ("renamed %s => %s" % (last_path, this_path))
134
 
        elif (this_verifier != last_verifier):
135
 
            yield revno, revision_id, "modified " + this_path
 
123
            yield revno, revision_id, ("renamed %s => %s" % (this_path, last_path))
 
124
            this_verifier = this_tree.get_file_verifier(this_path)
 
125
        else:
 
126
            this_verifier = this_tree.get_file_verifier(this_path)
 
127
            if (this_verifier != last_verifier):
 
128
                yield revno, revision_id, "modified " + this_path
136
129
 
137
130
        last_verifier = this_verifier
138
131
        last_path = this_path
139
 
        revno += 1
 
132
        last_tree = this_tree
 
133
        if last_path is None:
 
134
            return
 
135
        revno -= 1
140
136
 
141
137
 
142
138
def show_log(branch,