~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Jonathan Riddell
  • Date: 2011-09-07 14:20:10 UTC
  • mfrom: (6123.1.10 +trunk)
  • mto: (6123.1.12 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6124.
  • Revision ID: jriddell@canonical.com-20110907142010-kncwzcbpsxd714ug
mergeĀ inĀ trunk

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):