~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: John Arbash Meinel
  • Date: 2007-02-26 02:11:26 UTC
  • mto: (2255.11.3 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: john@arbash-meinel.com-20070226021126-m31pb4ci3lxrjha8
_iter_changes should return Unicode paths.
Also, support NULL_REVISION by special casing the source_index
and just stating that all entries are absent.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1404
1404
                require_versioned):
1405
1405
                yield f
1406
1406
            return
1407
 
        assert (self.source._revision_id in self.target.get_parent_ids())
1408
 
        parents = self.target.get_parent_ids()
 
1407
        parent_ids = self.target.get_parent_ids()
1409
1408
        target_index = 0
1410
 
        source_index = 1 + parents.index(self.source._revision_id)
 
1409
        if self.source._revision_id == NULL_REVISION:
 
1410
            source_index = None
 
1411
            indices = (target_index,)
 
1412
        else:
 
1413
            assert (self.source._revision_id in parent_ids), \
 
1414
                "Failure: source._revision_id: %s not in target.parent_ids(%s)" % (
 
1415
                self.source._revision_id, parent_ids)
 
1416
            source_index = 1 + parent_ids.index(self.source._revision_id)
 
1417
            indices = (source_index,target_index)
1411
1418
        # -- make all specific_files utf8 --
1412
1419
        if specific_files:
1413
1420
            specific_files_utf8 = set()
1442
1449
            # -- check all supplied paths are versioned in a search tree. --
1443
1450
            all_versioned = True
1444
1451
            for path in specific_files:
1445
 
                path = path.encode('utf8')
1446
1452
                path_entries = _entries_for_path(path)
1447
1453
                if not path_entries:
1448
1454
                    # this specified path is not present at all: error
1452
1458
                # for each id at this path
1453
1459
                for entry in path_entries:
1454
1460
                    # for each tree.
1455
 
                    for index in source_index, target_index:
 
1461
                    for index in indices:
1456
1462
                        if entry[1][index][0] != 'a': # absent
1457
1463
                            found_versioned = True
1458
1464
                            # all good: found a versioned cell
1511
1517
        # relocated path as one to search if its not searched already. If the
1512
1518
        # detail is not relocated, add the id.
1513
1519
        searched_specific_files = set()
 
1520
        NULL_PARENT_DETAILS = dirstate.DirState.NULL_PARENT_DETAILS
1514
1521
        def _process_entry(entry, path_info):
1515
1522
            """Compare an entry and real disk to generate delta information.
1516
1523
 
1519
1526
                (Perhaps we should pass in a concrete entry for this ?)
1520
1527
            """
1521
1528
            # TODO: when a parent has been renamed, dont emit path renames for children,
1522
 
            source_details = entry[1][source_index]
 
1529
            if source_index is None:
 
1530
                source_details = NULL_PARENT_DETAILS
 
1531
            else:
 
1532
                source_details = entry[1][source_index]
1523
1533
            target_details = entry[1][target_index]
1524
1534
            if source_details[0] in 'rfdl' and target_details[0] in 'fdl':
1525
1535
                # claimed content in both: diff
1588
1598
                    target_exec = bool(
1589
1599
                        stat.S_ISREG(path_info[3].st_mode)
1590
1600
                        and stat.S_IEXEC & path_info[3].st_mode)
1591
 
                    return ((entry[0][2], path, content_change, (True, True), (source_parent_id, target_parent_id), (old_basename, entry[0][1]), (dirstate.DirState._minikind_to_kind[source_details[0]], path_info[2]), (source_exec, target_exec)),)
 
1601
                    path_unicode = path.decode('utf8')
 
1602
                    return ((entry[0][2], path_unicode, content_change,
 
1603
                            (True, True),
 
1604
                            (source_parent_id, target_parent_id),
 
1605
                            (old_basename, entry[0][1]),
 
1606
                            (dirstate.DirState._minikind_to_kind[source_details[0]], path_info[2]),
 
1607
                            (source_exec, target_exec)),)
1592
1608
            elif source_details[0] in 'a' and target_details[0] in 'fdl':
1593
1609
                # looks like a new file
1594
1610
                if path_info is not None:
1602
1618
                    new_executable = bool(
1603
1619
                        stat.S_ISREG(path_info[3].st_mode)
1604
1620
                        and stat.S_IEXEC & path_info[3].st_mode)
1605
 
                    return ((entry[0][2], path, True, (False, True), (None, parent_id), (None, entry[0][1]), (None, path_info[2]), (None, new_executable)),)
 
1621
                    path_unicode = path.decode('utf8')
 
1622
                    return ((entry[0][2], path_unicode, True,
 
1623
                            (False, True),
 
1624
                            (None, parent_id),
 
1625
                            (None, entry[0][1]),
 
1626
                            (None, path_info[2]),
 
1627
                            (None, new_executable)),)
1606
1628
                else:
1607
1629
                    # but its not on disk: we deliberately treat this as just
1608
1630
                    # never-present. (Why ?! - RBC 20070224)
1617
1639
                parent_id = state._get_entry(source_index, path_utf8=entry[0][0])[0][2]
1618
1640
                if parent_id == entry[0][2]:
1619
1641
                    parent_id = None
1620
 
                return ((entry[0][2], old_path, True, (True, False), (parent_id, None), (entry[0][1], None), (dirstate.DirState._minikind_to_kind[source_details[0]], None), (source_details[3], None)),)
 
1642
                old_path_unicode = old_path.decode('utf8')
 
1643
                return ((entry[0][2], old_path_unicode, True,
 
1644
                        (True, False),
 
1645
                        (parent_id, None),
 
1646
                        (entry[0][1], None),
 
1647
                        (dirstate.DirState._minikind_to_kind[source_details[0]], None),
 
1648
                        (source_details[3], None)),)
1621
1649
            elif source_details[0] in 'fdl' and target_details[0] in 'r':
1622
1650
                # a rename; could be a true rename, or a rename inherited from
1623
1651
                # a renamed parent. TODO: handle this efficiently. Its not