~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-05-18 08:53:27 UTC
  • mfrom: (1713.1.4 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060518085327-89822346d9321aba
Merge benchmark selftests(Robert Collins, Martin Pool), bzr add chattiness(Robert Collins), and bzr push revision count reporting improvements(Robert Collins).

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib.branch import Branch
27
27
import bzrlib.bzrdir as bzrdir
28
28
from bzrlib.commands import Command, display_command
29
 
from bzrlib.revision import common_ancestor
30
29
import bzrlib.errors as errors
31
30
from bzrlib.errors import (BzrError, BzrCheckError, BzrCommandError, 
32
31
                           NotBranchError, DivergedBranches, NotConflicted,
36
35
from bzrlib.merge import Merge3Merger
37
36
from bzrlib.option import Option
38
37
from bzrlib.progress import DummyProgress, ProgressPhase
 
38
from bzrlib.revision import common_ancestor
39
39
from bzrlib.revisionspec import RevisionSpec
40
40
import bzrlib.trace
41
41
from bzrlib.trace import mutter, note, log_error, warning, is_quiet
273
273
        added, ignored = bzrlib.add.smart_add(file_list, not no_recurse, 
274
274
                                              action)
275
275
        if len(ignored) > 0:
276
 
            for glob in sorted(ignored.keys()):
277
 
                match_len = len(ignored[glob])
278
 
                if verbose:
 
276
            if verbose:
 
277
                for glob in sorted(ignored.keys()):
279
278
                    for path in ignored[glob]:
280
279
                        print "ignored %s matching \"%s\"" % (path, glob)
281
 
                else:
282
 
                    print "ignored %d file(s) matching \"%s\"" % (match_len,
283
 
                                                              glob)
 
280
            else:
 
281
                match_len = 0
 
282
                for glob, paths in ignored.items():
 
283
                    match_len += len(paths)
 
284
                print "ignored %d file(s)." % match_len
284
285
            print "If you wish to add some of these files, please add them"\
285
286
                " by name."
286
287
 
518
519
                                                  "path prefix.")
519
520
            dir_to = br_from.bzrdir.clone(location)
520
521
            br_to = dir_to.open_branch()
521
 
        old_rh = br_to.revision_history()
522
 
        try:
 
522
            count = len(br_to.revision_history())
 
523
        else:
 
524
            old_rh = br_to.revision_history()
523
525
            try:
524
 
                tree_to = dir_to.open_workingtree()
525
 
            except errors.NotLocalUrl:
526
 
                # TODO: This should be updated for branches which don't have a
527
 
                # working tree, as opposed to ones where we just couldn't 
528
 
                # update the tree.
529
 
                warning('This transport does not update the working '
530
 
                        'tree of: %s' % (br_to.base,))
531
 
                count = br_to.pull(br_from, overwrite)
532
 
            except NoWorkingTree:
533
 
                count = br_to.pull(br_from, overwrite)
534
 
            else:
535
 
                count = tree_to.pull(br_from, overwrite)
536
 
        except DivergedBranches:
537
 
            raise BzrCommandError("These branches have diverged."
538
 
                                  "  Try a merge then push with overwrite.")
 
526
                try:
 
527
                    tree_to = dir_to.open_workingtree()
 
528
                except errors.NotLocalUrl:
 
529
                    warning('This transport does not update the working '
 
530
                            'tree of: %s' % (br_to.base,))
 
531
                    count = br_to.pull(br_from, overwrite)
 
532
                except NoWorkingTree:
 
533
                    count = br_to.pull(br_from, overwrite)
 
534
                else:
 
535
                    count = tree_to.pull(br_from, overwrite)
 
536
            except DivergedBranches:
 
537
                raise BzrCommandError("These branches have diverged."
 
538
                                      "  Try a merge then push with overwrite.")
539
539
        note('%d revision(s) pushed.' % (count,))
540
540
 
541
541
        if verbose:
1782
1782
                            help='Use a different transport by default '
1783
1783
                                 'throughout the test suite.',
1784
1784
                            type=get_transport_type),
 
1785
                     Option('benchmark', help='run the bzr bencharks.'),
1785
1786
                    ]
1786
1787
 
1787
1788
    def run(self, testspecs_list=None, verbose=False, one=False,
1788
 
            keep_output=False, transport=None):
 
1789
            keep_output=False, transport=None, benchmark=None):
1789
1790
        import bzrlib.ui
1790
1791
        from bzrlib.tests import selftest
 
1792
        import bzrlib.benchmarks as benchmarks
1791
1793
        # we don't want progress meters from the tests to go to the
1792
1794
        # real output; and we don't want log messages cluttering up
1793
1795
        # the real logs.
1794
1796
        save_ui = bzrlib.ui.ui_factory
 
1797
        print '%10s: %s' % ('bzr', bzrlib.osutils.realpath(sys.argv[0]))
 
1798
        print '%10s: %s' % ('bzrlib', bzrlib.__path__[0])
 
1799
        print
1795
1800
        bzrlib.trace.info('running tests...')
1796
1801
        try:
1797
1802
            bzrlib.ui.ui_factory = bzrlib.ui.SilentUIFactory()
1799
1804
                pattern = '|'.join(testspecs_list)
1800
1805
            else:
1801
1806
                pattern = ".*"
 
1807
            if benchmark:
 
1808
                test_suite_factory = benchmarks.test_suite
 
1809
            else:
 
1810
                test_suite_factory = None
1802
1811
            result = selftest(verbose=verbose, 
1803
1812
                              pattern=pattern,
1804
1813
                              stop_on_failure=one, 
1805
1814
                              keep_output=keep_output,
1806
 
                              transport=transport)
 
1815
                              transport=transport,
 
1816
                              test_suite_factory=test_suite_factory)
1807
1817
            if result:
1808
1818
                bzrlib.trace.info('tests passed')
1809
1819
            else: