~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Martin Pool
  • Date: 2005-08-24 08:59:32 UTC
  • Revision ID: mbp@sourcefrog.net-20050824085932-c61f1f1f1c930e13
- Add a simple UIFactory 

  The idea of this is to let a client of bzrlib set some 
  policy about how output is displayed.

  In this revision all that's done is that progress bars
  are constructed by a policy established by the application
  rather than being randomly constructed in the library 
  or passed down the calls.  This avoids progress bars
  popping up while running the test suite and cleans up
  some code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
717
717
                    msg = "The branch %s has no revision %d." % (from_location,
718
718
                                                                 revno)
719
719
                    raise BzrCommandError(msg)
720
 
            
 
720
 
721
721
            merge((to_location, -1), (to_location, 0), this_dir=to_location,
722
722
                  check_clean=False, ignore_zero=True)
723
723
            from_location = pull_loc(br_from)
1344
1344
 
1345
1345
    def run(self, dir='.'):
1346
1346
        from bzrlib.check import check
 
1347
 
1347
1348
        check(find_branch(dir))
1348
1349
 
1349
1350
 
1350
 
 
1351
1351
class cmd_scan_cache(Command):
1352
1352
    hidden = True
1353
1353
    def run(self):
1404
1404
    hidden = True
1405
1405
    takes_options = ['verbose']
1406
1406
    def run(self, verbose=False):
 
1407
        import bzrlib.ui
1407
1408
        from bzrlib.selftest import selftest
1408
 
        return int(not selftest(verbose=verbose))
 
1409
 
 
1410
        # we don't want progress meters from the tests to go to the
 
1411
        # real output.
 
1412
 
 
1413
        save_ui = bzrlib.ui.ui_factory
 
1414
        try:
 
1415
            bzrlib.ui.ui_factory = bzrlib.ui.SilentUIFactory()
 
1416
            return int(not selftest(verbose=verbose))
 
1417
        finally:
 
1418
            bzrlib.ui.ui_factory = save_ui
1409
1419
 
1410
1420
 
1411
1421
class cmd_version(Command):
1937
1947
 
1938
1948
 
1939
1949
def main(argv):
 
1950
    import bzrlib.ui
 
1951
    
1940
1952
    bzrlib.trace.open_tracefile(argv)
1941
1953
 
 
1954
    bzrlib.ui.ui_factory = bzrlib.ui.TextUIFactory()
 
1955
 
1942
1956
    try:
1943
1957
        try:
1944
1958
            return run_bzr(argv[1:])