~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Vincent Ladeuil
  • Date: 2011-07-06 09:22:00 UTC
  • mfrom: (6008 +trunk)
  • mto: (6012.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6013.
  • Revision ID: v.ladeuil+lp@free.fr-20110706092200-7iai2mwzc0sqdsvf
MergingĀ inĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    rename_map,
45
45
    revision as _mod_revision,
46
46
    static_tuple,
47
 
    symbol_versioning,
48
47
    timestamp,
49
48
    transport,
50
49
    ui,
51
50
    urlutils,
52
51
    views,
 
52
    gpg,
53
53
    )
54
54
from bzrlib.branch import Branch
55
55
from bzrlib.conflicts import ConflictList
72
72
    _parse_revision_str,
73
73
    )
74
74
from bzrlib.trace import mutter, note, warning, is_quiet, get_verbosity_level
 
75
from bzrlib import (
 
76
    symbol_versioning,
 
77
    )
75
78
 
76
79
 
77
80
@symbol_versioning.deprecated_function(symbol_versioning.deprecated_in((2, 3, 0)))
328
331
        if revision_id is None and revision is None:
329
332
            raise errors.BzrCommandError('You must supply either'
330
333
                                         ' --revision or a revision_id')
331
 
        b = WorkingTree.open_containing(directory)[0].branch
 
334
 
 
335
        b = bzrdir.BzrDir.open_containing_tree_or_branch(directory)[1]
332
336
 
333
337
        revisions = b.repository.revisions
334
338
        if revisions is None:
412
416
                self.outf.write(page_bytes[:header_end])
413
417
                page_bytes = data
414
418
            self.outf.write('\nPage %d\n' % (page_idx,))
415
 
            decomp_bytes = zlib.decompress(page_bytes)
416
 
            self.outf.write(decomp_bytes)
417
 
            self.outf.write('\n')
 
419
            if len(page_bytes) == 0:
 
420
                self.outf.write('(empty)\n');
 
421
            else:
 
422
                decomp_bytes = zlib.decompress(page_bytes)
 
423
                self.outf.write(decomp_bytes)
 
424
                self.outf.write('\n')
418
425
 
419
426
    def _dump_entries(self, trans, basename):
420
427
        try:
481
488
            d.destroy_workingtree()
482
489
 
483
490
 
 
491
class cmd_repair_workingtree(Command):
 
492
    __doc__ = """Reset the working tree state file.
 
493
 
 
494
    This is not meant to be used normally, but more as a way to recover from
 
495
    filesystem corruption, etc. This rebuilds the working inventory back to a
 
496
    'known good' state. Any new modifications (adding a file, renaming, etc)
 
497
    will be lost, though modified files will still be detected as such.
 
498
 
 
499
    Most users will want something more like "bzr revert" or "bzr update"
 
500
    unless the state file has become corrupted.
 
501
 
 
502
    By default this attempts to recover the current state by looking at the
 
503
    headers of the state file. If the state file is too corrupted to even do
 
504
    that, you can supply --revision to force the state of the tree.
 
505
    """
 
506
 
 
507
    takes_options = ['revision', 'directory',
 
508
        Option('force',
 
509
               help='Reset the tree even if it doesn\'t appear to be'
 
510
                    ' corrupted.'),
 
511
    ]
 
512
    hidden = True
 
513
 
 
514
    def run(self, revision=None, directory='.', force=False):
 
515
        tree, _ = WorkingTree.open_containing(directory)
 
516
        self.add_cleanup(tree.lock_tree_write().unlock)
 
517
        if not force:
 
518
            try:
 
519
                tree.check_state()
 
520
            except errors.BzrError:
 
521
                pass # There seems to be a real error here, so we'll reset
 
522
            else:
 
523
                # Refuse
 
524
                raise errors.BzrCommandError(
 
525
                    'The tree does not appear to be corrupt. You probably'
 
526
                    ' want "bzr revert" instead. Use "--force" if you are'
 
527
                    ' sure you want to reset the working tree.')
 
528
        if revision is None:
 
529
            revision_ids = None
 
530
        else:
 
531
            revision_ids = [r.as_revision_id(tree.branch) for r in revision]
 
532
        try:
 
533
            tree.reset_state(revision_ids)
 
