14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
from __future__ import absolute_import
19
21
from bzrlib import (
34
36
def report_changes(to_file, old, new, specific_files,
35
37
show_short_reporter, show_long_callback,
36
38
short=False, want_unchanged=False,
37
want_unversioned=False, show_ids=False):
39
want_unversioned=False, show_ids=False, classify=True):
38
40
"""Display summary of changes.
40
42
This compares two trees with regards to a list of files, and delegates
76
79
delta.unversioned if not new.is_ignored(unversioned[0])]
77
80
show_long_callback(to_file, delta,
79
show_unchanged=want_unchanged)
82
show_unchanged=want_unchanged,
82
86
def show_tree_status(wt, show_unchanged=None,
117
122
:param verbose: If True, show all merged revisions, not just
119
124
:param versioned: If True, only shows versioned files.
125
:param classify: Add special symbols to indicate file kind.
120
126
:param show_long_callback: A callback: message = show_long_callback(to_file, delta,
121
127
show_ids, show_unchanged, indent, filter), only used with the long output
154
160
for hook in hooks['pre_status']:
155
161
hook(StatusHookParams(old, new, to_file, versioned,
156
show_ids, short, verbose))
162
show_ids, short, verbose, specific_files=specific_files))
158
164
specific_files, nonexistents \
159
165
= _filter_nonexistent(specific_files, old, new)
162
168
# Reporter used for short outputs
163
169
reporter = _mod_delta._ChangeReporter(output_file=to_file,
164
unversioned_filter=new.is_ignored)
170
unversioned_filter=new.is_ignored, classify=classify)
165
171
report_changes(to_file, old, new, specific_files,
166
172
reporter, show_long_callback,
167
173
short=short, want_unchanged=show_unchanged,
168
want_unversioned=want_unversioned, show_ids=show_ids)
174
want_unversioned=want_unversioned, show_ids=show_ids,
170
177
# show the ignored files among specific files (i.e. show the files
171
178
# identified from input that we choose to ignore).
197
to_file.write("%s %s\n" % (prefix, conflict))
204
to_file.write("%s %s\n" % (prefix, unicode(conflict)))
198
205
# Show files that were requested but don't exist (and are
199
206
# not versioned). We don't involve delta in this; these
200
207
# paths are really the province of just the status
217
224
raise errors.PathsDoNotExist(nonexistents)
218
225
for hook in hooks['post_status']:
219
226
hook(StatusHookParams(old, new, to_file, versioned,
220
show_ids, short, verbose))
227
show_ids, short, verbose, specific_files=specific_files))
379
386
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',
389
_mod_hooks.Hooks.__init__(self, "bzrlib.status", "hooks")
390
self.add_hook('post_status',
384
391
"Called with argument StatusHookParams after Bazaar has "
385
392
"displayed the status. StatusHookParams has the attributes "
386
393
"(old_tree, new_tree, to_file, versioned, show_ids, short, "
387
394
"verbose). The last four arguments correspond to the command "
388
395
"line options specified by the user for the status command. "
389
396
"to_file is the output stream for writing.",
391
self.create_hook(_mod_hooks.HookPoint('pre_status',
398
self.add_hook('pre_status',
392
399
"Called with argument StatusHookParams before Bazaar "
393
400
"displays the status. StatusHookParams has the attributes "
394
401
"(old_tree, new_tree, to_file, versioned, show_ids, short, "
395
402
"verbose). The last four arguments correspond to the command "
396
403
"line options specified by the user for the status command. "
397
404
"to_file is the output stream for writing.",
401
408
class StatusHookParams(object):
413
420
def __init__(self, old_tree, new_tree, to_file, versioned, show_ids,
421
short, verbose, specific_files=None):
415
422
"""Create a group of post_status hook parameters.
417
424
:param old_tree: Start tree (basis tree) for comparison.
421
428
:param show_ids: Show internal object ids.
422
429
:param short: Use short status indicators.
423
430
:param verbose: Verbose flag.
431
:param specific_files: If set, a list of filenames whose status should be
432
shown. It is an error to give a filename that is not in the working
433
tree, or in the working inventory or in the basis inventory.
425
435
self.old_tree = old_tree
426
436
self.new_tree = new_tree
429
439
self.show_ids = show_ids
430
440
self.short = short
431
441
self.verbose = verbose
442
self.specific_files = specific_files
433
444
def __eq__(self, other):
434
445
return self.__dict__ == other.__dict__
436
447
def __repr__(self):
437
return "<%s(%s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
448
return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
438
449
self.old_tree, self.new_tree, self.to_file, self.versioned,
439
self.show_ids, self.short, self.verbose)
450
self.show_ids, self.short, self.verbose, self.specific_files)
442
453
def _show_shelve_summary(params):
445
456
:param params: StatusHookParams.
447
manager = params.new_tree.get_shelf_manager()
458
# Don't show shelves if status of specific files is being shown, only if
459
# no file arguments have been passed
460
if params.specific_files:
462
get_shelf_manager = getattr(params.new_tree, 'get_shelf_manager', None)
463
if get_shelf_manager is None:
465
manager = get_shelf_manager()
448
466
shelves = manager.active_shelves()
450
params.to_file.write('%d shelves exist. '
451
'See "bzr shelve --list" for details.\n' % len(shelves))
468
singular = '%d shelf exists. '
469
plural = '%d shelves exist. '
470
if len(shelves) == 1:
474
params.to_file.write(fmt % len(shelves))
475
params.to_file.write('See "bzr shelve --list" for details.\n')
454
478
hooks = StatusHooks()