~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Aaron Bentley
  • Date: 2007-01-10 14:08:01 UTC
  • mto: This revision was merged to the branch mainline in revision 2254.
  • Revision ID: abentley@panoramicfeedback.com-20070110140801-ixdm903ldjr4emik
Added revert change display, with tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1199
1199
 
1200
1200
 
1201
1201
def revert(working_tree, target_tree, filenames, backups=False, 
1202
 
           pb=DummyProgress()):
 
1202
           pb=DummyProgress(), change_reporter=None):
1203
1203
    """Revert a working tree's contents to those of a target tree."""
1204
1204
    interesting_ids = find_interesting(working_tree, target_tree, filenames)
1205
1205
    tt = TreeTransform(working_tree, pb)
1209
1209
        child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
1210
1210
        try:
1211
1211
            _alter_files(working_tree, target_tree, tt, child_pb, 
1212
 
                         interesting_ids, backups)
 
1212
                         interesting_ids, backups, change_reporter)
1213
1213
        finally:
1214
1214
            child_pb.finished()
1215
1215
        pp.next_phase()
1230
1230
    return conflicts
1231
1231
 
1232
1232
 
1233
 
def _alter_files(working_tree, target_tree, tt, pb, interesting_ids, backups):
 
1233
def _alter_files(working_tree, target_tree, tt, pb, interesting_ids, backups, 
 
1234
                 report_changes):
 
1235
    from bzrlib import delta
1234
1236
    merge_modified = working_tree.merge_modified()
1235
 
    iterator = target_tree._iter_changes(working_tree, 
1236
 
                                         specific_file_ids=interesting_ids,
1237
 
                                         pb=pb)
 
1237
    change_list = list(target_tree._iter_changes(working_tree, 
 
1238
        specific_file_ids=interesting_ids, pb=pb))
1238
1239
    if target_tree.inventory.root is None:
1239
1240
        skip_root = True
1240
1241
    else:
1241
1242
        skip_root = False
1242
1243
    basis_tree = None
 
1244
    if report_changes:
 
1245
        change_reporter = delta.ChangeReporter(working_tree.inventory)
 
1246
        delta.report_changes(change_list, change_reporter)
1243
1247
    for id_num, (file_id, path, changed_content, versioned, parent, name, kind,
1244
 
                 executable) in enumerate(iterator):
 
1248
                 executable) in enumerate(change_list):
1245
1249
        if skip_root and file_id[0] is not None and parent[0] is None:
1246
1250
            continue
1247
1251
        trans_id = tt.trans_id_file_id(file_id)