~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

(gz) Provide st_uid and st_gid on _Win32Stat so it looks more like a normal
 stat object (Alexander Belchenko)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3733
3733
                                param_name='starting_with', short_name='s',
3734
3734
                                help=
3735
3735
                                'Load only the tests starting with TESTID.'),
 
3736
                     Option('sync',
 
3737
                            help="By default we disable fsync and fdatasync"
 
3738
                                 " while running the test suite.")
3736
3739
                     ]
3737
3740
    encoding_type = 'replace'
3738
3741
 
3746
3749
            first=False, list_only=False,
3747
3750
            randomize=None, exclude=None, strict=False,
3748
3751
            load_list=None, debugflag=None, starting_with=None, subunit=False,
3749
 
            parallel=None, lsprof_tests=False):
 
3752
            parallel=None, lsprof_tests=False,
 
3753
            sync=False):
3750
3754
        from bzrlib import tests
3751
3755
 
3752
3756
        if testspecs_list is not None:
3781
3785
            exclude_pattern = None
3782
3786
        else:
3783
3787
            exclude_pattern = '(' + '|'.join(exclude) + ')'
 
3788
        if not sync:
 
3789
            self._disable_fsync()
3784
3790
        selftest_kwargs = {"verbose": verbose,
3785
3791
                          "pattern": pattern,
3786
3792
                          "stop_on_failure": one,
3808
3814
            cleanup()
3809
3815
        return int(not result)
3810
3816
 
 
3817
    def _disable_fsync(self):
 
3818
        """Change the 'os' functionality to not synchronize."""
 
3819
        self._orig_fsync = getattr(os, 'fsync', None)
 
3820
        if self._orig_fsync is not None:
 
3821
            os.fsync = lambda filedes: None
 
3822
        self._orig_fdatasync = getattr(os, 'fdatasync', None)
 
3823
        if self._orig_fdatasync is not None:
 
3824
            os.fdatasync = lambda filedes: None
 
3825
 
3811
3826
 
3812
3827
class cmd_version(Command):
3813
3828
    __doc__ = """Show version of bzr."""
5600
5615
 
5601
5616
        self.add_cleanup(branch.lock_read().unlock)
5602
5617
        if revision:
5603
 
            graph = branch.repository.get_graph()
5604
 
            rev1, rev2 = _get_revision_range(revision, branch, self.name())
5605
 
            revid1, revid2 = rev1.rev_id, rev2.rev_id
5606
 
            # only show revisions between revid1 and revid2 (inclusive)
5607
 
            tags = [(tag, revid) for tag, revid in tags if
5608
 
                graph.is_between(revid, revid1, revid2)]
 
5618
            # Restrict to the specified range
 
5619
            tags = self._tags_for_range(branch, revision)
5609
5620
        if sort is None:
5610
5621
            sort = tag_sort_methods.get()
5611
5622
        sort(branch, tags)
5625
5636
        for tag, revspec in tags:
5626
5637
            self.outf.write('%-20s %s\n' % (tag, revspec))
5627
5638
 
 
5639
    def _tags_for_range(self, branch, revision):
 
5640
        range_valid = True
 
5641
        rev1, rev2 = _get_revision_range(revision, branch, self.name())
 
5642
        revid1, revid2 = rev1.rev_id, rev2.rev_id
 
5643
        # _get_revision_range will always set revid2 if it's not specified.
 
5644
        # If revid1 is None, it means we want to start from the branch
 
5645
        # origin which is always a valid ancestor. If revid1 == revid2, the
 
5646
        # ancestry check is useless.
 
5647
        if revid1 and revid1 != revid2:
 
5648
            # FIXME: We really want to use the same graph than
 
5649
            # branch.iter_merge_sorted_revisions below, but this is not
 
5650
            # easily available -- vila 2011-09-23
 
5651
            if branch.repository.get_graph().is_ancestor(revid2, revid1):
 
5652
                # We don't want to output anything in this case...
 
5653
                return []
 
5654
        # only show revisions between revid1 and revid2 (inclusive)
 
5655
        tagged_revids = branch.tags.get_reverse_tag_dict()
 
5656
        found = []
 
5657
        for r in branch.iter_merge_sorted_revisions(
 
5658
            start_revision_id=revid2, stop_revision_id=revid1,
 
5659
            stop_rule='include'):
 
5660
            revid_tags = tagged_revids.get(r[0], None)
 
5661
            if revid_tags:
 
5662
                found.extend([(tag, r[0]) for tag in revid_tags])
 
5663
        return found
 
5664
 
5628
5665
 
5629
5666
class cmd_reconfigure(Command):
5630
5667
    __doc__ = """Reconfigure the type of a bzr directory.