/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/builtins.py

  • Committer: Martin Pool
  • Date: 2008-02-06 00:41:04 UTC
  • mfrom: (3215 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3219.
  • Revision ID: mbp@sourcefrog.net-20080206004104-mxtn32habuhjq6b8
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
610
610
            else:
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)
 
613
                if not is_quiet():
 
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 '
2603
 
                                 'directory.'),
 
2602
                     Option('load-list', type=str, argname='TESTLISTFILE',
 
2603
                            help='Load a test id list from a text file.'),
2604
2604
                     ]
2605
2605
    encoding_type = 'replace'
2606
2606
 
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
            load_list=None):
2612
2613
        import bzrlib.ui
2613
2614
        from bzrlib.tests import selftest
2614
2615
        import bzrlib.benchmarks as benchmarks
2650
2651
                              random_seed=randomize,
2651
2652
                              exclude_pattern=exclude,
2652
2653
                              strict=strict,
2653
 
                              coverage_dir=coverage,
 
2654
                              load_list=load_list,
2654
2655
                              )
2655
2656
        finally:
2656
2657
            if benchfile is not None:
2759
2760
            bzr merge -r 81..82 ../bzr.dev
2760
2761
    """
2761
2762
 
 
2763
    encoding_type = 'exact'
2762
2764
    _see_also = ['update', 'remerge', 'status-flags']
2763
2765
    takes_args = ['branch?']
2764
2766
    takes_options = [
2783
2785
               short_name='d',
2784
2786
               type=unicode,
2785
2787
               ),
 
2788
        Option('preview', help='Instead of merging, show a diff of the merge.')
2786
2789
    ]
2787
2790
 
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,
 
2795
            preview=False,
2792
2796
            ):
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)
2860
2863
                    return 0
2861
2864
            merger.check_basis(not force)
2862
 
            conflict_count = merger.do_merge()
2863
 
            if allow_pending:
2864
 
                merger.set_pending()
2865
 
            if verified == 'failed':
2866
 
                warning('Preview patch does not match changes')
2867
 
            if conflict_count != 0:
2868
 
                return 1
 
2865
            if preview:
 
2866
                return self._do_preview(merger)
2869
2867
            else:
2870
 
                return 0
 
2868
                return self._do_merge(merger, change_reporter, allow_pending,
 
2869
                                      verified)
2871
2870
        finally:
2872
2871
            for cleanup in reversed(cleanups):
2873
2872
                cleanup()
2874
2873
 
 
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()
 
2878
        try:
 
2879
            result_tree = tt.get_preview_tree()
 
2880
            show_diff_trees(merger.this_tree, result_tree, self.outf,
 
2881
                            old_label='', new_label='')
 
2882
        finally:
 
2883
            tt.finalize()
 
2884
 
 
2885
    def _do_merge(self, merger, change_reporter, allow_pending, verified):
 
2886
        merger.change_reporter = change_reporter
 
2887
        conflict_count = merger.do_merge()
 
2888
        if allow_pending:
 
2889
            merger.set_pending()
 
2890
        if verified == 'failed':
 
2891
            warning('Preview patch does not match changes')
 
2892
        if conflict_count != 0:
 
2893
            return 1
 
2894
        else:
 
2895
            return 0
 
2896
 
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,
2895
2917
            revision, -1)
2896
2918
        if revision is not None and len(revision) == 2:
2897
 
            base_loc, location = self._select_branch_location(tree, location,
2898
 
                                                              revision, 0)
 
2919
            base_loc, _unused = self._select_branch_location(tree,
 
2920
                location, revision, 0)
2899
2921
        else:
2900
2922
            base_loc = other_loc
2901
2923
        # Open the branches
2922
2944
        else:
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
2937
2959
 
2938
 
    def _select_branch_location(self, tree, location, revision=None,
 
2960
    def _select_branch_location(self, tree, user_location, revision=None,
2939
2961
                                index=None):
2940
2962
        """Select a branch location, according to possible inputs.
2941
2963
 
2943
2965
        ``revision`` and ``index`` must be supplied.)
2944
2966
 
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.
2947
2969
 
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
2955
 
            location.
 
2975
        :return: (selected_location, user_location).  The default location
 
2976
            will be the user-entered location.
2956
2977
        """
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')
 
2985
        else:
 
2986
            location = user_location
 
2987
        return location, user_location
2964
2988
 
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.
2968
2991
 
2969
2992
        Report if the remembered location was used.
2970
2993
        """
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.
3328
3351
    
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.
 
3354
 
 
3355
    --verbose shows the path where each plugin is located.
3331
3356
 
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.
3342
3367
    """
 
3368
    takes_options = ['verbose']
3343
3369
 
3344
3370
    @display_command
3345
 
    def run(self):
 
3371
    def run(self, verbose=False):
3346
3372
        import bzrlib.plugin
3347
3373
        from inspect import getdoc
 
3374
        result = []
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':
 
3378
                version = ''
 
3379
            name_ver = '%s %s' % (name, version)
3350
3380
            d = getdoc(plugin.module)
3351
3381
            if d:
3352
 
                print '\t', d.split('\n')[0]
 
3382
                doc = d.split('\n')[0]
 
3383
            else:
 
3384
                doc = '(no description)'
 
3385
            result.append((name_ver, doc, plugin.path()))
 
3386
        for name_ver, doc, path in sorted(result):
 
3387
            print name_ver
 
3388
            print '   ', doc
 
3389
            if verbose:
 
3390
                print '   ', path
 
3391
            print
3353
3392
 
3354
3393
 
3355
3394
class cmd_testament(Command):