~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Aaron Bentley
  • Date: 2007-12-19 17:08:54 UTC
  • mto: This revision was merged to the branch mainline in revision 3135.
  • Revision ID: abentley@panoramicfeedback.com-20071219170854-wkjt195ere6aorsm
Try to optimize iter_changes_accelerated

Show diffs side-by-side

added added

removed removed

Lines of Context:
1460
1460
    if accelerator_tree is None:
1461
1461
        new_desired_files = desired_files
1462
1462
    else:
 
1463
        desired_file_ids = [f for f, i in desired_files]
 
1464
        paths = dict((e.file_id, p) for p, e in
 
1465
            accelerator_tree.iter_entries_by_dir(
 
1466
            specific_file_ids=desired_file_ids))
1463
1467
        new_desired_files = []
1464
1468
        for file_id, identifier in desired_files:
1465
1469
            want_new = True
 
1470
            accelerator_path = paths.get(file_id)
 
1471
            if accelerator_path is None:
 
1472
                new_desired_files.append((file_id, identifier))
 
1473
                continue
1466
1474
            try:
1467
 
                if (accelerator_tree.get_file_sha1(file_id) ==
1468
 
                    tree.get_file_sha1(file_id)):
1469
 
                    contents = accelerator_tree.get_file(file_id)
 
1475
                if (accelerator_tree.get_file_sha1(file_id, accelerator_path)
 
1476
                    == tree.get_file_sha1(file_id)):
 
1477
                    contents = accelerator_tree.get_file(file_id,
 
1478
                                                         accelerator_path)
1470
1479
                    try:
1471
1480
                        want_new = False
1472
1481
                        contents_bytes = (contents.read(),)
1475
1484
                    yield identifier, contents_bytes
1476
1485
            except errors.NoSuchId:
1477
1486
                pass
 
1487
            except IOError, e:
 
1488
                if e.errno != errno.ENOENT:
 
1489
                    raise
1478
1490
            if want_new:
1479
1491
                new_desired_files.append((file_id, identifier))
1480
1492
    for result in tree.iter_files_bytes(new_desired_files):