~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: v.ladeuil+lp at free
  • Date: 2007-05-18 18:20:31 UTC
  • mto: (2485.8.44 bzr.connection.sharing)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070518182031-gbg2cgidv5l20x9p
Takes Robert comments into account.

* bzrlib/transport/ftp.py:
(FtpTransport.__init__): Write a better explanation.

* bzrlib/tests/test_init.py:
(InstrumentedTransport): Just make hooks a class attribute.
(InstrumentedTransport._get_FTP): Run hook directly in the for
loop.
(TransportHooks.run_hook, TransportHooks.uninstall_hook): Not
needed. The hooks should be cleaned up by the test itself.
(TestInit.setUp.cleanup): Resset to default hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    option,
45
45
    osutils,
46
46
    trace,
47
 
    win32utils,
48
47
    )
49
48
""")
50
49
 
241
240
        if self.__doc__ == Command.__doc__:
242
241
            warn("No help message set for %r" % self)
243
242
 
244
 
    def _maybe_expand_globs(self, file_list):
245
 
        """Glob expand file_list if the platform does not do that itself.
246
 
        
247
 
        :return: A possibly empty list of unicode paths.
248
 
 
249
 
        Introduced in bzrlib 0.18.
250
 
        """
251
 
        if not file_list:
252
 
            file_list = []
253
 
        if sys.platform == 'win32':
254
 
            file_list = win32utils.glob_expand(file_list)
255
 
        return list(file_list)
256
 
 
257
243
    def _usage(self):
258
244
        """Return single-line grammar for this command.
259
245
 
332
318
 
333
319
        Maps from long option name to option object."""
334
320
        r = dict()
335
 
        r['help'] = option._help_option
 
321
        r['help'] = option.Option.OPTIONS['help']
336
322
        for o in self.takes_options:
337
323
            if isinstance(o, basestring):
338
324
                o = option.Option.OPTIONS[o]
548
534
 
549
535
def apply_lsprofiled(filename, the_callable, *args, **kwargs):
550
536
    from bzrlib.lsprof import profile
 
537
    import cPickle
551
538
    ret, stats = profile(the_callable, *args, **kwargs)
552
539
    stats.sort()
553
540
    if filename is None:
554
541
        stats.pprint()
555
542
    else:
556
 
        stats.save(filename)
557
 
        trace.note('Profile data written to "%s".', filename)
 
543
        stats.freeze()
 
544
        cPickle.dump(stats, open(filename, 'w'), 2)
 
545
        print 'Profile data written to %r.' % filename
558
546
    return ret
559
547
 
560
548
 
726
714
 
727
715
def run_bzr_catch_errors(argv):
728
716
    try:
729
 
        return run_bzr(argv)
 
717
        try:
 
718
            return run_bzr(argv)
 
719
        finally:
 
720
            # do this here inside the exception wrappers to catch EPIPE
 
721
            sys.stdout.flush()
730
722
    except (KeyboardInterrupt, Exception), e:
731
723
        # used to handle AssertionError and KeyboardInterrupt
732
724
        # specially here, but hopefully they're handled ok by the logger now