611
611
display_url = urlutils.unescape_for_display(stored_loc,
612
612
self.outf.encoding)
613
self.outf.write("Using saved location: %s\n" % display_url)
614
self.outf.write("Using saved location: %s\n" % display_url)
614
615
location = stored_loc
615
616
location_transport = transport.get_transport(
616
617
location, possible_transports=possible_transports)
963
964
def run(self, branch_location=None, to_location=None, revision=None,
964
965
lightweight=False, files_from=None, hardlink=False):
965
if files_from is not None:
966
accelerator_tree = WorkingTree.open(files_from)
968
accelerator_tree = None
969
966
if revision is None:
970
967
revision = [None]
971
968
elif len(revision) > 1:
974
971
if branch_location is None:
975
972
branch_location = osutils.getcwd()
976
973
to_location = branch_location
977
source = Branch.open(branch_location)
974
accelerator_tree, source = bzrdir.BzrDir.open_tree_or_branch(
976
if files_from is not None:
977
accelerator_tree = WorkingTree.open(files_from)
978
978
if len(revision) == 1 and revision[0] is not None:
979
979
revision_id = _mod_revision.ensure_null(
980
980
revision[0].in_history(source)[1])
1461
1461
bzr diff --prefix old/:new/
1463
# TODO: Option to use external diff command; could be GNU diff, wdiff,
1464
# or a graphical diff.
1466
# TODO: Python difflib is not exactly the same as unidiff; should
1467
# either fix it up or prefer to use an external diff.
1469
# TODO: Selected-file diff is inefficient and doesn't show you
1472
# TODO: This probably handles non-Unix newlines poorly.
1474
1463
_see_also = ['status']
1475
1464
takes_args = ['file*']
1476
1465
takes_options = [
1483
help='Use this command to compare files.',
1494
1487
aliases = ['di', 'dif']
1495
1488
encoding_type = 'exact'
1497
1490
@display_command
1498
1491
def run(self, revision=None, file_list=None, diff_options=None,
1499
prefix=None, old=None, new=None):
1492
prefix=None, old=None, new=None, using=None):
1500
1493
from bzrlib.diff import _get_trees_to_diff, show_diff_trees
1502
1495
if (prefix is None) or (prefix == '0'):
1523
1516
specific_files=specific_files,
1524
1517
external_diff_options=diff_options,
1525
1518
old_label=old_label, new_label=new_label,
1526
extra_trees=extra_trees)
1519
extra_trees=extra_trees, using=using)
1529
1522
class cmd_deleted(Command):
2612
2605
' expression.'),
2613
2606
Option('strict', help='Fail on missing dependencies or '
2614
2607
'known failures.'),
2615
Option('coverage', type=str, argname="DIRECTORY",
2616
help='Generate line coverage report in this '
2608
Option('load-list', type=str, argname='TESTLISTFILE',
2609
help='Load a test id list from a text file.'),
2619
2611
encoding_type = 'replace'
2622
2614
transport=None, benchmark=None,
2623
2615
lsprof_timed=None, cache_dir=None,
2624
2616
first=False, list_only=False,
2625
randomize=None, exclude=None, strict=False, coverage=None):
2617
randomize=None, exclude=None, strict=False,
2626
2619
import bzrlib.ui
2627
2620
from bzrlib.tests import selftest
2628
2621
import bzrlib.benchmarks as benchmarks
2797
2791
short_name='d',
2794
Option('preview', help='Instead of merging, show a diff of the merge.')
2802
2797
def run(self, branch=None, revision=None, force=False, merge_type=None,
2803
2798
show_base=False, reprocess=False, remember=False,
2804
2799
uncommitted=False, pull=False,
2805
2800
directory=None,
2807
2803
# This is actually a branch (or merge-directive) *location*.
2808
2804
location = branch
2858
2854
merger.merge_type = merge_type
2859
2855
merger.reprocess = reprocess
2860
2856
merger.show_base = show_base
2861
merger.change_reporter = change_reporter
2862
2857
self.sanity_check_merger(merger)
2863
2858
if (merger.base_rev_id == merger.other_rev_id and
2864
2859
merger.other_rev_id != None):
2873
2868
result.report(self.outf)
2875
2870
merger.check_basis(not force)
2876
conflict_count = merger.do_merge()
2878
merger.set_pending()
2879
if verified == 'failed':
2880
warning('Preview patch does not match changes')
2881
if conflict_count != 0:
2872
return self._do_preview(merger)
2874
return self._do_merge(merger, change_reporter, allow_pending,
2886
2877
for cleanup in reversed(cleanups):
2880
def _do_preview(self, merger):
2881
from bzrlib.diff import show_diff_trees
2882
tree_merger = merger.make_merger()
2883
tt = tree_merger.make_preview_transform()
2885
result_tree = tt.get_preview_tree()
2886
show_diff_trees(merger.this_tree, result_tree, self.outf,
2887
old_label='', new_label='')
2891
def _do_merge(self, merger, change_reporter, allow_pending, verified):
2892
merger.change_reporter = change_reporter
2893
conflict_count = merger.do_merge()
2895
merger.set_pending()
2896
if verified == 'failed':
2897
warning('Preview patch does not match changes')
2898
if conflict_count != 0:
2889
2903
def sanity_check_merger(self, merger):
2890
2904
if (merger.show_base and
2891
2905
not merger.merge_type is _mod_merge.Merge3Merger):
2905
2919
from bzrlib.tag import _merge_tags_if_possible
2906
2920
assert revision is None or len(revision) < 3
2907
2921
# find the branch locations
2908
other_loc, location = self._select_branch_location(tree, location,
2922
other_loc, user_location = self._select_branch_location(tree, location,
2910
2924
if revision is not None and len(revision) == 2:
2911
base_loc, location = self._select_branch_location(tree, location,
2925
base_loc, _unused = self._select_branch_location(tree,
2926
location, revision, 0)
2914
2928
base_loc = other_loc
2915
2929
# Open the branches
2937
2951
base_revision_id = None
2938
2952
# Remember where we merge from
2939
if ((tree.branch.get_parent() is None or remember) and
2940
other_branch is not None):
2941
tree.branch.set_parent(other_branch.base)
2953
if ((remember or tree.branch.get_submit_branch() is None) and
2954
user_location is not None):
2955
tree.branch.set_submit_branch(other_branch.base)
2942
2956
_merge_tags_if_possible(other_branch, tree.branch)
2943
2957
merger = _mod_merge.Merger.from_revision_ids(pb, tree,
2944
2958
other_revision_id, base_revision_id, other_branch, base_branch)
2949
2963
allow_pending = True
2950
2964
return merger, allow_pending
2952
def _select_branch_location(self, tree, location, revision=None,
2966
def _select_branch_location(self, tree, user_location, revision=None,
2954
2968
"""Select a branch location, according to possible inputs.
2957
2971
``revision`` and ``index`` must be supplied.)
2959
2973
Otherwise, the ``location`` parameter is used. If it is None, then the
2960
``parent`` location is used, and a note is printed.
2974
``submit`` or ``parent`` location is used, and a note is printed.
2962
2976
:param tree: The working tree to select a branch for merging into
2963
2977
:param location: The location entered by the user
2964
2978
:param revision: The revision parameter to the command
2965
2979
:param index: The index to use for the revision parameter. Negative
2966
2980
indices are permitted.
2967
:return: (selected_location, default_location). The default location
2968
will be the user-entered location, if any, or else the remembered
2981
:return: (selected_location, user_location). The default location
2982
will be the user-entered location.
2971
2984
if (revision is not None and index is not None
2972
2985
and revision[index] is not None):
2973
2986
branch = revision[index].get_branch()
2974
2987
if branch is not None:
2975
return branch, location
2976
location = self._get_remembered_parent(tree, location, 'Merging from')
2977
return location, location
2988
return branch, branch
2989
if user_location is None:
2990
location = self._get_remembered(tree, 'Merging from')
2992
location = user_location
2993
return location, user_location
2979
# TODO: move up to common parent; this isn't merge-specific anymore.
2980
def _get_remembered_parent(self, tree, supplied_location, verb_string):
2995
def _get_remembered(self, tree, verb_string):
2981
2996
"""Use tree.branch's parent if none was supplied.
2983
2998
Report if the remembered location was used.
2985
if supplied_location is not None:
2986
return supplied_location
2987
stored_location = tree.branch.get_parent()
3000
stored_location = tree.branch.get_submit_branch()
3001
if stored_location is None:
3002
stored_location = tree.branch.get_parent()
2988
3003
mutter("%s", stored_location)
2989
3004
if stored_location is None:
2990
3005
raise errors.BzrCommandError("No location specified or remembered")
3340
3355
class cmd_plugins(Command):
3341
3356
"""List the installed plugins.
3343
This command displays the list of installed plugins including the
3344
path where each one is located and a short description of each.
3358
This command displays the list of installed plugins including
3359
version of plugin and a short description of each.
3361
--verbose shows the path where each plugin is located.
3346
3363
A plugin is an external component for Bazaar that extends the
3347
3364
revision control system, by adding or replacing code in Bazaar.
3354
3371
install them. Instructions are also provided there on how to
3355
3372
write new plugins using the Python programming language.
3374
takes_options = ['verbose']
3358
3376
@display_command
3377
def run(self, verbose=False):
3360
3378
import bzrlib.plugin
3361
3379
from inspect import getdoc
3362
3381
for name, plugin in bzrlib.plugin.plugins().items():
3363
print plugin.path(), "[%s]" % plugin.__version__
3382
version = plugin.__version__
3383
if version == 'unknown':
3385
name_ver = '%s %s' % (name, version)
3364
3386
d = getdoc(plugin.module)
3366
print '\t', d.split('\n')[0]
3388
doc = d.split('\n')[0]
3390
doc = '(no description)'
3391
result.append((name_ver, doc, plugin.path()))
3392
for name_ver, doc, path in sorted(result):
3369
3400
class cmd_testament(Command):
3422
3453
def run(self, filename, all=False, long=False, revision=None,
3423
3454
show_ids=False):
3424
3455
from bzrlib.annotate import annotate_file
3425
tree, relpath = WorkingTree.open_containing(filename)
3426
branch = tree.branch
3456
wt, branch, relpath = \
3457
bzrdir.BzrDir.open_containing_tree_or_branch(filename)
3429
3463
if revision is None:
3430
3464
revision_id = branch.last_revision()
3432
3466
raise errors.BzrCommandError('bzr annotate --revision takes exactly 1 argument')
3434
3468
revision_id = revision[0].in_history(branch).rev_id
3435
file_id = tree.path2id(relpath)
3469
tree = branch.repository.revision_tree(revision_id)
3471
file_id = wt.path2id(relpath)
3473
file_id = tree.path2id(relpath)
3436
3474
if file_id is None:
3437
3475
raise errors.NotVersionedError(filename)
3438
tree = branch.repository.revision_tree(revision_id)
3439
3476
file_version = tree.inventory[file_id].revision
3440
3477
annotate_file(branch, file_version, file_id, long, all, self.outf,
3441
3478
show_ids=show_ids)
3446
3486
class cmd_re_sign(Command):