336
335
versioned_change = versioned_change_map[versioned]
337
336
reporter.report(file_id, path, versioned_change, renamed, modified,
338
337
exe_change, kind)
340
def report_short(to_file, delta, show_ids=False, show_unchanged=False,
341
indent='', filter=None):
342
"""Output given delta in status-like form to to_file, using a short format.
344
:param to_file: A file-like object where the output is displayed.
346
:param delta: A TreeDelta containing the changes to be displayed
348
:param show_ids: Output the file ids if True.
350
:param show_unchanged: Output the unchanged files if True.
352
:param indent: Added at the beginning of all output lines (for merged
355
:param filter: A callable receiving a path and a file id and
356
returning True if the path should be displayed.
359
def decorate_path(path, kind, meta_modified=None):
360
if kind == 'directory':
362
elif kind == 'symlink':
368
def show_more_renamed(item):
369
(oldpath, file_id, kind,
370
text_modified, meta_modified, newpath) = item
371
dec_new_path = decorate_path(newpath, kind, meta_modified)
372
to_file.write(' => %s' % dec_new_path)
373
if text_modified or meta_modified:
374
extra_modified.append((newpath, file_id, kind,
375
text_modified, meta_modified))
377
def show_more_kind_changed(item):
378
(path, file_id, old_kind, new_kind) = item
379
to_file.write(' (%s => %s)' % (old_kind, new_kind))
381
def show_path(path, file_id, kind, meta_modified,
382
default_format, with_file_id_format):
383
dec_path = decorate_path(path, kind, meta_modified)
385
to_file.write(with_file_id_format % dec_path)
387
to_file.write(default_format % dec_path)
389
def show_list(files, short_status_letter, default_format='%s',
390
with_file_id_format='%-30s', show_more=None):
392
prefix = indent + short_status_letter + ' '
395
path, file_id, kind = item[:3]
396
if (filter is not None and not filter(path, file_id)):
400
meta_modified = item[4]
402
to_file.write(prefix)
403
show_path(path, file_id, kind, meta_modified,
404
default_format, with_file_id_format)
405
if show_more is not None:
408
to_file.write(' %s' % file_id)
411
show_list(delta.removed, 'D')
412
show_list(delta.added, 'A')
414
# Reorder delta.renamed tuples so that all lists share the same
415
# order for their 3 first fields and that they also begin like
416
# the delta.modified tuples
417
renamed = [(p, i, k, tm, mm, np)
418
for p, np, i, k, tm, mm in delta.renamed]
419
show_list(renamed, 'R', with_file_id_format='%s',
420
show_more=show_more_renamed)
421
show_list(delta.kind_changed, 'K',
422
with_file_id_format='%s',
423
show_more=show_more_kind_changed)
424
show_list(delta.modified + extra_modified, 'M')
426
show_list(delta.unchanged, 'S')
428
show_list(delta.unversioned, ' ')
432
def report_long(to_file, delta, show_ids=False, show_unchanged=False,
433
indent='', filter=None):
434
"""Output given delta in status-like form to to_file.
436
:param to_file: A file-like object where the output is displayed.
438
:param delta: A TreeDelta containing the changes to be displayed
440
:param show_ids: Output the file ids if True.
442
:param show_unchanged: Output the unchanged files if True.
444
:param indent: Added at the beginning of all output lines (for merged
447
:param filter: A callable receiving a path and a file id and
448
returning True if the path should be displayed.
451
def decorate_path(path, kind, meta_modified=None):
452
if kind == 'directory':
454
elif kind == 'symlink':
460
def show_more_renamed(item):
461
(oldpath, file_id, kind,
462
text_modified, meta_modified, newpath) = item
463
dec_new_path = decorate_path(newpath, kind, meta_modified)
464
to_file.write(' => %s' % dec_new_path)
465
if text_modified or meta_modified:
466
extra_modified.append((newpath, file_id, kind,
467
text_modified, meta_modified))
469
def show_more_kind_changed(item):
470
(path, file_id, old_kind, new_kind) = item
471
to_file.write(' (%s => %s)' % (old_kind, new_kind))
473
def show_path(path, file_id, kind, meta_modified,
474
default_format, with_file_id_format):
475
dec_path = decorate_path(path, kind, meta_modified)
477
to_file.write(with_file_id_format % dec_path)
479
to_file.write(default_format % dec_path)
481
def show_list(files, long_status_name, default_format='%s',
482
with_file_id_format='%-30s', show_more=None):
485
prefix = indent + ' '
488
path, file_id, kind = item[:3]
489
if (filter is not None and not filter(path, file_id)):
492
to_file.write(indent + long_status_name + ':\n')
496
meta_modified = item[4]
498
to_file.write(prefix)
499
show_path(path, file_id, kind, meta_modified,
500
default_format, with_file_id_format)
501
if show_more is not None:
504
to_file.write(' %s' % file_id)
507
show_list(delta.removed, 'removed')
508
show_list(delta.added, 'added')
510
# Reorder delta.renamed tuples so that all lists share the same
511
# order for their 3 first fields and that they also begin like
512
# the delta.modified tuples
513
renamed = [(p, i, k, tm, mm, np)
514
for p, np, i, k, tm, mm in delta.renamed]
515
show_list(renamed, 'renamed', with_file_id_format='%s',
516
show_more=show_more_renamed)
517
show_list(delta.kind_changed, 'kind changed',
518
with_file_id_format='%s',
519
show_more=show_more_kind_changed)
520
show_list(delta.modified + extra_modified, 'modified')
522
show_list(delta.unchanged, 'unchanged')
524
show_list(delta.unversioned, 'unknown')