116
122
:param verbose: If True, show all merged revisions, not just
118
124
:param versioned: If True, only shows versioned files.
125
:param classify: Add special symbols to indicate file kind.
119
126
:param show_long_callback: A callback: message = show_long_callback(to_file, delta,
120
127
show_ids, show_unchanged, indent, filter), only used with the long output
122
129
if show_unchanged is not None:
123
130
warn("show_tree_status with show_unchanged has been deprecated "
124
"since bzrlib 0.9", DeprecationWarning, stacklevel=2)
131
"since breezy 0.9", DeprecationWarning, stacklevel=2)
126
133
if to_file is None:
127
134
to_file = sys.stdout
131
138
new_is_working_tree = True
132
139
if revision is None:
133
140
if wt.last_revision() != wt.branch.last_revision():
134
warning("working tree is out of date, run 'bzr update'")
141
warning("working tree is out of date, run 'brz update'")
136
143
old = new.basis_tree()
137
144
elif len(revision) > 0:
139
146
old = revision[0].as_tree(wt.branch)
140
except errors.NoSuchRevision, e:
147
except errors.NoSuchRevision as e:
141
148
raise errors.BzrCommandError(str(e))
142
149
if (len(revision) > 1) and (revision[1].spec is not None):
144
151
new = revision[1].as_tree(wt.branch)
145
152
new_is_working_tree = False
146
except errors.NoSuchRevision, e:
153
except errors.NoSuchRevision as e:
147
154
raise errors.BzrCommandError(str(e))
160
for hook in hooks['pre_status']:
161
hook(StatusHookParams(old, new, to_file, versioned,
162
show_ids, short, verbose, specific_files=specific_files))
153
164
specific_files, nonexistents \
154
165
= _filter_nonexistent(specific_files, old, new)
155
166
want_unversioned = not versioned
157
168
# Reporter used for short outputs
158
169
reporter = _mod_delta._ChangeReporter(output_file=to_file,
159
unversioned_filter=new.is_ignored)
170
unversioned_filter=new.is_ignored, classify=classify)
160
171
report_changes(to_file, old, new, specific_files,
161
172
reporter, show_long_callback,
162
173
short=short, want_unchanged=show_unchanged,
163
want_unversioned=want_unversioned, show_ids=show_ids)
174
want_unversioned=want_unversioned, show_ids=show_ids,
165
177
# show the ignored files among specific files (i.e. show the files
166
178
# identified from input that we choose to ignore).
301
316
merge_extra.discard(_mod_revision.NULL_REVISION)
303
318
# Get a handle to all of the revisions we will need
305
revisions = dict((rev.revision_id, rev) for rev in
306
branch.repository.get_revisions(merge_extra))
307
except errors.NoSuchRevision:
308
# One of the sub nodes is a ghost, check each one
310
for revision_id in merge_extra:
312
rev = branch.repository.get_revisions([revision_id])[0]
313
except errors.NoSuchRevision:
314
revisions[revision_id] = None
316
revisions[revision_id] = rev
319
revisions = dict(branch.repository.iter_revisions(merge_extra))
318
321
# Display the revisions brought in by this merge.
319
322
rev_id_iterator = _get_sorted_revisions(merge, merge_extra,
320
323
branch.repository.get_parent_map(merge_extra))
321
324
# Skip the first node
322
num, first, depth, eom = rev_id_iterator.next()
325
num, first, depth, eom = next(rev_id_iterator)
323
326
if first != merge:
324
327
raise AssertionError('Somehow we misunderstood how'
325
328
' iter_topo_order works %s != %s' % (first, merge))
356
359
# their groups individually. But for consistency of this
357
360
# function's API, it's better to sort both than just 'nonexistent'.
358
361
return sorted(remaining), sorted(nonexistent)
364
class StatusHooks(_mod_hooks.Hooks):
365
"""A dictionary mapping hook name to a list of callables for status hooks.
367
e.g. ['post_status'] Is the list of items to be called when the
368
status command has finished printing the status.
372
"""Create the default hooks.
374
These are all empty initially, because by default nothing should get
377
_mod_hooks.Hooks.__init__(self, "breezy.status", "hooks")
378
self.add_hook('post_status',
379
"Called with argument StatusHookParams after Bazaar has "
380
"displayed the status. StatusHookParams has the attributes "
381
"(old_tree, new_tree, to_file, versioned, show_ids, short, "
382
"verbose). The last four arguments correspond to the command "
383
"line options specified by the user for the status command. "
384
"to_file is the output stream for writing.",
386
self.add_hook('pre_status',
387
"Called with argument StatusHookParams before Bazaar "
388
"displays the status. StatusHookParams has the attributes "
389
"(old_tree, new_tree, to_file, versioned, show_ids, short, "
390
"verbose). The last four arguments correspond to the command "
391
"line options specified by the user for the status command. "
392
"to_file is the output stream for writing.",
396
class StatusHookParams(object):
397
"""Object holding parameters passed to post_status hooks.
399
:ivar old_tree: Start tree (basis tree) for comparison.
400
:ivar new_tree: Working tree.
401
:ivar to_file: If set, write to this file.
402
:ivar versioned: Show only versioned files.
403
:ivar show_ids: Show internal object ids.
404
:ivar short: Use short status indicators.
405
:ivar verbose: Verbose flag.
408
def __init__(self, old_tree, new_tree, to_file, versioned, show_ids,
409
short, verbose, specific_files=None):
410
"""Create a group of post_status hook parameters.
412
:param old_tree: Start tree (basis tree) for comparison.
413
:param new_tree: Working tree.
414
:param to_file: If set, write to this file.
415
:param versioned: Show only versioned files.
416
:param show_ids: Show internal object ids.
417
:param short: Use short status indicators.
418
:param verbose: Verbose flag.
419
:param specific_files: If set, a list of filenames whose status should be
420
shown. It is an error to give a filename that is not in the working
421
tree, or in the working inventory or in the basis inventory.
423
self.old_tree = old_tree
424
self.new_tree = new_tree
425
self.to_file = to_file
426
self.versioned = versioned
427
self.show_ids = show_ids
429
self.verbose = verbose
430
self.specific_files = specific_files
432
def __eq__(self, other):
433
return self.__dict__ == other.__dict__
436
return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
437
self.old_tree, self.new_tree, self.to_file, self.versioned,
438
self.show_ids, self.short, self.verbose, self.specific_files)
441
def _show_shelve_summary(params):
442
"""post_status hook to display a summary of shelves.
444
:param params: StatusHookParams.
446
# Don't show shelves if status of specific files is being shown, only if
447
# no file arguments have been passed
448
if params.specific_files:
450
get_shelf_manager = getattr(params.new_tree, 'get_shelf_manager', None)
451
if get_shelf_manager is None:
453
manager = get_shelf_manager()
454
shelves = manager.active_shelves()
456
singular = '%d shelf exists. '
457
plural = '%d shelves exist. '
458
if len(shelves) == 1:
462
params.to_file.write(fmt % len(shelves))
463
params.to_file.write('See "brz shelve --list" for details.\n')
466
hooks = StatusHooks()
469
hooks.install_named_hook('post_status', _show_shelve_summary,