~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Andrew Bennetts
  • Date: 2011-05-18 15:45:07 UTC
  • mto: This revision was merged to the branch mainline in revision 5895.
  • Revision ID: andrew.bennetts@canonical.com-20110518154507-t3qudgcb7fj3omjc
Use pydoctor in api-docs make target.

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,
47
48
    timestamp,
48
49
    transport,
49
50
    ui,
50
51
    urlutils,
51
52
    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
 
    )
78
75
 
79
76
 
80
77
@symbol_versioning.deprecated_function(symbol_versioning.deprecated_in((2, 3, 0)))
232
229
    unknown
233
230
        Not versioned and not matching an ignore pattern.
234
231
 
235
 
    Additionally for directories, symlinks and files with a changed
236
 
    executable bit, Bazaar indicates their type using a trailing
237
 
    character: '/', '@' or '*' respectively. These decorations can be
238
 
    disabled using the '--no-classify' option.
 
232
    Additionally for directories, symlinks and files with an executable
 
233
    bit, Bazaar indicates their type using a trailing character: '/', '@'
 
234
    or '*' respectively.
239
235
 
240
236
    To see ignored files use 'bzr ignored'.  For details on the
241
237
    changes to file texts, use 'bzr diff'.
272
268
                            short_name='V'),
273
269
                     Option('no-pending', help='Don\'t show pending merges.',
274
270
                           ),
275
 
                     Option('no-classify',
276
 
                            help='Do not mark object type using indicator.',
277
 
                           ),
278
271
                     ]
279
272
    aliases = ['st', 'stat']
280
273
 
283
276
 
284
277
    @display_command
285
278
    def run(self, show_ids=False, file_list=None, revision=None, short=False,
286
 
            versioned=False, no_pending=False, verbose=False,
287
 
            no_classify=False):
 
279
            versioned=False, no_pending=False, verbose=False):
288
280
        from bzrlib.status import show_tree_status
289
281
 
290
282
        if revision and len(revision) > 2:
304
296
        show_tree_status(tree, show_ids=show_ids,
305
297
                         specific_files=relfile_list, revision=revision,
306
298
                         to_file=self.outf, short=short, versioned=versioned,
307
 
                         show_pending=(not no_pending), verbose=verbose,
308
 
                         classify=not no_classify)
 
299
                         show_pending=(not no_pending), verbose=verbose)
309
300
 
310
301
 
311
302
class cmd_cat_revision(Command):
803
794
                                      require_versioned=True)
804
795
            # find_ids_across_trees may include some paths that don't
805
796
            # exist in 'tree'.
806
 
            entries = sorted(
807
 
                (tree.id2path(file_id), tree.inventory[file_id])
808
 
                for file_id in file_ids if tree.has_id(file_id))
 
797
            entries = sorted((tree.id2path(file_id), tree.inventory[file_id])
 
798
                             for file_id in file_ids if file_id in tree)
809
799
        else:
810
800
            entries = tree.inventory.entries()
811
801
 
1748
1738
            b = wt.branch
1749
1739
            last_revision = wt.last_revision()
1750
1740
 
1751
 
        self.add_cleanup(b.repository.lock_read().unlock)
1752
 
        graph = b.repository.get_graph()
1753
 
        revisions = [revid for revid, parents in
1754
 
            graph.iter_ancestry([last_revision])]
1755
 
        for revision_id in reversed(revisions):
1756
 
            if _mod_revision.is_null(revision_id):
1757
 
                continue
 
1741
        revision_ids = b.repository.get_ancestry(last_revision)
 
1742
        revision_ids.pop(0)
 
1743
        for revision_id in revision_ids:
1758
1744
            self.outf.write(revision_id + '\n')
1759
1745
 
1760
1746
 
2162
2148
        basis_inv = basis.inventory
2163
2149
        inv = wt.inventory
2164
2150
        for file_id in inv:
2165
 
            if basis_inv.has_id(file_id):
 
2151
            if file_id in basis_inv:
2166
2152
                continue
2167
2153
            if inv.is_root(file_id) and len(basis_inv) == 0:
2168
2154
                continue
2401
2387
            Option('exclude-common-ancestry',
2402
2388
                   help='Display only the revisions that are not part'
2403
2389
                   ' of both ancestries (require -rX..Y)'
2404
 
                   ),
2405
 
            Option('signatures',
2406
 
                   help='Show digital signature validity'),
 
2390
                   )
2407
2391
            ]
