~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Jelmer Vernooij
  • Date: 2009-09-02 15:23:35 UTC
  • mfrom: (4666 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4757.
  • Revision ID: jelmer@samba.org-20090902152335-h9m8dt9p08snroln
merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
 
121
121
 
122
122
def _get_one_revision_tree(command_name, revisions, branch=None, tree=None):
 
123
    """Get a revision tree. Not suitable for commands that change the tree.
 
124
    
 
125
    Specifically, the basis tree in dirstate trees is coupled to the dirstate
 
126
    and doing a commit/uncommit/pull will at best fail due to changing the
 
127
    basis revision data.
 
128
 
 
129
    If tree is passed in, it should be already locked, for lifetime management
 
130
    of the trees internal cached state.
 
131
    """
123
132
    if branch is None:
124
133
        branch = tree.branch
125
134
    if revisions is None:
603
612
    branches that will be merged later (without showing the two different
604
613
    adds as a conflict). It is also useful when merging another project
605
614
    into a subdirectory of this one.
 
615
    
 
616
    Any files matching patterns in the ignore list will not be added
 
617
    unless they are explicitly mentioned.
606
618
    """
607
619
    takes_args = ['file*']
608
620
    takes_options = [
616
628
               help='Lookup file ids from this tree.'),
617
629
        ]
618
630
    encoding_type = 'replace'
619
 
    _see_also = ['remove']
 
631
    _see_also = ['remove', 'ignore']
620
632
 
621
633
    def run(self, file_list, no_recurse=False, dry_run=False, verbose=False,
622
634
            file_ids_from=None):
654
666
                    for path in ignored[glob]:
655
667
                        self.outf.write("ignored %s matching \"%s\"\n"
656
668
                                        % (path, glob))
657
 
            else:
658
 
                match_len = 0
659
 
                for glob, paths in ignored.items():
660
 
                    match_len += len(paths)
661
 
                self.outf.write("ignored %d file(s).\n" % match_len)
662
 
            self.outf.write("If you wish to add ignored files, "
663
 
                            "please add them explicitly by name. "
664
 
                            "(\"bzr ignored\" gives a list)\n")
665
669
 
666
670
 
667
671
class cmd_mkdir(Command):
1172
1176
        help='Hard-link working tree files where possible.'),
1173
1177
        Option('no-tree',
1174
1178
            help="Create a branch without a working-tree."),
 
1179
        Option('switch',
 
1180
            help="Switch the checkout in the current directory "
 
1181
                 "to the new branch."),
1175
1182
        Option('stacked',
1176
1183
            help='Create a stacked branch referring to the source branch. '
1177
1184
                'The new branch will depend on the availability of the source '
1188
1195
 
1189
1196
    def run(self, from_location, to_location=None, revision=None,
1190
1197
            hardlink=False, stacked=False, standalone=False, no_tree=False,
1191
 
            use_existing_dir=False):
 
1198
            use_existing_dir=False, switch=False):
 
1199
        from bzrlib import switch as _mod_switch
1192
1200
        from bzrlib.tag import _merge_tags_if_possible
1193
 
 
1194
1201
        accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1195
1202
            from_location)
1196
1203
        if (accelerator_tree is not None and
1250
1257
            except (errors.NotStacked, errors.UnstackableBranchFormat,
1251
1258
                errors.UnstackableRepositoryFormat), e:
1252
1259
                note('Branched %d revision(s).' % branch.revno())
 
1260
            if switch:
 
1261
                # Switch to the new branch
 
1262
                wt, _ = WorkingTree.open_containing('.')
 
1263
                _mod_switch.switch(wt.bzrdir, branch)
 
1264
                note('Switched to branch: %s',
 
1265
                    urlutils.unescape_for_display(branch.base, 'utf-8'))
1253
1266
        finally:
1254
1267
            br_from.unlock()
1255
1268
 
3025
3038
                raise errors.BzrCommandError("empty commit message specified")
3026
3039
            return my_message
3027
3040
 
 
3041
        # The API permits a commit with a filter of [] to mean 'select nothing'
 
3042
        # but the command line should not do that.
 
3043
        if not selected_list:
 
3044
            selected_list = None
3028
3045
        try:
3029
3046
            tree.commit(message_callback=get_message,
3030
3047
                        specific_files=selected_list,
3365
3382
                     Option('lsprof-timed',
3366
3383
                            help='Generate lsprof output for benchmarked'
3367
3384
                                 ' sections of code.'),
 
3385
                     Option('lsprof-tests',
 
3386
                            help='Generate lsprof output for each test.'),
3368
3387
                     Option('cache-dir', type=str,
3369
3388
                            help='Cache intermediate benchmark output in this '
3370
3389
                                 'directory.'),
3411
3430
            first=False, list_only=False,
3412
3431
            randomize=None, exclude=None, strict=False,
3413
3432
            load_list=None, debugflag=None, starting_with=None, subunit=False,
3414
 
            parallel=None):
 
3433
            parallel=None, lsprof_tests=False):
3415
3434
        from bzrlib.tests import selftest
3416
3435
        import bzrlib.benchmarks as benchmarks
3417
3436
        from bzrlib.benchmarks import tree_creator
3451
3470
                              "transport": transport,
3452
3471
                              "test_suite_factory": test_suite_factory,
3453
3472
                              "lsprof_timed": lsprof_timed,
 
3473
                              "lsprof_tests": lsprof_tests,
3454
3474
                              "bench_history": benchfile,
3455
3475
                              "matching_tests_first": first,
3456
3476
                              "list_only": list_only,
5627
5647
        if writer is None:
5628
5648
            writer = bzrlib.option.diff_writer_registry.get()
5629
5649
        try:
5630
 
            Shelver.from_args(writer(sys.stdout), revision, all, file_list,
5631
 
                              message, destroy=destroy).run()
 
5650
            shelver = Shelver.from_args(writer(sys.stdout), revision, all,
 
5651
                file_list, message, destroy=destroy)
 
5652
            try:
 
5653
                shelver.run()
 
5654
            finally:
 
5655
                shelver.work_tree.unlock()
5632
5656
        except errors.UserAbort:
5633
5657
            return 0
5634
5658
 
5673
5697
 
5674
5698
    def run(self, shelf_id=None, action='apply'):
5675
5699
        from bzrlib.shelf_ui import Unshelver
5676
 
        Unshelver.from_args(shelf_id, action).run()
 
5700
        unshelver = Unshelver.from_args(shelf_id, action)
 
5701
        try:
 
5702
            unshelver.run()
 
5703
        finally:
 
5704
            unshelver.tree.unlock()
5677
5705
 
5678
5706
 
5679
5707
class cmd_clean_tree(Command):