~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

Merged bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
273
273
                os.unlink(name)
274
274
                raise
275
275
 
276
 
            for segment in contents:
277
 
                f.write(segment)
 
276
            f.writelines(contents)
278
277
        finally:
279
278
            f.close()
280
279
        self._set_mode(trans_id, mode_id, S_ISREG)
1199
1198
 
1200
1199
 
1201
1200
def revert(working_tree, target_tree, filenames, backups=False, 
1202
 
           pb=DummyProgress()):
 
1201
           pb=DummyProgress(), change_reporter=None):
1203
1202
    """Revert a working tree's contents to those of a target tree."""
1204
1203
    interesting_ids = find_interesting(working_tree, target_tree, filenames)
1205
1204
    tt = TreeTransform(working_tree, pb)
1209
1208
        child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
1210
1209
        try:
1211
1210
            _alter_files(working_tree, target_tree, tt, child_pb, 
1212
 
                         interesting_ids, backups)
 
1211
                         interesting_ids, backups, change_reporter)
1213
1212
        finally:
1214
1213
            child_pb.finished()
1215
1214
        pp.next_phase()
1230
1229
    return conflicts
1231
1230
 
1232
1231
 
1233
 
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
1234
1235
    merge_modified = working_tree.merge_modified()
1235
 
    iterator = target_tree._iter_changes(working_tree, 
1236
 
                                         specific_file_ids=interesting_ids,
1237
 
                                         pb=pb)
 
1236
    change_list = list(target_tree._iter_changes(working_tree,
 
1237
        specific_file_ids=interesting_ids, pb=pb))
1238
1238
    if target_tree.inventory.root is None:
1239
1239
        skip_root = True
1240
1240
    else:
1241
1241
        skip_root = False
1242
1242
    basis_tree = None
 
1243
    if report_changes:
 
1244
        change_reporter = delta.ChangeReporter(working_tree.inventory)
 
1245
        delta.report_changes(change_list, change_reporter)
1243
1246
    for id_num, (file_id, path, changed_content, versioned, parent, name, kind,
1244
 
                 executable) in enumerate(iterator):
 
1247
                 executable) in enumerate(change_list):
1245
1248
        if skip_root and file_id[0] is not None and parent[0] is None:
1246
1249
            continue
1247
1250
        trans_id = tt.trans_id_file_id(file_id)