bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
1 |
# Copyright (C) 2009 Jelmer Vernooij <jelmer@samba.org>
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
||
18 |
"""Git Trees."""
|
|
19 |
||
0.264.3
by Jelmer Vernooij
Make RevisionTree inventoryless. |
20 |
from dulwich.object_store import tree_lookup_path |
21 |
import stat |
|
0.264.6
by Jelmer Vernooij
Implement custom GitRevisionTree.iter_entries_by_dir, GitRevisionTree.list_files. |
22 |
import posixpath |
0.264.3
by Jelmer Vernooij
Make RevisionTree inventoryless. |
23 |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
24 |
from bzrlib import ( |
25 |
delta, |
|
26 |
errors, |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
27 |
inventory, |
28 |
osutils, |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
29 |
revisiontree, |
30 |
tree, |
|
31 |
)
|
|
32 |
||
33 |
from bzrlib.plugins.git.mapping import ( |
|
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
34 |
mode_is_executable, |
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
35 |
mode_kind, |
36 |
)
|
|
37 |
||
38 |
||
39 |
class GitRevisionTree(revisiontree.RevisionTree): |
|
0.200.959
by Jelmer Vernooij
Improve docstrings. |
40 |
"""Revision tree implementation based on Git objects.""" |
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
41 |
|
42 |
def __init__(self, repository, revision_id): |
|
43 |
self._revision_id = revision_id |
|
44 |
self._repository = repository |
|
0.264.3
by Jelmer Vernooij
Make RevisionTree inventoryless. |
45 |
self.store = repository._git.object_store |
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
46 |
assert isinstance(revision_id, str) |
0.200.1283
by Jelmer Vernooij
Provide Repository.get_file_graph() and Tree.get_file_revision(). |
47 |
self.commit_id, self.mapping = repository.lookup_bzr_revision_id(revision_id) |
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
48 |
try: |
0.200.1283
by Jelmer Vernooij
Provide Repository.get_file_graph() and Tree.get_file_revision(). |
49 |
commit = self.store[self.commit_id] |
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
50 |
except KeyError, r: |
51 |
raise errors.NoSuchRevision(repository, revision_id) |
|
52 |
self.tree = commit.tree |
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
53 |
self._fileid_map = self.mapping.get_fileid_map(self.store.__getitem__, self.tree) |
0.264.3
by Jelmer Vernooij
Make RevisionTree inventoryless. |
54 |
|
0.200.1283
by Jelmer Vernooij
Provide Repository.get_file_graph() and Tree.get_file_revision(). |
55 |
def get_file_revision(self, file_id, path=None): |
56 |
if path is None: |
|
57 |
path = self.id2path(file_id) |
|
58 |
change_scanner = self._repository._file_change_scanner |
|
59 |
(path, commit_id) = change_scanner.find_last_change_revision(path, |
|
60 |
self.commit_id) |
|
61 |
return self._repository.lookup_foreign_revision_id(commit_id, self.mapping) |
|
62 |
||
63 |
def get_file_mtime(self, file_id, path=None): |
|
64 |
revid = self.get_file_revision(file_id, path) |
|
65 |
try: |
|
66 |
rev = self._repository.get_revision(revid) |
|
67 |
except errors.NoSuchRevision: |
|
68 |
raise errors.FileTimestampUnavailable(path) |
|
69 |
return rev.timestamp |
|
70 |
||
0.264.3
by Jelmer Vernooij
Make RevisionTree inventoryless. |
71 |
def id2path(self, file_id): |
0.200.1328
by Jelmer Vernooij
More test fixes. |
72 |
return self._fileid_map.lookup_path(file_id) |
0.264.3
by Jelmer Vernooij
Make RevisionTree inventoryless. |
73 |
|
74 |
def path2id(self, path): |
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
75 |
if self.mapping.is_special_file(path): |
76 |
return None |
|
77 |
return self._fileid_map.lookup_file_id(path.encode('utf-8')) |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
78 |
|
0.200.1204
by Jelmer Vernooij
Implement GitRevisionTree.get_root_id(). |
79 |
def get_root_id(self): |
80 |
return self.path2id("") |
|
81 |
||
0.200.1208
by Jelmer Vernooij
Add GitWorkingTree.has_id and GitWorkingTree.has_or_had_id. |
82 |
def has_or_had_id(self, file_id): |
83 |
return self.has_id(file_id) |
|
84 |
||
85 |
def has_id(self, file_id): |
|
86 |
try: |
|
87 |
path = self.id2path(file_id) |
|
88 |
except errors.NoSuchId: |
|
89 |
return False |
|
90 |
return self.has_filename(path) |
|
91 |
||
0.200.1241
by Jelmer Vernooij
Implement GitRevisionTree.kind. |
92 |
def kind(self, file_id, path=None): |
93 |
if path is None: |
|
0.200.1248
by Jelmer Vernooij
Fix handling of path in Tree.kind. |
94 |
path = self.id2path(file_id) |
0.200.1283
by Jelmer Vernooij
Provide Repository.get_file_graph() and Tree.get_file_revision(). |
95 |
try: |
96 |
(mode, hexsha) = tree_lookup_path(self.store.__getitem__, self.tree, |
|
97 |
path) |
|
98 |
except KeyError: |
|
99 |
raise errors.NoSuchId(self, file_id) |
|
0.200.1253
by Jelmer Vernooij
Fix Tree.kind(TREE_ROOT). |
100 |
if mode is None: |
101 |
# the tree root is a directory
|
|
102 |
return "directory" |
|
0.200.1241
by Jelmer Vernooij
Implement GitRevisionTree.kind. |
103 |
return mode_kind(mode) |
104 |
||
0.200.1197
by Jelmer Vernooij
Implement GitRevisionTree.has_filename. |
105 |
def has_filename(self, path): |
106 |
try: |
|
107 |
tree_lookup_path(self.store.__getitem__, self.tree, |
|
108 |
path.encode("utf-8")) |
|
109 |
except KeyError: |
|
110 |
return False |
|
111 |
else: |
|
112 |
return True |
|
113 |
||
0.264.6
by Jelmer Vernooij
Implement custom GitRevisionTree.iter_entries_by_dir, GitRevisionTree.list_files. |
114 |
def list_files(self, include_root=False, from_dir=None, recursive=True): |
115 |
if from_dir is None: |
|
0.200.1197
by Jelmer Vernooij
Implement GitRevisionTree.has_filename. |
116 |
from_dir = u"" |
117 |
(mode, hexsha) = tree_lookup_path(self.store.__getitem__, self.tree, |
|
118 |
from_dir.encode("utf-8")) |
|
0.264.9
by Jelmer Vernooij
Implement basic GitWorkingTree.iter_entries_by_dir. |
119 |
if mode is None: # Root |
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
120 |
root_ie = self._get_dir_ie("", None) |
0.264.9
by Jelmer Vernooij
Implement basic GitWorkingTree.iter_entries_by_dir. |
121 |
else: |
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
122 |
parent_path = posixpath.dirname(from_dir.encode("utf-8")) |
0.200.1328
by Jelmer Vernooij
More test fixes. |
123 |
parent_id = self._fileid_map.lookup_file_id(parent_path) |
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
124 |
if mode_kind(mode) == 'directory': |
125 |
root_ie = self._get_dir_ie(from_dir.encode("utf-8"), parent_id) |
|
126 |
else: |
|
127 |
root_ie = self._get_file_ie(from_dir.encode("utf-8"), |
|
128 |
posixpath.basename(from_dir), mode, hexsha) |
|
129 |
if from_dir != "" or include_root: |
|
130 |
yield (from_dir, "V", root_ie.kind, root_ie.file_id, root_ie) |
|
0.264.6
by Jelmer Vernooij
Implement custom GitRevisionTree.iter_entries_by_dir, GitRevisionTree.list_files. |
131 |
todo = set() |
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
132 |
if root_ie.kind == 'directory': |
133 |
todo.add((from_dir.encode("utf-8"), hexsha, root_ie.file_id)) |
|
0.264.6
by Jelmer Vernooij
Implement custom GitRevisionTree.iter_entries_by_dir, GitRevisionTree.list_files. |
134 |
while todo: |
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
135 |
(path, hexsha, parent_id) = todo.pop() |
0.264.6
by Jelmer Vernooij
Implement custom GitRevisionTree.iter_entries_by_dir, GitRevisionTree.list_files. |
136 |
tree = self.store[hexsha] |
137 |
for name, mode, hexsha in tree.iteritems(): |
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
138 |
if self.mapping.is_special_file(name): |
139 |
continue
|
|
0.264.6
by Jelmer Vernooij
Implement custom GitRevisionTree.iter_entries_by_dir, GitRevisionTree.list_files. |
140 |
child_path = posixpath.join(path, name) |
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
141 |
if stat.S_ISDIR(mode): |
142 |
ie = self._get_dir_ie(child_path, parent_id) |
|
143 |
if recursive: |
|
144 |
todo.add((child_path, hexsha, ie.file_id)) |
|
145 |
else: |
|
146 |
ie = self._get_file_ie(child_path, name, mode, hexsha, parent_id) |
|
147 |
yield child_path, "V", ie.kind, ie.file_id, ie |
|
148 |
||
149 |
def _get_file_ie(self, path, name, mode, hexsha, parent_id): |
|
150 |
kind = mode_kind(mode) |
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
151 |
file_id = self._fileid_map.lookup_file_id(path) |
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
152 |
ie = inventory.entry_factory[kind](file_id, name.decode("utf-8"), parent_id) |
153 |
if kind == 'symlink': |
|
154 |
ie.symlink_target = self.store[hexsha].data |
|
0.200.1401
by Jelmer Vernooij
Cope with submodules in working trees. |
155 |
elif kind == 'tree-reference': |
156 |
ie.reference_revision = self.mapping.revision_id_foreign_to_bzr(hexsha) |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
157 |
else: |
158 |
data = self.store[hexsha].data |
|
159 |
ie.text_sha1 = osutils.sha_string(data) |
|
160 |
ie.text_size = len(data) |
|
161 |
ie.executable = mode_is_executable(mode) |
|
162 |
return ie |
|
163 |
||
164 |
def _get_dir_ie(self, path, parent_id): |
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
165 |
file_id = self._fileid_map.lookup_file_id(path) |
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
166 |
return inventory.InventoryDirectory(file_id, |
167 |
posixpath.basename(path).decode("utf-8"), parent_id) |
|
0.264.6
by Jelmer Vernooij
Implement custom GitRevisionTree.iter_entries_by_dir, GitRevisionTree.list_files. |
168 |
|
169 |
def iter_entries_by_dir(self, specific_file_ids=None, yield_parents=False): |
|
0.200.1285
by Jelmer Vernooij
Support specific_file_ids argument to Tree.iter_entries_by_dir. |
170 |
# FIXME: Support yield parents
|
0.264.6
by Jelmer Vernooij
Implement custom GitRevisionTree.iter_entries_by_dir, GitRevisionTree.list_files. |
171 |
if specific_file_ids is not None: |
0.200.1285
by Jelmer Vernooij
Support specific_file_ids argument to Tree.iter_entries_by_dir. |
172 |
specific_paths = [self.id2path(file_id) for file_id in specific_file_ids] |
173 |
if specific_paths in ([u""], []): |
|
174 |
specific_paths = None |
|
175 |
else: |
|
176 |
specific_paths = set(specific_paths) |
|
177 |
else: |
|
178 |
specific_paths = None |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
179 |
todo = set([("", self.tree, None)]) |
0.264.6
by Jelmer Vernooij
Implement custom GitRevisionTree.iter_entries_by_dir, GitRevisionTree.list_files. |
180 |
while todo: |
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
181 |
path, tree_sha, parent_id = todo.pop() |
182 |
ie = self._get_dir_ie(path, parent_id) |
|
0.200.1285
by Jelmer Vernooij
Support specific_file_ids argument to Tree.iter_entries_by_dir. |
183 |
if specific_paths is None or path in specific_paths: |
184 |
yield path, ie |
|
0.264.6
by Jelmer Vernooij
Implement custom GitRevisionTree.iter_entries_by_dir, GitRevisionTree.list_files. |
185 |
tree = self.store[tree_sha] |
186 |
for name, mode, hexsha in tree.iteritems(): |
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
187 |
if self.mapping.is_special_file(name): |
188 |
continue
|
|
0.264.6
by Jelmer Vernooij
Implement custom GitRevisionTree.iter_entries_by_dir, GitRevisionTree.list_files. |
189 |
child_path = posixpath.join(path, name) |
190 |
if stat.S_ISDIR(mode): |
|
0.200.1285
by Jelmer Vernooij
Support specific_file_ids argument to Tree.iter_entries_by_dir. |
191 |
if (specific_paths is None or |
192 |
any(filter(lambda p: p.startswith(child_path), specific_paths))): |
|
193 |
todo.add((child_path, hexsha, ie.file_id)) |
|
194 |
elif specific_paths is None or child_path in specific_paths: |
|
0.200.1307
by Jelmer Vernooij
Formatting fixes, specify path to a couple more functions. |
195 |
yield (child_path, |
196 |
self._get_file_ie(child_path, name, mode, hexsha, |
|
0.200.1285
by Jelmer Vernooij
Support specific_file_ids argument to Tree.iter_entries_by_dir. |
197 |
ie.file_id)) |
0.264.6
by Jelmer Vernooij
Implement custom GitRevisionTree.iter_entries_by_dir, GitRevisionTree.list_files. |
198 |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
199 |
def get_revision_id(self): |
0.200.959
by Jelmer Vernooij
Improve docstrings. |
200 |
"""See RevisionTree.get_revision_id.""" |
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
201 |
return self._revision_id |
202 |
||
0.200.1321
by Jelmer Vernooij
More fixes for compatibility with bzr.dev testsuite. |
203 |
def get_file_sha1(self, file_id, path=None, stat_value=None): |
0.200.1255
by Jelmer Vernooij
Implement GitRevisionTree.get_file_sha1. |
204 |
return osutils.sha_string(self.get_file_text(file_id, path)) |
205 |
||
0.200.1302
by Jelmer Vernooij
Significantly improve performance of WorkingTree.extras(). |
206 |
def get_file_verifier(self, file_id, path=None, stat_value=None): |
207 |
if path is None: |
|
208 |
path = self.id2path(file_id) |
|
209 |
(mode, hexsha) = tree_lookup_path(self.store.__getitem__, self.tree, |
|
210 |
path) |
|
211 |
return ("GIT", hexsha) |
|
212 |
||
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
213 |
def get_file_text(self, file_id, path=None): |
0.200.959
by Jelmer Vernooij
Improve docstrings. |
214 |
"""See RevisionTree.get_file_text.""" |
0.264.3
by Jelmer Vernooij
Make RevisionTree inventoryless. |
215 |
if path is None: |
216 |
path = self.id2path(file_id) |
|
0.200.1302
by Jelmer Vernooij
Significantly improve performance of WorkingTree.extras(). |
217 |
(mode, hexsha) = tree_lookup_path(self.store.__getitem__, self.tree, path) |
0.264.3
by Jelmer Vernooij
Make RevisionTree inventoryless. |
218 |
if stat.S_ISREG(mode): |
219 |
return self.store[hexsha].data |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
220 |
else: |
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
221 |
return "" |
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
222 |
|
0.264.10
by Jelmer Vernooij
Yield inventory entries. |
223 |
def _comparison_data(self, entry, path): |
224 |
if entry is None: |
|
225 |
return None, False, None |
|
226 |
return entry.kind, entry.executable, None |
|
227 |
||
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
228 |
|
0.252.43
by Jelmer Vernooij
Some refactoring, support proper file ids in revision deltas. |
229 |
def tree_delta_from_git_changes(changes, mapping, |
230 |
(old_fileid_map, new_fileid_map), specific_file=None, |
|
231 |
require_versioned=False): |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
232 |
"""Create a TreeDelta from two git trees. |
0.200.959
by Jelmer Vernooij
Improve docstrings. |
233 |
|
234 |
source and target are iterators over tuples with:
|
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
235 |
(filename, sha, mode)
|
236 |
"""
|
|
237 |
ret = delta.TreeDelta() |
|
238 |
for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes: |
|
0.252.43
by Jelmer Vernooij
Some refactoring, support proper file ids in revision deltas. |
239 |
if mapping.is_control_file(oldpath): |
240 |
oldpath = None |
|
241 |
if mapping.is_control_file(newpath): |
|
242 |
newpath = None |
|
243 |
if oldpath is None and newpath is None: |
|
244 |
continue
|
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
245 |
if oldpath is None: |
0.200.1338
by Jelmer Vernooij
Simplify code for getting file id map. |
246 |
file_id = new_fileid_map.lookup_file_id(newpath.encode("utf-8")) |
247 |
ret.added.append((newpath, file_id, mode_kind(newmode))) |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
248 |
elif newpath is None: |
0.200.1338
by Jelmer Vernooij
Simplify code for getting file id map. |
249 |
file_id = old_fileid_map.lookup_file_id(oldpath.encode("utf-8")) |
250 |
ret.removed.append((oldpath, file_id, mode_kind(oldmode))) |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
251 |
elif oldpath != newpath: |
0.200.1338
by Jelmer Vernooij
Simplify code for getting file id map. |
252 |
file_id = old_fileid_map.lookup_file_id(oldpath.encode("utf-8")) |
253 |
ret.renamed.append((oldpath, newpath, file_id, mode_kind(newmode), (oldsha != newsha), (oldmode != newmode))) |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
254 |
elif mode_kind(oldmode) != mode_kind(newmode): |
0.200.1338
by Jelmer Vernooij
Simplify code for getting file id map. |
255 |
file_id = new_fileid_map.lookup_file_id(newpath.encode("utf-8")) |
256 |
ret.kind_changed.append((newpath, file_id, mode_kind(oldmode), mode_kind(newmode))) |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
257 |
elif oldsha != newsha or oldmode != newmode: |
0.200.1338
by Jelmer Vernooij
Simplify code for getting file id map. |
258 |
file_id = new_fileid_map.lookup_file_id(newpath.encode("utf-8")) |
259 |
ret.modified.append((newpath, file_id, mode_kind(newmode), (oldsha != newsha), (oldmode != newmode))) |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
260 |
else: |
0.200.1338
by Jelmer Vernooij
Simplify code for getting file id map. |
261 |
file_id = new_fileid_map.lookup_file_id(newpath.encode("utf-8")) |
262 |
ret.unchanged.append((newpath, file_id, mode_kind(newmode))) |
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
263 |
return ret |
264 |
||
265 |
||
0.200.959
by Jelmer Vernooij
Improve docstrings. |
266 |
def changes_from_git_changes(changes, mapping, specific_file=None, |
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
267 |
require_versioned=False): |
268 |
"""Create a iter_changes-like generator from a git stream. |
|
0.200.959
by Jelmer Vernooij
Improve docstrings. |
269 |
|
270 |
source and target are iterators over tuples with:
|
|
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
271 |
(filename, sha, mode)
|
272 |
"""
|
|
273 |
for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes: |
|
274 |
path = (oldpath, newpath) |
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
275 |
if mapping.is_special_file(oldpath) or mapping.is_special_file(newpath): |
276 |
continue
|
|
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
277 |
if oldpath is None: |
278 |
fileid = mapping.generate_file_id(newpath) |
|
279 |
oldexe = None |
|
280 |
oldkind = None |
|
281 |
oldname = None |
|
282 |
oldparent = None |
|
283 |
else: |
|
0.200.1345
by Jelmer Vernooij
paths should be unicode when yielded by iter_changes. |
284 |
oldpath = oldpath.decode("utf-8") |
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
285 |
oldexe = mode_is_executable(oldmode) |
286 |
oldkind = mode_kind(oldmode) |
|
287 |
try: |
|
288 |
(oldparentpath, oldname) = oldpath.rsplit("/", 1) |
|
289 |
except ValueError: |
|
290 |
oldparent = None |
|
291 |
oldname = oldpath |
|
292 |
else: |
|
293 |
oldparent = mapping.generate_file_id(oldparentpath) |
|
294 |
fileid = mapping.generate_file_id(oldpath) |
|
295 |
if newpath is None: |
|
296 |
newexe = None |
|
297 |
newkind = None |
|
298 |
newname = None |
|
299 |
newparent = None |
|
300 |
else: |
|
0.200.1345
by Jelmer Vernooij
paths should be unicode when yielded by iter_changes. |
301 |
newpath = newpath.decode("utf-8") |
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
302 |
newexe = mode_is_executable(newmode) |
303 |
newkind = mode_kind(newmode) |
|
304 |
try: |
|
305 |
newparentpath, newname = newpath.rsplit("/", 1) |
|
306 |
except ValueError: |
|
307 |
newparent = None |
|
308 |
newname = newpath |
|
309 |
else: |
|
310 |
newparent = mapping.generate_file_id(newparentpath) |
|
0.200.959
by Jelmer Vernooij
Improve docstrings. |
311 |
yield (fileid, (oldpath, newpath), (oldsha != newsha), |
312 |
(oldpath is not None, newpath is not None), |
|
313 |
(oldparent, newparent), (oldname, newname), |
|
314 |
(oldkind, newkind), (oldexe, newexe)) |
|
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
315 |
|
316 |
||
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
317 |
class InterGitRevisionTrees(tree.InterTree): |
318 |
"""InterTree that works between two git revision trees.""" |
|
319 |
||
0.200.659
by Jelmer Vernooij
Prevent tests using InterGitRevisionTrees. |
320 |
_matching_from_tree_format = None |
321 |
_matching_to_tree_format = None |
|
322 |
_test_mutable_trees_to_test_trees = None |
|
323 |
||
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
324 |
@classmethod
|
325 |
def is_compatible(cls, source, target): |
|
0.200.959
by Jelmer Vernooij
Improve docstrings. |
326 |
return (isinstance(source, GitRevisionTree) and |
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
327 |
isinstance(target, GitRevisionTree)) |
328 |
||
329 |
def compare(self, want_unchanged=False, specific_files=None, |
|
330 |
extra_trees=None, require_versioned=False, include_root=False, |
|
331 |
want_unversioned=False): |
|
332 |
if self.source._repository._git.object_store != self.target._repository._git.object_store: |
|
333 |
raise AssertionError |
|
334 |
changes = self.source._repository._git.object_store.tree_changes( |
|
335 |
self.source.tree, self.target.tree, want_unchanged=want_unchanged) |
|
0.252.43
by Jelmer Vernooij
Some refactoring, support proper file ids in revision deltas. |
336 |
source_fileid_map = self.source.mapping.get_fileid_map( |
337 |
self.source._repository._git.object_store.__getitem__, |
|
338 |
self.source.tree) |
|
339 |
target_fileid_map = self.target.mapping.get_fileid_map( |
|
340 |
self.target._repository._git.object_store.__getitem__, |
|
341 |
self.target.tree) |
|
0.200.959
by Jelmer Vernooij
Improve docstrings. |
342 |
return tree_delta_from_git_changes(changes, self.target.mapping, |
0.252.43
by Jelmer Vernooij
Some refactoring, support proper file ids in revision deltas. |
343 |
(source_fileid_map, target_fileid_map), |
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
344 |
specific_file=specific_files) |
345 |
||
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
346 |
def iter_changes(self, include_unchanged=False, specific_files=None, |
0.200.959
by Jelmer Vernooij
Improve docstrings. |
347 |
pb=None, extra_trees=[], require_versioned=True, |
348 |
want_unversioned=False): |
|
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
349 |
if self.source._repository._git.object_store != self.target._repository._git.object_store: |
350 |
raise AssertionError |
|
351 |
changes = self.source._repository._git.object_store.tree_changes( |
|
0.200.959
by Jelmer Vernooij
Improve docstrings. |
352 |
self.source.tree, self.target.tree, |
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
353 |
want_unchanged=include_unchanged) |
0.200.959
by Jelmer Vernooij
Improve docstrings. |
354 |
return changes_from_git_changes(changes, self.target.mapping, |
0.200.622
by Jelmer Vernooij
Implement InterTree.iter_changes() as well. |
355 |
specific_file=specific_files) |
356 |
||
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
357 |
|
358 |
tree.InterTree.register_optimiser(InterGitRevisionTrees) |