47
46
except KeyError, r:
48
47
raise errors.NoSuchRevision(repository, revision_id)
49
48
self.tree = commit.tree
51
file_id_map_sha = store[self.tree][self.mapping.BZR_FILE_IDS_FILE][1]
55
file_ids = self.mapping.import_fileid_map(store[file_id_map_sha])
56
fileid_map = GitFileIdMap(file_ids, self.mapping)
57
self._inventory = GitInventory(self.tree, self.mapping, fileid_map, store,
49
fileid_map = self.mapping.get_fileid_map(store.__getitem__, self.tree)
50
self._inventory = GitInventory(self.tree, self.mapping, fileid_map,
60
53
def get_revision_id(self):
61
54
return self._revision_id
70
63
return entry.object.data
73
def tree_delta_from_git_changes(changes, mapping, specific_file=None,
74
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):
75
69
"""Create a TreeDelta from two git trees.
77
71
source and target are iterators over tuples with:
80
74
ret = delta.TreeDelta()
81
75
for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
76
if mapping.is_control_file(oldpath):
78
if mapping.is_control_file(newpath):
80
if oldpath is None and newpath is None:
82
82
if oldpath is None:
83
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)))
84
84
elif newpath is None:
85
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)))
86
86
elif oldpath != newpath:
87
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)))
88
88
elif mode_kind(oldmode) != mode_kind(newmode):
89
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)))
90
90
elif oldsha != newsha or oldmode != newmode:
91
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)))
93
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)))
157
157
raise AssertionError
158
158
changes = self.source._repository._git.object_store.tree_changes(
159
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__,
163
target_fileid_map = self.target.mapping.get_fileid_map(
164
self.target._repository._git.object_store.__getitem__,
160
166
return tree_delta_from_git_changes(changes, self.target.mapping,
167
(source_fileid_map, target_fileid_map),
161
168
specific_file=specific_files)
163
170
def iter_changes(self, include_unchanged=False, specific_files=None,