534
        except errors.BzrError, e:
 
535
            if revision_ids is None:
 
536
                extra = (', the header appears corrupt, try passing -r -1'
 
537
                         ' to set the state to the last commit')
 
538
            else:
 
539
                extra = ''
 
540
            raise errors.BzrCommandError('failed to reset the tree state'
 
541
                                         + extra)
 
542
 
 
543
 
484
544
class cmd_revno(Command):
485
545
    __doc__ = """Show current revision number.
486
546
 
737
797
                                      require_versioned=True)
738
798
            # find_ids_across_trees may include some paths that don't
739
799
            # exist in 'tree'.
740
 
            entries = sorted((tree.id2path(file_id), tree.inventory[file_id])
741
 
                             for file_id in file_ids if file_id in tree)
 
800
            entries = sorted(
 
801
                (tree.id2path(file_id), tree.inventory[file_id])
 
802
                for file_id in file_ids if tree.has_id(file_id))
742
803
        else:
743
804
            entries = tree.inventory.entries()
744
805
 
905
966
    match the remote one, use pull --overwrite. This will work even if the two
906
967
    branches have diverged.
907
968
 
908
 
    If there is no default location set, the first pull will set it.  After
909
 
    that, you can omit the location to use the default.  To change the
910
 
    default, use --remember. The value will only be saved if the remote
911
 
    location can be accessed.
 
969
    If there is no default location set, the first pull will set it (use
 
970
    --no-remember to avoid settting it). After that, you can omit the
 
971
    location to use the default.  To change the default, use --remember. The
 
972
    value will only be saved if the remote location can be accessed.
912
973
 
913
974
    Note: The location can be specified either in the form of a branch,
914
975
    or in the form of a path to a file containing a merge directive generated
933
994
    takes_args = ['location?']
934
995
    encoding_type = 'replace'
935
996
 
936
 
    def run(self, location=None, remember=False, overwrite=False,
 
997
    def run(self, location=None, remember=None, overwrite=False,
937
998
            revision=None, verbose=False,
938
999
            directory=None, local=False,
939
1000
            show_base=False):
990
1051
            branch_from = Branch.open(location,
991
1052
                possible_transports=possible_transports)
992
1053
            self.add_cleanup(branch_from.lock_read().unlock)
993
 
 
994
 
            if branch_to.get_parent() is None or remember:
 
1054
            # Remembers if asked explicitly or no previous location is set
 
1055
            if (remember
 
1056
                or (remember is None and branch_to.get_parent() is None)):
995
1057
                branch_to.set_parent(branch_from.base)
996
1058
 
997
1059
        if revision is not None:
1015
1077
            log.show_branch_change(
1016
1078
                branch_to, self.outf, result.old_revno,
1017
1079
                result.old_revid)
 
1080
        if getattr(result, 'tag_conflicts', None):
 
1081
            return 1
 
1082
        else:
 
1083
            return 0
1018
1084
 
1019
1085
 
1020
1086
class cmd_push(Command):
1037
1103
    do a merge (see bzr help merge) from the other branch, and commit that.
1038
1104
    After that you will be able to do a push without '--overwrite'.
1039
1105
 
1040
 
    If there is no default push location set, the first push will set it.
1041
 
    After that, you can omit the location to use the default.  To change the
1042
 
    default, use --remember. The value will only be saved if the remote
1043
 
    location can be accessed.
 
1106
    If there is no default push location set, the first push will set it (use
 
1107
    --no-remember to avoid settting it).  After that, you can omit the
 
1108
    location to use the default.  To change the default, use --remember. The
 
1109
    value will only be saved if the remote location can be accessed.
1044
1110
    """
1045
1111
 
1046
1112
    _see_also = ['pull', 'update', 'working-trees']
1074
1140
    takes_args = ['location?']
1075
1141
    encoding_type = 'replace'
1076
1142
 
