278
@deprecated_function(one_zero)
279
def diff_cmd_helper(tree, specific_files, external_diff_options,
280
old_revision_spec=None, new_revision_spec=None,
282
old_label='a/', new_label='b/'):
283
"""Helper for cmd_diff.
288
:param specific_files:
289
The specific files to compare, or None
291
:param external_diff_options:
292
If non-None, run an external diff, and pass it these options
294
:param old_revision_spec:
295
If None, use basis tree as old revision, otherwise use the tree for
296
the specified revision.
298
:param new_revision_spec:
299
If None, use working tree as new revision, otherwise use the tree for
300
the specified revision.
302
:param revision_specs:
303
Zero, one or two RevisionSpecs from the command line, saying what revisions
304
to compare. This can be passed as an alternative to the old_revision_spec
305
and new_revision_spec parameters.
307
The more general form is show_diff_trees(), where the caller
308
supplies any two trees.
311
# TODO: perhaps remove the old parameters old_revision_spec and
312
# new_revision_spec, since this is only really for use from cmd_diff and
313
# it now always passes through a sequence of revision_specs -- mbp
318
revision = spec.in_store(tree.branch)
320
revision = spec.in_store(None)
321
revision_id = revision.rev_id
322
branch = revision.branch
323
return branch.repository.revision_tree(revision_id)
325
if revision_specs is not None:
326
if len(revision_specs) > 0:
327
old_revision_spec = revision_specs[0]
328
if len(revision_specs) > 1:
329
new_revision_spec = revision_specs[1]
331
if old_revision_spec is None:
332
old_tree = tree.basis_tree()
334
old_tree = spec_tree(old_revision_spec)
336
if (new_revision_spec is None
337
or new_revision_spec.spec is None):
340
new_tree = spec_tree(new_revision_spec)
342
if new_tree is not tree:
343
extra_trees = (tree,)
347
return show_diff_trees(old_tree, new_tree, sys.stdout, specific_files,
348
external_diff_options,
349
old_label=old_label, new_label=new_label,
350
extra_trees=extra_trees)
353
278
def _get_trees_to_diff(path_list, revision_specs, old_url, new_url):
354
279
"""Get the trees and specific files to diff given a list of paths.
445
370
return branch.basis_tree()
448
revision = spec.in_store(branch)
449
revision_id = revision.rev_id
450
rev_branch = revision.branch
451
return rev_branch.repository.revision_tree(revision_id)
373
if not spec.needs_branch():
374
branch = _mod_branch.Branch.open(spec.get_branch())
375
revision_id = spec.as_revision_id(branch)
376
return branch.repository.revision_tree(revision_id)
454
379
def _relative_paths_in_tree(tree, paths):