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