2408
2392
    encoding_type = 'replace'
2409
2393
 
2422
2406
            include_merges=False,
2423
2407
            authors=None,
2424
2408
            exclude_common_ancestry=False,
2425
 
            signatures=False,
2426
2409
            ):
2427
2410
        from bzrlib.log import (
2428
2411
            Logger,
2482
2465
            self.add_cleanup(b.lock_read().unlock)
2483
2466
            rev1, rev2 = _get_revision_range(revision, b, self.name())
2484
2467
 
2485
 
        if b.get_config().validate_signatures_in_log():
2486
 
            signatures = True
2487
 
 
2488
 
        if signatures:
2489
 
            if not gpg.GPGStrategy.verify_signatures_available():
2490
 
                raise errors.GpgmeNotInstalled(None)
2491
 
 
2492
2468
        # Decide on the type of delta & diff filtering to use
2493
2469
        # TODO: add an --all-files option to make this configurable & consistent
2494
2470
        if not verbose:
2540
2516
            message_search=message, delta_type=delta_type,
2541
2517
            diff_type=diff_type, _match_using_deltas=match_using_deltas,
2542
2518
            exclude_common_ancestry=exclude_common_ancestry,
2543
 
            signature=signatures
2544
2519
            )
2545
2520
        Logger(b, rqst).show(lf)
2546
2521
 
3216
3191
        from bzrlib.msgeditor import (
3217
3192
            edit_commit_message_encoded,
3218
3193
            generate_commit_message_template,
3219
 
            make_commit_message_template_encoded,
3220
 
            set_commit_message,
 
3194
            make_commit_message_template_encoded
3221
3195
        )
3222
3196
 
3223
3197
        commit_stamp = offset = None
3289
3263
                # make_commit_message_template_encoded returns user encoding.
3290
3264
                # We probably want to be using edit_commit_message instead to
3291
3265
                # avoid this.
3292
 
                my_message = set_commit_message(commit_obj)
3293
 
                if my_message is None:
3294
 
                    start_message = generate_commit_message_template(commit_obj)
3295
 
                    my_message = edit_commit_message_encoded(text,
3296
 
                        start_message=start_message)
 
3266
                start_message = generate_commit_message_template(commit_obj)
 
3267
                my_message = edit_commit_message_encoded(text,
 
3268
                    start_message=start_message)
3297
3269
                if my_message is None:
3298
3270
                    raise errors.BzrCommandError("please specify a commit"
3299
3271
                        " message with either --message or --file")
3674
3646
        if typestring == "sftp":
3675
3647
            from bzrlib.tests import stub_sftp
3676
3648
            return stub_sftp.SFTPAbsoluteServer
3677
 
        elif typestring == "memory":
 
3649
        if typestring == "memory":
3678
3650
            from bzrlib.tests import test_server
3679
3651
            return memory.MemoryServer
3680
 
        elif typestring == "fakenfs":
 
3652
        if typestring == "fakenfs":
3681
3653
            from bzrlib.tests import test_server
3682
3654
            return test_server.FakeNFSServer
3683
3655
        msg = "No known transport type %s. Supported types are: sftp\n" %\
3717
3689
                     Option('randomize', type=str, argname="SEED",
3718
3690
                            help='Randomize the order of tests using the given'
3719
3691
                                 ' seed or "now" for the current time.'),
3720
 
                     ListOption('exclude', type=str, argname="PATTERN",
3721
 
                                short_name='x',
3722
 
                                help='Exclude tests that match this regular'
3723
 
                                ' expression.'),
 
3692
                     Option('exclude', type=str, argname="PATTERN",
 
3693
                            short_name='x',
 
3694
                            help='Exclude tests that match this regular'
 
3695
                                 ' expression.'),
3724
3696
                     Option('subunit',
3725
3697
                        help='Output test progress via subunit.'),
3726
3698
                     Option('strict', help='Fail on missing dependencies or '
3777
3749
                "--benchmark is no longer supported from bzr 2.2; "
3778
3750
                "use bzr-usertest instead")
3779
3751
        test_suite_factory = None
3780
 
        if not exclude:
3781
 
            exclude_pattern = None
3782
 
        else:
3783
 
            exclude_pattern = '(' + '|'.join(exclude) + ')'