1077
 
    def run(self, location=None, remember=False, overwrite=False,
 
1143
    def run(self, location=None, remember=None, overwrite=False,
1078
1144
        create_prefix=False, verbose=False, revision=None,
1079
1145
        use_existing_dir=False, directory=None, stacked_on=None,
1080
1146
        stacked=False, strict=None, no_tree=False):
1144
1210
 
1145
1211
    To retrieve the branch as of a particular revision, supply the --revision
1146
1212
    parameter, as in "branch foo/bar -r 5".
 
1213
 
 
1214
    The synonyms 'clone' and 'get' for this command are deprecated.
1147
1215
    """
1148
1216
 
1149
1217
    _see_also = ['checkout']
1179
1247
            files_from=None):
1180
1248
        from bzrlib import switch as _mod_switch
1181
1249
        from bzrlib.tag import _merge_tags_if_possible
 
1250
        if self.invoked_as in ['get', 'clone']:
 
1251
            ui.ui_factory.show_user_warning(
 
1252
                'deprecated_command',
 
1253
                deprecated_name=self.invoked_as,
 
1254
                recommended_name='branch',
 
1255
                deprecated_in_version='2.4')
1182
1256
        accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1183
1257
            from_location)
1184
1258
        if not (hardlink or files_from):
1668
1742
            b = wt.branch
1669
1743
            last_revision = wt.last_revision()
1670
1744
 
1671
 
        revision_ids = b.repository.get_ancestry(last_revision)
1672
 
        revision_ids.pop(0)
1673
 
        for revision_id in revision_ids:
 
1745
        self.add_cleanup(b.repository.lock_read().unlock)
 
1746
        graph = b.repository.get_graph()
 
1747
        revisions = [revid for revid, parents in
 
1748
            graph.iter_ancestry([last_revision])]
 
1749
        for revision_id in reversed(revisions):
 
1750
            if _mod_revision.is_null(revision_id):
 
1751
                continue
1674
1752
            self.outf.write(revision_id + '\n')
1675
1753
 
1676
1754
 
1961
2039
            type=unicode,
1962
2040
            ),
1963
2041
        RegistryOption('format',
 
2042
            short_name='F',
1964
2043
            help='Diff format to use.',
1965
2044
            lazy_registry=('bzrlib.diff', 'format_registry'),
1966
 
            value_switches=False, title='Diff format'),
 
2045
            title='Diff format'),
1967
2046
        ]
1968
2047
    aliases = ['di', 'dif']
1969
2048
    encoding_type = 'exact'
2077
2156
        basis_inv = basis.inventory
2078
2157
        inv = wt.inventory
2079
2158
        for file_id in inv:
2080
 
            if file_id in basis_inv:
 
2159
            if basis_inv.has_id(file_id):
2081
2160
                continue
2082
2161
            if inv.is_root(file_id) and len(basis_inv) == 0:
2083
2162
                continue
2316
2395
            Option('exclude-common-ancestry',
2317
2396
                   help='Display only the revisions that are not part'
2318
2397
                   ' of both ancestries (require -rX..Y)'
2319
 
                   )
 
2398
                   ),
 
2399
            Option('signatures',
 
2400
                   help='Show digital signature validity'),
2320
2401
            ]
2321
2402
    encoding_type = 'replace'
2322
2403
 
2335
2416
            include_merges=False,
2336
2417
            authors=None,
2337
2418
            exclude_common_ancestry=False,
 
2419
            signatures=False,
2338
2420
            ):
2339
2421
        from bzrlib.log import (
2340
2422
            Logger,
2394
2476
            self.add_cleanup(b.lock_read().unlock)
2395
2477
            rev1, rev2 = _get_revision_range(revision, b, self.name())
2396
2478
 
 
2479
        if b.get_config().validate_signatures_in_log():
 
2480
            signatures = True
 
2481
 
 
2482
        if signatures:
 
2483
            if not gpg.GPGStrategy.verify_signatures_available():
 
2484
                raise errors.GpgmeNotInstalled(None)
 
2485
 
2397
2486
        # Decide on the type of delta & diff filtering to use
2398
2487
        # TODO: add an --all-files option to make this configurable & consistent
2399
2488
        if not verbose:
2445
2534
            message_search=message, delta_type=delta_type,
2446
2535
            diff_type=diff_type, _match_using_deltas=match_using_deltas,
2447
2536
            exclude_common_ancestry=exclude_common_ancestry,
 
2537
            signature=signatures
2448
2538
            )
2449
2539
        Logger(b, rqst).show(lf)
2450
2540
 
2726
2816
            bzr ignore "RE:(?!debian/).*"
2727
2817
        
2728
2818
        Ignore everything except the "local" toplevel directory,
2729
 
        but always ignore ``*~`` autosave files, even under local/::
 
2819
        but always ignore autosave files ending in ~, even under local/::
2730
2820
        
2731
2821
            bzr ignore "*"
2732
2822
            bzr ignore "!./local"
2860
2950
         zip                          .zip
2861
2951
      =================       =========================
2862
2952
    """
 
2953
    encoding = 'exact'
2863
2954
    takes_args = ['dest', 'branch_or_subdir?']
2864
2955
    takes_options = ['directory',
2865
2956
        Option('format',
3043
3134
      to trigger updates to external systems like bug trackers. The --fixes
3044
3135
      option can be used to record the association between a revision and
3045
3136
      one or more bugs. See ``bzr help bugs`` for details.
3046
 
 
3047
 
      A selective commit may fail in some cases where the committed
3048
 
      tree would be invalid. Consider::
3049
 
  
3050
 
        bzr init foo
3051
 
        mkdir foo/bar
3052
 
        bzr add foo/bar
3053
 
        bzr commit foo -m "committing foo"
3054
 
        bzr mv foo/bar foo/baz
3055
 
        mkdir foo/bar
3056
 
        bzr add foo/bar
3057
 
        bzr commit foo/bar -m "committing bar but not baz"
3058
 
  
3059
 
      In the example above, the last commit will fail by design. This gives
3060
 
      the user the opportunity to decide whether they want to commit the
3061
 
      rename at the same time, separately first, or not at all. (As a general
3062
 
      rule, when in doubt, Bazaar has a policy of Doing the Safe Thing.)
3063
3137
    """
3064
 
    # TODO: Run hooks on tree to-be-committed, and after commit.
3065
 
 
3066
 
    # TODO: Strict commit that fails if there are deleted files.
3067
 
    #       (what does "deleted files" mean ??)
3068
 
 
3069
 
    # TODO: Give better message for -s, --summary, used by tla people
3070
 
 
3071
 
    # XXX: verbose currently does nothing
3072
3138
 
3073
3139
    _see_also = ['add', 'bugs', 'hooks', 'uncommit']
3074
3140
    takes_args = ['selected*']
3106
3172
             Option('show-diff', short_name='p',
3107
3173
                    help='When no message is supplied, show the diff along'
3108
3174
                    ' with the status summary in the message editor.'),
 
3175
             Option('lossy', 
 
3176
                    help='When committing to a foreign version control '
 
3177
                    'system do not push data that can not be natively '
 
3178
                    'represented.'),
3109
3179
             ]
3110
3180
    aliases = ['ci', 'checkin']
3111
3181
 
3130
3200
 
3131
3201
    def run(self, message=None, file=None, verbose=False, selected_list=None,
3132
3202
            unchanged=False, strict=False, local=False, fixes=None,
3133
 
            author=None, show_diff=False, exclude=None, commit_time=None):
 
3203
            author=None, show_diff=False, exclude=None, commit_time=None,
 
3204
            lossy=False):
3134
3205
        from bzrlib.errors import (
3135
3206
            PointlessCommit,
3136
3207
            ConflictsInTree,
3139
3210
        from bzrlib.msgeditor import (
3140
3211
            edit_commit_message_encoded,
3141
3212
            generate_commit_message_template,
3142
 
            make_commit_message_template_encoded
 
3213
            make_commit_message_template_encoded,
 
3214
            set_commit_message,
3143
3215
        )
3144
3216
 
3145
3217
        commit_stamp = offset = None
3150
3222
                raise errors.BzrCommandError(
3151
3223
                    "Could not parse --commit-time: " + str(e))
3152
3224
 
3153
 
        # TODO: Need a blackbox test for invoking the external editor; may be
3154
 
        # slightly problematic to run this cross-platform.
3155
 
 
3156
 
        # TODO: do more checks that the commit will succeed before
3157
 
        # spending the user's valuable time typing a commit message.
3158
 
 
3159
3225
        properties = {}
3160
3226
 
3161
3227
        tree, selected_list = WorkingTree.open_containing_paths(selected_list)
3217
3283
                # make_commit_message_template_encoded returns user encoding.
3218
3284
                # We probably want to be using edit_commit_message instead to
3219
3285
                # avoid this.
3220
 
                start_message = generate_commit_message_template(commit_obj)
3221
 
                my_message = edit_commit_message_encoded(text,
3222
 
                    start_message=start_message)
 
3286
                my_message = set_commit_message(commit_obj)
 
3287
                if my_message is None:
 
3288
                    start_message = generate_commit_message_template(commit_obj)
 
3289
                    my_message = edit_commit_message_encoded(text,
 
3290
                        start_message=start_message)
3223
3291
                if my_message is None:
3224
3292
                    raise errors.BzrCommandError("please specify a commit"
3225
3293
                        " message with either --message or --file")
3238
3306
                        reporter=None, verbose=verbose, revprops=properties,
3239
3307
                        authors=author, timestamp=commit_stamp,
3240
3308
                        timezone=offset,
3241
 
                        exclude=tree.safe_relpath_files(exclude))
 
3309
                        exclude=tree.safe_relpath_files(exclude),
 
3310
                        lossy=lossy)
3242
3311
        except PointlessCommit:
3243
3312
            raise errors.BzrCommandError("No changes to commit."
3244
 
                              " Use --unchanged to commit anyhow.")
 
3313
                " Please 'bzr add' the files you want to commit, or use"
 
3314
                " --unchanged to force an empty commit.")
3245
3315
        except ConflictsInTree:
3246
3316
            raise errors.BzrCommandError('Conflicts detected in working '
3247
3317
                'tree.  Use "bzr conflicts" to list, "bzr resolve FILE" to'
3425
3495
                self.outf.write(c.username() + '\n')
3426
3496
            return
3427
3497
 
 
3498
        if email:
 
3499
            raise errors.BzrCommandError("--email can only be used to display existing "
 
3500
                                         "identity")
 
3501
 
3428
3502
        # display a warning if an email address isn't included in the given name.
3429
3503
        try:
3430
3504
            _mod_config.extract_email_address(name)
3594
3668
        if typestring == "sftp":
3595
3669
            from bzrlib.tests import stub_sftp
3596
3670
            return stub_sftp.SFTPAbsoluteServer
3597
 
        if typestring == "memory":
 
3671
        elif typestring == "memory":
3598
3672
            from bzrlib.tests import test_server
3599
3673
            return memory.MemoryServer
3600
 
        if typestring == "fakenfs":
 
3674
        elif typestring == "fakenfs":
3601
3675
            from bzrlib.tests import test_server
3602
3676
            return test_server.FakeNFSServer
3603
3677
        msg = "No known transport type %s. Supported types are: sftp\n" %\
3637
3711
                     Option('randomize', type=str, argname="SEED",
3638
3712
                            help='Randomize the order of tests using the given'
3639
3713
                                 ' seed or "now" for the current time.'),
3640
 
                     Option('exclude', type=str, argname="PATTERN",
3641
 
                            short_name='x',
3642
 
                            help='Exclude tests that match this regular'
3643
 
                                 ' expression.'),
 
3714
                     ListOption('exclude', type=str, argname="PATTERN",
 
3715
                                short_name='x',
 
3716
                                help='Exclude tests that match this regular'
 
3717
                                ' expression.'),
3644
3718
                     Option('subunit',
3645
3719
                        help='Output test progress via subunit.'),
3646
3720
                     Option('strict', help='Fail on missing dependencies or '
3697
3771
                "--benchmark is no longer supported from bzr 2.2; "
3698
3772
                "use bzr-usertest instead")
3699
3773
        test_suite_factory = None
 
3774
        if not exclude:
 
3775
            exclude_pattern = None
 
3776
        else:
 
3777
            exclude_pattern = '(' + '|'.join(exclude) + ')'
3700
3778
        selftest_kwargs = {"verbose": verbose,
3701
3779
                          "pattern": pattern,
3702
3780
                          "stop_on_failure": one,
3707
3785
                          "matching_tests_first": first,
3708
3786
                          "list_only": list_only,
3709
3787
                          "random_seed": randomize,
3710
 
                          "exclude_pattern": exclude,
 
3788
                          "exclude_pattern": exclude_pattern,
3711
3789
                          "strict": strict,
3712
3790
                          "load_list": load_list,
3713
3791
                          "debug_flags": debugflag,
3782
3860
    The source of the merge can be specified either in the form of a branch,
3783
3861
    or in the form of a path to a file containing a merge directive generated
3784
3862
    with bzr send. If neither is specified, the default is the upstream branch
3785
 
    or the branch most recently merged using --remember.
 
3863
    or the branch most recently merged using --remember.  The source of the
 
3864
    merge may also be specified in the form of a path to a file in another
 
3865
    branch:  in this case, only the modifications to that file are merged into
 
3866
    the current working tree.
3786
3867
 
3787
3868
    When merging from a branch, by default bzr will try to merge in all new
3788
3869
    work from the other branch, automatically determining an appropriate base
3795
3876
    through OTHER, excluding BASE but including OTHER, will be merged.  If this
3796
3877
    causes some revisions to be skipped, i.e. if the destination branch does
3797
3878
    not already contain revision BASE, such a merge is commonly referred to as
3798
 
    a "cherrypick".
 
3879
    a "cherrypick". Unlike a normal merge, Bazaar does not currently track
 
3880
    cherrypicks. The changes look like a normal commit, and the history of the
 
3881
    changes from the other branch is not stored in the commit.
3799
3882
 
3800
3883
    Revision numbers are always relative to the source branch.
3801
3884
 
3806
3889
 
3807
3890
    Use bzr resolve when you have fixed a problem.  See also bzr conflicts.
3808
3891
 
3809
 
    If there is no default branch set, the first merge will set it. After
3810
 
    that, you can omit the branch to use the default.  To change the
3811
 
    default, use --remember. The value will only be saved if the remote
3812
 
    location can be accessed.
 
3892
    If there is no default branch set, the first merge will set it (use
 
3893
    --no-remember to avoid settting it). After that, you can omit the branch
 
3894
    to use the default.  To change the default, use --remember. The value will
 
3895
    only be saved if the remote location can be accessed.
3813
3896
 
3814
3897
    The results of the merge are placed into the destination working
3815
3898
    directory, where they can be reviewed (with bzr diff), tested, and then
3816
3899
    committed to record the result of the merge.
3817
3900
 
3818
3901
    merge refuses to run if there are any uncommitted changes, unless
3819
 
    --force is given. The --force option can also be used to create a
 
3902
    --force is given.  If --force is given, then the changes from the source 
 
3903
    will be merged with the current working tree, including any uncommitted
 
3904
    changes in the tree.  The --force option can also be used to create a
3820
3905
    merge revision which has more than two parents.
3821
3906
 
3822
3907
    If one would like to merge changes from the working tree of the other
3880
3965
    ]
3881
3966
 
3882
3967
    def run(self, location=None, revision=None, force=False,
3883
 
            merge_type=None, show_base=False, reprocess=None, remember=False,
 
3968
            merge_type=None, show_base=False, reprocess=None, remember=None,
3884
3969
            uncommitted=False, pull=False,
3885
3970
            directory=None,
3886
3971
            preview=False,
3894
3979
        merger = None
3895
3980
        allow_pending = True
3896
3981
        verified = 'inapplicable'
 
3982
 
3897
3983
        tree = WorkingTree.open_containing(directory)[0]
 
3984
        if tree.branch.revno() == 0:
 
3985
            raise errors.BzrCommandError('Merging into empty branches not currently supported, '
 
3986
                                         'https://bugs.launchpad.net/bzr/+bug/308562')
3898
3987
 
3899
3988
        try:
3900
3989
            basis_tree = tree.revision_tree(tree.last_revision())
3946
4035
        self.sanity_check_merger(merger)
3947
4036
        if (merger.base_rev_id == merger.other_rev_id and
3948
4037
            merger.other_rev_id is not None):
 
4038
            # check if location is a nonexistent file (and not a branch) to
 
4039
            # disambiguate the 'Nothing to do'
 
4040
            if merger.interesting_files:
 
4041
                if not merger.other_tree.has_filename(
 
4042
                    merger.interesting_files[0]):
 
4043
                    note("merger: " + str(merger))
 
4044
                    raise errors.PathsDoNotExist([location])
3949
4045
            note('Nothing to do.')
3950
4046
            return 0
3951
4047
        if pull and not preview:
4063
4159
        if other_revision_id is None:
4064
4160
            other_revision_id = _mod_revision.ensure_null(
4065
4161
                other_branch.last_revision())
4066
 
        # Remember where we merge from
4067
 
        if ((remember or tree.branch.get_submit_branch() is None) and
4068
 
             user_location is not None):
 
4162
        # Remember where we merge from. We need to remember if:
 
4163
        # - user specify a location (and we don't merge from the parent
 
4164
        #   branch)
 
4165
        # - user ask to remember or there is no previous location set to merge
 
4166
        #   from and user didn't ask to *not* remember
 
4167
        if (user_location is not None
 
4168
            and ((remember
 
4169
                  or (remember is None
 
4170
                      and tree.branch.get_submit_branch() is None)))):
4069
4171
            tree.branch.set_submit_branch(other_branch.base)
4070
4172
        # Merge tags (but don't set them in the master branch yet, the user
4071
4173
        # might revert this merge).  Commit will propagate them.
4581
4683
 
4582
4684
    @display_command
4583
4685
    def run(self, verbose=False):
4584
 
        import bzrlib.plugin
4585
 
        from inspect import getdoc
4586
 
        result = []
4587
 
        for name, plugin in bzrlib.plugin.plugins().items():
4588
 
            version = plugin.__version__
4589
 
            if version == 'unknown':
4590
 
                version = ''
4591
 
            name_ver = '%s %s' % (name, version)
4592
 
            d = getdoc(plugin.module)
4593
 
            if d:
4594
 
                doc = d.split('\n')[0]
4595
 
            else:
4596
 
                doc = '(no description)'
4597
 
            result.append((name_ver, doc, plugin.path()))
4598
 
        for name_ver, doc, path in sorted(result):
4599
 
            self.outf.write("%s\n" % name_ver)
4600
 
            self.outf.write("   %s\n" % doc)
4601
 
            if verbose:
4602
 
                self.outf.write("   %s\n" % path)
4603
 
            self.outf.write("\n")
 
4686
        from bzrlib import plugin
 
4687
        # Don't give writelines a generator as some codecs don't like that
 
4688
        self.outf.writelines(
 
4689
            list(plugin.describe_plugins(show_paths=verbose)))
4604
4690
 
4605
4691
 
4606
4692
class cmd_testament(Command):
4659
4745
    @display_command
4660
4746
    def run(self, filename, all=False, long=False, revision=None,
4661
4747
            show_ids=False, directory=None):
4662
 
        from bzrlib.annotate import annotate_file, annotate_file_tree
 
4748
        from bzrlib.annotate import (
 
4749
            annotate_file_tree,
 
4750
            )
4663
4751
        wt, branch, relpath = \
4664
4752
            _open_directory_or_containing_tree_or_branch(filename, directory)
4665
4753
        if wt is not None:
4668
4756
            self.add_cleanup(branch.lock_read().unlock)
4669
4757
        tree = _get_one_revision_tree('annotate', revision, branch=branch)
4670
4758
        self.add_cleanup(tree.lock_read().unlock)
4671
 
        if wt is not None:
 
4759
        if wt is not None and revision is None:
4672
4760
            file_id = wt.path2id(relpath)
4673
4761
        else:
4674
4762
            file_id = tree.path2id(relpath)
4675
4763
        if file_id is None:
4676
4764
            raise errors.NotVersionedError(filename)
4677
 
        file_version = tree.inventory[file_id].revision
4678
4765
        if wt is not None and revision is None:
4679
4766
            # If there is a tree and we're not annotating historical
4680
4767
            # versions, annotate the working tree's content.
4681
4768
            annotate_file_tree(wt, file_id, self.outf, long, all,
4682
4769
                show_ids=show_ids)
4683
4770
        else:
4684
 
            annotate_file(branch, file_version, file_id, long, all, self.outf,
4685
 
                          show_ids=show_ids)
 
4771
            annotate_file_tree(tree, file_id, self.outf, long, all,
 
4772
                show_ids=show_ids, branch=branch)
4686
4773
 
4687
4774
 
4688
4775
class cmd_re_sign(Command):
4903
4990
 
4904
4991
        if not force:
4905
4992
            if not ui.ui_factory.confirm_action(
4906
 
                    'Uncommit these revisions',
 
4993
                    u'Uncommit these revisions',
4907
4994
                    'bzrlib.builtins.uncommit',
4908
4995
                    {}):
4909
4996
                self.outf.write('Canceled\n')
5245
5332
    source branch defaults to that containing the working directory, but can
5246
5333
    be changed using --from.
5247
5334
 
 
5335
    Both the submit branch and the public branch follow the usual behavior with
 
5336
    respect to --remember: If there is no default location set, the first send
 
5337
    will set it (use --no-remember to avoid settting it). After that, you can
 
5338
    omit the location to use the default.  To change the default, use
 
5339
    --remember. The value will only be saved if the location can be accessed.
 
5340
 
5248
5341
    In order to calculate those changes, bzr must analyse the submit branch.
5249
5342
    Therefore it is most efficient for the submit branch to be a local mirror.
5250
5343
    If a public location is known for the submit_branch, that location is used
5319
5412
        ]
5320
5413
 
5321
5414
    def run(self, submit_branch=None, public_branch=None, no_bundle=False,
5322
 
            no_patch=False, revision=None, remember=False, output=None,
 
5415
            no_patch=False, revision=None, remember=None, output=None,
5323
5416
            format=None, mail_to=None, message=None, body=None,
5324
5417
            strict=None, **kwargs):
5325
5418
        from bzrlib.send import send
5517
5610
                    revno = branch.revision_id_to_dotted_revno(revid)
5518
5611
                    if isinstance(revno, tuple):
5519
5612
                        revno = '.'.join(map(str, revno))
5520
 
                except errors.NoSuchRevision:
 
5613
                except (errors.NoSuchRevision, errors.GhostRevisionsHaveNoRevno):
5521
5614
                    # Bad tag data/merges can lead to tagged revisions
5522
5615
                    # which are not in this branch. Fail gracefully ...
5523
5616
                    revno = '?'
5581
5674
            unstacked=None):
5582
5675
        directory = bzrdir.BzrDir.open(location)
5583
5676
        if stacked_on and unstacked:
5584
 
            raise BzrCommandError("Can't use both --stacked-on and --unstacked")
 
5677
            raise errors.BzrCommandError("Can't use both --stacked-on and --unstacked")
5585
5678
        elif stacked_on is not None:
5586
5679
            reconfigure.ReconfigureStackedOn().apply(directory, stacked_on)
5587
5680
        elif unstacked:
6054
6147
    """
6055
6148
    takes_options = ['directory',
6056
6149
                     Option('ignored', help='Delete all ignored files.'),
6057
 
                     Option('detritus', help='Delete conflict files, merge'
 
6150
                     Option('detritus', help='Delete conflict files, merge and revert'
6058
6151
                            ' backups, and failed selftest dirs.'),
6059
6152
                     Option('unknown',
6060
6153
                            help='Delete files unknown to bzr (default).'),
6119
6212
            self.outf.write('%s %s\n' % (path, location))
6120
6213
 
6121
6214
 
 
6215
class cmd_export_pot(Command):
 
6216
    __doc__ = """Export command helps and error messages in po format."""
 
6217
 
 
6218
    hidden = True
 
6219
 
 
6220
    def run(self):
 
6221
        from bzrlib.export_pot import export_pot
 
6222
        export_pot(self.outf)
 
6223
 
 
6224
 
6122
6225
def _register_lazy_builtins():
6123
6226
    # register lazy builtins from other modules; called at startup and should
6124
6227
    # be only called once.
6129
6232
        ('cmd_version_info', [], 'bzrlib.cmd_version_info'),
6130
6233
        ('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
6131
6234
        ('cmd_conflicts', [], 'bzrlib.conflicts'),
6132
 
        ('cmd_sign_my_commits', [], 'bzrlib.sign_my_commits'),
 
6235
        ('cmd_sign_my_commits', [], 'bzrlib.commit_signature_commands'),
 
6236
        ('cmd_verify_signatures', [],
 
6237
                                        'bzrlib.commit_signature_commands'),
6133
6238
        ('cmd_test_script', [], 'bzrlib.cmd_test_script'),
6134
6239
        ]:
6135
6240
        builtin_command_registry.register_lazy(name, aliases, module_name)