227
227
view_revs_iter = get_view_revisions(mainline_revs, rev_nos, branch,
228
228
direction, include_merges=include_merges)
229
229
if specific_fileid:
230
# find all the revisions that change the specific file
231
sfw = branch.repository.weave_store.get_weave(specific_fileid,
232
branch.repository.get_transaction())
233
sfw_revids = set(sfw.versions())
234
# build the ancestry of each revision in the graph
235
# - only listing the ancestors that change the specific file.
236
rev_graph = branch.repository.get_revision_graph(mainline_revs[-1])
237
sorted_rev_list = topo_sort(rev_graph)
239
for rev in sorted_rev_list:
241
if rev in sfw_revids:
242
rev_ancestry.add(rev)
243
for parent in rev_graph[rev]:
244
rev_ancestry = rev_ancestry.union(ancestry[parent])
245
ancestry[rev] = rev_ancestry
247
def is_merging_rev():
248
parents = rev_graph[r]
250
leftparent = parents[0]
251
for rightparent in parents[1:]:
252
if not ancestry[leftparent].issuperset(
253
ancestry[rightparent]):
257
# filter from the view the revisions that did not change or merge
259
view_revisions = [(r, n, d) for r, n, d in view_revs_iter if
260
r in sfw_revids or is_merging_rev()]
230
view_revisions = _get_revisions_touching_file_id(branch,
262
235
view_revisions = list(view_revs_iter)
302
275
lf.show_merge_revno(rev, merge_depth, revno)
278
def _get_revisions_touching_file_id(branch, file_id, mainline_revisions,
280
"""Return the list of revision ids which touch a given file id.
282
This includes the revisions which directly change the file id,
283
and the revisions which merge these changes. So if the
291
And 'C' changes a file, then both C and D will be returned.
293
This will also can be restricted based on a subset of the mainline.
295
# find all the revisions that change the specific file
296
sfw = branch.repository.weave_store.get_weave(file_id,
297
branch.repository.get_transaction())
298
sfw_revids = set(sfw.versions())
299
# build the ancestry of each revision in the graph
300
# - only listing the ancestors that change the specific file.
301
rev_graph = branch.repository.get_revision_graph(mainline_revisions[-1])
302
sorted_rev_list = topo_sort(rev_graph)
304
for rev in sorted_rev_list:
306
if rev in sfw_revids:
307
rev_ancestry.add(rev)
308
for parent in rev_graph[rev]:
309
rev_ancestry = rev_ancestry.union(ancestry[parent])
310
ancestry[rev] = rev_ancestry
312
def is_merging_rev():
313
parents = rev_graph[r]
315
leftparent = parents[0]
316
for rightparent in parents[1:]:
317
if not ancestry[leftparent].issuperset(
318
ancestry[rightparent]):
322
# filter from the view the revisions that did not change or merge
324
return [(r, n, d) for r, n, d in view_revs_iter
325
if r in sfw_revids or is_merging_rev()]
305
328
def get_view_revisions(mainline_revs, rev_nos, branch, direction,
306
329
include_merges=True):
307
330
"""Produce an iterator of revisions to show