~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-16 17:33:27 UTC
  • mfrom: (5755.2.10 2.4-max-entries-gc-602614)
  • Revision ID: pqm@pqm.ubuntu.com-20110516173327-5ehst0ttceohsf5w
(jameinel) Add bzr.groupcompress.max_bytes_to_index to limit peak memory
 when delta-compressing large files (bug #602614) (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
379
379
        These are all empty initially, because by default nothing should get
380
380
        notified.
381
381
        """
382
 
        _mod_hooks.Hooks.__init__(self)
383
 
        self.create_hook(_mod_hooks.HookPoint('post_status',
 
382
        _mod_hooks.Hooks.__init__(self, "bzrlib.status", "hooks")
 
383
        self.add_hook('post_status',
384
384
            "Called with argument StatusHookParams after Bazaar has "
385
385
            "displayed the status. StatusHookParams has the attributes "
386
386
            "(old_tree, new_tree, to_file, versioned, show_ids, short, "
387
387
            "verbose). The last four arguments correspond to the command "
388
388
            "line options specified by the user for the status command. "
389
389
            "to_file is the output stream for writing.",
390
 
            (2, 3), None))
391
 
        self.create_hook(_mod_hooks.HookPoint('pre_status',
 
390
            (2, 3))
 
391
        self.add_hook('pre_status',
392
392
            "Called with argument StatusHookParams before Bazaar "
393
393
            "displays the status. StatusHookParams has the attributes "
394
394
            "(old_tree, new_tree, to_file, versioned, show_ids, short, "
395
395
            "verbose). The last four arguments correspond to the command "
396
396
            "line options specified by the user for the status command. "
397
397
            "to_file is the output stream for writing.",
398
 
            (2, 3), None))
 
398
            (2, 3))
399
399
 
400
400
 
401
401
class StatusHookParams(object):
444
444
 
445
445
    :param params: StatusHookParams.
446
446
    """
447
 
    manager = params.new_tree.get_shelf_manager()
 
447
    get_shelf_manager = getattr(params.new_tree, 'get_shelf_manager', None)
 
448
    if get_shelf_manager is None:
 
449
        return
 
450
    manager = get_shelf_manager()
448
451
    shelves = manager.active_shelves()
449
452
    if shelves:
450
 
        params.to_file.write('%d shelves exist. '
451
 
            'See "bzr shelve --list" for details.\n' % len(shelves))
 
453
        singular = '%d shelf exists. '
 
454
        plural = '%d shelves exist. '
 
455
        if len(shelves) == 1:
 
456
            fmt = singular
 
457
        else:
 
458
            fmt = plural
 
459
        params.to_file.write(fmt % len(shelves))
 
460
        params.to_file.write('See "bzr shelve --list" for details.\n')
452
461
 
453
462
 
454
463
hooks = StatusHooks()