~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-02-01 23:48:08 UTC
  • mfrom: (2225.1.6 revert)
  • Revision ID: pqm@pqm.ubuntu.com-20070201234808-3b1302d73474bd8c
Display changes made by revert

Show diffs side-by-side

added added

removed removed

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