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)
2598
2599
' expression.'),
2599
2600
Option('strict', help='Fail on missing dependencies or '
2600
2601
'known failures.'),
2601
Option('coverage', type=str, argname="DIRECTORY",
2602
help='Generate line coverage report in this '
2602
Option('load-list', type=str, argname='TESTLISTFILE',
2603
help='Load a test id list from a text file.'),
2605
2605
encoding_type = 'replace'
2608
2608
transport=None, benchmark=None,
2609
2609
lsprof_timed=None, cache_dir=None,
2610
2610
first=False, list_only=False,
2611
randomize=None, exclude=None, strict=False, coverage=None):
2611
randomize=None, exclude=None, strict=False,
2612
2613
import bzrlib.ui
2613
2614
from bzrlib.tests import selftest
2614
2615
import bzrlib.benchmarks as benchmarks
2783
2785
short_name='d',
2788
Option('preview', help='Instead of merging, show a diff of the merge.')
2788
2791
def run(self, branch=None, revision=None, force=False, merge_type=None,
2789
2792
show_base=False, reprocess=False, remember=False,
2790
2793
uncommitted=False, pull=False,
2791
2794
directory=None,
2793
2797
# This is actually a branch (or merge-directive) *location*.
2794
2798
location = branch
2844
2848
merger.merge_type = merge_type
2845
2849
merger.reprocess = reprocess
2846
2850
merger.show_base = show_base
2847
merger.change_reporter = change_reporter
2848
2851
self.sanity_check_merger(merger)
2849
2852
if (merger.base_rev_id == merger.other_rev_id and
2850
2853
merger.other_rev_id != None):
2859
2862
result.report(self.outf)
2861
2864
merger.check_basis(not force)
2862
conflict_count = merger.do_merge()
2864
merger.set_pending()
2865
if verified == 'failed':
2866
warning('Preview patch does not match changes')
2867
if conflict_count != 0:
2866
return self._do_preview(merger)
2868
return self._do_merge(merger, change_reporter, allow_pending,
2872
2871
for cleanup in reversed(cleanups):
2874
def _do_preview(self, merger):
2875
from bzrlib.diff import show_diff_trees
2876
tree_merger = merger.make_merger()
2877
tt = tree_merger.make_preview_transform()
2879
result_tree = tt.get_preview_tree()
2880
show_diff_trees(merger.this_tree, result_tree, self.outf,
2881
old_label='', new_label='')
2885
def _do_merge(self, merger, change_reporter, allow_pending, verified):
2886
merger.change_reporter = change_reporter
2887
conflict_count = merger.do_merge()
2889
merger.set_pending()
2890
if verified == 'failed':
2891
warning('Preview patch does not match changes')
2892
if conflict_count != 0:
2875
2897
def sanity_check_merger(self, merger):
2876
2898
if (merger.show_base and
2877
2899
not merger.merge_type is _mod_merge.Merge3Merger):
2891
2913
from bzrlib.tag import _merge_tags_if_possible
2892
2914
assert revision is None or len(revision) < 3
2893
2915
# find the branch locations
2894
other_loc, location = self._select_branch_location(tree, location,
2916
other_loc, user_location = self._select_branch_location(tree, location,
2896
2918
if revision is not None and len(revision) == 2:
2897
base_loc, location = self._select_branch_location(tree, location,
2919
base_loc, _unused = self._select_branch_location(tree,
2920
location, revision, 0)
2900
2922
base_loc = other_loc
2901
2923
# Open the branches
2923
2945
base_revision_id = None
2924
2946
# Remember where we merge from
2925
if ((tree.branch.get_parent() is None or remember) and
2926
other_branch is not None):
2927
tree.branch.set_parent(other_branch.base)
2947
if ((remember or tree.branch.get_submit_branch() is None) and
2948
user_location is not None):
2949
tree.branch.set_submit_branch(other_branch.base)
2928
2950
_merge_tags_if_possible(other_branch, tree.branch)
2929
2951
merger = _mod_merge.Merger.from_revision_ids(pb, tree,
2930
2952
other_revision_id, base_revision_id, other_branch, base_branch)
2935
2957
allow_pending = True
2936
2958
return merger, allow_pending
2938
def _select_branch_location(self, tree, location, revision=None,
2960
def _select_branch_location(self, tree, user_location, revision=None,
2940
2962
"""Select a branch location, according to possible inputs.
2943
2965
``revision`` and ``index`` must be supplied.)
2945
2967
Otherwise, the ``location`` parameter is used. If it is None, then the
2946
``parent`` location is used, and a note is printed.
2968
``submit`` or ``parent`` location is used, and a note is printed.
2948
2970
:param tree: The working tree to select a branch for merging into
2949
2971
:param location: The location entered by the user
2950
2972
:param revision: The revision parameter to the command
2951
2973
:param index: The index to use for the revision parameter. Negative
2952
2974
indices are permitted.
2953
:return: (selected_location, default_location). The default location
2954
will be the user-entered location, if any, or else the remembered
2975
:return: (selected_location, user_location). The default location
2976
will be the user-entered location.
2957
2978
if (revision is not None and index is not None
2958
2979
and revision[index] is not None):
2959
2980
branch = revision[index].get_branch()
2960
2981
if branch is not None:
2961
return branch, location
2962
location = self._get_remembered_parent(tree, location, 'Merging from')
2963
return location, location
2982
return branch, branch
2983
if user_location is None:
2984
location = self._get_remembered(tree, 'Merging from')
2986
location = user_location
2987
return location, user_location
2965
# TODO: move up to common parent; this isn't merge-specific anymore.
2966
def _get_remembered_parent(self, tree, supplied_location, verb_string):
2989
def _get_remembered(self, tree, verb_string):
2967
2990
"""Use tree.branch's parent if none was supplied.
2969
2992
Report if the remembered location was used.
2971
if supplied_location is not None:
2972
return supplied_location
2973
stored_location = tree.branch.get_parent()
2994
stored_location = tree.branch.get_submit_branch()
2995
if stored_location is None:
2996
stored_location = tree.branch.get_parent()
2974
2997
mutter("%s", stored_location)
2975
2998
if stored_location is None:
2976
2999
raise errors.BzrCommandError("No location specified or remembered")
3326
3349
class cmd_plugins(Command):
3327
3350
"""List the installed plugins.
3329
This command displays the list of installed plugins including the
3330
path where each one is located and a short description of each.
3352
This command displays the list of installed plugins including
3353
version of plugin and a short description of each.
3355
--verbose shows the path where each plugin is located.
3332
3357
A plugin is an external component for Bazaar that extends the
3333
3358
revision control system, by adding or replacing code in Bazaar.
3340
3365
install them. Instructions are also provided there on how to
3341
3366
write new plugins using the Python programming language.
3368
takes_options = ['verbose']
3344
3370
@display_command
3371
def run(self, verbose=False):
3346
3372
import bzrlib.plugin
3347
3373
from inspect import getdoc
3348
3375
for name, plugin in bzrlib.plugin.plugins().items():
3349
print plugin.path(), "[%s]" % plugin.__version__
3376
version = plugin.__version__
3377
if version == 'unknown':
3379
name_ver = '%s %s' % (name, version)
3350
3380
d = getdoc(plugin.module)
3352
print '\t', d.split('\n')[0]
3382
doc = d.split('\n')[0]
3384
doc = '(no description)'
3385
result.append((name_ver, doc, plugin.path()))
3386
for name_ver, doc, path in sorted(result):
3355
3394
class cmd_testament(Command):