~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Vincent Ladeuil
  • Date: 2010-06-17 09:23:19 UTC
  • mfrom: (5301 +trunk)
  • mto: (5247.1.8 first-try)
  • mto: This revision was merged to the branch mainline in revision 5326.
  • Revision ID: v.ladeuil+lp@free.fr-20100617092319-da2bzdtf3j0voynf
Merge bzr.dev into cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
491
491
    takes_options = [
492
492
        Option('force',
493
493
               help='Remove the working tree even if it has '
494
 
                    'uncommitted changes.'),
 
494
                    'uncommitted or shelved changes.'),
495
495
        ]
496
496
 
497
497
    def run(self, location_list, force=False):
511
511
            if not force:
512
512
                if (working.has_changes()):
513
513
                    raise errors.UncommittedChanges(working)
 
514
                if working.get_shelf_manager().last_shelf() is not None:
 
515
                    raise errors.ShelvedChanges(working)
514
516
 
515
517
            if working.user_url != working.branch.user_url:
516
518
                raise errors.BzrCommandError("You cannot remove the working tree"
3309
3311
 
3310
3312
            bzr whoami "Frank Chu <fchu@example.com>"
3311
3313
    """
3312
 
    takes_options = [ Option('email',
 
3314
    takes_options = [ 'directory',
 
3315
                      Option('email',
3313
3316
                             help='Display email address only.'),
3314
3317
                      Option('branch',
3315
3318
                             help='Set identity for the current branch instead of '
3319
3322
    encoding_type = 'replace'
3320
3323
 
3321
3324
    @display_command
3322
 
    def run(self, email=False, branch=False, name=None):
 
3325
    def run(self, email=False, branch=False, name=None, directory=None):
3323
3326
        if name is None:
3324
 
            # use branch if we're inside one; otherwise global config
3325
 
            try:
3326
 
                c = Branch.open_containing('.')[0].get_config()
3327
 
            except errors.NotBranchError:
3328
 
                c = config.GlobalConfig()
 
3327
            if directory is None:
 
3328
                # use branch if we're inside one; otherwise global config
 
3329
                try:
 
3330
                    c = Branch.open_containing(u'.')[0].get_config()
 
3331
                except errors.NotBranchError:
 
3332
                    c = config.GlobalConfig()
 
3333
            else:
 
3334
                c = Branch.open(directory).get_config()
3329
3335
            if email:
3330
3336
                self.outf.write(c.user_email() + '\n')
3331
3337
            else:
3341
3347
 
3342
3348
        # use global config unless --branch given
3343
3349
        if branch:
3344
 
            c = Branch.open_containing('.')[0].get_config()
 
3350
            if directory is None:
 
3351
                c = Branch.open_containing(u'.')[0].get_config()
 
3352
            else:
 
3353
                c = Branch.open(directory).get_config()
3345
3354
        else:
3346
3355
            c = config.GlobalConfig()
3347
3356
        c.set_user_option('email', name)
4289
4298
    _see_also = ['merge', 'pull']
4290
4299
    takes_args = ['other_branch?']
4291
4300
    takes_options = [
 
4301
        'directory',
4292
4302
        Option('reverse', 'Reverse the order of revisions.'),
4293
4303
        Option('mine-only',
4294
4304
               'Display changes in the local branch only.'),
4316
4326
            theirs_only=False,
4317
4327
            log_format=None, long=False, short=False, line=False,
4318
4328
            show_ids=False, verbose=False, this=False, other=False,
4319
 
            include_merges=False, revision=None, my_revision=None):
 
4329
            include_merges=False, revision=None, my_revision=None,
 
4330
            directory=u'.'):
4320
4331
        from bzrlib.missing import find_unmerged, iter_log_revisions
4321
4332
        def message(s):
4322
4333
            if not is_quiet():
4335
4346
        elif theirs_only:
4336
4347
            restrict = 'remote'
4337
4348
 
4338
 
        local_branch = Branch.open_containing(u".")[0]
 
4349
        local_branch = Branch.open_containing(directory)[0]
4339
4350
        self.add_cleanup(local_branch.lock_read().unlock)
4340
4351
 
4341
4352
        parent = local_branch.get_parent()
5012
5023
    _see_also = ['send']
5013
5024
 
5014
5025
    takes_options = [
 
5026
        'directory',
5015
5027
        RegistryOption.from_kwargs('patch-type',
5016
5028
            'The type of patch to include in the directive.',
5017
5029
            title='Patch type',
5030
5042
    encoding_type = 'exact'
5031
5043
 
5032
5044
    def run(self, submit_branch=None, public_branch=None, patch_type='bundle',
5033
 
            sign=False, revision=None, mail_to=None, message=None):
 
5045
            sign=False, revision=None, mail_to=None, message=None,
 
5046
            directory=u'.'):
5034
5047
        from bzrlib.revision import ensure_null, NULL_REVISION
5035
5048
        include_patch, include_bundle = {
5036
5049
            'plain': (False, False),
5037
5050
            'diff': (True, False),
5038
5051
            'bundle': (True, True),
5039
5052
            }[patch_type]
5040
 
        branch = Branch.open('.')
 
5053
        branch = Branch.open(directory)
5041
5054
        stored_submit_branch = branch.get_submit_branch()
5042
5055
        if submit_branch is None:
5043
5056
            submit_branch = stored_submit_branch
5128
5141
    given, in which case it is sent to a file.
5129
5142
 
5130
5143
    Mail is sent using your preferred mail program.  This should be transparent
5131
 
    on Windows (it uses MAPI).  On Linux, it requires the xdg-email utility.
 
5144
    on Windows (it uses MAPI).  On Unix, it requires the xdg-email utility.
5132
5145
    If the preferred client can't be found (or used), your editor will be used.
5133
5146
 
5134
5147
    To use a specific mail program, set the mail_client configuration option.
5531
5544
    """
5532
5545
 
5533
5546
    takes_args = ['to_location?']
5534
 
    takes_options = [Option('force',
 
5547
    takes_options = ['directory',
 
5548
                     Option('force',
5535
5549
                        help='Switch even if local commits will be lost.'),
5536
5550
                     'revision',
5537
5551
                     Option('create-branch', short_name='b',
5540
5554
                    ]
5541
5555
 
5542
5556
    def run(self, to_location=None, force=False, create_branch=False,
5543
 
            revision=None):
 
5557
            revision=None, directory=u'.'):
5544
5558
        from bzrlib import switch
5545
 
        tree_location = '.'
 
5559
        tree_location = directory
5546
5560
        revision = _get_one_revision('switch', revision)
5547
5561
        control_dir = bzrdir.BzrDir.open_containing(tree_location)[0]
5548
5562
        if to_location is None:
5549
5563
            if revision is None:
5550
5564
                raise errors.BzrCommandError('You must supply either a'
5551
5565
                                             ' revision or a location')
5552
 
            to_location = '.'
 
5566
            to_location = tree_location
5553
5567
        try:
5554
5568
            branch = control_dir.open_branch()
5555
5569
            had_explicit_nick = branch.get_config().has_explicit_nickname()
5830
5844
    takes_args = ['file*']
5831
5845
 
5832
5846
    takes_options = [
 
5847
        'directory',
5833
5848
        'revision',
5834
5849
        Option('all', help='Shelve all changes.'),
5835
5850
        'message',
5844
5859
    _see_also = ['unshelve']
5845
5860
 
5846
5861
    def run(self, revision=None, all=False, file_list=None, message=None,
5847
 
            writer=None, list=False, destroy=False):
 
5862
            writer=None, list=False, destroy=False, directory=u'.'):
5848
5863
        if list:
5849
5864
            return self.run_for_list()
5850
5865
        from bzrlib.shelf_ui import Shelver
5852
5867
            writer = bzrlib.option.diff_writer_registry.get()
5853
5868
        try:
5854
5869
            shelver = Shelver.from_args(writer(sys.stdout), revision, all,
5855
 
                file_list, message, destroy=destroy)
 
5870
                file_list, message, destroy=destroy, directory=directory)
5856
5871
            try:
5857
5872
                shelver.run()
5858
5873
            finally:
5886
5901
 
5887
5902
    takes_args = ['shelf_id?']
5888
5903
    takes_options = [
 
5904
        'directory',
5889
5905
        RegistryOption.from_kwargs(
5890
5906
            'action', help="The action to perform.",
5891
5907
            enum_switch=False, value_switches=True,
5899
5915
    ]
5900
5916
    _see_also = ['shelve']
5901
5917
 
5902
 
    def run(self, shelf_id=None, action='apply'):
 
5918
    def run(self, shelf_id=None, action='apply', directory=u'.'):
5903
5919
        from bzrlib.shelf_ui import Unshelver
5904
 
        unshelver = Unshelver.from_args(shelf_id, action)
 
5920
        unshelver = Unshelver.from_args(shelf_id, action, directory=directory)
5905
5921
        try:
5906
5922
            unshelver.run()
5907
5923
        finally: