~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: John Arbash Meinel
  • Date: 2011-09-12 18:40:02 UTC
  • mfrom: (6132 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6133.
  • Revision ID: john@arbash-meinel.com-20110912184002-o23eu21fdgp35h2q
Merge bzr.dev, resolve release-notes (aka NEWS) conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3236
3236
    aliases = ['ci', 'checkin']
3237
3237
 
3238
3238
    def _iter_bug_fix_urls(self, fixes, branch):
 
3239
        default_bugtracker  = None
3239
3240
        # Configure the properties for bug fixing attributes.
3240
3241
        for fixed_bug in fixes:
3241
3242
            tokens = fixed_bug.split(':')
3242
 
            if len(tokens) != 2:
 
3243
            if len(tokens) == 1:
 
3244
                if default_bugtracker is None:
 
3245
                    branch_config = branch.get_config()
 
3246
                    default_bugtracker = branch_config.get_user_option(
 
3247
                        "bugtracker")
 
3248
                if default_bugtracker is None:
 
3249
                    raise errors.BzrCommandError(
 
3250
                        "No tracker specified for bug %s. Use the form "
 
3251
                        "'tracker:id' or specify a default bug tracker "
 
3252
                        "using the `bugtracker` option.\nSee "
 
3253
                        "\"bzr help bugs\" for more information on this "
 
3254
                        "feature. Commit refused." % fixed_bug)
 
3255
                tag = default_bugtracker
 
3256
                bug_id = tokens[0]
 
3257
            elif len(tokens) != 2:
3243
3258
                raise errors.BzrCommandError(
3244
3259
                    "Invalid bug %s. Must be in the form of 'tracker:id'. "
3245
3260
                    "See \"bzr help bugs\" for more information on this "
3246
3261
                    "feature.\nCommit refused." % fixed_bug)
3247
 
            tag, bug_id = tokens
 
3262
            else:
 
3263
                tag, bug_id = tokens
3248
3264
            try:
3249
3265
                yield bugtracker.get_bug_url(tag, branch, bug_id)
3250
3266
            except errors.UnknownBugTrackerAbbreviation:
3786
3802
                                param_name='starting_with', short_name='s',
3787
3803
                                help=
3788
3804
                                'Load only the tests starting with TESTID.'),
 
3805
                     Option('sync',
 
3806
                            help="By default we disable fsync and fdatasync"
 
3807
                                 " while running the test suite.")
3789
3808
                     ]
3790
3809
    encoding_type = 'replace'
3791
3810
 
3799
3818
            first=False, list_only=False,
3800
3819
            randomize=None, exclude=None, strict=False,
3801
3820
            load_list=None, debugflag=None, starting_with=None, subunit=False,
3802
 
            parallel=None, lsprof_tests=False):
 
3821
            parallel=None, lsprof_tests=False,
 
3822
            sync=False):
3803
3823
        from bzrlib import tests
3804
3824
 
3805
3825
        if testspecs_list is not None:
3834
3854
            exclude_pattern = None
3835
3855
        else:
3836
3856
            exclude_pattern = '(' + '|'.join(exclude) + ')'
 
3857
        if not sync:
 
3858
            self._disable_fsync()
3837
3859
        selftest_kwargs = {"verbose": verbose,
3838
3860
                          "pattern": pattern,
3839
3861
                          "stop_on_failure": one,
3861
3883
            cleanup()
3862
3884
        return int(not result)
3863
3885
 
 
3886
    def _disable_fsync(self):
 
3887
        """Change the 'os' functionality to not synchronize."""
 
3888
        self._orig_fsync = getattr(os, 'fsync', None)
 
3889
        if self._orig_fsync is not None:
 
3890
            os.fsync = lambda filedes: None
 
3891
        self._orig_fdatasync = getattr(os, 'fdatasync', None)
 
3892
        if self._orig_fdatasync is not None:
 
3893
            os.fdatasync = lambda filedes: None
 
3894
 
3864
3895
 
3865
3896
class cmd_version(Command):
3866
3897
    __doc__ = """Show version of bzr."""
5621
5652
                if tag_name is None:
5622
5653
                    raise errors.BzrCommandError(
5623
5654
                        "Please specify a tag name.")
5624
 
            if (not force) and branch.tags.has_tag(tag_name):
 
5655
            try:
 
5656
                existing_target = branch.tags.lookup_tag(tag_name)
 
5657
            except errors.NoSuchTag:
 
5658
                existing_target = None
 
5659
            if not force and existing_target not in (None, revision_id):
5625
5660
                raise errors.TagAlreadyExists(tag_name)
5626
 
            branch.tags.set_tag(tag_name, revision_id)
5627
 
            note('Created tag %s.' % tag_name)
 
5661
            if existing_target == revision_id:
 
5662
                note('Tag %s already exists for that revision.' % tag_name)
 
5663
            else:
 
5664
                branch.tags.set_tag(tag_name, revision_id)
 
5665
                if existing_target is None:
 
5666
                    note('Created tag %s.' % tag_name)
 
5667
                else:
 
5668
                    note('Updated tag %s.' % tag_name)
5628
5669
 
5629
5670
 
5630
5671
class cmd_tags(Command):
5700
5741
    takes_args = ['location?']
5701
5742
    takes_options = [
5702
5743
        RegistryOption.from_kwargs(
5703
 
            'target_type',
5704
 
            title='Target type',
5705
 
            help='The type to reconfigure the directory to.',
 
5744
            'tree_type',
 
5745
            title='Tree type',
 
5746
            help='The relation between branch and tree.',
5706
5747
            value_switches=True, enum_switch=False,
5707
5748
            branch='Reconfigure to be an unbound branch with no working tree.',
5708
5749
            tree='Reconfigure to be an unbound branch with a working tree.',
5709
5750
            checkout='Reconfigure to be a bound branch with a working tree.',
5710
5751
            lightweight_checkout='Reconfigure to be a lightweight'
5711
5752
                ' checkout (with no local history).',
 
5753
            ),
 
5754
        RegistryOption.from_kwargs(
 
5755
            'repository_type',
 
5756
            title='Repository type',
 
5757
            help='Location fo the repository.',
 
5758
            value_switches=True, enum_switch=False,
5712
5759
            standalone='Reconfigure to be a standalone branch '
5713
5760
                '(i.e. stop using shared repository).',
5714
5761
            use_shared='Reconfigure to use a shared repository.',
 
5762
            ),
 
5763
        RegistryOption.from_kwargs(
 
5764
            'repository_trees',
 
5765
            title='Trees in Repository',
 
5766
            help='Whether new branches in the repository have trees.',
 
5767
            value_switches=True, enum_switch=False,
5715
5768
            with_trees='Reconfigure repository to create '
5716
5769
                'working trees on branches by default.',
5717
5770
            with_no_trees='Reconfigure repository to not create '
5731
5784
            ),
5732
5785
        ]
5733
5786
 
5734
 
    def run(self, location=None, target_type=None, bind_to=None, force=False,
5735
 
            stacked_on=None,
5736
 
            unstacked=None):
 
5787
    def run(self, location=None, bind_to=None, force=False,
 
5788
            tree_type=None, repository_type=None, repository_trees=None,
 
5789
            stacked_on=None, unstacked=None):
5737
5790
        directory = bzrdir.BzrDir.open(location)
5738
5791
        if stacked_on and unstacked:
5739
5792
            raise errors.BzrCommandError("Can't use both --stacked-on and --unstacked")
5744
5797
        # At the moment you can use --stacked-on and a different
5745
5798
        # reconfiguration shape at the same time; there seems no good reason
5746
5799
        # to ban it.
5747
 
        if target_type is None:
 
5800
        if (tree_type is None and
 
5801
            repository_type is None and
 
5802
            repository_trees is None):
5748
5803
            if stacked_on or unstacked:
5749
5804
                return
5750
5805
            else:
5751
5806
                raise errors.BzrCommandError('No target configuration '
5752
5807
                    'specified')
5753
 
        elif target_type == 'branch':
 
5808
        reconfiguration = None
 
5809
        if tree_type == 'branch':
5754
5810
            reconfiguration = reconfigure.Reconfigure.to_branch(directory)
5755
 
        elif target_type == 'tree':
 
5811
        elif tree_type == 'tree':
5756
5812
            reconfiguration = reconfigure.Reconfigure.to_tree(directory)
5757
 
        elif target_type == 'checkout':
 
5813
        elif tree_type == 'checkout':
5758
5814
            reconfiguration = reconfigure.Reconfigure.to_checkout(
5759
5815
                directory, bind_to)
5760
 
        elif target_type == 'lightweight-checkout':
 
5816
        elif tree_type == 'lightweight-checkout':
5761
5817
            reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
5762
5818
                directory, bind_to)
5763
 
        elif target_type == 'use-shared':
 
5819
        if reconfiguration:
 
5820
            reconfiguration.apply(force)
 
5821
            reconfiguration = None
 
5822
        if repository_type == 'use-shared':
5764
5823
            reconfiguration = reconfigure.Reconfigure.to_use_shared(directory)
5765
 
        elif target_type == 'standalone':
 
5824
        elif repository_type == 'standalone':
5766
5825
            reconfiguration = reconfigure.Reconfigure.to_standalone(directory)
5767
 
        elif target_type == 'with-trees':
 
5826
        if reconfiguration:
 
5827
            reconfiguration.apply(force)
 
5828
            reconfiguration = None
 
5829
        if repository_trees == 'with-trees':
5768
5830
            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5769
5831
                directory, True)
5770
 
        elif target_type == 'with-no-trees':
 
5832
        elif repository_trees == 'with-no-trees':
5771
5833
            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5772
5834
                directory, False)
5773
 
        reconfiguration.apply(force)
 
5835
        if reconfiguration:
 
5836
            reconfiguration.apply(force)
 
5837
            reconfiguration = None
5774
5838
 
5775
5839
 
5776
5840
class cmd_switch(Command):