3784
3752
        selftest_kwargs = {"verbose": verbose,
3785
3753
                          "pattern": pattern,
3786
3754
                          "stop_on_failure": one,
3791
3759
                          "matching_tests_first": first,
3792
3760
                          "list_only": list_only,
3793
3761
                          "random_seed": randomize,
3794
 
                          "exclude_pattern": exclude_pattern,
 
3762
                          "exclude_pattern": exclude,
3795
3763
                          "strict": strict,
3796
3764
                          "load_list": load_list,
3797
3765
                          "debug_flags": debugflag,
3866
3834
    The source of the merge can be specified either in the form of a branch,
3867
3835
    or in the form of a path to a file containing a merge directive generated
3868
3836
    with bzr send. If neither is specified, the default is the upstream branch
3869
 
    or the branch most recently merged using --remember.  The source of the
3870
 
    merge may also be specified in the form of a path to a file in another
3871
 
    branch:  in this case, only the modifications to that file are merged into
3872
 
    the current working tree.
 
3837
    or the branch most recently merged using --remember.
3873
3838
 
3874
3839
    When merging from a branch, by default bzr will try to merge in all new
3875
3840
    work from the other branch, automatically determining an appropriate base
3905
3870
    committed to record the result of the merge.
3906
3871
 
3907
3872
    merge refuses to run if there are any uncommitted changes, unless
3908
 
    --force is given.  If --force is given, then the changes from the source 
3909
 
    will be merged with the current working tree, including any uncommitted
3910
 
    changes in the tree.  The --force option can also be used to create a
 
3873
    --force is given. The --force option can also be used to create a
3911
3874
    merge revision which has more than two parents.
3912
3875
 
3913
3876
    If one would like to merge changes from the working tree of the other
3985
3948
        merger = None
3986
3949
        allow_pending = True
3987
3950
        verified = 'inapplicable'
3988
 
 
3989
3951
        tree = WorkingTree.open_containing(directory)[0]
3990
 
        if tree.branch.revno() == 0:
3991
 
            raise errors.BzrCommandError('Merging into empty branches not currently supported, '
3992
 
                                         'https://bugs.launchpad.net/bzr/+bug/308562')
3993
3952
 
3994
3953
        try:
3995
3954
            basis_tree = tree.revision_tree(tree.last_revision())
4041
4000
        self.sanity_check_merger(merger)
4042
4001
        if (merger.base_rev_id == merger.other_rev_id and
4043
4002
            merger.other_rev_id is not None):
4044
 
            # check if location is a nonexistent file (and not a branch) to
4045
 
            # disambiguate the 'Nothing to do'
4046
 
            if merger.interesting_files:
4047
 
                if not merger.other_tree.has_filename(
4048
 
                    merger.interesting_files[0]):
4049
 
                    note("merger: " + str(merger))
4050
 
                    raise errors.PathsDoNotExist([location])
4051
4003
            note('Nothing to do.')
4052
4004
            return 0
4053
4005
        if pull and not preview:
4996
4948
 
4997
4949
        if not force:
4998
4950
            if not ui.ui_factory.confirm_action(
4999
 
                    u'Uncommit these revisions',
 
4951
                    'Uncommit these revisions',
5000
4952
                    'bzrlib.builtins.uncommit',
5001
4953
                    {}):
5002
4954
                self.outf.write('Canceled\n')
5680
5632
            unstacked=None):
5681
5633
        directory = bzrdir.BzrDir.open(location)
5682
5634
        if stacked_on and unstacked:
5683
 
            raise errors.BzrCommandError("Can't use both --stacked-on and --unstacked")
 
5635
            raise BzrCommandError("Can't use both --stacked-on and --unstacked")
5684
5636
        elif stacked_on is not None:
5685
5637
            reconfigure.ReconfigureStackedOn().apply(directory, stacked_on)
5686
5638
        elif unstacked:
6238
6190
        ('cmd_version_info', [], 'bzrlib.cmd_version_info'),
6239
6191
        ('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
6240
6192
        ('cmd_conflicts', [], 'bzrlib.conflicts'),
6241
 
        ('cmd_sign_my_commits', [], 'bzrlib.commit_signature_commands'),
6242
 
        ('cmd_verify_signatures', [],
6243
 
                                        'bzrlib.commit_signature_commands'),
 
6193
        ('cmd_sign_my_commits', [], 'bzrlib.sign_my_commits'),
6244
6194
        ('cmd_test_script', [], 'bzrlib.cmd_test_script'),
6245
6195
        ]:
6246
6196
        builtin_command_registry.register_lazy(name, aliases, module_name)