/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from bzrlib import (
20
20
    delta as _mod_delta,
21
 
    hooks as _mod_hooks,
22
21
    log,
23
22
    osutils,
24
23
    tsort,
151
150
        old.lock_read()
152
151
        new.lock_read()
153
152
        try:
154
 
            for hook in hooks['pre_status']:
155
 
                hook(StatusHookParams(old, new, to_file, versioned,
156
 
                    show_ids, short, verbose))
157
 
 
158
153
            specific_files, nonexistents \
159
154
                = _filter_nonexistent(specific_files, old, new)
160
155
            want_unversioned = not versioned
215
210
                show_pending_merges(new, to_file, short, verbose=verbose)
216
211
            if nonexistents:
217
212
                raise errors.PathsDoNotExist(nonexistents)
218
 
            for hook in hooks['post_status']:
219
 
                hook(StatusHookParams(old, new, to_file, versioned,
220
 
                    show_ids, short, verbose))
221
213
        finally:
222
214
            old.unlock()
223
215
            new.unlock()
364
356
    # their groups individually.  But for consistency of this
365
357
    # function's API, it's better to sort both than just 'nonexistent'.
366
358
    return sorted(remaining), sorted(nonexistent)
367
 
 
368
 
 
369
 
class StatusHooks(_mod_hooks.Hooks):
370
 
    """A dictionary mapping hook name to a list of callables for status hooks.
371
 
 
372
 
    e.g. ['post_status'] Is the list of items to be called when the
373
 
    status command has finished printing the status.
374
 
    """
375
 
 
376
 
    def __init__(self):
377
 
        """Create the default hooks.
378
 
 
379
 
        These are all empty initially, because by default nothing should get
380
 
        notified.
381
 
        """
382
 
        _mod_hooks.Hooks.__init__(self)
383
 
        self.create_hook(_mod_hooks.HookPoint('post_status',
384
 
            "Called with argument StatusHookParams after Bazaar has "
385
 
            "displayed the status. StatusHookParams has the attributes "
386
 
            "(old_tree, new_tree, to_file, versioned, show_ids, short, "
387
 
            "verbose). The last four arguments correspond to the command "
388
 
            "line options specified by the user for the status command. "
389
 
            "to_file is the output stream for writing.",
390
 
            (2, 3), None))
391
 
        self.create_hook(_mod_hooks.HookPoint('pre_status',
392
 
            "Called with argument StatusHookParams before Bazaar "
393
 
            "displays the status. StatusHookParams has the attributes "
394
 
            "(old_tree, new_tree, to_file, versioned, show_ids, short, "
395
 
            "verbose). The last four arguments correspond to the command "
396
 
            "line options specified by the user for the status command. "
397
 
            "to_file is the output stream for writing.",
398
 
            (2, 3), None))
399
 
 
400
 
 
401
 
hooks = StatusHooks()
402
 
 
403
 
 
404
 
class StatusHookParams(object):
405
 
    """Object holding parameters passed to post_status hooks.
406
 
 
407
 
    :ivar old_tree: Start tree (basis tree) for comparison.
408
 
    :ivar new_tree: Working tree.
409
 
    :ivar to_file: If set, write to this file.
410
 
    :ivar versioned: Show only versioned files.
411
 
    :ivar show_ids: Show internal object ids.
412
 
    :ivar short: Use short status indicators.
413
 
    :ivar verbose: Verbose flag.
414
 
    """
415
 
 
416
 
    def __init__(self, old_tree, new_tree, to_file, versioned, show_ids,
417
 
            short, verbose):
418
 
        """Create a group of post_status hook parameters.
419
 
 
420
 
        :param old_tree: Start tree (basis tree) for comparison.
421
 
        :param new_tree: Working tree.
422
 
        :param to_file: If set, write to this file.
423
 
        :param versioned: Show only versioned files.
424
 
        :param show_ids: Show internal object ids.
425
 
        :param short: Use short status indicators.
426
 
        :param verbose: Verbose flag.
427
 
        """
428
 
        self.old_tree = old_tree
429
 
        self.new_tree = new_tree
430
 
        self.to_file = to_file
431
 
        self.versioned = versioned
432
 
        self.show_ids = show_ids
433
 
        self.short = short
434
 
        self.verbose = verbose
435
 
 
436
 
    def __eq__(self, other):
437
 
        return self.__dict__ == other.__dict__
438
 
 
439
 
    def __repr__(self):
440
 
        return "<%s(%s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
441
 
            self.old_tree, self.new_tree, self.to_file, self.versioned,
442
 
            self.show_ids, self.short, self.verbose)
443