/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 bzrlib/diff.py

Merge bzr.dev and resolve conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
import time
29
29
 
30
30
from bzrlib import (
 
31
    branch as _mod_branch,
31
32
    bzrdir,
32
33
    commands,
33
34
    errors,
40
41
 
41
42
from bzrlib.symbol_versioning import (
42
43
        deprecated_function,
43
 
        one_zero,
44
44
        one_three
45
45
        )
46
46
from bzrlib.trace import mutter, warning
275
275
                        new_abspath, e)
276
276
 
277
277
 
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,
281
 
                    revision_specs=None,
282
 
                    old_label='a/', new_label='b/'):
283
 
    """Helper for cmd_diff.
284
 
 
285
 
    :param tree:
286
 
        A WorkingTree
287
 
 
288
 
    :param specific_files:
289
 
        The specific files to compare, or None
290
 
 
291
 
    :param external_diff_options:
292
 
        If non-None, run an external diff, and pass it these options
293
 
 
294
 
    :param old_revision_spec:
295
 
        If None, use basis tree as old revision, otherwise use the tree for
296
 
        the specified revision. 
297
 
 
298
 
    :param new_revision_spec:
299
 
        If None, use working tree as new revision, otherwise use the tree for
300
 
        the specified revision.
301
 
    
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.
306
 
 
307
 
    The more general form is show_diff_trees(), where the caller
308
 
    supplies any two trees.
309
 
    """
310
 
 
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
314
 
    # 20061221
315
 
 
316
 
    def spec_tree(spec):
317
 
        if tree:
318
 
            revision = spec.in_store(tree.branch)
319
 
        else:
320
 
            revision = spec.in_store(None)
321
 
        revision_id = revision.rev_id
322
 
        branch = revision.branch
323
 
        return branch.repository.revision_tree(revision_id)
324
 
 
325
 
    if revision_specs is not None:
326
 
        assert (old_revision_spec is None
327
 
                and new_revision_spec is None)
328
 
        if len(revision_specs) > 0:
329
 
            old_revision_spec = revision_specs[0]
330
 
        if len(revision_specs) > 1:
331
 
            new_revision_spec = revision_specs[1]
332
 
 
333
 
    if old_revision_spec is None:
334
 
        old_tree = tree.basis_tree()
335
 
    else:
336
 
        old_tree = spec_tree(old_revision_spec)
337
 
 
338
 
    if (new_revision_spec is None
339
 
        or new_revision_spec.spec is None):
340
 
        new_tree = tree
341
 
    else:
342
 
        new_tree = spec_tree(new_revision_spec)
343
 
 
344
 
    if new_tree is not tree:
345
 
        extra_trees = (tree,)
346
 
    else:
347
 
        extra_trees = None
348
 
 
349
 
    return show_diff_trees(old_tree, new_tree, sys.stdout, specific_files,
350
 
                           external_diff_options,
351
 
                           old_label=old_label, new_label=new_label,
352
 
                           extra_trees=extra_trees)
353
 
 
354
 
 
355
278
def _get_trees_to_diff(path_list, revision_specs, old_url, new_url):
356
279
    """Get the trees and specific files to diff given a list of paths.
357
280
 
447
370
                return branch.basis_tree()
448
371
        else:
449
372
            return tree
450
 
    revision = spec.in_store(branch)
451
 
    revision_id = revision.rev_id
452
 
    rev_branch = revision.branch
453
 
    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
377
 
455
378
 
456
379
def _relative_paths_in_tree(tree, paths):
516
439
def _patch_header_date(tree, file_id, path):
517
440
    """Returns a timestamp suitable for use in a patch header."""
518
441
    mtime = tree.get_file_mtime(file_id, path)
519
 
    assert mtime is not None, \
520
 
        "got an mtime of None for file-id %s, path %s in tree %s" % (
521
 
                file_id, path, tree)
522
442
    return timestamp.format_patch_date(mtime)
523
443
 
524
444
 
913
833
        else:
914
834
            extra_factories = []
915
835
        if external_diff_options:
916
 
            assert isinstance(external_diff_options, basestring)
917
836
            opts = external_diff_options.split()
918
837
            def diff_file(olab, olines, nlab, nlines, to_file):
919
838
                external_diff(olab, olines, nlab, nlines, to_file, opts)