307
307
def diff_cmd_helper(tree, specific_files, external_diff_options,
308
308
old_revision_spec=None, new_revision_spec=None,
309
310
old_label='a/', new_label='b/'):
310
311
"""Helper for cmd_diff.
316
:param specific_files:
316
317
The specific files to compare, or None
318
external_diff_options
319
:param external_diff_options:
319
320
If non-None, run an external diff, and pass it these options
322
:param old_revision_spec:
322
323
If None, use basis tree as old revision, otherwise use the tree for
323
324
the specified revision.
326
:param new_revision_spec:
326
327
If None, use working tree as new revision, otherwise use the tree for
327
328
the specified revision.
330
:param revision_specs:
331
Zero, one or two RevisionSpecs from the command line, saying what revisions
332
to compare. This can be passed as an alternative to the old_revision_spec
333
and new_revision_spec parameters.
329
335
The more general form is show_diff_trees(), where the caller
330
336
supplies any two trees.
339
# TODO: perhaps remove the old parameters old_revision_spec and
340
# new_revision_spec, since this is only really for use from cmd_diff and
341
# it now always passes through a sequence of revision_specs -- mbp
332
344
def spec_tree(spec):
334
346
revision = spec.in_store(tree.branch)
337
349
revision_id = revision.rev_id
338
350
branch = revision.branch
339
351
return branch.repository.revision_tree(revision_id)
353
if revision_specs is not None:
354
assert (old_revision_spec is None
355
and new_revision_spec is None)
356
if len(revision_specs) > 0:
357
old_revision_spec = revision_specs[0]
358
if len(revision_specs) > 1:
359
new_revision_spec = revision_specs[1]
340
361
if old_revision_spec is None:
341
362
old_tree = tree.basis_tree()
343
364
old_tree = spec_tree(old_revision_spec)
345
if new_revision_spec is None:
366
if (new_revision_spec is None
367
or new_revision_spec.spec is None):
348
370
new_tree = spec_tree(new_revision_spec)
349
372
if new_tree is not tree:
350
373
extra_trees = (tree,)