~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Ian Clatworthy
  • Date: 2009-09-07 07:44:36 UTC
  • mto: (4634.37.2 prepare-2.0)
  • mto: This revision was merged to the branch mainline in revision 4689.
  • Revision ID: ian.clatworthy@canonical.com-20090907074436-pede7phglz90jrvf
split developer docs into their own website/chm file

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
 
1472
1485
            title='Deletion Strategy', value_switches=True, enum_switch=False,
1473
1486
            safe='Only delete files if they can be'
1474
1487
                 ' safely recovered (default).',
1475
 
            keep="Don't delete any files.",
 
1488
            keep='Delete from bzr but leave the working copy.',
1476
1489
            force='Delete all the specified files, even if they can not be '
1477
1490
                'recovered and even if they are non-empty directories.')]
1478
1491
    aliases = ['rm', 'del']
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,
5627
5644
        if writer is None:
5628
5645
            writer = bzrlib.option.diff_writer_registry.get()
5629
5646
        try:
5630
 
            Shelver.from_args(writer(sys.stdout), revision, all, file_list,
5631
 
                              message, destroy=destroy).run()
 
5647
            shelver = Shelver.from_args(writer(sys.stdout), revision, all,
 
5648
                file_list, message, destroy=destroy)
 
5649
            try:
 
5650
                shelver.run()
 
5651
            finally:
 
5652
                shelver.work_tree.unlock()
5632
5653
        except errors.UserAbort:
5633
5654
            return 0
5634
5655
 
5673
5694
 
5674
5695
    def run(self, shelf_id=None, action='apply'):
5675
5696
        from bzrlib.shelf_ui import Unshelver
5676
 
        Unshelver.from_args(shelf_id, action).run()
 
5697
        unshelver = Unshelver.from_args(shelf_id, action)
 
5698
        try:
 
5699
            unshelver.run()
 
5700
        finally:
 
5701
            unshelver.tree.unlock()
5677
5702
 
5678
5703
 
5679
5704
class cmd_clean_tree(Command):