/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tree.py

Fix some more tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        except KeyError, r:
47
47
            raise errors.NoSuchRevision(repository, revision_id)
48
48
        self.tree = commit.tree
49
 
        self._inventory = GitInventory(self.tree, self.mapping, store, 
50
 
                                       revision_id)
 
49
        fileid_map = self.mapping.get_fileid_map(store.__getitem__, self.tree)
 
50
        self._inventory = GitInventory(self.tree, self.mapping, fileid_map,
 
51
            store, revision_id)
51
52
 
52
53
    def get_revision_id(self):
53
54
        return self._revision_id
62
63
        return entry.object.data
63
64
 
64
65
 
65
 
def tree_delta_from_git_changes(changes, mapping, specific_file=None, 
66
 
                                require_versioned=False):
 
66
def tree_delta_from_git_changes(changes, mapping,
 
67
        (old_fileid_map, new_fileid_map), specific_file=None,
 
68
        require_versioned=False):
67
69
    """Create a TreeDelta from two git trees.
68
70
    
69
71
    source and target are iterators over tuples with: 
71
73
    """
72
74
    ret = delta.TreeDelta()
73
75
    for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
 
76
        if mapping.is_control_file(oldpath):
 
77
            oldpath = None
 
78
        if mapping.is_control_file(newpath):
 
79
            newpath = None
 
80
        if oldpath is None and newpath is None:
 
81
            continue
74
82
        if oldpath is None:
75
 
            ret.added.append((newpath, mapping.generate_file_id(newpath), mode_kind(newmode)))
 
83
            ret.added.append((newpath, new_fileid_map.lookup_file_id(newpath.encode("utf-8")), mode_kind(newmode)))
76
84
        elif newpath is None:
77
 
            ret.removed.append((oldpath, mapping.generate_file_id(oldpath), mode_kind(oldmode)))
 
85
            ret.removed.append((oldpath, old_fileid_map.lookup_file_id(oldpath.encode("utf-8")), mode_kind(oldmode)))
78
86
        elif oldpath != newpath:
79
 
            ret.renamed.append((oldpath, newpath, mapping.generate_file_id(oldpath), mode_kind(newmode), (oldsha != newsha), (oldmode != newmode)))
 
87
            ret.renamed.append((oldpath, newpath, old_fileid_map.lookup_file_id(oldpath.encode("utf-8")), mode_kind(newmode), (oldsha != newsha), (oldmode != newmode)))
80
88
        elif mode_kind(oldmode) != mode_kind(newmode):
81
 
            ret.kind_changed.append((newpath, mapping.generate_file_id(newpath), mode_kind(oldmode), mode_kind(newmode)))
 
89
            ret.kind_changed.append((newpath, new_fileid_map.lookup_file_id(newpath.encode("utf-8")), mode_kind(oldmode), mode_kind(newmode)))
82
90
        elif oldsha != newsha or oldmode != newmode:
83
 
            ret.modified.append((newpath, mapping.generate_file_id(newpath), mode_kind(newmode), (oldsha != newsha), (oldmode != newmode)))
 
91
            ret.modified.append((newpath, new_fileid_map.lookup_file_id(newpath.encode("utf-8")), mode_kind(newmode), (oldsha != newsha), (oldmode != newmode)))
84
92
        else:
85
 
            ret.unchanged.append((newpath, mapping.generate_file_id(newpath), mode_kind(newmode)))
 
93
            ret.unchanged.append((newpath, new_fileid_map.lookup_file_id(newpath.encode("utf-8")), mode_kind(newmode)))
86
94
    return ret
87
95
 
88
96
 
149
157
            raise AssertionError
150
158
        changes = self.source._repository._git.object_store.tree_changes(
151
159
            self.source.tree, self.target.tree, want_unchanged=want_unchanged)
 
160
        source_fileid_map = self.source.mapping.get_fileid_map(
 
161
            self.source._repository._git.object_store.__getitem__,
 
162
            self.source.tree)
 
163
        target_fileid_map = self.target.mapping.get_fileid_map(
 
164
            self.target._repository._git.object_store.__getitem__,
 
165
            self.target.tree)
152
166
        return tree_delta_from_git_changes(changes, self.target.mapping, 
 
167
            (source_fileid_map, target_fileid_map),
153
168
            specific_file=specific_files)
154
169
 
155
170
    def iter_changes(self, include_unchanged=False, specific_files=None,