34
34
def report_changes(to_file, old, new, specific_files,
35
35
show_short_reporter, show_long_callback,
36
36
short=False, want_unchanged=False,
37
want_unversioned=False, show_ids=False):
37
want_unversioned=False, show_ids=False, classify=True):
38
38
"""Display summary of changes.
40
40
This compares two trees with regards to a list of files, and delegates
76
77
delta.unversioned if not new.is_ignored(unversioned[0])]
77
78
show_long_callback(to_file, delta,
79
show_unchanged=want_unchanged)
80
show_unchanged=want_unchanged,
82
84
def show_tree_status(wt, show_unchanged=None,
117
120
:param verbose: If True, show all merged revisions, not just
119
122
:param versioned: If True, only shows versioned files.
123
:param classify: Add special symbols to indicate file kind.
120
124
:param show_long_callback: A callback: message = show_long_callback(to_file, delta,
121
125
show_ids, show_unchanged, indent, filter), only used with the long output
154
158
for hook in hooks['pre_status']:
155
159
hook(StatusHookParams(old, new, to_file, versioned,
156
show_ids, short, verbose))
160
show_ids, short, verbose, specific_files=specific_files))
158
162
specific_files, nonexistents \
159
163
= _filter_nonexistent(specific_files, old, new)
162
166
# Reporter used for short outputs
163
167
reporter = _mod_delta._ChangeReporter(output_file=to_file,
164
unversioned_filter=new.is_ignored)
168
unversioned_filter=new.is_ignored, classify=classify)
165
169
report_changes(to_file, old, new, specific_files,
166
170
reporter, show_long_callback,
167
171
short=short, want_unchanged=show_unchanged,
168
want_unversioned=want_unversioned, show_ids=show_ids)
172
want_unversioned=want_unversioned, show_ids=show_ids,
170
175
# show the ignored files among specific files (i.e. show the files
171
176
# identified from input that we choose to ignore).
197
to_file.write("%s %s\n" % (prefix, conflict))
202
to_file.write("%s %s\n" % (prefix, unicode(conflict)))
198
203
# Show files that were requested but don't exist (and are
199
204
# not versioned). We don't involve delta in this; these
200
205
# paths are really the province of just the status
217
222
raise errors.PathsDoNotExist(nonexistents)
218
223
for hook in hooks['post_status']:
219
224
hook(StatusHookParams(old, new, to_file, versioned,
220
show_ids, short, verbose))
225
show_ids, short, verbose, specific_files=specific_files))
379
384
These are all empty initially, because by default nothing should get
382
_mod_hooks.Hooks.__init__(self)
383
self.create_hook(_mod_hooks.HookPoint('post_status',
387
_mod_hooks.Hooks.__init__(self, "bzrlib.status", "hooks")
388
self.add_hook('post_status',
384
389
"Called with argument StatusHookParams after Bazaar has "
385
390
"displayed the status. StatusHookParams has the attributes "
386
391
"(old_tree, new_tree, to_file, versioned, show_ids, short, "
387
392
"verbose). The last four arguments correspond to the command "
388
393
"line options specified by the user for the status command. "
389
394
"to_file is the output stream for writing.",
391
self.create_hook(_mod_hooks.HookPoint('pre_status',
396
self.add_hook('pre_status',
392
397
"Called with argument StatusHookParams before Bazaar "
393
398
"displays the status. StatusHookParams has the attributes "
394
399
"(old_tree, new_tree, to_file, versioned, show_ids, short, "
395
400
"verbose). The last four arguments correspond to the command "
396
401
"line options specified by the user for the status command. "
397
402
"to_file is the output stream for writing.",
401
406
class StatusHookParams(object):
413
418
def __init__(self, old_tree, new_tree, to_file, versioned, show_ids,
419
short, verbose, specific_files=None):
415
420
"""Create a group of post_status hook parameters.
417
422
:param old_tree: Start tree (basis tree) for comparison.
421
426
:param show_ids: Show internal object ids.
422
427
:param short: Use short status indicators.
423
428
:param verbose: Verbose flag.
429
:param specific_files: If set, a list of filenames whose status should be
430
shown. It is an error to give a filename that is not in the working
431
tree, or in the working inventory or in the basis inventory.
425
433
self.old_tree = old_tree
426
434
self.new_tree = new_tree
429
437
self.show_ids = show_ids
430
438
self.short = short
431
439
self.verbose = verbose
440
self.specific_files = specific_files
433
442
def __eq__(self, other):
434
443
return self.__dict__ == other.__dict__
436
445
def __repr__(self):
437
return "<%s(%s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
446
return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
438
447
self.old_tree, self.new_tree, self.to_file, self.versioned,
439
self.show_ids, self.short, self.verbose)
448
self.show_ids, self.short, self.verbose, self.specific_files)
442
451
def _show_shelve_summary(params):
445
454
:param params: StatusHookParams.
456
# Don't show shelves if status of specific files is being shown, only if
457
# no file arguments have been passed
458
if params.specific_files:
447
460
get_shelf_manager = getattr(params.new_tree, 'get_shelf_manager', None)
448
461
if get_shelf_manager is None:
450
463
manager = get_shelf_manager()
451
464
shelves = manager.active_shelves()
453
params.to_file.write('%d shelves exist. '
454
'See "bzr shelve --list" for details.\n' % len(shelves))
466
singular = '%d shelf exists. '
467
plural = '%d shelves exist. '
468
if len(shelves) == 1:
472
params.to_file.write(fmt % len(shelves))
473
params.to_file.write('See "bzr shelve --list" for details.\n')
457
476
hooks = StatusHooks()