27
27
revision as _mod_revision,
29
29
from . import errors as errors
30
from .sixish import text_type
31
30
from .trace import mutter, warning
32
31
from .workingtree import ShelvingUnsupported
71
70
changes = new.iter_changes(old, want_unchanged, specific_files,
72
require_versioned=False, want_unversioned=want_unversioned)
71
require_versioned=False, want_unversioned=want_unversioned)
73
72
_mod_delta.report_changes(changes, show_short_reporter)
75
74
delta = new.changes_from(old, want_unchanged=want_unchanged,
76
specific_files=specific_files,
77
want_unversioned=want_unversioned)
75
specific_files=specific_files,
76
want_unversioned=want_unversioned)
78
77
# filter out unknown files. We may want a tree method for
80
79
delta.unversioned = [unversioned for unversioned in
81
delta.unversioned if not new.is_ignored(unversioned[0])]
80
delta.unversioned if not new.is_ignored(unversioned[0])]
82
81
show_long_callback(to_file, delta,
84
83
show_unchanged=want_unchanged,
152
151
with old.lock_read(), new.lock_read():
153
152
for hook in hooks['pre_status']:
154
hook(StatusHookParams(old, new, to_file, versioned,
155
show_ids, short, verbose, specific_files=specific_files))
153
hook(StatusHookParams(
154
old, new, to_file, versioned, show_ids, short, verbose,
155
specific_files=specific_files))
157
157
specific_files, nonexistents \
158
158
= _filter_nonexistent(specific_files, old, new)
159
159
want_unversioned = not versioned
161
161
# Reporter used for short outputs
162
reporter = _mod_delta._ChangeReporter(output_file=to_file,
163
unversioned_filter=new.is_ignored, classify=classify)
162
reporter = _mod_delta._ChangeReporter(
163
output_file=to_file, unversioned_filter=new.is_ignored,
164
165
report_changes(to_file, old, new, specific_files,
165
166
reporter, show_long_callback,
166
167
short=short, want_unversioned=want_unversioned,
171
172
if specific_files is not None:
172
173
# Ignored files is sorted because specific_files is already sorted
173
174
ignored_files = [specific for specific in
174
specific_files if new.is_ignored(specific)]
175
specific_files if new.is_ignored(specific)]
175
176
if len(ignored_files) > 0 and not short:
176
177
to_file.write("ignored:\n")
185
186
conflicts = new.conflicts()
186
187
if specific_files is not None:
187
conflicts = conflicts.select_conflicts(new, specific_files,
188
ignore_misses=True, recurse=True)[1]
188
conflicts = conflicts.select_conflicts(
189
new, specific_files, ignore_misses=True, recurse=True)[1]
189
190
if len(conflicts) > 0 and not short:
190
191
to_file.write("conflicts:\n")
191
192
for conflict in conflicts:
216
217
raise errors.PathsDoNotExist(nonexistents)
217
218
for hook in hooks['post_status']:
218
hook(StatusHookParams(old, new, to_file, versioned,
219
show_ids, short, verbose, specific_files=specific_files))
219
hook(StatusHookParams(
220
old, new, to_file, versioned, show_ids, short, verbose,
221
specific_files=specific_files))
222
224
def _get_sorted_revisions(tip_revision, revision_ids, parent_map):
235
237
# of any references pointing outside of this graph.
236
238
parent_graph = {}
237
239
for revision_id in revision_ids:
238
if revision_id not in parent_map: # ghost
240
if revision_id not in parent_map: # ghost
239
241
parent_graph[revision_id] = []
241
243
# Only include parents which are in this sub-graph
242
244
parent_graph[revision_id] = [p for p in parent_map[revision_id]
243
if p in revision_ids]
245
if p in revision_ids]
244
246
sorter = tsort.MergeSorter(parent_graph, tip_revision)
245
247
return sorter.iter_topo_order()
287
289
rev = branch.repository.get_revision(merge)
288
290
except errors.NoSuchRevision:
289
291
# If we are missing a revision, just print out the revision id
290
to_file.write(first_prefix + '(ghost) ' + merge.decode('utf-8') + '\n')
292
to_file.write(first_prefix + '(ghost) ' +
293
merge.decode('utf-8') + '\n')
291
294
other_revisions.append(merge)
308
311
# Display the revisions brought in by this merge.
309
312
rev_id_iterator = _get_sorted_revisions(merge, merge_extra,
310
branch.repository.get_parent_map(merge_extra))
313
branch.repository.get_parent_map(merge_extra))
311
314
# Skip the first node
312
315
num, first, depth, eom = next(rev_id_iterator)
313
316
if first != merge:
314
317
raise AssertionError('Somehow we misunderstood how'
315
' iter_topo_order works %s != %s' % (first, merge))
318
' iter_topo_order works %s != %s' % (first, merge))
316
319
for num, sub_merge, depth, eom in rev_id_iterator:
317
320
rev = revisions[sub_merge]
319
to_file.write(sub_prefix + '(ghost) ' + sub_merge.decode('utf-8') + '\n')
322
to_file.write(sub_prefix + '(ghost) ' +
323
sub_merge.decode('utf-8') + '\n')
321
325
show_log_message(revisions[sub_merge], sub_prefix)
340
344
s = old_tree.filter_unversioned_files(orig_paths)
341
345
s = new_tree.filter_unversioned_files(s)
342
346
nonexistent = [path for path in s if not new_tree.has_filename(path)]
343
remaining = [path for path in orig_paths if not path in nonexistent]
347
remaining = [path for path in orig_paths if path not in nonexistent]
344
348
# Sorting the 'remaining' list doesn't have much effect in
345
349
# practice, since the various status output sections will sort
346
350
# their groups individually. But for consistency of this
364
368
_mod_hooks.Hooks.__init__(self, "breezy.status", "hooks")
365
self.add_hook('post_status',
366
371
"Called with argument StatusHookParams after Bazaar has "
367
372
"displayed the status. StatusHookParams has the attributes "
368
373
"(old_tree, new_tree, to_file, versioned, show_ids, short, "
370
375
"line options specified by the user for the status command. "
371
376
"to_file is the output stream for writing.",
373
self.add_hook('pre_status',
374
380
"Called with argument StatusHookParams before Bazaar "
375
381
"displays the status. StatusHookParams has the attributes "
376
382
"(old_tree, new_tree, to_file, versioned, show_ids, short, "
395
401
def __init__(self, old_tree, new_tree, to_file, versioned, show_ids,
396
short, verbose, specific_files=None):
402
short, verbose, specific_files=None):
397
403
"""Create a group of post_status hook parameters.
399
405
:param old_tree: Start tree (basis tree) for comparison.
404
410
:param short: Use short status indicators.
405
411
:param verbose: Verbose flag.
406
412
:param specific_files: If set, a list of filenames whose status should be
407
shown. It is an error to give a filename that is not in the working
408
tree, or in the working inventory or in the basis inventory.
413
shown. It is an error to give a filename that is not in the
414
working tree, or in the working inventory or in the basis inventory.
410
416
self.old_tree = old_tree
411
417
self.new_tree = new_tree
420
426
return self.__dict__ == other.__dict__
422
428
def __repr__(self):
423
return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
424
self.old_tree, self.new_tree, self.to_file, self.versioned,
425
self.show_ids, self.short, self.verbose, self.specific_files)
429
return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (
430
self.__class__.__name__, self.old_tree, self.new_tree,
431
self.to_file, self.versioned, self.show_ids, self.short,
432
self.verbose, self.specific_files)
428
435
def _show_shelve_summary(params):