85
85
get_terminal_encoding,
88
from breezy.sixish import (
95
def find_touching_revisions(branch, file_id):
93
from .tree import find_previous_path
96
def find_touching_revisions(repository, last_revision, last_tree, last_path):
96
97
"""Yield a description of revisions which affect the file_id.
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?
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)
115
this_path = this_tree.id2path(file_id)
116
except errors.NoSuchId:
117
this_verifier = this_path = None
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, []))
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)
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?
124
if not this_verifier and not last_verifier:
125
# not present in either
127
elif this_verifier and not last_verifier:
128
yield revno, revision_id, "added " + this_path
129
elif not this_verifier and last_verifier:
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)
126
this_verifier = this_tree.get_file_verifier(this_path)
127
if (this_verifier != last_verifier):
128
yield revno, revision_id, "modified " + this_path
137
130
last_verifier = this_verifier
138
131
last_path = this_path
132
last_tree = this_tree
133
if last_path is None:
142
138
def show_log(branch,