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
70
68
changes = new.iter_changes(old, want_unchanged, specific_files,
71
require_versioned=False, want_unversioned=want_unversioned)
69
require_versioned=False, want_unversioned=want_unversioned)
72
70
_mod_delta.report_changes(changes, show_short_reporter)
74
72
delta = new.changes_from(old, want_unchanged=want_unchanged,
75
specific_files=specific_files,
76
want_unversioned=want_unversioned)
73
specific_files=specific_files,
74
want_unversioned=want_unversioned)
77
75
# filter out unknown files. We may want a tree method for
79
delta.unversioned = [unversioned for unversioned in
80
delta.unversioned if not new.is_ignored(unversioned[0])]
77
delta.unversioned = [change for change in delta.unversioned
78
if not new.is_ignored(change.path[1])]
81
79
show_long_callback(to_file, delta,
83
81
show_unchanged=want_unchanged,
149
146
raise errors.BzrCommandError(str(e))
149
with old.lock_read(), new.lock_read():
155
150
for hook in hooks['pre_status']:
156
hook(StatusHookParams(old, new, to_file, versioned,
157
show_ids, short, verbose, specific_files=specific_files))
151
hook(StatusHookParams(
152
old, new, to_file, versioned, show_ids, short, verbose,
153
specific_files=specific_files))
159
155
specific_files, nonexistents \
160
156
= _filter_nonexistent(specific_files, old, new)
161
157
want_unversioned = not versioned
163
159
# Reporter used for short outputs
164
reporter = _mod_delta._ChangeReporter(output_file=to_file,
165
unversioned_filter=new.is_ignored, classify=classify)
160
reporter = _mod_delta._ChangeReporter(
161
output_file=to_file, unversioned_filter=new.is_ignored,
166
163
report_changes(to_file, old, new, specific_files,
167
164
reporter, show_long_callback,
168
165
short=short, want_unversioned=want_unversioned,
173
170
if specific_files is not None:
174
171
# Ignored files is sorted because specific_files is already sorted
175
172
ignored_files = [specific for specific in
176
specific_files if new.is_ignored(specific)]
173
specific_files if new.is_ignored(specific)]
177
174
if len(ignored_files) > 0 and not short:
178
175
to_file.write("ignored:\n")
187
184
conflicts = new.conflicts()
188
185
if specific_files is not None:
189
conflicts = conflicts.select_conflicts(new, specific_files,
190
ignore_misses=True, recurse=True)[1]
186
conflicts = conflicts.select_conflicts(
187
new, specific_files, ignore_misses=True, recurse=True)[1]
191
188
if len(conflicts) > 0 and not short:
192
189
to_file.write("conflicts:\n")
193
190
for conflict in conflicts:
198
to_file.write("%s %s\n" % (prefix, unicode(conflict)))
195
to_file.write("%s %s\n" % (prefix, conflict.describe()))
199
196
# Show files that were requested but don't exist (and are
200
197
# not versioned). We don't involve delta in this; these
201
198
# paths are really the province of just the status
218
215
raise errors.PathsDoNotExist(nonexistents)
219
216
for hook in hooks['post_status']:
220
hook(StatusHookParams(old, new, to_file, versioned,
221
show_ids, short, verbose, specific_files=specific_files))
217
hook(StatusHookParams(
218
old, new, to_file, versioned, show_ids, short, verbose,
219
specific_files=specific_files))
229
222
def _get_sorted_revisions(tip_revision, revision_ids, parent_map):
242
235
# of any references pointing outside of this graph.
243
236
parent_graph = {}
244
237
for revision_id in revision_ids:
245
if revision_id not in parent_map: # ghost
238
if revision_id not in parent_map: # ghost
246
239
parent_graph[revision_id] = []
248
241
# Only include parents which are in this sub-graph
249
242
parent_graph[revision_id] = [p for p in parent_map[revision_id]
250
if p in revision_ids]
243
if p in revision_ids]
251
244
sorter = tsort.MergeSorter(parent_graph, tip_revision)
252
245
return sorter.iter_topo_order()
294
287
rev = branch.repository.get_revision(merge)
295
288
except errors.NoSuchRevision:
296
289
# If we are missing a revision, just print out the revision id
297
to_file.write(first_prefix + '(ghost) ' + merge + '\n')
290
to_file.write(first_prefix + '(ghost) ' +
291
merge.decode('utf-8') + '\n')
298
292
other_revisions.append(merge)
315
309
# Display the revisions brought in by this merge.
316
310
rev_id_iterator = _get_sorted_revisions(merge, merge_extra,
317
branch.repository.get_parent_map(merge_extra))
311
branch.repository.get_parent_map(merge_extra))
318
312
# Skip the first node
319
313
num, first, depth, eom = next(rev_id_iterator)
320
314
if first != merge:
321
315
raise AssertionError('Somehow we misunderstood how'
322
' iter_topo_order works %s != %s' % (first, merge))
316
' iter_topo_order works %s != %s' % (first, merge))
323
317
for num, sub_merge, depth, eom in rev_id_iterator:
324
318
rev = revisions[sub_merge]
326
to_file.write(sub_prefix + '(ghost) ' + sub_merge + '\n')
320
to_file.write(sub_prefix + '(ghost) ' +
321
sub_merge.decode('utf-8') + '\n')
328
323
show_log_message(revisions[sub_merge], sub_prefix)
347
342
s = old_tree.filter_unversioned_files(orig_paths)
348
343
s = new_tree.filter_unversioned_files(s)
349
344
nonexistent = [path for path in s if not new_tree.has_filename(path)]
350
remaining = [path for path in orig_paths if not path in nonexistent]
345
remaining = [path for path in orig_paths if path not in nonexistent]
351
346
# Sorting the 'remaining' list doesn't have much effect in
352
347
# practice, since the various status output sections will sort
353
348
# their groups individually. But for consistency of this
371
366
_mod_hooks.Hooks.__init__(self, "breezy.status", "hooks")
372
self.add_hook('post_status',
373
369
"Called with argument StatusHookParams after Bazaar has "
374
370
"displayed the status. StatusHookParams has the attributes "
375
371
"(old_tree, new_tree, to_file, versioned, show_ids, short, "
377
373
"line options specified by the user for the status command. "
378
374
"to_file is the output stream for writing.",
380
self.add_hook('pre_status',
381
378
"Called with argument StatusHookParams before Bazaar "
382
379
"displays the status. StatusHookParams has the attributes "
383
380
"(old_tree, new_tree, to_file, versioned, show_ids, short, "
402
399
def __init__(self, old_tree, new_tree, to_file, versioned, show_ids,
403
short, verbose, specific_files=None):
400
short, verbose, specific_files=None):
404
401
"""Create a group of post_status hook parameters.
406
403
:param old_tree: Start tree (basis tree) for comparison.
411
408
:param short: Use short status indicators.
412
409
:param verbose: Verbose flag.
413
410
:param specific_files: If set, a list of filenames whose status should be
414
shown. It is an error to give a filename that is not in the working
415
tree, or in the working inventory or in the basis inventory.
411
shown. It is an error to give a filename that is not in the
412
working tree, or in the working inventory or in the basis inventory.
417
414
self.old_tree = old_tree
418
415
self.new_tree = new_tree
427
424
return self.__dict__ == other.__dict__
429
426
def __repr__(self):
430
return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (self.__class__.__name__,
431
self.old_tree, self.new_tree, self.to_file, self.versioned,
432
self.show_ids, self.short, self.verbose, self.specific_files)
427
return "<%s(%s, %s, %s, %s, %s, %s, %s, %s)>" % (
428
self.__class__.__name__, self.old_tree, self.new_tree,
429
self.to_file, self.versioned, self.show_ids, self.short,
430
self.verbose, self.specific_files)
435
433
def _show_shelve_summary(params):