Status: | Merged |
---|---|
Approved by: | Jelmer Vernooij |
Approved revision: | no longer in the source branch. |
Merge reported by: | Jelmer Vernooij |
Merged at revision: | not available |
Proposed branch: | lp:~jelmer/brz/misc |
Merge into: | lp:brz |
Diff against target: |
6886 lines (+1193/-1039) 120 files modified
Makefile (+1/-1) breezy/annotate.py (+5/-4) breezy/branch.py (+1/-1) breezy/branchbuilder.py (+4/-2) breezy/builtins.py (+11/-10) breezy/bundle/bundle_data.py (+37/-40) breezy/bundle/serializer/v08.py (+11/-11) breezy/bzr/bzrdir.py (+1/-1) breezy/bzr/inventory.py (+20/-7) breezy/bzr/inventorytree.py (+34/-23) breezy/bzr/vf_repository.py (+7/-5) breezy/bzr/workingtree.py (+37/-25) breezy/bzr/workingtree_3.py (+4/-3) breezy/bzr/workingtree_4.py (+49/-55) breezy/commit.py (+5/-3) breezy/conflicts.py (+2/-1) breezy/diff.py (+41/-44) breezy/export/dir_exporter.py (+3/-3) breezy/export/tar_exporter.py (+5/-5) breezy/export/zip_exporter.py (+3/-3) breezy/fetch.py (+2/-2) breezy/filter_tree.py (+4/-6) breezy/lockable_files.py (+1/-1) breezy/log.py (+7/-7) breezy/memorytree.py (+15/-15) breezy/merge.py (+71/-41) breezy/mutabletree.py (+1/-1) breezy/plugins/commitfromnews/committemplate.py (+1/-1) breezy/plugins/fastimport/exporter.py (+14/-13) breezy/plugins/fastimport/revision_store.py (+13/-7) breezy/plugins/fastimport/tests/test_generic_processor.py (+9/-12) breezy/plugins/fastimport/tests/test_revision_store.py (+5/-3) breezy/plugins/grep/grep.py (+3/-3) breezy/plugins/upload/cmds.py (+6/-7) breezy/plugins/weave_fmt/test_bzrdir.py (+2/-2) breezy/plugins/weave_fmt/test_repository.py (+1/-1) breezy/rename_map.py (+1/-2) breezy/revisionspec.py (+2/-3) breezy/revisiontree.py (+6/-4) breezy/shelf.py (+17/-9) breezy/shelf_ui.py (+8/-4) breezy/tests/blackbox/test_merge.py (+3/-3) breezy/tests/blackbox/test_mkdir.py (+7/-7) breezy/tests/blackbox/test_resolve.py (+1/-1) breezy/tests/blackbox/test_versioning.py (+1/-1) breezy/tests/per_branch/test_branch.py (+1/-1) breezy/tests/per_branch/test_commit.py (+3/-3) breezy/tests/per_branch/test_sprout.py (+3/-6) breezy/tests/per_branch/test_stacking.py (+1/-3) breezy/tests/per_foreign_vcs/test_branch.py (+5/-2) breezy/tests/per_interbranch/test_fetch.py (+1/-3) breezy/tests/per_interrepository/test_fetch.py (+5/-5) breezy/tests/per_intertree/test_compare.py (+12/-7) breezy/tests/per_merger.py (+5/-5) breezy/tests/per_repository/test_commit_builder.py (+19/-19) breezy/tests/per_repository/test_fetch.py (+2/-2) breezy/tests/per_repository/test_repository.py (+10/-11) breezy/tests/per_repository/test_revision.py (+3/-1) breezy/tests/per_repository_vf/test_merge_directive.py (+1/-1) breezy/tests/per_repository_vf/test_repository.py (+4/-4) breezy/tests/per_repository_vf/test_write_group.py (+3/-1) breezy/tests/per_tree/test_annotate_iter.py (+2/-2) breezy/tests/per_tree/test_get_file_mtime.py (+3/-5) breezy/tests/per_tree/test_get_file_with_stat.py (+2/-4) breezy/tests/per_tree/test_get_symlink_target.py (+5/-5) breezy/tests/per_tree/test_is_executable.py (+1/-1) breezy/tests/per_tree/test_test_trees.py (+12/-12) breezy/tests/per_tree/test_tree.py (+16/-19) breezy/tests/per_workingtree/test_add.py (+11/-11) breezy/tests/per_workingtree/test_add_reference.py (+7/-6) breezy/tests/per_workingtree/test_annotate_iter.py (+7/-7) breezy/tests/per_workingtree/test_basis_tree.py (+1/-1) breezy/tests/per_workingtree/test_commit.py (+6/-5) breezy/tests/per_workingtree/test_content_filters.py (+19/-11) breezy/tests/per_workingtree/test_eol_conversion.py (+2/-2) breezy/tests/per_workingtree/test_executable.py (+4/-4) breezy/tests/per_workingtree/test_get_file_mtime.py (+9/-10) breezy/tests/per_workingtree/test_merge_from_branch.py (+2/-2) breezy/tests/per_workingtree/test_mkdir.py (+2/-2) breezy/tests/per_workingtree/test_move.py (+2/-2) breezy/tests/per_workingtree/test_nested_specifics.py (+2/-2) breezy/tests/per_workingtree/test_parents.py (+7/-5) breezy/tests/per_workingtree/test_paths2ids.py (+1/-1) breezy/tests/per_workingtree/test_put_file.py (+7/-7) breezy/tests/per_workingtree/test_readonly.py (+2/-2) breezy/tests/per_workingtree/test_rename_one.py (+4/-4) breezy/tests/per_workingtree/test_revision_tree.py (+5/-5) breezy/tests/per_workingtree/test_symlinks.py (+2/-4) breezy/tests/per_workingtree/test_unversion.py (+9/-9) breezy/tests/per_workingtree/test_workingtree.py (+13/-13) breezy/tests/test_annotate.py (+23/-23) breezy/tests/test_bisect.py (+2/-2) breezy/tests/test_branchbuilder.py (+8/-7) breezy/tests/test_bundle.py (+43/-27) breezy/tests/test_bzrdir.py (+3/-1) breezy/tests/test_commit.py (+19/-19) breezy/tests/test_commit_merge.py (+2/-2) breezy/tests/test_diff.py (+12/-10) breezy/tests/test_dirstate.py (+3/-3) breezy/tests/test_fetch.py (+1/-1) breezy/tests/test_filter_tree.py (+2/-2) breezy/tests/test_foreign.py (+3/-3) breezy/tests/test_memorytree.py (+13/-13) breezy/tests/test_merge.py (+19/-19) breezy/tests/test_merge_core.py (+21/-17) breezy/tests/test_repository.py (+4/-4) breezy/tests/test_revert.py (+5/-5) breezy/tests/test_revisiontree.py (+3/-3) breezy/tests/test_shelf.py (+7/-5) breezy/tests/test_subsume.py (+5/-5) breezy/tests/test_transform.py (+67/-65) breezy/tests/test_treebuilder.py (+6/-4) breezy/tests/test_upstream_import.py (+3/-6) breezy/tests/test_workingtree_4.py (+5/-5) breezy/transform.py (+107/-67) breezy/transport/local.py (+1/-1) breezy/tree.py (+51/-43) breezy/treebuilder.py (+1/-2) breezy/workingtree.py (+24/-35) doc/en/release-notes/brz-3.0.txt (+5/-0) |
To merge this branch: | bzr merge lp:~jelmer/brz/misc |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Packman | Approve | ||
Review via email:
|
Commit message
Description of the change
Various smaller fixes:
* Expect foreign branch nicks to be text_type; this is consistent with the test for regular branches
* Use skipTest rather than skip
* Avoid specifying revision_id in two more tests
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Makefile' |
2 | --- Makefile 2017-10-26 11:10:38 +0000 |
3 | +++ Makefile 2017-11-19 19:02:26 +0000 |
4 | @@ -50,7 +50,7 @@ |
5 | # Generate a stream for PQM to watch. |
6 | -$(RM) -f selftest.log |
7 | echo `date` ": selftest starts" 1>&2 |
8 | - BRZ_PLUGIN_PATH=$(BRZ_PLUGIN_PATH) $(PYTHON3) -Werror -Wignore::ImportWarning -O \ |
9 | + BRZ_PLUGIN_PATH=$(BRZ_PLUGIN_PATH) $(PYTHON3) -Wignore::ImportWarning -O \ |
10 | ./brz selftest -Oselftest.timeout=120 --load-list=python3.passing \ |
11 | --subunit2 $(tests) | tee selftest.log | subunit-2to1 |
12 | echo `date` ": selftest ends" 1>&2 |
13 | |
14 | === modified file 'breezy/annotate.py' |
15 | --- breezy/annotate.py 2017-11-12 13:53:51 +0000 |
16 | +++ breezy/annotate.py 2017-11-19 19:02:26 +0000 |
17 | @@ -53,19 +53,20 @@ |
18 | ) |
19 | |
20 | |
21 | -def annotate_file_tree(tree, file_id, to_file, verbose=False, full=False, |
22 | - show_ids=False, branch=None): |
23 | +def annotate_file_tree(tree, path, to_file, verbose=False, full=False, |
24 | + show_ids=False, branch=None, file_id=None): |
25 | """Annotate file_id in a tree. |
26 | |
27 | The tree should already be read_locked() when annotate_file_tree is called. |
28 | |
29 | :param tree: The tree to look for revision numbers and history from. |
30 | - :param file_id: The file_id to annotate. |
31 | + :param path: The path to annotate |
32 | :param to_file: The file to output the annotation to. |
33 | :param verbose: Show all details rather than truncating to ensure |
34 | reasonable text width. |
35 | :param full: XXXX Not sure what this does. |
36 | :param show_ids: Show revision ids in the annotation output. |
37 | + :param file_id: The file_id to annotate (must match file path) |
38 | :param branch: Branch to use for revision revno lookups |
39 | """ |
40 | if branch is None: |
41 | @@ -74,7 +75,7 @@ |
42 | to_file = sys.stdout |
43 | |
44 | # Handle the show_ids case |
45 | - annotations = list(tree.annotate_iter(file_id)) |
46 | + annotations = list(tree.annotate_iter(path, file_id)) |
47 | if show_ids: |
48 | return _show_id_annotations(annotations, to_file, full) |
49 | |
50 | |
51 | === modified file 'breezy/branch.py' |
52 | --- breezy/branch.py 2017-11-12 13:53:51 +0000 |
53 | +++ breezy/branch.py 2017-11-19 19:02:26 +0000 |
54 | @@ -1421,7 +1421,7 @@ |
55 | for path, file_id in basis_tree.iter_references(): |
56 | reference_parent = self.reference_parent(file_id, path) |
57 | reference_parent.create_checkout(tree.abspath(path), |
58 | - basis_tree.get_reference_revision(file_id, path), |
59 | + basis_tree.get_reference_revision(path, file_id), |
60 | lightweight) |
61 | return tree |
62 | |
63 | |
64 | === modified file 'breezy/branchbuilder.py' |
65 | --- breezy/branchbuilder.py 2017-11-16 00:39:04 +0000 |
66 | +++ breezy/branchbuilder.py 2017-11-19 19:02:26 +0000 |
67 | @@ -280,10 +280,12 @@ |
68 | for from_relpath, to_relpath in pending.to_rename: |
69 | tree.rename_one(from_relpath, to_relpath) |
70 | if pending.to_unversion_ids: |
71 | - tree.unversion(pending.to_unversion_ids) |
72 | + tree.unversion([tree.id2path(fid) for fid in pending.to_unversion_ids]) |
73 | tree.add(pending.to_add_files, pending.to_add_file_ids, pending.to_add_kinds) |
74 | for file_id, content in viewitems(pending.new_contents): |
75 | - tree.put_file_bytes_non_atomic(file_id, content) |
76 | + tree.put_file_bytes_non_atomic( |
77 | + tree.id2path(file_id), content, |
78 | + file_id=file_id) |
79 | |
80 | def get_branch(self): |
81 | """Return the branch created by the builder.""" |
82 | |
83 | === modified file 'breezy/builtins.py' |
84 | --- breezy/builtins.py 2017-11-12 13:53:51 +0000 |
85 | +++ breezy/builtins.py 2017-11-19 19:02:26 +0000 |
86 | @@ -1050,10 +1050,11 @@ |
87 | into_existing = False |
88 | else: |
89 | # 'fix' the case of a potential 'from' |
90 | - from_id = tree.path2id( |
91 | - tree.get_canonical_inventory_path(rel_names[0])) |
92 | + from_path = tree.get_canonical_inventory_path(rel_names[0]) |
93 | + from_id = tree.path2id(from_path) |
94 | if (not osutils.lexists(names_list[0]) and |
95 | - from_id and tree.stored_kind(from_id) == "directory"): |
96 | + from_id and |
97 | + tree.stored_kind(from_path, from_id) == "directory"): |
98 | into_existing = False |
99 | # move/rename |
100 | if into_existing: |
101 | @@ -3404,9 +3405,9 @@ |
102 | from .filter_tree import ContentFilterTree |
103 | filter_tree = ContentFilterTree(rev_tree, |
104 | rev_tree._content_filter_stack) |
105 | - content = filter_tree.get_file_text(actual_file_id) |
106 | + content = filter_tree.get_file_text(relpath, actual_file_id) |
107 | else: |
108 | - content = rev_tree.get_file_text(actual_file_id) |
109 | + content = rev_tree.get_file_text(relpath, actual_file_id) |
110 | self.cleanup_now() |
111 | self.outf.write(content) |
112 | |
113 | @@ -4697,7 +4698,7 @@ |
114 | if file_id is None: |
115 | raise errors.NotVersionedError(filename) |
116 | interesting_ids.add(file_id) |
117 | - if tree.kind(file_id) != "directory": |
118 | + if tree.kind(filename, file_id) != "directory": |
119 | continue |
120 | |
121 | # FIXME: Support nested trees |
122 | @@ -5190,11 +5191,11 @@ |
123 | if wt is not None and revision is None: |
124 | # If there is a tree and we're not annotating historical |
125 | # versions, annotate the working tree's content. |
126 | - annotate_file_tree(wt, file_id, self.outf, long, all, |
127 | - show_ids=show_ids) |
128 | + annotate_file_tree(wt, relpath, self.outf, long, all, |
129 | + show_ids=show_ids, file_id=file_id) |
130 | else: |
131 | - annotate_file_tree(tree, file_id, self.outf, long, all, |
132 | - show_ids=show_ids, branch=branch) |
133 | + annotate_file_tree(tree, relpath, self.outf, long, all, |
134 | + show_ids=show_ids, branch=branch, file_id=file_id) |
135 | |
136 | |
137 | class cmd_re_sign(Command): |
138 | |
139 | === modified file 'breezy/bundle/bundle_data.py' |
140 | --- breezy/bundle/bundle_data.py 2017-11-12 13:53:51 +0000 |
141 | +++ breezy/bundle/bundle_data.py 2017-11-19 19:02:26 +0000 |
142 | @@ -476,7 +476,7 @@ |
143 | self._renamed_r = {} # new_path => old_path |
144 | self._new_id = {} # new_path => new_id |
145 | self._new_id_r = {} # new_id => new_path |
146 | - self._kinds = {} # new_id => kind |
147 | + self._kinds = {} # new_path => kind |
148 | self._last_changed = {} # new_id => revision_id |
149 | self._executable = {} # new_id => executable value |
150 | self.patches = {} |
151 | @@ -502,7 +502,7 @@ |
152 | """Files that don't exist in base need a new id.""" |
153 | self._new_id[new_path] = new_id |
154 | self._new_id_r[new_id] = new_path |
155 | - self._kinds[new_id] = kind |
156 | + self._kinds[new_path] = kind |
157 | |
158 | def note_last_changed(self, file_id, revision_id): |
159 | if (file_id in self._last_changed |
160 | @@ -618,7 +618,7 @@ |
161 | new_path = self.id2path(file_id) |
162 | return self.base_tree.path2id(new_path) |
163 | |
164 | - def get_file(self, file_id): |
165 | + def get_file(self, path, file_id=None): |
166 | """Return a file-like object containing the new contents of the |
167 | file given by file_id. |
168 | |
169 | @@ -626,16 +626,19 @@ |
170 | in the text-store, so that the file contents would |
171 | then be cached. |
172 | """ |
173 | + if file_id is None: |
174 | + file_id = self.path2id(path) |
175 | base_id = self.old_contents_id(file_id) |
176 | if (base_id is not None and |
177 | base_id != self.base_tree.get_root_id()): |
178 | - patch_original = self.base_tree.get_file(base_id) |
179 | + patch_original = self.base_tree.get_file( |
180 | + self.base_tree.id2path(base_id), base_id) |
181 | else: |
182 | patch_original = None |
183 | - file_patch = self.patches.get(self.id2path(file_id)) |
184 | + file_patch = self.patches.get(path) |
185 | if file_patch is None: |
186 | if (patch_original is None and |
187 | - self.kind(file_id) == 'directory'): |
188 | + self.kind(path, file_id) == 'directory'): |
189 | return BytesIO() |
190 | if patch_original is None: |
191 | raise AssertionError("None: %s" % file_id) |
192 | @@ -646,54 +649,50 @@ |
193 | 'Malformed patch for %s, %r' % (file_id, file_patch)) |
194 | return patched_file(file_patch, patch_original) |
195 | |
196 | - def get_symlink_target(self, file_id, path=None): |
197 | - if path is None: |
198 | - path = self.id2path(file_id) |
199 | + def get_symlink_target(self, path, file_id=None): |
200 | try: |
201 | return self._targets[path] |
202 | except KeyError: |
203 | - return self.base_tree.get_symlink_target(file_id) |
204 | - |
205 | - def kind(self, file_id): |
206 | - if file_id in self._kinds: |
207 | - return self._kinds[file_id] |
208 | - return self.base_tree.kind(file_id) |
209 | - |
210 | - def get_file_revision(self, file_id): |
211 | - path = self.id2path(file_id) |
212 | + return self.base_tree.get_symlink_target(path, file_id) |
213 | + |
214 | + def kind(self, path, file_id=None): |
215 | + try: |
216 | + return self._kinds[path] |
217 | + except KeyError: |
218 | + return self.base_tree.kind(path, file_id) |
219 | + |
220 | + def get_file_revision(self, path, file_id=None): |
221 | if path in self._last_changed: |
222 | return self._last_changed[path] |
223 | else: |
224 | - return self.base_tree.get_file_revision(file_id) |
225 | + return self.base_tree.get_file_revision(path, file_id) |
226 | |
227 | - def is_executable(self, file_id): |
228 | - path = self.id2path(file_id) |
229 | + def is_executable(self, path, file_id=None): |
230 | if path in self._executable: |
231 | return self._executable[path] |
232 | else: |
233 | - return self.base_tree.is_executable(file_id) |
234 | + return self.base_tree.is_executable(path, file_id) |
235 | |
236 | - def get_last_changed(self, file_id): |
237 | - path = self.id2path(file_id) |
238 | + def get_last_changed(self, path, file_id=None): |
239 | if path in self._last_changed: |
240 | return self._last_changed[path] |
241 | - return self.base_tree.get_file_revision(file_id) |
242 | + return self.base_tree.get_file_revision(path, file_id) |
243 | |
244 | - def get_size_and_sha1(self, file_id): |
245 | + def get_size_and_sha1(self, new_path, file_id=None): |
246 | """Return the size and sha1 hash of the given file id. |
247 | If the file was not locally modified, this is extracted |
248 | from the base_tree. Rather than re-reading the file. |
249 | """ |
250 | - new_path = self.id2path(file_id) |
251 | if new_path is None: |
252 | return None, None |
253 | if new_path not in self.patches: |
254 | # If the entry does not have a patch, then the |
255 | # contents must be the same as in the base_tree |
256 | - text_size = self.base_tree.get_file_size(file_id) |
257 | - text_sha1 = self.base_tree.get_file_sha1(file_id) |
258 | + base_path = self.base_tree.id2path(file_id) |
259 | + text_size = self.base_tree.get_file_size(base_path, file_id) |
260 | + text_sha1 = self.base_tree.get_file_sha1(base_path, file_id) |
261 | return text_size, text_sha1 |
262 | - fileobj = self.get_file(file_id) |
263 | + fileobj = self.get_file(new_path, file_id) |
264 | content = fileobj.read() |
265 | return len(content), sha_string(content) |
266 | |
267 | @@ -705,32 +704,30 @@ |
268 | from os.path import dirname, basename |
269 | inv = Inventory(None, self.revision_id) |
270 | |
271 | - def add_entry(file_id): |
272 | - path = self.id2path(file_id) |
273 | - if path is None: |
274 | - return |
275 | + def add_entry(path, file_id): |
276 | if path == '': |
277 | parent_id = None |
278 | else: |
279 | parent_path = dirname(path) |
280 | parent_id = self.path2id(parent_path) |
281 | |
282 | - kind = self.kind(file_id) |
283 | - revision_id = self.get_last_changed(file_id) |
284 | + kind = self.kind(path, file_id) |
285 | + revision_id = self.get_last_changed(path, file_id) |
286 | |
287 | name = basename(path) |
288 | if kind == 'directory': |
289 | ie = InventoryDirectory(file_id, name, parent_id) |
290 | elif kind == 'file': |
291 | ie = InventoryFile(file_id, name, parent_id) |
292 | - ie.executable = self.is_executable(file_id) |
293 | + ie.executable = self.is_executable(path, file_id) |
294 | elif kind == 'symlink': |
295 | ie = InventoryLink(file_id, name, parent_id) |
296 | - ie.symlink_target = self.get_symlink_target(file_id, path) |
297 | + ie.symlink_target = self.get_symlink_target(path, file_id) |
298 | ie.revision = revision_id |
299 | |
300 | if kind == 'file': |
301 | - ie.text_size, ie.text_sha1 = self.get_size_and_sha1(file_id) |
302 | + ie.text_size, ie.text_sha1 = self.get_size_and_sha1( |
303 | + path, file_id) |
304 | if ie.text_size is None: |
305 | raise BzrError( |
306 | 'Got a text_size of None for file_id %r' % file_id) |
307 | @@ -738,7 +735,7 @@ |
308 | |
309 | sorted_entries = self.sorted_path_id() |
310 | for path, file_id in sorted_entries: |
311 | - add_entry(file_id) |
312 | + add_entry(path, file_id) |
313 | |
314 | return inv |
315 | |
316 | |
317 | === modified file 'breezy/bundle/serializer/v08.py' |
318 | --- breezy/bundle/serializer/v08.py 2017-08-26 13:58:53 +0000 |
319 | +++ breezy/bundle/serializer/v08.py 2017-11-19 19:02:26 +0000 |
320 | @@ -257,9 +257,9 @@ |
321 | new_label = '' |
322 | |
323 | def do_diff(file_id, old_path, new_path, action, force_binary): |
324 | - def tree_lines(tree, require_text=False): |
325 | + def tree_lines(tree, path, require_text=False): |
326 | if tree.has_id(file_id): |
327 | - tree_file = tree.get_file(file_id) |
328 | + tree_file = tree.get_file(path, file_id) |
329 | if require_text is True: |
330 | tree_file = text_file(tree_file) |
331 | return tree_file.readlines() |
332 | @@ -269,14 +269,14 @@ |
333 | try: |
334 | if force_binary: |
335 | raise errors.BinaryFile() |
336 | - old_lines = tree_lines(old_tree, require_text=True) |
337 | - new_lines = tree_lines(new_tree, require_text=True) |
338 | + old_lines = tree_lines(old_tree, old_path, require_text=True) |
339 | + new_lines = tree_lines(new_tree, new_path, require_text=True) |
340 | action.write(self.to_file) |
341 | internal_diff(old_path, old_lines, new_path, new_lines, |
342 | self.to_file) |
343 | except errors.BinaryFile: |
344 | - old_lines = tree_lines(old_tree, require_text=False) |
345 | - new_lines = tree_lines(new_tree, require_text=False) |
346 | + old_lines = tree_lines(old_tree, old_path, require_text=False) |
347 | + new_lines = tree_lines(new_tree, new_path, require_text=False) |
348 | action.add_property('encoding', 'base64') |
349 | action.write(self.to_file) |
350 | binary_diff(old_path, old_lines, new_path, new_lines, |
351 | @@ -304,7 +304,7 @@ |
352 | for path, file_id, kind in delta.added: |
353 | action = Action('added', [kind, path], [('file-id', file_id)]) |
354 | meta_modified = (kind=='file' and |
355 | - new_tree.is_executable(file_id)) |
356 | + new_tree.is_executable(path, file_id)) |
357 | finish_action(action, file_id, kind, meta_modified, True, |
358 | DEVNULL, path) |
359 | |
360 | @@ -321,13 +321,13 @@ |
361 | path, path) |
362 | |
363 | for path, file_id, kind in delta.unchanged: |
364 | - new_rev = new_tree.get_file_revision(file_id) |
365 | + new_rev = new_tree.get_file_revision(path, file_id) |
366 | if new_rev is None: |
367 | continue |
368 | - old_rev = old_tree.get_file_revision(file_id) |
369 | + old_rev = old_tree.get_file_revision(path, file_id) |
370 | if new_rev != old_rev: |
371 | - action = Action('modified', [new_tree.kind(file_id), |
372 | - new_tree.id2path(file_id)]) |
373 | + action = Action('modified', [new_tree.kind(path, file_id), |
374 | + path]) |
375 | action.add_utf8_property('last-changed', new_rev) |
376 | action.write(self.to_file) |
377 | |
378 | |
379 | === modified file 'breezy/bzr/bzrdir.py' |
380 | --- breezy/bzr/bzrdir.py 2017-08-05 01:03:53 +0000 |
381 | +++ breezy/bzr/bzrdir.py 2017-11-19 19:02:26 +0000 |
382 | @@ -477,7 +477,7 @@ |
383 | target = urlutils.join(url, urlutils.escape(path)) |
384 | sublocation = source_branch.reference_parent(file_id, path) |
385 | sublocation.controldir.sprout(target, |
386 | - basis.get_reference_revision(file_id, path), |
387 | + basis.get_reference_revision(path, file_id), |
388 | force_new_repo=force_new_repo, recurse=recurse, |
389 | stacked=stacked) |
390 | return result |
391 | |
392 | === modified file 'breezy/bzr/inventory.py' |
393 | --- breezy/bzr/inventory.py 2017-11-12 18:17:03 +0000 |
394 | +++ breezy/bzr/inventory.py 2017-11-19 19:02:26 +0000 |
395 | @@ -462,15 +462,22 @@ |
396 | from_file_id = self.file_id |
397 | if to_entry: |
398 | to_file_id = to_entry.file_id |
399 | + to_path = to_tree.id2path(to_file_id) |
400 | else: |
401 | to_file_id = None |
402 | + to_path = None |
403 | + if from_file_id is not None: |
404 | + from_path = tree.id2path(from_file_id) |
405 | + else: |
406 | + from_path = None |
407 | if reverse: |
408 | to_file_id, from_file_id = from_file_id, to_file_id |
409 | tree, to_tree = to_tree, tree |
410 | from_label, to_label = to_label, from_label |
411 | differ = DiffText(tree, to_tree, output_to, 'utf-8', '', '', |
412 | text_diff) |
413 | - return differ.diff_text(from_file_id, to_file_id, from_label, to_label) |
414 | + return differ.diff_text(from_path, to_path, from_label, to_label, |
415 | + from_file_id, to_file_id) |
416 | |
417 | def has_text(self): |
418 | """See InventoryEntry.has_text.""" |
419 | @@ -482,10 +489,10 @@ |
420 | |
421 | def _read_tree_state(self, path, work_tree): |
422 | """See InventoryEntry._read_tree_state.""" |
423 | - self.text_sha1 = work_tree.get_file_sha1(self.file_id, path=path) |
424 | + self.text_sha1 = work_tree.get_file_sha1(path, self.file_id) |
425 | # FIXME: 20050930 probe for the text size when getting sha1 |
426 | # in _read_tree_state |
427 | - self.executable = work_tree.is_executable(self.file_id, path=path) |
428 | + self.executable = work_tree.is_executable(path, self.file_id) |
429 | |
430 | def __repr__(self): |
431 | return ("%s(%r, %r, parent_id=%r, sha1=%r, len=%s, revision=%s)" |
432 | @@ -576,7 +583,8 @@ |
433 | |
434 | def _read_tree_state(self, path, work_tree): |
435 | """See InventoryEntry._read_tree_state.""" |
436 | - self.symlink_target = work_tree.get_symlink_target(self.file_id) |
437 | + self.symlink_target = work_tree.get_symlink_target( |
438 | + work_tree.id2path(self.file_id), self.file_id) |
439 | |
440 | def _forget_tree_state(self): |
441 | self.symlink_target = None |
442 | @@ -609,7 +617,7 @@ |
443 | """Populate fields in the inventory entry from the given tree. |
444 | """ |
445 | self.reference_revision = work_tree.get_reference_revision( |
446 | - self.file_id, path) |
447 | + path, self.file_id) |
448 | |
449 | def _forget_tree_state(self): |
450 | self.reference_revision = None |
451 | @@ -745,8 +753,13 @@ |
452 | if (not yield_parents and specific_file_ids is not None and |
453 | len(specific_file_ids) == 1): |
454 | file_id = list(specific_file_ids)[0] |
455 | - if self.has_id(file_id): |
456 | - yield self.id2path(file_id), self[file_id] |
457 | + if file_id is not None: |
458 | + try: |
459 | + path = self.id2path(file_id) |
460 | + except errors.NoSuchId: |
461 | + pass |
462 | + else: |
463 | + yield path, self[file_id] |
464 | return |
465 | from_dir = self.root |
466 | if (specific_file_ids is None or yield_parents or |
467 | |
468 | === modified file 'breezy/bzr/inventorytree.py' |
469 | --- breezy/bzr/inventorytree.py 2017-11-12 13:53:51 +0000 |
470 | +++ breezy/bzr/inventorytree.py 2017-11-19 19:02:26 +0000 |
471 | @@ -170,14 +170,20 @@ |
472 | with self.lock_read(): |
473 | return self._path2inv_file_id(path)[1] |
474 | |
475 | - def _path2inv_file_id(self, path): |
476 | + def _path2inv_file_id(self, path, file_id=None): |
477 | """Lookup a inventory and inventory file id by path. |
478 | |
479 | :param path: Path to look up |
480 | + :param file_id: Optional file_id matching path, if known. |
481 | :return: tuple with inventory and inventory file id |
482 | """ |
483 | - # FIXME: Support nested trees |
484 | - return self.root_inventory, self.root_inventory.path2id(path) |
485 | + if file_id is not None: |
486 | + inv, inv_file_id = self._unpack_file_id(file_id) |
487 | + else: |
488 | + # FIXME: Support nested trees |
489 | + inv = self.root_inventory |
490 | + inv_file_id = self.root_inventory.path2id(path) |
491 | + return inv, inv_file_id |
492 | |
493 | def id2path(self, file_id): |
494 | """Return the path for a file id. |
495 | @@ -606,33 +612,36 @@ |
496 | RevisionTree.__init__(self, repository, revision_id) |
497 | self._inventory = inv |
498 | |
499 | - def get_file_mtime(self, file_id, path=None): |
500 | - inv, inv_file_id = self._unpack_file_id(file_id) |
501 | - ie = inv[inv_file_id] |
502 | + def get_file_mtime(self, path, file_id=None): |
503 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
504 | + try: |
505 | + ie = inv[inv_file_id] |
506 | + except errors.NoSuchId: |
507 | + raise errors.NoSuchFile(path) |
508 | try: |
509 | revision = self._repository.get_revision(ie.revision) |
510 | except errors.NoSuchRevision: |
511 | raise FileTimestampUnavailable(self.id2path(file_id)) |
512 | return revision.timestamp |
513 | |
514 | - def get_file_size(self, file_id): |
515 | - inv, inv_file_id = self._unpack_file_id(file_id) |
516 | + def get_file_size(self, path, file_id=None): |
517 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
518 | return inv[inv_file_id].text_size |
519 | |
520 | - def get_file_sha1(self, file_id, path=None, stat_value=None): |
521 | - inv, inv_file_id = self._unpack_file_id(file_id) |
522 | + def get_file_sha1(self, path, file_id=None, stat_value=None): |
523 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
524 | ie = inv[inv_file_id] |
525 | if ie.kind == "file": |
526 | return ie.text_sha1 |
527 | return None |
528 | |
529 | - def get_file_revision(self, file_id, path=None): |
530 | - inv, inv_file_id = self._unpack_file_id(file_id) |
531 | + def get_file_revision(self, path, file_id=None): |
532 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
533 | ie = inv[inv_file_id] |
534 | return ie.revision |
535 | |
536 | - def is_executable(self, file_id, path=None): |
537 | - inv, inv_file_id = self._unpack_file_id(file_id) |
538 | + def is_executable(self, path, file_id=None): |
539 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
540 | ie = inv[inv_file_id] |
541 | if ie.kind != "file": |
542 | return False |
543 | @@ -658,22 +667,22 @@ |
544 | for path, entry in entries: |
545 | yield path, 'V', entry.kind, entry.file_id, entry |
546 | |
547 | - def get_symlink_target(self, file_id, path=None): |
548 | - inv, inv_file_id = self._unpack_file_id(file_id) |
549 | + def get_symlink_target(self, path, file_id=None): |
550 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
551 | ie = inv[inv_file_id] |
552 | # Inventories store symlink targets in unicode |
553 | return ie.symlink_target |
554 | |
555 | - def get_reference_revision(self, file_id, path=None): |
556 | - inv, inv_file_id = self._unpack_file_id(file_id) |
557 | + def get_reference_revision(self, path, file_id=None): |
558 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
559 | return inv[inv_file_id].reference_revision |
560 | |
561 | def get_root_id(self): |
562 | if self.root_inventory.root: |
563 | return self.root_inventory.root.file_id |
564 | |
565 | - def kind(self, file_id): |
566 | - inv, inv_file_id = self._unpack_file_id(file_id) |
567 | + def kind(self, path, file_id=None): |
568 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
569 | return inv[inv_file_id].kind |
570 | |
571 | def path_content_summary(self, path): |
572 | @@ -730,7 +739,7 @@ |
573 | """See Tree.iter_files_bytes. |
574 | |
575 | This version is implemented on top of Repository.iter_files_bytes""" |
576 | - repo_desired_files = [(f, self.get_file_revision(f), i) |
577 | + repo_desired_files = [(f, self.get_file_revision(self.id2path(f), f), i) |
578 | for f, i in desired_files] |
579 | try: |
580 | for result in self._repository.iter_files_bytes(repo_desired_files): |
581 | @@ -738,10 +747,12 @@ |
582 | except errors.RevisionNotPresent as e: |
583 | raise errors.NoSuchFile(e.file_id) |
584 | |
585 | - def annotate_iter(self, file_id, |
586 | + def annotate_iter(self, path, file_id=None, |
587 | default_revision=revision.CURRENT_REVISION): |
588 | """See Tree.annotate_iter""" |
589 | - text_key = (file_id, self.get_file_revision(file_id)) |
590 | + if file_id is None: |
591 | + file_id = self.path2id(path) |
592 | + text_key = (file_id, self.get_file_revision(path, file_id)) |
593 | annotator = self._repository.texts.get_annotator() |
594 | annotations = annotator.annotate_flat(text_key) |
595 | return [(key[-1], line) for key, line in annotations] |
596 | |
597 | === modified file 'breezy/bzr/vf_repository.py' |
598 | --- breezy/bzr/vf_repository.py 2017-11-14 01:20:51 +0000 |
599 | +++ breezy/bzr/vf_repository.py 2017-11-19 19:02:26 +0000 |
600 | @@ -484,7 +484,7 @@ |
601 | nostore_sha = parent_entry.text_sha1 |
602 | else: |
603 | nostore_sha = None |
604 | - file_obj, stat_value = tree.get_file_with_stat(file_id, change[1][1]) |
605 | + file_obj, stat_value = tree.get_file_with_stat(change[1][1], file_id) |
606 | try: |
607 | text = file_obj.read() |
608 | finally: |
609 | @@ -501,7 +501,7 @@ |
610 | entry.text_sha1 = parent_entry.text_sha1 |
611 | elif kind == 'symlink': |
612 | # Wants a path hint? |
613 | - entry.symlink_target = tree.get_symlink_target(file_id) |
614 | + entry.symlink_target = tree.get_symlink_target(change[1][1], file_id) |
615 | if (carry_over_possible and |
616 | parent_entry.symlink_target == entry.symlink_target): |
617 | carried_over = True |
618 | @@ -523,7 +523,7 @@ |
619 | # references. |
620 | raise errors.UnsupportedOperation(tree.add_reference, |
621 | self.repository) |
622 | - reference_revision = tree.get_reference_revision(change[0]) |
623 | + reference_revision = tree.get_reference_revision(change[1][1], change[0]) |
624 | entry.reference_revision = reference_revision |
625 | if (carry_over_possible and |
626 | parent_entry.reference_revision == reference_revision): |
627 | @@ -2878,11 +2878,13 @@ |
628 | for revision, tree in viewitems(parent_trees): |
629 | if not tree.has_id(ie.file_id): |
630 | continue |
631 | - parent_id = tree.get_file_revision(ie.file_id) |
632 | + path = tree.id2path(ie.file_id) |
633 | + parent_id = tree.get_file_revision(path, ie.file_id) |
634 | if parent_id in text_parents: |
635 | continue |
636 | text_parents.append((ie.file_id, parent_id)) |
637 | - lines = revision_tree.get_file(ie.file_id).readlines() |
638 | + revision_tree_path = revision_tree.id2path(ie.file_id) |
639 | + lines = revision_tree.get_file(revision_tree_path, ie.file_id).readlines() |
640 | repository.texts.add_lines(text_key, text_parents, lines) |
641 | try: |
642 | # install the inventory |
643 | |
644 | === modified file 'breezy/bzr/workingtree.py' |
645 | --- breezy/bzr/workingtree.py 2017-11-12 13:53:51 +0000 |
646 | +++ breezy/bzr/workingtree.py 2017-11-19 19:02:26 +0000 |
647 | @@ -427,7 +427,7 @@ |
648 | else: |
649 | new_status = '?' |
650 | # XXX: Really should be a more abstract reporter interface |
651 | - kind_ch = osutils.kind_marker(self.kind(fid)) |
652 | + kind_ch = osutils.kind_marker(self.kind(f, fid)) |
653 | to_file.write(new_status + ' ' + f + kind_ch + '\n') |
654 | # Unversion file |
655 | inv_delta.append((f, None, fid, None)) |
656 | @@ -565,7 +565,7 @@ |
657 | ignore_globs.update(ignores.get_runtime_ignores()) |
658 | ignore_globs.update(ignores.get_user_ignores()) |
659 | if self.has_filename(breezy.IGNORE_FILENAME): |
660 | - f = self.get_file_byname(breezy.IGNORE_FILENAME) |
661 | + f = self.get_file(breezy.IGNORE_FILENAME) |
662 | try: |
663 | ignore_globs.update(ignores.parse_ignore_file(f)) |
664 | finally: |
665 | @@ -724,15 +724,13 @@ |
666 | mode=self.controldir._get_file_mode()) |
667 | self._inventory_is_modified = False |
668 | |
669 | - def get_file_mtime(self, file_id, path=None): |
670 | + def get_file_mtime(self, path, file_id=None): |
671 | """See Tree.get_file_mtime.""" |
672 | - if not path: |
673 | - path = self.id2path(file_id) |
674 | try: |
675 | return os.lstat(self.abspath(path)).st_mtime |
676 | except OSError as e: |
677 | if e.errno == errno.ENOENT: |
678 | - raise FileTimestampUnavailable(path) |
679 | + raise errors.NoSuchFile(path) |
680 | raise |
681 | |
682 | def _is_executable_from_path_and_stat_from_basis(self, path, stat_result): |
683 | @@ -747,13 +745,11 @@ |
684 | mode = stat_result.st_mode |
685 | return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode) |
686 | |
687 | - def is_executable(self, file_id, path=None): |
688 | + def is_executable(self, path, file_id=None): |
689 | if not self._supports_executable(): |
690 | - inv, inv_file_id = self._unpack_file_id(file_id) |
691 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
692 | return inv[inv_file_id].executable |
693 | else: |
694 | - if not path: |
695 | - path = self.id2path(file_id) |
696 | mode = os.lstat(self.abspath(path)).st_mode |
697 | return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode) |
698 | |
699 | @@ -799,7 +795,7 @@ |
700 | # raise if there was no inventory, or if we read the wrong inventory. |
701 | raise errors.NoSuchRevisionInTree(self, revision_id) |
702 | |
703 | - def annotate_iter(self, file_id, |
704 | + def annotate_iter(self, path, file_id=None, |
705 | default_revision=_mod_revision.CURRENT_REVISION): |
706 | """See Tree.annotate_iter |
707 | |
708 | @@ -811,15 +807,19 @@ |
709 | attribution will be correct). |
710 | """ |
711 | with self.lock_read(): |
712 | + if file_id is None: |
713 | + file_id = self.path2id(path) |
714 | maybe_file_parent_keys = [] |
715 | for parent_id in self.get_parent_ids(): |
716 | try: |
717 | parent_tree = self.revision_tree(parent_id) |
718 | except errors.NoSuchRevisionInTree: |
719 | - parent_tree = self.branch.repository.revision_tree(parent_id) |
720 | + parent_tree = self.branch.repository.revision_tree( |
721 | + parent_id) |
722 | with parent_tree.lock_read(): |
723 | + |
724 | try: |
725 | - kind = parent_tree.kind(file_id) |
726 | + kind = parent_tree.kind(path, file_id) |
727 | except errors.NoSuchId: |
728 | continue |
729 | if kind != 'file': |
730 | @@ -827,8 +827,10 @@ |
731 | # directories have a "text" which is the empty text, and we |
732 | # know that won't mess up annotations. But it seems cleaner |
733 | continue |
734 | + parent_path = parent_tree.id2path(file_id) |
735 | parent_text_key = ( |
736 | - file_id, parent_tree.get_file_revision(file_id)) |
737 | + file_id, |
738 | + parent_tree.get_file_revision(parent_path, file_id)) |
739 | if parent_text_key not in maybe_file_parent_keys: |
740 | maybe_file_parent_keys.append(parent_text_key) |
741 | graph = _mod_graph.Graph(self.branch.repository.texts) |
742 | @@ -840,7 +842,7 @@ |
743 | |
744 | # Now we have the parents of this content |
745 | annotator = self.branch.repository.texts.get_annotator() |
746 | - text = self.get_file_text(file_id) |
747 | + text = self.get_file_text(path, file_id) |
748 | this_key =(file_id, default_revision) |
749 | annotator.add_special_text(this_key, file_parent_keys, text) |
750 | annotations = [(key[-1], line) |
751 | @@ -889,7 +891,8 @@ |
752 | if not self.has_id(file_id): |
753 | continue |
754 | text_hash = s.get("hash") |
755 | - if text_hash == self.get_file_sha1(file_id): |
756 | + path = self.id2path(file_id) |
757 | + if text_hash == self.get_file_sha1(path, file_id): |
758 | merge_hashes[file_id] = text_hash |
759 | return merge_hashes |
760 | finally: |
761 | @@ -1413,19 +1416,28 @@ |
762 | inv.remove_recursive_id(to_id) |
763 | inv.rename(entry.from_id, entry.to_parent_id, entry.to_tail) |
764 | |
765 | - def unversion(self, file_ids): |
766 | - """Remove the file ids in file_ids from the current versioned set. |
767 | + def unversion(self, paths, file_ids=None): |
768 | + """Remove the paths in paths from the current versioned set. |
769 | |
770 | - When a file_id is unversioned, all of its children are automatically |
771 | + When a path is unversioned, all of its children are automatically |
772 | unversioned. |
773 | |
774 | - :param file_ids: The file ids to stop versioning. |
775 | + :param paths: The paths to stop versioning. |
776 | + :param file_ids: Optional file_ids for the paths |
777 | :raises: NoSuchId if any fileid is not currently versioned. |
778 | """ |
779 | with self.lock_tree_write(): |
780 | - for file_id in file_ids: |
781 | - if not self._inventory.has_id(file_id): |
782 | - raise errors.NoSuchId(self, file_id) |
783 | + if file_ids is not None: |
784 | + for file_id in file_ids: |
785 | + if not self._inventory.has_id(file_id): |
786 | + raise errors.NoSuchId(self, file_id) |
787 | + else: |
788 | + file_ids = set() |
789 | + for path in paths: |
790 | + file_id = self._inventory.path2id(path) |
791 | + if file_id is None: |
792 | + raise errors.NoSuchFile(self, path) |
793 | + file_ids.add(file_id) |
794 | for file_id in file_ids: |
795 | if self._inventory.has_id(file_id): |
796 | self._inventory.remove_recursive_id(file_id) |
797 | @@ -1440,9 +1452,9 @@ |
798 | # - RBC 20060907 |
799 | self._write_inventory(self._inventory) |
800 | |
801 | - def stored_kind(self, file_id): |
802 | + def stored_kind(self, path, file_id=None): |
803 | """See Tree.stored_kind""" |
804 | - inv, inv_file_id = self._unpack_file_id(file_id) |
805 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
806 | return inv[inv_file_id].kind |
807 | |
808 | def extras(self): |
809 | |
810 | === modified file 'breezy/bzr/workingtree_3.py' |
811 | --- breezy/bzr/workingtree_3.py 2017-08-29 13:25:07 +0000 |
812 | +++ breezy/bzr/workingtree_3.py 2017-11-19 19:02:26 +0000 |
813 | @@ -82,10 +82,11 @@ |
814 | trace.mutter('Could not write hashcache for %s\nError: %s', |
815 | self._hashcache.cache_file_name(), e) |
816 | |
817 | - def get_file_sha1(self, file_id, path=None, stat_value=None): |
818 | + def get_file_sha1(self, path, file_id=None, stat_value=None): |
819 | with self.lock_read(): |
820 | - if not path: |
821 | - path = self._inventory.id2path(file_id) |
822 | + # To make sure NoSuchFile gets raised.. |
823 | + if self.path2id(path) is None: |
824 | + raise errors.NoSuchFile(path) |
825 | return self._hashcache.get_sha1(path, stat_value) |
826 | |
827 | |
828 | |
829 | === modified file 'breezy/bzr/workingtree_4.py' |
830 | --- breezy/bzr/workingtree_4.py 2017-11-12 13:53:51 +0000 |
831 | +++ breezy/bzr/workingtree_4.py 2017-11-19 19:02:26 +0000 |
832 | @@ -303,7 +303,7 @@ |
833 | with self.lock_tree_write(): |
834 | for pos, f in enumerate(files): |
835 | if kinds[pos] is None: |
836 | - kinds[pos] = self._kind(f) |
837 | + kinds[pos] = self.kind(f) |
838 | |
839 | def _generate_inventory(self): |
840 | """Create and set self.inventory from the dirstate object. |
841 | @@ -393,11 +393,11 @@ |
842 | path = path.encode('utf8') |
843 | return state._get_entry(0, fileid_utf8=file_id, path_utf8=path) |
844 | |
845 | - def get_file_sha1(self, file_id, path=None, stat_value=None): |
846 | + def get_file_sha1(self, path, file_id=None, stat_value=None): |
847 | # check file id is valid unconditionally. |
848 | entry = self._get_entry(file_id=file_id, path=path) |
849 | if entry[0] is None: |
850 | - raise errors.NoSuchId(self, file_id) |
851 | + raise errors.NoSuchFile(self, path) |
852 | if path is None: |
853 | path = pathjoin(entry[0][0], entry[0][1]).decode('utf8') |
854 | |
855 | @@ -415,7 +415,7 @@ |
856 | stat_value=stat_value) |
857 | if entry[1][0][0] == b'f': |
858 | if link_or_sha1 is None: |
859 | - file_obj, statvalue = self.get_file_with_stat(file_id, path) |
860 | + file_obj, statvalue = self.get_file_with_stat(path, file_id) |
861 | try: |
862 | sha1 = osutils.sha_file(file_obj) |
863 | finally: |
864 | @@ -448,14 +448,11 @@ |
865 | with self.lock_read(): |
866 | return self.current_dirstate().get_parent_ids() |
867 | |
868 | - def get_reference_revision(self, file_id, path=None): |
869 | + def get_reference_revision(self, path, file_id=None): |
870 | # referenced tree's revision is whatever's currently there |
871 | - return self.get_nested_tree(file_id, path).last_revision() |
872 | + return self.get_nested_tree(path, file_id).last_revision() |
873 | |
874 | - def get_nested_tree(self, file_id, path=None): |
875 | - if path is None: |
876 | - path = self.id2path(file_id) |
877 | - # else: check file_id is at path? |
878 | + def get_nested_tree(self, path, file_id=None): |
879 | return WorkingTree.open(self.abspath(path)) |
880 | |
881 | def get_root_id(self): |
882 | @@ -492,7 +489,7 @@ |
883 | return False # Missing entries are not executable |
884 | return entry[1][0][3] # Executable? |
885 | |
886 | - def is_executable(self, file_id, path=None): |
887 | + def is_executable(self, path, file_id=None): |
888 | """Test if a file is executable or not. |
889 | |
890 | Note: The caller is expected to take a read-lock before calling this. |
891 | @@ -504,8 +501,6 @@ |
892 | return entry[1][0][3] |
893 | else: |
894 | self._must_be_locked() |
895 | - if not path: |
896 | - path = self.id2path(file_id) |
897 | mode = osutils.lstat(self.abspath(path)).st_mode |
898 | return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode) |
899 | |
900 | @@ -550,7 +545,7 @@ |
901 | continue |
902 | relpath = pathjoin(key[0].decode('utf8'), key[1].decode('utf8')) |
903 | try: |
904 | - if self._kind(relpath) == 'tree-reference': |
905 | + if self.kind(relpath) == 'tree-reference': |
906 | yield relpath, key[2] |
907 | except errors.NoSuchFile: |
908 | # path is missing on disk. |
909 | @@ -562,21 +557,7 @@ |
910 | entry = self._get_entry(file_id=file_id, path=path) |
911 | state._observed_sha1(entry, *sha_and_stat) |
912 | |
913 | - def kind(self, file_id): |
914 | - """Return the kind of a file. |
915 | - |
916 | - This is always the actual kind that's on disk, regardless of what it |
917 | - was added as. |
918 | - |
919 | - Note: The caller is expected to take a read-lock before calling this. |
920 | - """ |
921 | - relpath = self.id2path(file_id) |
922 | - if relpath is None: |
923 | - raise AssertionError( |
924 | - "path for id {%s} is None!" % file_id) |
925 | - return self._kind(relpath) |
926 | - |
927 | - def _kind(self, relpath): |
928 | + def kind(self, relpath, file_id=None): |
929 | abspath = self.abspath(relpath) |
930 | kind = file_kind(abspath) |
931 | if (self._repo_supports_tree_reference and kind == 'directory'): |
932 | @@ -1206,20 +1187,27 @@ |
933 | finally: |
934 | self.branch.unlock() |
935 | |
936 | - def unversion(self, file_ids): |
937 | - """Remove the file ids in file_ids from the current versioned set. |
938 | + def unversion(self, paths, file_ids=None): |
939 | + """Remove the file ids in paths from the current versioned set. |
940 | |
941 | When a file_id is unversioned, all of its children are automatically |
942 | unversioned. |
943 | |
944 | - :param file_ids: The file ids to stop versioning. |
945 | + :param paths: The file ids to stop versioning. |
946 | :raises: NoSuchId if any fileid is not currently versioned. |
947 | """ |
948 | with self.lock_tree_write(): |
949 | - if not file_ids: |
950 | + if not paths: |
951 | return |
952 | state = self.current_dirstate() |
953 | state._read_dirblocks_if_needed() |
954 | + if file_ids is None: |
955 | + file_ids = set() |
956 | + for path in paths: |
957 | + file_id = self.path2id(path) |
958 | + if file_id is None: |
959 | + raise errors.NoSuchFile(self, path) |
960 | + file_ids.add(file_id) |
961 | ids_to_unversion = set(file_ids) |
962 | paths_to_unversion = set() |
963 | # sketch: |
964 | @@ -1705,10 +1693,12 @@ |
965 | return "<%s of %s in %s>" % \ |
966 | (self.__class__.__name__, self._revision_id, self._dirstate) |
967 | |
968 | - def annotate_iter(self, file_id, |
969 | + def annotate_iter(self, path, file_id=None, |
970 | default_revision=_mod_revision.CURRENT_REVISION): |
971 | """See Tree.annotate_iter""" |
972 | - text_key = (file_id, self.get_file_revision(file_id)) |
973 | + if file_id is None: |
974 | + file_id = self.path2id(path) |
975 | + text_key = (file_id, self.get_file_revision(path, file_id)) |
976 | annotations = self._repository.texts.annotate(text_key) |
977 | return [(key[-1], line) for (key, line) in annotations] |
978 | |
979 | @@ -1851,7 +1841,7 @@ |
980 | parent_ie.children[name_unicode] = inv_entry |
981 | self._inventory = inv |
982 | |
983 | - def get_file_mtime(self, file_id, path=None): |
984 | + def get_file_mtime(self, path, file_id=None): |
985 | """Return the modification time for this record. |
986 | |
987 | We return the timestamp of the last-changed revision. |
988 | @@ -1859,7 +1849,7 @@ |
989 | # Make sure the file exists |
990 | entry = self._get_entry(file_id, path=path) |
991 | if entry == (None, None): # do we raise? |
992 | - raise errors.NoSuchId(self, file_id) |
993 | + raise errors.NoSuchFile(path) |
994 | parent_index = self._get_parent_index() |
995 | last_changed_revision = entry[1][parent_index][4] |
996 | try: |
997 | @@ -1868,7 +1858,7 @@ |
998 | raise FileTimestampUnavailable(self.id2path(file_id)) |
999 | return rev.timestamp |
1000 | |
1001 | - def get_file_sha1(self, file_id, path=None, stat_value=None): |
1002 | + def get_file_sha1(self, path, file_id=None, stat_value=None): |
1003 | entry = self._get_entry(file_id=file_id, path=path) |
1004 | parent_index = self._get_parent_index() |
1005 | parent_details = entry[1][parent_index] |
1006 | @@ -1876,20 +1866,22 @@ |
1007 | return parent_details[1] |
1008 | return None |
1009 | |
1010 | - def get_file_revision(self, file_id): |
1011 | + def get_file_revision(self, path, file_id=None): |
1012 | with self.lock_read(): |
1013 | - inv, inv_file_id = self._unpack_file_id(file_id) |
1014 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
1015 | return inv[inv_file_id].revision |
1016 | |
1017 | - def get_file(self, file_id, path=None): |
1018 | - return BytesIO(self.get_file_text(file_id)) |
1019 | + def get_file(self, path, file_id=None): |
1020 | + return BytesIO(self.get_file_text(path, file_id)) |
1021 | |
1022 | - def get_file_size(self, file_id): |
1023 | + def get_file_size(self, path, file_id=None): |
1024 | """See Tree.get_file_size""" |
1025 | - inv, inv_file_id = self._unpack_file_id(file_id) |
1026 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
1027 | return inv[inv_file_id].text_size |
1028 | |
1029 | - def get_file_text(self, file_id, path=None): |
1030 | + def get_file_text(self, path, file_id=None): |
1031 | + if file_id is None: |
1032 | + file_id = self.path2id(path) |
1033 | content = None |
1034 | for _, content_iter in self.iter_files_bytes([(file_id, None)]): |
1035 | if content is not None: |
1036 | @@ -1903,8 +1895,8 @@ |
1037 | ' the requested data') |
1038 | return content |
1039 | |
1040 | - def get_reference_revision(self, file_id, path=None): |
1041 | - inv, inv_file_id = self._unpack_file_id(file_id) |
1042 | + def get_reference_revision(self, path, file_id=None): |
1043 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
1044 | return inv[inv_file_id].reference_revision |
1045 | |
1046 | def iter_files_bytes(self, desired_files): |
1047 | @@ -1921,8 +1913,10 @@ |
1048 | identifier)) |
1049 | return self._repository.iter_files_bytes(repo_desired_files) |
1050 | |
1051 | - def get_symlink_target(self, file_id, path=None): |
1052 | - entry = self._get_entry(file_id=file_id) |
1053 | + def get_symlink_target(self, path, file_id=None): |
1054 | + entry = self._get_entry(file_id=file_id, path=path) |
1055 | + if entry is None: |
1056 | + raise errors.NoSuchId(tree=self, file_id=file_id) |
1057 | parent_index = self._get_parent_index() |
1058 | if entry[1][parent_index][0] != b'l': |
1059 | return None |
1060 | @@ -1952,16 +1946,16 @@ |
1061 | def has_filename(self, filename): |
1062 | return bool(self.path2id(filename)) |
1063 | |
1064 | - def kind(self, file_id): |
1065 | - entry = self._get_entry(file_id=file_id)[1] |
1066 | + def kind(self, path, file_id=None): |
1067 | + entry = self._get_entry(file_id=file_id, path=path)[1] |
1068 | if entry is None: |
1069 | raise errors.NoSuchId(tree=self, file_id=file_id) |
1070 | parent_index = self._get_parent_index() |
1071 | return dirstate.DirState._minikind_to_kind[entry[parent_index][0]] |
1072 | |
1073 | - def stored_kind(self, file_id): |
1074 | + def stored_kind(self, path, file_id=None): |
1075 | """See Tree.stored_kind""" |
1076 | - return self.kind(file_id) |
1077 | + return self.kind(path, file_id) |
1078 | |
1079 | def path_content_summary(self, path): |
1080 | """See Tree.path_content_summary.""" |
1081 | @@ -1977,8 +1971,8 @@ |
1082 | else: |
1083 | return (kind, None, None, None) |
1084 | |
1085 | - def is_executable(self, file_id, path=None): |
1086 | - inv, inv_file_id = self._unpack_file_id(file_id) |
1087 | + def is_executable(self, path, file_id=None): |
1088 | + inv, inv_file_id = self._path2inv_file_id(path, file_id) |
1089 | ie = inv[inv_file_id] |
1090 | if ie.kind != "file": |
1091 | return False |
1092 | |
1093 | === modified file 'breezy/commit.py' |
1094 | --- breezy/commit.py 2017-08-07 21:57:48 +0000 |
1095 | +++ breezy/commit.py 2017-11-19 19:02:26 +0000 |
1096 | @@ -459,7 +459,9 @@ |
1097 | # Make the working tree be up to date with the branch. This |
1098 | # includes automatic changes scheduled to be made to the tree, such |
1099 | # as updating its basis and unversioning paths that were missing. |
1100 | - self.work_tree.unversion(self.deleted_ids) |
1101 | + self.work_tree.unversion( |
1102 | + {self.work_tree.id2path(file_id) for file_id in self.deleted_ids}, |
1103 | + self.deleted_ids) |
1104 | self._set_progress_stage("Updating the working tree") |
1105 | self.work_tree.update_basis_by_delta(self.rev_id, |
1106 | self.builder.get_basis_delta()) |
1107 | @@ -742,7 +744,7 @@ |
1108 | |
1109 | def _commit_nested_tree(self, file_id, path): |
1110 | "Commit a nested tree." |
1111 | - sub_tree = self.work_tree.get_nested_tree(file_id, path) |
1112 | + sub_tree = self.work_tree.get_nested_tree(path, file_id) |
1113 | # FIXME: be more comprehensive here: |
1114 | # this works when both trees are in --trees repository, |
1115 | # but when both are bound to a different repository, |
1116 | @@ -763,7 +765,7 @@ |
1117 | strict=self.strict, verbose=self.verbose, |
1118 | local=self.local, reporter=self.reporter) |
1119 | except PointlessCommit: |
1120 | - return self.work_tree.get_reference_revision(file_id) |
1121 | + return self.work_tree.get_reference_revision(path, file_id) |
1122 | |
1123 | def _set_progress_stage(self, name, counter=False): |
1124 | """Set the progress stage and emit an update to the progress bar.""" |
1125 | |
1126 | === modified file 'breezy/conflicts.py' |
1127 | --- breezy/conflicts.py 2017-09-26 00:55:04 +0000 |
1128 | +++ breezy/conflicts.py 2017-11-19 19:02:26 +0000 |
1129 | @@ -513,8 +513,9 @@ |
1130 | raise AssertionError('bad winner: %r' % (winner,)) |
1131 | if path_to_create is not None: |
1132 | tid = tt.trans_id_tree_path(path_to_create) |
1133 | + tree = self._revision_tree(tt._tree, revid) |
1134 | transform.create_from_tree( |
1135 | - tt, tid, self._revision_tree(tt._tree, revid), file_id) |
1136 | + tt, tid, tree, tree.id2path(file_id), file_id=file_id) |
1137 | tt.version_file(file_id, tid) |
1138 | else: |
1139 | tid = tt.trans_id_file_id(file_id) |
1140 | |
1141 | === modified file 'breezy/diff.py' |
1142 | --- breezy/diff.py 2017-11-12 13:53:51 +0000 |
1143 | +++ breezy/diff.py 2017-11-19 19:02:26 +0000 |
1144 | @@ -482,7 +482,7 @@ |
1145 | def _patch_header_date(tree, file_id, path): |
1146 | """Returns a timestamp suitable for use in a patch header.""" |
1147 | try: |
1148 | - mtime = tree.get_file_mtime(file_id, path) |
1149 | + mtime = tree.get_file_mtime(path, file_id) |
1150 | except FileTimestampUnavailable: |
1151 | mtime = 0 |
1152 | return timestamp.format_patch_date(mtime) |
1153 | @@ -602,13 +602,13 @@ |
1154 | if 'symlink' not in (old_kind, new_kind): |
1155 | return self.CANNOT_DIFF |
1156 | if old_kind == 'symlink': |
1157 | - old_target = self.old_tree.get_symlink_target(file_id) |
1158 | + old_target = self.old_tree.get_symlink_target(old_path, file_id) |
1159 | elif old_kind is None: |
1160 | old_target = None |
1161 | else: |
1162 | return self.CANNOT_DIFF |
1163 | if new_kind == 'symlink': |
1164 | - new_target = self.new_tree.get_symlink_target(file_id) |
1165 | + new_target = self.new_tree.get_symlink_target(new_path, file_id) |
1166 | elif new_kind is None: |
1167 | new_target = None |
1168 | else: |
1169 | @@ -670,26 +670,27 @@ |
1170 | return self.CANNOT_DIFF |
1171 | from_label = '%s%s\t%s' % (self.old_label, old_path, old_date) |
1172 | to_label = '%s%s\t%s' % (self.new_label, new_path, new_date) |
1173 | - return self.diff_text(from_file_id, to_file_id, from_label, to_label, |
1174 | - old_path, new_path) |
1175 | + return self.diff_text(old_path, new_path, from_label, to_label, |
1176 | + from_file_id, to_file_id) |
1177 | |
1178 | - def diff_text(self, from_file_id, to_file_id, from_label, to_label, |
1179 | - from_path=None, to_path=None): |
1180 | + def diff_text(self, from_path, to_path, from_label, to_label, |
1181 | + from_file_id=None, to_file_id=None): |
1182 | """Diff the content of given files in two trees |
1183 | |
1184 | - :param from_file_id: The id of the file in the from tree. If None, |
1185 | + :param from_path: The path in the from tree. If None, |
1186 | the file is not present in the from tree. |
1187 | - :param to_file_id: The id of the file in the to tree. This may refer |
1188 | - to a different file from from_file_id. If None, |
1189 | + :param to_path: The path in the to tree. This may refer |
1190 | + to a different file from from_path. If None, |
1191 | the file is not present in the to tree. |
1192 | - :param from_path: The path in the from tree or None if unknown. |
1193 | - :param to_path: The path in the to tree or None if unknown. |
1194 | + :param from_file_id: The id of the file in the from tree or None if |
1195 | + unknown. |
1196 | + :param to_file_id: The id of the file in the to tree or None if |
1197 | + unknown. |
1198 | """ |
1199 | def _get_text(tree, file_id, path): |
1200 | - if file_id is not None: |
1201 | - return tree.get_file_lines(file_id, path) |
1202 | - else: |
1203 | + if file_id is None: |
1204 | return [] |
1205 | + return tree.get_file_lines(path, file_id) |
1206 | try: |
1207 | from_text = _get_text(self.old_tree, from_file_id, from_path) |
1208 | to_text = _get_text(self.new_tree, to_file_id, to_path) |
1209 | @@ -797,10 +798,10 @@ |
1210 | relpath_tmp = relpath_tmp.replace(u'?', u'_') |
1211 | return osutils.pathjoin(self._root, prefix, relpath_tmp) |
1212 | |
1213 | - def _write_file(self, file_id, tree, prefix, relpath, force_temp=False, |
1214 | - allow_write=False): |
1215 | + def _write_file(self, relpath, tree, prefix, force_temp=False, |
1216 | + allow_write=False, file_id=None): |
1217 | if not force_temp and isinstance(tree, WorkingTree): |
1218 | - full_path = tree.abspath(tree.id2path(file_id)) |
1219 | + full_path = tree.abspath(relpath) |
1220 | if self._is_safepath(full_path): |
1221 | return full_path |
1222 | |
1223 | @@ -813,7 +814,7 @@ |
1224 | except OSError as e: |
1225 | if e.errno != errno.EEXIST: |
1226 | raise |
1227 | - source = tree.get_file(file_id, relpath) |
1228 | + source = tree.get_file(relpath, file_id) |
1229 | try: |
1230 | target = open(full_path, 'wb') |
1231 | try: |
1232 | @@ -823,7 +824,7 @@ |
1233 | finally: |
1234 | source.close() |
1235 | try: |
1236 | - mtime = tree.get_file_mtime(file_id) |
1237 | + mtime = tree.get_file_mtime(relpath, file_id) |
1238 | except FileTimestampUnavailable: |
1239 | pass |
1240 | else: |
1241 | @@ -832,12 +833,12 @@ |
1242 | osutils.make_readonly(full_path) |
1243 | return full_path |
1244 | |
1245 | - def _prepare_files(self, file_id, old_path, new_path, force_temp=False, |
1246 | - allow_write_new=False): |
1247 | - old_disk_path = self._write_file(file_id, self.old_tree, 'old', |
1248 | - old_path, force_temp) |
1249 | - new_disk_path = self._write_file(file_id, self.new_tree, 'new', |
1250 | - new_path, force_temp, |
1251 | + def _prepare_files(self, old_path, new_path, force_temp=False, |
1252 | + allow_write_new=False, file_id=None): |
1253 | + old_disk_path = self._write_file(old_path, self.old_tree, 'old', |
1254 | + force_temp, file_id=file_id) |
1255 | + new_disk_path = self._write_file(new_path, self.new_tree, 'new', |
1256 | + force_temp, file_id=file_id, |
1257 | allow_write=allow_write_new) |
1258 | return old_disk_path, new_disk_path |
1259 | |
1260 | @@ -853,10 +854,10 @@ |
1261 | if (old_kind, new_kind) != ('file', 'file'): |
1262 | return DiffPath.CANNOT_DIFF |
1263 | (old_disk_path, new_disk_path) = self._prepare_files( |
1264 | - file_id, old_path, new_path) |
1265 | + old_path, new_path, file_id=file_id) |
1266 | self._execute(old_disk_path, new_disk_path) |
1267 | |
1268 | - def edit_file(self, file_id): |
1269 | + def edit_file(self, old_path, new_path, file_id=None): |
1270 | """Use this tool to edit a file. |
1271 | |
1272 | A temporary copy will be edited, and the new contents will be |
1273 | @@ -865,12 +866,9 @@ |
1274 | :param file_id: The id of the file to edit. |
1275 | :return: The new contents of the file. |
1276 | """ |
1277 | - old_path = self.old_tree.id2path(file_id) |
1278 | - new_path = self.new_tree.id2path(file_id) |
1279 | old_abs_path, new_abs_path = self._prepare_files( |
1280 | - file_id, old_path, new_path, |
1281 | - allow_write_new=True, |
1282 | - force_temp=True) |
1283 | + old_path, new_path, allow_write_new=True, force_temp=True, |
1284 | + file_id=file_id) |
1285 | command = self._get_command(old_abs_path, new_abs_path) |
1286 | subprocess.call(command, cwd=self._root) |
1287 | new_file = open(new_abs_path, 'rb') |
1288 | @@ -1025,7 +1023,7 @@ |
1289 | self.to_file.write("=== modified %s '%s'%s\n" % (kind[0], |
1290 | newpath_encoded, prop_str)) |
1291 | if changed_content: |
1292 | - self._diff(file_id, oldpath, newpath, kind[0], kind[1]) |
1293 | + self._diff(oldpath, newpath, kind[0], kind[1], file_id=file_id) |
1294 | has_changes = 1 |
1295 | if renamed: |
1296 | has_changes = 1 |
1297 | @@ -1038,18 +1036,17 @@ |
1298 | :param old_path: The path of the file in the old tree |
1299 | :param new_path: The path of the file in the new tree |
1300 | """ |
1301 | - try: |
1302 | - old_kind = self.old_tree.kind(file_id) |
1303 | - except (errors.NoSuchId, errors.NoSuchFile): |
1304 | + if old_path is None: |
1305 | old_kind = None |
1306 | - try: |
1307 | - new_kind = self.new_tree.kind(file_id) |
1308 | - except (errors.NoSuchId, errors.NoSuchFile): |
1309 | + else: |
1310 | + old_kind = self.old_tree.kind(old_path, file_id) |
1311 | + if new_path is None: |
1312 | new_kind = None |
1313 | - self._diff(file_id, old_path, new_path, old_kind, new_kind) |
1314 | - |
1315 | - |
1316 | - def _diff(self, file_id, old_path, new_path, old_kind, new_kind): |
1317 | + else: |
1318 | + new_kind = self.new_tree.kind(new_path, file_id) |
1319 | + self._diff(old_path, new_path, old_kind, new_kind, file_id=file_id) |
1320 | + |
1321 | + def _diff(self, old_path, new_path, old_kind, new_kind, file_id): |
1322 | result = DiffPath._diff_many(self.differs, file_id, old_path, |
1323 | new_path, old_kind, new_kind) |
1324 | if result is DiffPath.CANNOT_DIFF: |
1325 | |
1326 | === modified file 'breezy/export/dir_exporter.py' |
1327 | --- breezy/export/dir_exporter.py 2017-05-22 00:56:52 +0000 |
1328 | +++ breezy/export/dir_exporter.py 2017-11-19 19:02:26 +0000 |
1329 | @@ -62,7 +62,7 @@ |
1330 | os.mkdir(fullpath) |
1331 | elif ie.kind == "symlink": |
1332 | try: |
1333 | - symlink_target = tree.get_symlink_target(ie.file_id, tp) |
1334 | + symlink_target = tree.get_symlink_target(tp, ie.file_id) |
1335 | os.symlink(symlink_target, fullpath) |
1336 | except OSError as e: |
1337 | raise errors.BzrError( |
1338 | @@ -80,7 +80,7 @@ |
1339 | fullpath = osutils.pathjoin(dest, relpath) |
1340 | # We set the mode and let the umask sort out the file info |
1341 | mode = 0o666 |
1342 | - if tree.is_executable(file_id, treepath): |
1343 | + if tree.is_executable(treepath, file_id): |
1344 | mode = 0o777 |
1345 | out = os.fdopen(os.open(fullpath, flags, mode), 'wb') |
1346 | try: |
1347 | @@ -90,7 +90,7 @@ |
1348 | if force_mtime is not None: |
1349 | mtime = force_mtime |
1350 | else: |
1351 | - mtime = tree.get_file_mtime(file_id, treepath) |
1352 | + mtime = tree.get_file_mtime(treepath, file_id) |
1353 | os.utime(fullpath, (mtime, mtime)) |
1354 | |
1355 | yield |
1356 | |
1357 | === modified file 'breezy/export/tar_exporter.py' |
1358 | --- breezy/export/tar_exporter.py 2017-05-22 00:56:52 +0000 |
1359 | +++ breezy/export/tar_exporter.py 2017-11-19 19:02:26 +0000 |
1360 | @@ -49,10 +49,10 @@ |
1361 | if force_mtime is not None: |
1362 | item.mtime = force_mtime |
1363 | else: |
1364 | - item.mtime = tree.get_file_mtime(entry.file_id, tree_path) |
1365 | + item.mtime = tree.get_file_mtime(tree_path, entry.file_id) |
1366 | if entry.kind == "file": |
1367 | item.type = tarfile.REGTYPE |
1368 | - if tree.is_executable(entry.file_id, tree_path): |
1369 | + if tree.is_executable(tree_path, entry.file_id): |
1370 | item.mode = 0o755 |
1371 | else: |
1372 | item.mode = 0o644 |
1373 | @@ -60,7 +60,7 @@ |
1374 | # the tarfile contract, which wants the size of the file up front. We |
1375 | # want to make sure it doesn't change, and we need to read it in one |
1376 | # go for content filtering. |
1377 | - content = tree.get_file_text(entry.file_id, tree_path) |
1378 | + content = tree.get_file_text(tree_path, entry.file_id) |
1379 | item.size = len(content) |
1380 | fileobj = BytesIO(content) |
1381 | elif entry.kind == "directory": |
1382 | @@ -73,7 +73,7 @@ |
1383 | item.type = tarfile.SYMTYPE |
1384 | item.size = 0 |
1385 | item.mode = 0o755 |
1386 | - item.linkname = tree.get_symlink_target(entry.file_id, tree_path) |
1387 | + item.linkname = tree.get_symlink_target(tree_path, entry.file_id) |
1388 | fileobj = None |
1389 | else: |
1390 | raise errors.BzrError("don't know how to export {%s} of kind %r" |
1391 | @@ -124,7 +124,7 @@ |
1392 | rev = tree.repository.get_revision(tree.get_revision_id()) |
1393 | root_mtime = rev.timestamp |
1394 | elif tree.get_root_id() is not None: |
1395 | - root_mtime = tree.get_file_mtime(tree.get_root_id()) |
1396 | + root_mtime = tree.get_file_mtime('', tree.get_root_id()) |
1397 | else: |
1398 | root_mtime = None |
1399 | |
1400 | |
1401 | === modified file 'breezy/export/zip_exporter.py' |
1402 | --- breezy/export/zip_exporter.py 2017-05-22 00:56:52 +0000 |
1403 | +++ breezy/export/zip_exporter.py 2017-11-19 19:02:26 +0000 |
1404 | @@ -66,7 +66,7 @@ |
1405 | if force_mtime is not None: |
1406 | mtime = force_mtime |
1407 | else: |
1408 | - mtime = tree.get_file_mtime(ie.file_id, tp) |
1409 | + mtime = tree.get_file_mtime(tp, ie.file_id) |
1410 | date_time = time.localtime(mtime)[:6] |
1411 | filename = osutils.pathjoin(root, dp).encode('utf8') |
1412 | if ie.kind == "file": |
1413 | @@ -75,7 +75,7 @@ |
1414 | date_time=date_time) |
1415 | zinfo.compress_type = compression |
1416 | zinfo.external_attr = _FILE_ATTR |
1417 | - content = tree.get_file_text(file_id, tp) |
1418 | + content = tree.get_file_text(tp, file_id) |
1419 | zipf.writestr(zinfo, content) |
1420 | elif ie.kind == "directory": |
1421 | # Directories must contain a trailing slash, to indicate |
1422 | @@ -93,7 +93,7 @@ |
1423 | date_time=date_time) |
1424 | zinfo.compress_type = compression |
1425 | zinfo.external_attr = _FILE_ATTR |
1426 | - zipf.writestr(zinfo, tree.get_symlink_target(file_id, tp)) |
1427 | + zipf.writestr(zinfo, tree.get_symlink_target(tp, file_id)) |
1428 | yield |
1429 | |
1430 | zipf.close() |
1431 | |
1432 | === modified file 'breezy/fetch.py' |
1433 | --- breezy/fetch.py 2017-06-08 23:30:31 +0000 |
1434 | +++ breezy/fetch.py 2017-11-19 19:02:26 +0000 |
1435 | @@ -217,7 +217,7 @@ |
1436 | revision_root = {} |
1437 | for tree in self.iter_rev_trees(revs): |
1438 | root_id = tree.get_root_id() |
1439 | - revision_id = tree.get_file_revision(root_id, u"") |
1440 | + revision_id = tree.get_file_revision(u'', root_id) |
1441 | revision_root[revision_id] = root_id |
1442 | # Find out which parents we don't already know root ids for |
1443 | parents = set(viewvalues(parent_map)) |
1444 | @@ -323,7 +323,7 @@ |
1445 | pass |
1446 | else: |
1447 | try: |
1448 | - parent_ids.append(tree.get_file_revision(root_id)) |
1449 | + parent_ids.append(tree.get_file_revision(u'', root_id)) |
1450 | except errors.NoSuchId: |
1451 | # not in the tree |
1452 | pass |
1453 | |
1454 | === modified file 'breezy/filter_tree.py' |
1455 | --- breezy/filter_tree.py 2017-05-22 00:56:52 +0000 |
1456 | +++ breezy/filter_tree.py 2017-11-19 19:02:26 +0000 |
1457 | @@ -44,10 +44,8 @@ |
1458 | self.backing_tree = backing_tree |
1459 | self.filter_stack_callback = filter_stack_callback |
1460 | |
1461 | - def get_file_text(self, file_id, path=None): |
1462 | - chunks = self.backing_tree.get_file_lines(file_id, path) |
1463 | - if path is None: |
1464 | - path = self.backing_tree.id2path(file_id) |
1465 | + def get_file_text(self, path, file_id=None): |
1466 | + chunks = self.backing_tree.get_file_lines(path, file_id) |
1467 | filters = self.filter_stack_callback(path) |
1468 | context = ContentFilterContext(path, self, None) |
1469 | contents = filtered_output_bytes(chunks, filters, context) |
1470 | @@ -57,8 +55,8 @@ |
1471 | def has_filename(self, filename): |
1472 | return self.backing_tree.has_filename |
1473 | |
1474 | - def is_executable(self, file_id, path=None): |
1475 | - return self.backing_tree.is_executable(file_id, path) |
1476 | + def is_executable(self, path, file_id=None): |
1477 | + return self.backing_tree.is_executable(path, file_id) |
1478 | |
1479 | def iter_entries_by_dir(self, specific_file_ids=None, yield_parents=None): |
1480 | # NB: This simply returns the parent tree's entries; the length may be |
1481 | |
1482 | === modified file 'breezy/lockable_files.py' |
1483 | --- breezy/lockable_files.py 2017-08-27 17:24:34 +0000 |
1484 | +++ breezy/lockable_files.py 2017-11-19 19:02:26 +0000 |
1485 | @@ -292,7 +292,7 @@ |
1486 | def create(self, mode=None): |
1487 | """Create lock mechanism""" |
1488 | # for old-style locks, create the file now |
1489 | - self._transport.put_bytes(self._escaped_name, '', |
1490 | + self._transport.put_bytes(self._escaped_name, b'', |
1491 | mode=self._file_modebits) |
1492 | |
1493 | def validate_token(self, token): |
1494 | |
1495 | === modified file 'breezy/log.py' |
1496 | --- breezy/log.py 2017-11-12 13:53:51 +0000 |
1497 | +++ breezy/log.py 2017-11-19 19:02:26 +0000 |
1498 | @@ -2062,7 +2062,7 @@ |
1499 | tree1 = None |
1500 | for fp in relpaths: |
1501 | file_id = tree.path2id(fp) |
1502 | - kind = _get_kind_for_file_id(tree, file_id) |
1503 | + kind = _get_kind_for_file_id(tree, fp, file_id) |
1504 | if file_id is None: |
1505 | # go back to when time began |
1506 | if tree1 is None: |
1507 | @@ -2076,7 +2076,7 @@ |
1508 | tree1 = b.repository.revision_tree(rev1) |
1509 | if tree1: |
1510 | file_id = tree1.path2id(fp) |
1511 | - kind = _get_kind_for_file_id(tree1, file_id) |
1512 | + kind = _get_kind_for_file_id(tree1, fp, file_id) |
1513 | info_list.append((fp, file_id, kind)) |
1514 | |
1515 | elif start_rev_info == end_rev_info: |
1516 | @@ -2084,7 +2084,7 @@ |
1517 | tree = b.repository.revision_tree(end_rev_info.rev_id) |
1518 | for fp in relpaths: |
1519 | file_id = tree.path2id(fp) |
1520 | - kind = _get_kind_for_file_id(tree, file_id) |
1521 | + kind = _get_kind_for_file_id(tree, fp, file_id) |
1522 | info_list.append((fp, file_id, kind)) |
1523 | |
1524 | else: |
1525 | @@ -2098,7 +2098,7 @@ |
1526 | tree1 = None |
1527 | for fp in relpaths: |
1528 | file_id = tree.path2id(fp) |
1529 | - kind = _get_kind_for_file_id(tree, file_id) |
1530 | + kind = _get_kind_for_file_id(tree, fp, file_id) |
1531 | if file_id is None: |
1532 | if tree1 is None: |
1533 | rev_id = start_rev_info.rev_id |
1534 | @@ -2108,15 +2108,15 @@ |
1535 | else: |
1536 | tree1 = b.repository.revision_tree(rev_id) |
1537 | file_id = tree1.path2id(fp) |
1538 | - kind = _get_kind_for_file_id(tree1, file_id) |
1539 | + kind = _get_kind_for_file_id(tree1, fp, file_id) |
1540 | info_list.append((fp, file_id, kind)) |
1541 | return b, info_list, start_rev_info, end_rev_info |
1542 | |
1543 | |
1544 | -def _get_kind_for_file_id(tree, file_id): |
1545 | +def _get_kind_for_file_id(tree, path, file_id): |
1546 | """Return the kind of a file-id or None if it doesn't exist.""" |
1547 | if file_id is not None: |
1548 | - return tree.kind(file_id) |
1549 | + return tree.kind(path, file_id) |
1550 | else: |
1551 | return None |
1552 | |
1553 | |
1554 | === modified file 'breezy/memorytree.py' |
1555 | --- breezy/memorytree.py 2017-08-29 14:45:14 +0000 |
1556 | +++ breezy/memorytree.py 2017-11-19 19:02:26 +0000 |
1557 | @@ -85,16 +85,12 @@ |
1558 | missing files, so is a no-op. |
1559 | """ |
1560 | |
1561 | - def get_file(self, file_id, path=None): |
1562 | + def get_file(self, path, file_id=None): |
1563 | """See Tree.get_file.""" |
1564 | - if path is None: |
1565 | - path = self.id2path(file_id) |
1566 | return self._file_transport.get(path) |
1567 | |
1568 | - def get_file_sha1(self, file_id, path=None, stat_value=None): |
1569 | + def get_file_sha1(self, path, file_id=None, stat_value=None): |
1570 | """See Tree.get_file_sha1().""" |
1571 | - if path is None: |
1572 | - path = self.id2path(file_id) |
1573 | stream = self._file_transport.get(path) |
1574 | return sha_file(stream) |
1575 | |
1576 | @@ -120,7 +116,7 @@ |
1577 | id = self.path2id(path) |
1578 | if id is None: |
1579 | return 'missing', None, None, None |
1580 | - kind = self.kind(id) |
1581 | + kind = self.kind(path, id) |
1582 | if kind == 'file': |
1583 | bytes = self._file_transport.get_bytes(path) |
1584 | size = len(bytes) |
1585 | @@ -154,10 +150,12 @@ |
1586 | """See Tree.has_filename().""" |
1587 | return self._file_transport.has(filename) |
1588 | |
1589 | - def is_executable(self, file_id, path=None): |
1590 | + def is_executable(self, path, file_id=None): |
1591 | return self._inventory[file_id].executable |
1592 | |
1593 | - def kind(self, file_id): |
1594 | + def kind(self, path, file_id=None): |
1595 | + if file_id is None: |
1596 | + file_id = self.path2id(path) |
1597 | return self._inventory[file_id].kind |
1598 | |
1599 | def mkdir(self, path, file_id=None): |
1600 | @@ -238,13 +236,13 @@ |
1601 | self._file_transport.mkdir(path) |
1602 | elif entry.kind == 'file': |
1603 | self._file_transport.put_file(path, |
1604 | - self._basis_tree.get_file(entry.file_id)) |
1605 | + self._basis_tree.get_file(path, entry.file_id)) |
1606 | else: |
1607 | raise NotImplementedError(self._populate_from_branch) |
1608 | |
1609 | - def put_file_bytes_non_atomic(self, file_id, bytes): |
1610 | + def put_file_bytes_non_atomic(self, path, bytes, file_id=None): |
1611 | """See MutableTree.put_file_bytes_non_atomic.""" |
1612 | - self._file_transport.put_bytes(self.id2path(file_id), bytes) |
1613 | + self._file_transport.put_bytes(path, bytes) |
1614 | |
1615 | def unlock(self): |
1616 | """Release a lock. |
1617 | @@ -264,19 +262,21 @@ |
1618 | else: |
1619 | self._locks -= 1 |
1620 | |
1621 | - def unversion(self, file_ids): |
1622 | - """Remove the file ids in file_ids from the current versioned set. |
1623 | + def unversion(self, paths, file_ids=None): |
1624 | + """Remove the paths from the current versioned set. |
1625 | |
1626 | When a file_id is unversioned, all of its children are automatically |
1627 | unversioned. |
1628 | |
1629 | - :param file_ids: The file ids to stop versioning. |
1630 | + :param paths: The paths to stop versioning. |
1631 | :raises: NoSuchId if any fileid is not currently versioned. |
1632 | """ |
1633 | with self.lock_tree_write(): |
1634 | # XXX: This should be in mutabletree, but the inventory-save action |
1635 | # is not relevant to memory tree. Until that is done in unlock by |
1636 | # working tree, we cannot share the implementation. |
1637 | + if file_ids is None: |
1638 | + file_ids = {self.path2id(path) for path in paths} |
1639 | for file_id in file_ids: |
1640 | if self._inventory.has_id(file_id): |
1641 | self._inventory.remove_recursive_id(file_id) |
1642 | |
1643 | === modified file 'breezy/merge.py' |
1644 | --- breezy/merge.py 2017-07-30 16:59:50 +0000 |
1645 | +++ breezy/merge.py 2017-11-19 19:02:26 +0000 |
1646 | @@ -651,9 +651,9 @@ |
1647 | hook(merge) |
1648 | if self.recurse == 'down': |
1649 | for relpath, file_id in self.this_tree.iter_references(): |
1650 | - sub_tree = self.this_tree.get_nested_tree(file_id, relpath) |
1651 | + sub_tree = self.this_tree.get_nested_tree(relpath, file_id) |
1652 | other_revision = self.other_tree.get_reference_revision( |
1653 | - file_id, relpath) |
1654 | + relpath, file_id) |
1655 | if other_revision == sub_tree.last_revision(): |
1656 | continue |
1657 | sub_merge = Merger(sub_tree.branch, this_tree=sub_tree) |
1658 | @@ -661,7 +661,9 @@ |
1659 | other_branch = self.other_branch.reference_parent(file_id, |
1660 | relpath) |
1661 | sub_merge.set_other_revision(other_revision, other_branch) |
1662 | - base_revision = self.base_tree.get_reference_revision(file_id) |
1663 | + base_tree_path = self.base_tree.id2path(file_id) |
1664 | + base_revision = self.base_tree.get_reference_revision( |
1665 | + base_tree_path, file_id) |
1666 | sub_merge.base_tree = \ |
1667 | sub_tree.branch.repository.revision_tree(base_revision) |
1668 | sub_merge.base_rev_id = base_revision |
1669 | @@ -1005,7 +1007,7 @@ |
1670 | def get_sha1(ie, tree): |
1671 | if ie.kind != 'file': |
1672 | return None |
1673 | - return tree.get_file_sha1(file_id) |
1674 | + return tree.get_file_sha1(tree.id2path(file_id), file_id) |
1675 | base_sha1 = get_sha1(base_ie, self.base_tree) |
1676 | lca_sha1s = [get_sha1(ie, tree) for ie, tree |
1677 | in zip(lca_entries, self._lca_trees)] |
1678 | @@ -1028,7 +1030,8 @@ |
1679 | def get_target(ie, tree): |
1680 | if ie.kind != 'symlink': |
1681 | return None |
1682 | - return tree.get_symlink_target(file_id) |
1683 | + path = tree.id2path(file_id) |
1684 | + return tree.get_symlink_target(path, file_id) |
1685 | base_target = get_target(base_ie, self.base_tree) |
1686 | lca_targets = [get_target(ie, tree) for ie, tree |
1687 | in zip(lca_entries, self._lca_trees)] |
1688 | @@ -1069,10 +1072,11 @@ |
1689 | def write_modified(self, results): |
1690 | modified_hashes = {} |
1691 | for path in results.modified_paths: |
1692 | - file_id = self.working_tree.path2id(self.working_tree.relpath(path)) |
1693 | + wt_relpath = self.working_tree.relpath(path) |
1694 | + file_id = self.working_tree.path2id(wt_relpath) |
1695 | if file_id is None: |
1696 | continue |
1697 | - hash = self.working_tree.get_file_sha1(file_id) |
1698 | + hash = self.working_tree.get_file_sha1(wt_relpath, file_id) |
1699 | if hash is None: |
1700 | continue |
1701 | modified_hashes[file_id] = hash |
1702 | @@ -1095,25 +1099,31 @@ |
1703 | @staticmethod |
1704 | def contents_sha1(tree, file_id): |
1705 | """Determine the sha1 of the file contents (used as a key method).""" |
1706 | - if not tree.has_id(file_id): |
1707 | + try: |
1708 | + path = tree.id2path(file_id) |
1709 | + except errors.NoSuchId: |
1710 | return None |
1711 | - return tree.get_file_sha1(file_id) |
1712 | + return tree.get_file_sha1(path, file_id) |
1713 | |
1714 | @staticmethod |
1715 | def executable(tree, file_id): |
1716 | """Determine the executability of a file-id (used as a key method).""" |
1717 | - if not tree.has_id(file_id): |
1718 | + try: |
1719 | + path = tree.id2path(file_id) |
1720 | + except errors.NoSuchId: |
1721 | return None |
1722 | - if tree.kind(file_id) != "file": |
1723 | + if tree.kind(path, file_id) != "file": |
1724 | return False |
1725 | - return tree.is_executable(file_id) |
1726 | + return tree.is_executable(path, file_id) |
1727 | |
1728 | @staticmethod |
1729 | - def kind(tree, file_id): |
1730 | + def kind(tree, path, file_id): |
1731 | """Determine the kind of a file-id (used as a key method).""" |
1732 | - if not tree.has_id(file_id): |
1733 | + try: |
1734 | + path = tree.id2path(file_id) |
1735 | + except errors.NoSuchId: |
1736 | return None |
1737 | - return tree.kind(file_id) |
1738 | + return tree.kind(path, file_id) |
1739 | |
1740 | @staticmethod |
1741 | def _three_way(base, other, this): |
1742 | @@ -1251,13 +1261,18 @@ |
1743 | def _do_merge_contents(self, file_id): |
1744 | """Performs a merge on file_id contents.""" |
1745 | def contents_pair(tree): |
1746 | - if not tree.has_id(file_id): |
1747 | - return (None, None) |
1748 | - kind = tree.kind(file_id) |
1749 | + try: |
1750 | + path = tree.id2path(file_id) |
1751 | + except errors.NoSuchId: |
1752 | + return (None, None) |
1753 | + try: |
1754 | + kind = tree.kind(path, file_id) |
1755 | + except errors.NoSuchFile: |
1756 | + return (None, None) |
1757 | if kind == "file": |
1758 | - contents = tree.get_file_sha1(file_id) |
1759 | + contents = tree.get_file_sha1(path, file_id) |
1760 | elif kind == "symlink": |
1761 | - contents = tree.get_symlink_target(file_id) |
1762 | + contents = tree.get_symlink_target(path, file_id) |
1763 | else: |
1764 | contents = None |
1765 | return kind, contents |
1766 | @@ -1319,7 +1334,8 @@ |
1767 | # conflict |
1768 | self.tt.version_file(file_id, trans_id) |
1769 | transform.create_from_tree( |
1770 | - self.tt, trans_id, self.other_tree, file_id, |
1771 | + self.tt, trans_id, self.other_tree, |
1772 | + self.other_tree.id2path(file_id), file_id=file_id, |
1773 | filter_tree_path=self._get_filter_tree_path(file_id)) |
1774 | inhibit_content_conflict = True |
1775 | elif params.other_kind is None: # file_id is not in OTHER |
1776 | @@ -1377,7 +1393,8 @@ |
1777 | if self.other_tree.has_id(file_id): |
1778 | # OTHER changed the file |
1779 | transform.create_from_tree( |
1780 | - self.tt, trans_id, self.other_tree, file_id, |
1781 | + self.tt, trans_id, self.other_tree, |
1782 | + self.other_tree.id2path(file_id), file_id=file_id, |
1783 | filter_tree_path=self._get_filter_tree_path(file_id)) |
1784 | return 'done', None |
1785 | elif self.this_tree.has_id(file_id): |
1786 | @@ -1411,20 +1428,26 @@ |
1787 | |
1788 | def get_lines(self, tree, file_id): |
1789 | """Return the lines in a file, or an empty list.""" |
1790 | - if tree.has_id(file_id): |
1791 | - return tree.get_file_lines(file_id) |
1792 | - else: |
1793 | + try: |
1794 | + path = tree.id2path(file_id) |
1795 | + except errors.NoSuchId: |
1796 | return [] |
1797 | + else: |
1798 | + return tree.get_file_lines(path, file_id) |
1799 | |
1800 | def text_merge(self, file_id, trans_id): |
1801 | """Perform a three-way text merge on a file_id""" |
1802 | # it's possible that we got here with base as a different type. |
1803 | # if so, we just want two-way text conflicts. |
1804 | - if self.base_tree.has_id(file_id) and \ |
1805 | - self.base_tree.kind(file_id) == "file": |
1806 | - base_lines = self.get_lines(self.base_tree, file_id) |
1807 | - else: |
1808 | + try: |
1809 | + base_path = self.base_tree.id2path(file_id) |
1810 | + except errors.NoSuchId: |
1811 | base_lines = [] |
1812 | + else: |
1813 | + if self.base_tree.kind(base_path, file_id) == "file": |
1814 | + base_lines = self.get_lines(self.base_tree, file_id) |
1815 | + else: |
1816 | + base_lines = [] |
1817 | other_lines = self.get_lines(self.other_tree, file_id) |
1818 | this_lines = self.get_lines(self.this_tree, file_id) |
1819 | m3 = merge3.Merge3(base_lines, this_lines, other_lines, |
1820 | @@ -1503,22 +1526,29 @@ |
1821 | versioned = False |
1822 | file_group = [] |
1823 | for suffix, tree, lines in data: |
1824 | - if tree.has_id(file_id): |
1825 | - trans_id = self._conflict_file(name, parent_id, tree, file_id, |
1826 | - suffix, lines, filter_tree_path) |
1827 | + try: |
1828 | + path = tree.id2path(file_id) |
1829 | + except errors.NoSuchId: |
1830 | + pass |
1831 | + else: |
1832 | + trans_id = self._conflict_file( |
1833 | + name, parent_id, path, tree, file_id, suffix, lines, |
1834 | + filter_tree_path) |
1835 | file_group.append(trans_id) |
1836 | if set_version and not versioned: |
1837 | self.tt.version_file(file_id, trans_id) |
1838 | versioned = True |
1839 | return file_group |
1840 | |
1841 | - def _conflict_file(self, name, parent_id, tree, file_id, suffix, |
1842 | + def _conflict_file(self, name, parent_id, path, tree, file_id, suffix, |
1843 | lines=None, filter_tree_path=None): |
1844 | """Emit a single conflict file.""" |
1845 | name = name + '.' + suffix |
1846 | trans_id = self.tt.create_path(name, parent_id) |
1847 | - transform.create_from_tree(self.tt, trans_id, tree, file_id, lines, |
1848 | - filter_tree_path) |
1849 | + transform.create_from_tree( |
1850 | + self.tt, trans_id, tree, path, |
1851 | + file_id=file_id, bytes=lines, |
1852 | + filter_tree_path=filter_tree_path) |
1853 | return trans_id |
1854 | |
1855 | def merge_executable(self, file_id, file_status): |
1856 | @@ -1702,7 +1732,7 @@ |
1857 | out_path = osutils.pathjoin(temp_dir, name) |
1858 | out_file = open(out_path, "wb") |
1859 | try: |
1860 | - in_file = tree.get_file(file_id) |
1861 | + in_file = tree.get_file(tree.id2path(file_id), file_id) |
1862 | for line in in_file: |
1863 | out_file.write(line) |
1864 | finally: |
1865 | @@ -1852,10 +1882,10 @@ |
1866 | try: |
1867 | entries = self._entries_to_incorporate() |
1868 | entries = list(entries) |
1869 | - for num, (entry, parent_id) in enumerate(entries): |
1870 | + for num, (entry, parent_id, path) in enumerate(entries): |
1871 | child_pb.update(gettext('Preparing file merge'), num, len(entries)) |
1872 | parent_trans_id = self.tt.trans_id_file_id(parent_id) |
1873 | - trans_id = transform.new_by_entry(self.tt, entry, |
1874 | + trans_id = transform.new_by_entry(path, self.tt, entry, |
1875 | parent_trans_id, self.other_tree) |
1876 | finally: |
1877 | child_pb.finished() |
1878 | @@ -1887,17 +1917,17 @@ |
1879 | # an edge case, so we don't do anything special for those. We let |
1880 | # them cause conflicts. |
1881 | merge_into_root.file_id = generate_ids.gen_file_id(name_in_target) |
1882 | - yield (merge_into_root, target_id) |
1883 | + yield (merge_into_root, target_id, '') |
1884 | if subdir.kind != 'directory': |
1885 | # No children, so we are done. |
1886 | return |
1887 | - for ignored_path, entry in other_inv.iter_entries_by_dir(subdir_id): |
1888 | + for path, entry in other_inv.iter_entries_by_dir(subdir_id): |
1889 | parent_id = entry.parent_id |
1890 | if parent_id == subdir.file_id: |
1891 | # The root's parent ID has changed, so make sure children of |
1892 | # the root refer to the new ID. |
1893 | parent_id = merge_into_root.file_id |
1894 | - yield (entry, parent_id) |
1895 | + yield (entry, parent_id, path) |
1896 | |
1897 | |
1898 | def merge_inner(this_branch, other_tree, base_tree, ignore_zero=False, |
1899 | |
1900 | === modified file 'breezy/mutabletree.py' |
1901 | --- breezy/mutabletree.py 2017-08-29 21:29:35 +0000 |
1902 | +++ breezy/mutabletree.py 2017-11-19 19:02:26 +0000 |
1903 | @@ -307,7 +307,7 @@ |
1904 | :return: None |
1905 | """ |
1906 | |
1907 | - def put_file_bytes_non_atomic(self, file_id, bytes): |
1908 | + def put_file_bytes_non_atomic(self, path, bytes, file_id=None): |
1909 | """Update the content of a file in the tree. |
1910 | |
1911 | Note that the file is written in-place rather than being |
1912 | |
1913 | === modified file 'breezy/plugins/commitfromnews/committemplate.py' |
1914 | --- breezy/plugins/commitfromnews/committemplate.py 2017-07-23 23:43:55 +0000 |
1915 | +++ breezy/plugins/commitfromnews/committemplate.py 2017-11-19 19:02:26 +0000 |
1916 | @@ -69,7 +69,7 @@ |
1917 | # changed in new version of the file. So for now a direct diff |
1918 | # using patiencediff is done. |
1919 | old_revision = self.commit.basis_tree.get_file_revision( |
1920 | - found_entry.file_id) |
1921 | + old_path, found_entry.file_id) |
1922 | needed = [(found_entry.file_id, found_entry.revision, 'new'), |
1923 | (found_entry.file_id, old_revision, 'old')] |
1924 | contents = self.commit.builder.repository.iter_files_bytes(needed) |
1925 | |
1926 | === modified file 'breezy/plugins/fastimport/exporter.py' |
1927 | --- breezy/plugins/fastimport/exporter.py 2017-09-26 01:06:03 +0000 |
1928 | +++ breezy/plugins/fastimport/exporter.py 2017-11-19 19:02:26 +0000 |
1929 | @@ -294,16 +294,15 @@ |
1930 | marks_file.export_marks(self.export_marks_file, revision_ids) |
1931 | |
1932 | def is_empty_dir(self, tree, path): |
1933 | - path_id = tree.path2id(path) |
1934 | - if path_id is None: |
1935 | + # Continue if path is not a directory |
1936 | + try: |
1937 | + if tree.kind(path) != 'directory': |
1938 | + return False |
1939 | + except bazErrors.NoSuchFile: |
1940 | self.warning("Skipping empty_dir detection - no file_id for %s" % |
1941 | (path,)) |
1942 | return False |
1943 | |
1944 | - # Continue if path is not a directory |
1945 | - if tree.kind(path_id) != 'directory': |
1946 | - return False |
1947 | - |
1948 | # Use treewalk to find the contents of our directory |
1949 | contents = list(tree.walkdirs(prefix=path))[0] |
1950 | if len(contents[1]) == 0: |
1951 | @@ -487,19 +486,21 @@ |
1952 | # Record modifications |
1953 | for path, id_, kind in changes.added + my_modified + rd_modifies: |
1954 | if kind == 'file': |
1955 | - text = tree_new.get_file_text(id_) |
1956 | + text = tree_new.get_file_text(path, id_) |
1957 | file_cmds.append(commands.FileModifyCommand(path.encode("utf-8"), |
1958 | - helpers.kind_to_mode('file', tree_new.is_executable(id_)), |
1959 | + helpers.kind_to_mode( |
1960 | + 'file', tree_new.is_executable(path, id_)), |
1961 | None, text)) |
1962 | elif kind == 'symlink': |
1963 | file_cmds.append(commands.FileModifyCommand(path.encode("utf-8"), |
1964 | helpers.kind_to_mode('symlink', False), |
1965 | - None, tree_new.get_symlink_target(id_))) |
1966 | + None, tree_new.get_symlink_target(path, id_))) |
1967 | elif kind == 'directory': |
1968 | if not self.plain_format: |
1969 | - file_cmds.append(commands.FileModifyCommand(path.encode("utf-8"), |
1970 | - helpers.kind_to_mode('directory', False), |
1971 | - None, None)) |
1972 | + file_cmds.append( |
1973 | + commands.FileModifyCommand(path.encode("utf-8"), |
1974 | + helpers.kind_to_mode('directory', False), None, |
1975 | + None)) |
1976 | else: |
1977 | self.warning("cannot export '%s' of kind %s yet - ignoring" % |
1978 | (path, kind)) |
1979 | @@ -557,7 +558,7 @@ |
1980 | |
1981 | # Renaming a directory implies all children must be renamed. |
1982 | # Note: changes_from() doesn't handle this |
1983 | - if kind == 'directory' and tree_old.kind(id_) == 'directory': |
1984 | + if kind == 'directory' and tree_old.kind(oldpath, id_) == 'directory': |
1985 | for p, e in tree_old.inventory.iter_entries_by_dir(from_dir=id_): |
1986 | if e.kind == 'directory' and self.plain_format: |
1987 | continue |
1988 | |
1989 | === modified file 'breezy/plugins/fastimport/revision_store.py' |
1990 | --- breezy/plugins/fastimport/revision_store.py 2017-09-26 00:55:04 +0000 |
1991 | +++ breezy/plugins/fastimport/revision_store.py 2017-11-19 19:02:26 +0000 |
1992 | @@ -66,12 +66,14 @@ |
1993 | # TODO: Handle root renames? |
1994 | return self._basis_inv.root.file_id |
1995 | |
1996 | - def get_file_with_stat(self, file_id, path=None): |
1997 | - content = self.get_file_text(file_id, path) |
1998 | + def get_file_with_stat(self, path, file_id=None): |
1999 | + content = self.get_file_text(path, file_id) |
2000 | sio = StringIO(content) |
2001 | return sio, None |
2002 | |
2003 | - def get_file_text(self, file_id, path=None): |
2004 | + def get_file_text(self, path, file_id=None): |
2005 | + if file_id is None: |
2006 | + file_id = self.path2id(path) |
2007 | try: |
2008 | return self._content_provider(file_id) |
2009 | except KeyError: |
2010 | @@ -83,13 +85,15 @@ |
2011 | 'unordered', True) |
2012 | return stream.next().get_bytes_as('fulltext') |
2013 | |
2014 | - def get_symlink_target(self, file_id): |
2015 | + def get_symlink_target(self, path, file_id=None): |
2016 | + if file_id is None: |
2017 | + file_id = self.path2id(path) |
2018 | if file_id in self._new_info_by_id: |
2019 | ie = self._new_info_by_id[file_id][1] |
2020 | return ie.symlink_target |
2021 | return self._basis_inv[file_id].symlink_target |
2022 | |
2023 | - def get_reference_revision(self, file_id, path=None): |
2024 | + def get_reference_revision(self, path, file_id=None): |
2025 | raise NotImplementedError(_TreeShim.get_reference_revision) |
2026 | |
2027 | def _delta_to_iter_changes(self): |
2028 | @@ -222,12 +226,14 @@ |
2029 | def get_file_text(self, revision_id, file_id): |
2030 | """Get the text stored for a file in a given revision.""" |
2031 | revtree = self.repo.revision_tree(revision_id) |
2032 | - return revtree.get_file_text(file_id) |
2033 | + path = revtree.id2path(file_id) |
2034 | + return revtree.get_file_text(path, file_id) |
2035 | |
2036 | def get_file_lines(self, revision_id, file_id): |
2037 | """Get the lines stored for a file in a given revision.""" |
2038 | revtree = self.repo.revision_tree(revision_id) |
2039 | - return osutils.split_lines(revtree.get_file_text(file_id)) |
2040 | + path = revtree.id2path(file_id) |
2041 | + return osutils.split_lines(revtree.get_file_text(path, file_id)) |
2042 | |
2043 | def start_new_revision(self, revision, parents, parent_invs): |
2044 | """Init the metadata needed for get_parents_and_revision_for_entry(). |
2045 | |
2046 | === modified file 'breezy/plugins/fastimport/tests/test_generic_processor.py' |
2047 | --- breezy/plugins/fastimport/tests/test_generic_processor.py 2017-08-26 13:58:53 +0000 |
2048 | +++ breezy/plugins/fastimport/tests/test_generic_processor.py 2017-11-19 19:02:26 +0000 |
2049 | @@ -175,21 +175,20 @@ |
2050 | def assertContent(self, branch, tree, path, content): |
2051 | file_id = tree.path2id(path) |
2052 | with branch.lock_read(): |
2053 | - self.assertEqual(tree.get_file_text(file_id), content) |
2054 | + self.assertEqual(tree.get_file_text(path, file_id), content) |
2055 | |
2056 | def assertSymlinkTarget(self, branch, tree, path, target): |
2057 | file_id = tree.path2id(path) |
2058 | with branch.lock_read(): |
2059 | - self.assertEqual(tree.get_symlink_target(file_id), target) |
2060 | + self.assertEqual(tree.get_symlink_target(path, file_id), target) |
2061 | |
2062 | def assertExecutable(self, branch, tree, path, executable): |
2063 | - file_id = tree.path2id(path) |
2064 | with branch.lock_read(): |
2065 | - self.assertEqual(tree.is_executable(file_id), executable) |
2066 | + self.assertEqual(tree.is_executable(path), executable) |
2067 | |
2068 | def assertRevisionRoot(self, revtree, path): |
2069 | self.assertEqual(revtree.get_revision_id(), |
2070 | - revtree.get_file_revision(revtree.path2id(path))) |
2071 | + revtree.get_file_revision(path)) |
2072 | |
2073 | |
2074 | class TestImportToPackTag(TestCaseForGenericProcessor): |
2075 | @@ -1943,11 +1942,10 @@ |
2076 | rev_b = branch.repository.get_parent_map([rev_c])[rev_c][0] |
2077 | rtree_a, rtree_b, rtree_c, rtree_d = branch.repository.revision_trees([ |
2078 | rev_a, rev_b, rev_c, rev_d]) |
2079 | - foo_id = rtree_a.path2id('foo') |
2080 | - self.assertEqual(rev_a, rtree_a.get_file_revision(foo_id)) |
2081 | - self.assertEqual(rev_b, rtree_b.get_file_revision(foo_id)) |
2082 | - self.assertEqual(rev_c, rtree_c.get_file_revision(foo_id)) |
2083 | - self.assertEqual(rev_c, rtree_d.get_file_revision(foo_id)) |
2084 | + self.assertEqual(rev_a, rtree_a.get_file_revision('foo')) |
2085 | + self.assertEqual(rev_b, rtree_b.get_file_revision('foo')) |
2086 | + self.assertEqual(rev_c, rtree_c.get_file_revision('foo')) |
2087 | + self.assertEqual(rev_c, rtree_d.get_file_revision('foo')) |
2088 | |
2089 | |
2090 | class TestCommitCommands(TestCaseForGenericProcessor): |
2091 | @@ -1987,5 +1985,4 @@ |
2092 | self.addCleanup(branch.unlock) |
2093 | rev_a = branch.last_revision() |
2094 | rtree_a = branch.repository.revision_tree(rev_a) |
2095 | - foo_id = rtree_a.path2id(u'foo\ufffd') |
2096 | - self.assertEqual(rev_a, rtree_a.get_file_revision(foo_id)) |
2097 | + self.assertEqual(rev_a, rtree_a.get_file_revision(u'foo\ufffd')) |
2098 | |
2099 | === modified file 'breezy/plugins/fastimport/tests/test_revision_store.py' |
2100 | --- breezy/plugins/fastimport/tests/test_revision_store.py 2017-06-08 23:30:31 +0000 |
2101 | +++ breezy/plugins/fastimport/tests/test_revision_store.py 2017-11-19 19:02:26 +0000 |
2102 | @@ -98,7 +98,7 @@ |
2103 | shim = revision_store._TreeShim(repo=None, basis_inv=basis_inv, |
2104 | inv_delta=[], |
2105 | content_provider=content_provider) |
2106 | - f_obj, stat_val = shim.get_file_with_stat('baz-id') |
2107 | + f_obj, stat_val = shim.get_file_with_stat('bar/baz', 'baz-id') |
2108 | self.assertIs(None, stat_val) |
2109 | self.assertEqualDiff('content of\nbaz-id\n', f_obj.read()) |
2110 | |
2111 | @@ -112,7 +112,8 @@ |
2112 | basis_inv.add(ie) |
2113 | shim = revision_store._TreeShim(repo=None, basis_inv=basis_inv, |
2114 | inv_delta=[], content_provider=None) |
2115 | - self.assertEqual(u'link-target', shim.get_symlink_target('link-id')) |
2116 | + self.assertEqual(u'link-target', |
2117 | + shim.get_symlink_target('link', 'link-id')) |
2118 | |
2119 | def test_get_symlink_target_from_delta(self): |
2120 | basis_inv = self.make_trivial_basis_inv() |
2121 | @@ -122,7 +123,8 @@ |
2122 | shim = revision_store._TreeShim(repo=None, basis_inv=basis_inv, |
2123 | inv_delta=inv_delta, |
2124 | content_provider=None) |
2125 | - self.assertEqual(u'link-target', shim.get_symlink_target('link-id')) |
2126 | + self.assertEqual(u'link-target', |
2127 | + shim.get_symlink_target('link', 'link-id')) |
2128 | |
2129 | def test__delta_to_iter_changes(self): |
2130 | basis_inv = self.make_trivial_basis_inv() |
2131 | |
2132 | === modified file 'breezy/plugins/grep/grep.py' |
2133 | --- breezy/plugins/grep/grep.py 2017-11-12 13:53:51 +0000 |
2134 | +++ breezy/plugins/grep/grep.py 2017-11-19 19:02:26 +0000 |
2135 | @@ -428,7 +428,7 @@ |
2136 | # If old result is valid, print results immediately. |
2137 | # Otherwise, add file info to to_grep so that the |
2138 | # loop later will get chunks and grep them |
2139 | - cache_id = tree.get_file_revision(fid) |
2140 | + cache_id = tree.get_file_revision(fp, fid) |
2141 | if cache_id in outputter.cache: |
2142 | # GZ 2010-06-05: Not really sure caching and re-outputting |
2143 | # the old path is really the right thing, |
2144 | @@ -455,7 +455,7 @@ |
2145 | for (path, fid), chunks in tree.iter_files_bytes(to_grep): |
2146 | path = _make_display_path(relpath, path) |
2147 | _file_grep(chunks[0], path, opts, revno, path_prefix, |
2148 | - tree.get_file_revision(fid, path)) |
2149 | + tree.get_file_revision(path, fid)) |
2150 | |
2151 | |
2152 | def _make_display_path(relpath, path): |
2153 | @@ -478,7 +478,7 @@ |
2154 | """ |
2155 | |
2156 | path = _make_display_path(relpath, path) |
2157 | - file_text = tree.get_file_text(id) |
2158 | + file_text = tree.get_file_text(relpath, id) |
2159 | _file_grep(file_text, path, opts, revno, path_prefix) |
2160 | |
2161 | |
2162 | |
2163 | === modified file 'breezy/plugins/upload/cmds.py' |
2164 | --- breezy/plugins/upload/cmds.py 2017-11-12 13:53:51 +0000 |
2165 | +++ breezy/plugins/upload/cmds.py 2017-11-19 19:02:26 +0000 |
2166 | @@ -153,12 +153,11 @@ |
2167 | if self._ignored is None: |
2168 | try: |
2169 | ignore_file_path = '.bzrignore-upload' |
2170 | - ignore_file_id = self.tree.path2id(ignore_file_path) |
2171 | - ignore_file = self.tree.get_file(ignore_file_id, |
2172 | - ignore_file_path) |
2173 | + ignore_file = self.tree.get_file(ignore_file_path) |
2174 | + except errors.NoSuchFile: |
2175 | + ignored_patterns = [] |
2176 | + else: |
2177 | ignored_patterns = ignores.parse_ignore_file(ignore_file) |
2178 | - except errors.NoSuchId: |
2179 | - ignored_patterns = [] |
2180 | self._ignored = globbing.Globster(ignored_patterns) |
2181 | return self._ignored |
2182 | |
2183 | @@ -177,13 +176,13 @@ |
2184 | |
2185 | def upload_file(self, relpath, id, mode=None): |
2186 | if mode is None: |
2187 | - if self.tree.is_executable(id): |
2188 | + if self.tree.is_executable(relpath, id): |
2189 | mode = 0o775 |
2190 | else: |
2191 | mode = 0o664 |
2192 | if not self.quiet: |
2193 | self.outf.write('Uploading %s\n' % relpath) |
2194 | - self._up_put_bytes(relpath, self.tree.get_file_text(id), mode) |
2195 | + self._up_put_bytes(relpath, self.tree.get_file_text(relpath, id), mode) |
2196 | |
2197 | def upload_file_robustly(self, relpath, id, mode=None): |
2198 | """Upload a file, clearing the way on the remote side. |
2199 | |
2200 | === modified file 'breezy/plugins/weave_fmt/test_bzrdir.py' |
2201 | --- breezy/plugins/weave_fmt/test_bzrdir.py 2017-11-12 13:53:51 +0000 |
2202 | +++ breezy/plugins/weave_fmt/test_bzrdir.py 2017-11-19 19:02:26 +0000 |
2203 | @@ -337,13 +337,13 @@ |
2204 | foo_id = 'foo-20051004035605-91e788d1875603ae' |
2205 | rt.lock_read() |
2206 | try: |
2207 | - eq(rt.get_file_text(foo_id), 'initial contents\n') |
2208 | + eq(rt.get_file_text('foo', foo_id), 'initial contents\n') |
2209 | finally: |
2210 | rt.unlock() |
2211 | rt = b.repository.revision_tree(rh[1]) |
2212 | rt.lock_read() |
2213 | try: |
2214 | - eq(rt.get_file_text(foo_id), 'new contents\n') |
2215 | + eq(rt.get_file_text('foo', foo_id), 'new contents\n') |
2216 | finally: |
2217 | rt.unlock() |
2218 | # check a backup was made: |
2219 | |
2220 | === modified file 'breezy/plugins/weave_fmt/test_repository.py' |
2221 | --- breezy/plugins/weave_fmt/test_repository.py 2017-06-11 01:22:16 +0000 |
2222 | +++ breezy/plugins/weave_fmt/test_repository.py 2017-11-19 19:02:26 +0000 |
2223 | @@ -143,7 +143,7 @@ |
2224 | control.create_branch() |
2225 | tree = control.create_workingtree() |
2226 | tree.add(['foo'], ['Foo:Bar'], ['file']) |
2227 | - tree.put_file_bytes_non_atomic('Foo:Bar', 'content\n') |
2228 | + tree.put_file_bytes_non_atomic('foo', 'content\n', 'Foo:Bar') |
2229 | try: |
2230 | tree.commit('first post', rev_id='first') |
2231 | except IllegalPath: |
2232 | |
2233 | === modified file 'breezy/rename_map.py' |
2234 | --- breezy/rename_map.py 2017-11-11 18:16:54 +0000 |
2235 | +++ breezy/rename_map.py 2017-11-19 19:02:26 +0000 |
2236 | @@ -108,8 +108,7 @@ |
2237 | try: |
2238 | for num, path in enumerate(paths): |
2239 | task.update(gettext('Determining hash hits'), num, len(paths)) |
2240 | - hits = self.hitcounts(self.tree.get_file_lines(None, |
2241 | - path=path)) |
2242 | + hits = self.hitcounts(self.tree.get_file_lines(path)) |
2243 | all_hits.extend((v, path, k) for k, v in viewitems(hits)) |
2244 | finally: |
2245 | task.finished() |
2246 | |
2247 | === modified file 'breezy/revisionspec.py' |
2248 | --- breezy/revisionspec.py 2017-11-12 13:53:51 +0000 |
2249 | +++ breezy/revisionspec.py 2017-11-19 19:02:26 +0000 |
2250 | @@ -897,12 +897,11 @@ |
2251 | self._raise_invalid(numstring, context_branch) |
2252 | tree, file_path = workingtree.WorkingTree.open_containing(path) |
2253 | with tree.lock_read(): |
2254 | - file_id = tree.path2id(file_path) |
2255 | - if file_id is None: |
2256 | + if not tree.has_filename(file_path): |
2257 | raise errors.InvalidRevisionSpec(self.user_spec, |
2258 | context_branch, "File '%s' is not versioned." % |
2259 | file_path) |
2260 | - revision_ids = [r for (r, l) in tree.annotate_iter(file_id)] |
2261 | + revision_ids = [r for (r, l) in tree.annotate_iter(file_path)] |
2262 | try: |
2263 | revision_id = revision_ids[index] |
2264 | except IndexError: |
2265 | |
2266 | === modified file 'breezy/revisiontree.py' |
2267 | --- breezy/revisiontree.py 2017-08-26 13:06:15 +0000 |
2268 | +++ breezy/revisiontree.py 2017-11-19 19:02:26 +0000 |
2269 | @@ -64,17 +64,19 @@ |
2270 | """Return the revision id associated with this tree.""" |
2271 | return self._revision_id |
2272 | |
2273 | - def get_file_revision(self, file_id, path=None): |
2274 | + def get_file_revision(self, path, file_id=None): |
2275 | """Return the revision id in which a file was last changed.""" |
2276 | raise NotImplementedError(self.get_file_revision) |
2277 | |
2278 | - def get_file_text(self, file_id, path=None): |
2279 | + def get_file_text(self, path, file_id=None): |
2280 | + if file_id is None: |
2281 | + file_id = self.path2id(path) |
2282 | for (identifier, content) in self.iter_files_bytes([(file_id, None)]): |
2283 | ret = "".join(content) |
2284 | return ret |
2285 | |
2286 | - def get_file(self, file_id, path=None): |
2287 | - return BytesIO(self.get_file_text(file_id)) |
2288 | + def get_file(self, path, file_id=None): |
2289 | + return BytesIO(self.get_file_text(path, file_id)) |
2290 | |
2291 | def is_locked(self): |
2292 | return self._repository.is_locked() |
2293 | |
2294 | === modified file 'breezy/shelf.py' |
2295 | --- breezy/shelf.py 2017-07-16 01:55:39 +0000 |
2296 | +++ breezy/shelf.py 2017-11-19 19:02:26 +0000 |
2297 | @@ -125,8 +125,10 @@ |
2298 | if kind[0] != kind [1]: |
2299 | yield ('change kind', file_id, kind[0], kind[1], paths[0]) |
2300 | elif kind[0] == 'symlink': |
2301 | - t_target = self.target_tree.get_symlink_target(file_id) |
2302 | - w_target = self.work_tree.get_symlink_target(file_id) |
2303 | + t_target = self.target_tree.get_symlink_target( |
2304 | + paths[0], file_id) |
2305 | + w_target = self.work_tree.get_symlink_target( |
2306 | + paths[1], file_id) |
2307 | yield ('modify target', file_id, paths[0], t_target, |
2308 | w_target) |
2309 | elif changed: |
2310 | @@ -178,12 +180,14 @@ |
2311 | :param new_target: The target that the symlink should have due |
2312 | to shelving. |
2313 | """ |
2314 | - new_target = self.target_tree.get_symlink_target(file_id) |
2315 | + new_path = self.target_tree.id2path(file_id) |
2316 | + new_target = self.target_tree.get_symlink_target(new_path, file_id) |
2317 | w_trans_id = self.work_transform.trans_id_file_id(file_id) |
2318 | self.work_transform.delete_contents(w_trans_id) |
2319 | self.work_transform.create_symlink(new_target, w_trans_id) |
2320 | |
2321 | - old_target = self.work_tree.get_symlink_target(file_id) |
2322 | + old_path = self.work_tree.id2path(file_id) |
2323 | + old_target = self.work_tree.get_symlink_target(old_path, file_id) |
2324 | s_trans_id = self.shelf_transform.trans_id_file_id(file_id) |
2325 | self.shelf_transform.delete_contents(s_trans_id) |
2326 | self.shelf_transform.create_symlink(old_target, s_trans_id) |
2327 | @@ -207,7 +211,8 @@ |
2328 | def _content_from_tree(tt, tree, file_id): |
2329 | trans_id = tt.trans_id_file_id(file_id) |
2330 | tt.delete_contents(trans_id) |
2331 | - transform.create_from_tree(tt, trans_id, tree, file_id) |
2332 | + transform.create_from_tree(tt, trans_id, tree, tree.id2path(file_id), |
2333 | + file_id) |
2334 | |
2335 | def shelve_content_change(self, file_id): |
2336 | """Shelve a kind change or binary file content change. |
2337 | @@ -263,15 +268,18 @@ |
2338 | if kind is None: |
2339 | to_transform.create_file('', s_trans_id) |
2340 | else: |
2341 | - transform.create_from_tree(to_transform, s_trans_id, |
2342 | - tree, file_id) |
2343 | + transform.create_from_tree( |
2344 | + to_transform, s_trans_id, tree, |
2345 | + tree.id2path(file_id), file_id) |
2346 | if version: |
2347 | to_transform.version_file(file_id, s_trans_id) |
2348 | |
2349 | def _inverse_lines(self, new_lines, file_id): |
2350 | """Produce a version with only those changes removed from new_lines.""" |
2351 | - target_lines = self.target_tree.get_file_lines(file_id) |
2352 | - work_lines = self.work_tree.get_file_lines(file_id) |
2353 | + target_path = self.target_tree.id2path(file_id) |
2354 | + target_lines = self.target_tree.get_file_lines(target_path, file_id) |
2355 | + work_path = self.work_tree.id2path(file_id) |
2356 | + work_lines = self.work_tree.get_file_lines(work_path, file_id) |
2357 | return merge3.Merge3(new_lines, target_lines, work_lines).merge_lines() |
2358 | |
2359 | def finalize(self): |
2360 | |
2361 | === modified file 'breezy/shelf_ui.py' |
2362 | --- breezy/shelf_ui.py 2017-07-16 01:55:39 +0000 |
2363 | +++ breezy/shelf_ui.py 2017-11-19 19:02:26 +0000 |
2364 | @@ -231,7 +231,6 @@ |
2365 | self.change_editor.finish() |
2366 | self.work_tree.unlock() |
2367 | |
2368 | - |
2369 | def get_parsed_patch(self, file_id, invert=False): |
2370 | """Return a parsed version of a file's patch. |
2371 | |
2372 | @@ -300,7 +299,8 @@ |
2373 | :param file_id: The id of the file that was modified. |
2374 | :return: The number of changes. |
2375 | """ |
2376 | - work_tree_lines = self.work_tree.get_file_lines(file_id) |
2377 | + path = self.work_tree.id2path(file_id) |
2378 | + work_tree_lines = self.work_tree.get_file_lines(path, file_id) |
2379 | try: |
2380 | lines, change_count = self._select_hunks(creator, file_id, |
2381 | work_tree_lines) |
2382 | @@ -324,7 +324,8 @@ |
2383 | if self.reporter.invert_diff: |
2384 | target_lines = work_tree_lines |
2385 | else: |
2386 | - target_lines = self.target_tree.get_file_lines(file_id) |
2387 | + path = self.target_tree.path2id(file_id) |
2388 | + target_lines = self.target_tree.get_file_lines(path, file_id) |
2389 | textfile.check_text_lines(work_tree_lines) |
2390 | textfile.check_text_lines(target_lines) |
2391 | parsed = self.get_parsed_patch(file_id, self.reporter.invert_diff) |
2392 | @@ -362,7 +363,10 @@ |
2393 | content of the file, and change_region_count is the number of |
2394 | changed regions. |
2395 | """ |
2396 | - lines = osutils.split_lines(self.change_editor.edit_file(file_id)) |
2397 | + lines = osutils.split_lines(self.change_editor.edit_file( |
2398 | + self.change_editor.old_tree.id2path(file_id), |
2399 | + self.change_editor.new_tree.id2path(file_id), |
2400 | + file_id=file_id)) |
2401 | return lines, self._count_changed_regions(work_tree_lines, lines) |
2402 | |
2403 | @staticmethod |
2404 | |
2405 | === modified file 'breezy/tests/blackbox/test_merge.py' |
2406 | --- breezy/tests/blackbox/test_merge.py 2017-11-16 00:39:04 +0000 |
2407 | +++ breezy/tests/blackbox/test_merge.py 2017-11-19 19:02:26 +0000 |
2408 | @@ -148,7 +148,7 @@ |
2409 | '=======\n' |
2410 | 'D\n' |
2411 | '>>>>>>> MERGE-SOURCE\n', |
2412 | - tree.get_file_text('f-id')) |
2413 | + tree.get_file_text(tree.id2path('f-id'))) |
2414 | |
2415 | def test_merge_explicit_reprocess_show_base(self): |
2416 | tree, other = self.create_conflicting_branches() |
2417 | @@ -170,7 +170,7 @@ |
2418 | 'B\n' |
2419 | 'D\n' |
2420 | '>>>>>>> MERGE-SOURCE\n', |
2421 | - tree.get_file_text('f-id')) |
2422 | + tree.get_file_text(tree.id2path('f-id'))) |
2423 | |
2424 | def test_merge_override_show_base(self): |
2425 | tree, other = self.create_conflicting_branches() |
2426 | @@ -188,7 +188,7 @@ |
2427 | 'B\n' |
2428 | 'D\n' |
2429 | '>>>>>>> MERGE-SOURCE\n', |
2430 | - tree.get_file_text('f-id')) |
2431 | + tree.get_file_text(tree.id2path('f-id'))) |
2432 | |
2433 | def test_merge_with_missing_file(self): |
2434 | """Merge handles missing file conflicts""" |
2435 | |
2436 | === modified file 'breezy/tests/blackbox/test_mkdir.py' |
2437 | --- breezy/tests/blackbox/test_mkdir.py 2017-05-21 18:10:28 +0000 |
2438 | +++ breezy/tests/blackbox/test_mkdir.py 2017-11-19 19:02:26 +0000 |
2439 | @@ -27,33 +27,33 @@ |
2440 | def test_mkdir(self): |
2441 | tree = self.make_branch_and_tree('.') |
2442 | self.run_bzr(['mkdir', 'somedir']) |
2443 | - self.assertEqual(tree.kind(tree.path2id('somedir')), "directory") |
2444 | + self.assertEqual(tree.kind('somedir'), "directory") |
2445 | |
2446 | def test_mkdir_multi(self): |
2447 | tree = self.make_branch_and_tree('.') |
2448 | self.run_bzr(['mkdir', 'somedir', 'anotherdir']) |
2449 | - self.assertEqual(tree.kind(tree.path2id('somedir')), "directory") |
2450 | - self.assertEqual(tree.kind(tree.path2id('anotherdir')), "directory") |
2451 | + self.assertEqual(tree.kind('somedir'), "directory") |
2452 | + self.assertEqual(tree.kind('anotherdir'), "directory") |
2453 | |
2454 | def test_mkdir_parents(self): |
2455 | tree = self.make_branch_and_tree('.') |
2456 | self.run_bzr(['mkdir', '-p', 'somedir/foo']) |
2457 | - self.assertEqual(tree.kind(tree.path2id('somedir/foo')), "directory") |
2458 | + self.assertEqual(tree.kind('somedir/foo'), "directory") |
2459 | |
2460 | def test_mkdir_parents_existing_versioned_dir(self): |
2461 | tree = self.make_branch_and_tree('.') |
2462 | tree.mkdir('somedir') |
2463 | - self.assertEqual(tree.kind(tree.path2id('somedir')), "directory") |
2464 | + self.assertEqual(tree.kind('somedir'), "directory") |
2465 | self.run_bzr(['mkdir', '-p', 'somedir']) |
2466 | |
2467 | def test_mkdir_parents_existing_unversioned_dir(self): |
2468 | tree = self.make_branch_and_tree('.') |
2469 | os.mkdir('somedir') |
2470 | self.run_bzr(['mkdir', '-p', 'somedir']) |
2471 | - self.assertEqual(tree.kind(tree.path2id('somedir')), "directory") |
2472 | + self.assertEqual(tree.kind('somedir'), "directory") |
2473 | |
2474 | def test_mkdir_parents_with_unversioned_parent(self): |
2475 | tree = self.make_branch_and_tree('.') |
2476 | os.mkdir('somedir') |
2477 | self.run_bzr(['mkdir', '-p', 'somedir/foo']) |
2478 | - self.assertEqual(tree.kind(tree.path2id('somedir/foo')), "directory") |
2479 | + self.assertEqual(tree.kind('somedir/foo'), "directory") |
2480 | |
2481 | === modified file 'breezy/tests/blackbox/test_resolve.py' |
2482 | --- breezy/tests/blackbox/test_resolve.py 2017-06-13 10:58:47 +0000 |
2483 | +++ breezy/tests/blackbox/test_resolve.py 2017-11-19 19:02:26 +0000 |
2484 | @@ -119,7 +119,7 @@ |
2485 | self.build_tree_contents([('tree/file', |
2486 | '<<<<<<<\na\n=======\n>>>>>>>\n')]) |
2487 | tree.add('file', 'file_id') |
2488 | - self.assertEqual(tree.kind('file_id'), 'file') |
2489 | + self.assertEqual(tree.kind('file', 'file_id'), 'file') |
2490 | file_conflict = conflicts.TextConflict('file', file_id='file_id') |
2491 | tree.set_conflicts(conflicts.ConflictList([file_conflict])) |
2492 | note = self.run_bzr('resolve', retcode=1, working_dir='tree')[1] |
2493 | |
2494 | === modified file 'breezy/tests/blackbox/test_versioning.py' |
2495 | --- breezy/tests/blackbox/test_versioning.py 2017-11-12 13:53:51 +0000 |
2496 | +++ breezy/tests/blackbox/test_versioning.py 2017-11-19 19:02:26 +0000 |
2497 | @@ -147,7 +147,7 @@ |
2498 | new.lock_read() |
2499 | |
2500 | def get_text_by_path(tree, path): |
2501 | - return tree.get_file_text(tree.path2id(path), path) |
2502 | + return tree.get_file_text(path) |
2503 | |
2504 | self.assertEqual(get_text_by_path(new, 'b/two'), 'old contents') |
2505 | self.assertEqual(get_text_by_path(new, 'top'), 'old contents') |
2506 | |
2507 | === modified file 'breezy/tests/per_branch/test_branch.py' |
2508 | --- breezy/tests/per_branch/test_branch.py 2017-10-07 22:42:22 +0000 |
2509 | +++ breezy/tests/per_branch/test_branch.py 2017-11-19 19:02:26 +0000 |
2510 | @@ -113,7 +113,7 @@ |
2511 | tree = b2.repository.revision_tree(rev1) |
2512 | tree.lock_read() |
2513 | self.addCleanup(tree.unlock) |
2514 | - self.assertEqual(tree.get_file_text(tree.path2id('foo')), 'hello') |
2515 | + self.assertEqual(tree.get_file_text('foo'), 'hello') |
2516 | |
2517 | def get_unbalanced_tree_pair(self): |
2518 | """Return two branches, a and b, with one file in a.""" |
2519 | |
2520 | === modified file 'breezy/tests/per_branch/test_commit.py' |
2521 | --- breezy/tests/per_branch/test_commit.py 2017-10-07 22:42:22 +0000 |
2522 | +++ breezy/tests/per_branch/test_commit.py 2017-11-19 19:02:26 +0000 |
2523 | @@ -187,7 +187,7 @@ |
2524 | # setting up a playground |
2525 | tree.add('rootfile') |
2526 | rootfile_id = tree.path2id('rootfile') |
2527 | - tree.put_file_bytes_non_atomic(rootfile_id, 'abc') |
2528 | + tree.put_file_bytes_non_atomic('rootfile', 'abc') |
2529 | tree.add('dir') |
2530 | dir_id = tree.path2id('dir') |
2531 | tree.add('dir/subfile') |
2532 | @@ -202,9 +202,9 @@ |
2533 | tree.lock_write() |
2534 | try: |
2535 | # making changes |
2536 | - tree.put_file_bytes_non_atomic(rootfile_id, 'jkl') |
2537 | + tree.put_file_bytes_non_atomic('rootfile', 'jkl') |
2538 | tree.rename_one('dir/subfile', 'dir/subfile_renamed') |
2539 | - tree.unversion([to_be_unversioned_id]) |
2540 | + tree.unversion(['to_be_unversioned']) |
2541 | tree.mkdir('added_dir') |
2542 | added_dir_id = tree.path2id('added_dir') |
2543 | # start to capture pre_commit delta |
2544 | |
2545 | === modified file 'breezy/tests/per_branch/test_sprout.py' |
2546 | --- breezy/tests/per_branch/test_sprout.py 2017-08-07 14:41:20 +0000 |
2547 | +++ breezy/tests/per_branch/test_sprout.py 2017-11-19 19:02:26 +0000 |
2548 | @@ -176,12 +176,9 @@ |
2549 | tree.lock_read() |
2550 | self.addCleanup(tree.unlock) |
2551 | # Check that the symlink target is safely round-tripped in the trees. |
2552 | - self.assertEqual( |
2553 | - target, |
2554 | - tree.get_symlink_target(tree.path2id(link_name))) |
2555 | - self.assertEqual( |
2556 | - target, |
2557 | - tree.basis_tree().get_symlink_target(tree.path2id(link_name))) |
2558 | + self.assertEqual(target, tree.get_symlink_target(link_name)) |
2559 | + self.assertEqual(target, |
2560 | + tree.basis_tree().get_symlink_target(link_name)) |
2561 | |
2562 | def test_sprout_with_ghost_in_mainline(self): |
2563 | tree = self.make_branch_and_tree('tree1') |
2564 | |
2565 | === modified file 'breezy/tests/per_branch/test_stacking.py' |
2566 | --- breezy/tests/per_branch/test_stacking.py 2017-08-07 21:10:20 +0000 |
2567 | +++ breezy/tests/per_branch/test_stacking.py 2017-11-19 19:02:26 +0000 |
2568 | @@ -483,9 +483,7 @@ |
2569 | rtree = target.repository.revision_tree(rev2) |
2570 | rtree.lock_read() |
2571 | self.addCleanup(rtree.unlock) |
2572 | - self.assertEqual( |
2573 | - 'new content', |
2574 | - rtree.get_file_text(rtree.path2id('a'), 'a')) |
2575 | + self.assertEqual('new content', rtree.get_file_text('a')) |
2576 | self.check_lines_added_or_present(target, rev2) |
2577 | |
2578 | def test_transform_fallback_location_hook(self): |
2579 | |
2580 | === modified file 'breezy/tests/per_foreign_vcs/test_branch.py' |
2581 | --- breezy/tests/per_foreign_vcs/test_branch.py 2017-07-23 17:17:18 +0000 |
2582 | +++ breezy/tests/per_foreign_vcs/test_branch.py 2017-11-19 19:02:26 +0000 |
2583 | @@ -29,6 +29,9 @@ |
2584 | from breezy.tests import ( |
2585 | TestCaseWithTransport, |
2586 | ) |
2587 | +from breezy.sixish import ( |
2588 | + text_type, |
2589 | + ) |
2590 | |
2591 | |
2592 | class ForeignBranchFactory(object): |
2593 | @@ -96,8 +99,8 @@ |
2594 | def test__get_nick(self): |
2595 | """Make sure _get_nick is implemented and returns a string.""" |
2596 | branch = self.make_branch() |
2597 | - self.assertIsInstance(branch._get_nick(local=False), str) |
2598 | - self.assertIsInstance(branch._get_nick(local=True), str) |
2599 | + self.assertIsInstance(branch._get_nick(local=False), text_type) |
2600 | + self.assertIsInstance(branch._get_nick(local=True), text_type) |
2601 | |
2602 | def test_null_revid_revno(self): |
2603 | """null: should return revno 0.""" |
2604 | |
2605 | === modified file 'breezy/tests/per_interbranch/test_fetch.py' |
2606 | --- breezy/tests/per_interbranch/test_fetch.py 2017-08-10 00:51:26 +0000 |
2607 | +++ breezy/tests/per_interbranch/test_fetch.py 2017-11-19 19:02:26 +0000 |
2608 | @@ -42,9 +42,7 @@ |
2609 | tree = b2.repository.revision_tree(rev1) |
2610 | tree.lock_read() |
2611 | self.addCleanup(tree.unlock) |
2612 | - self.assertEqual( |
2613 | - tree.get_file_text(tree.path2id('foo'), 'foo'), |
2614 | - 'hello') |
2615 | + self.assertEqual(tree.get_file_text('foo'), 'hello') |
2616 | |
2617 | def test_fetch_revisions_limit(self): |
2618 | """Test fetch-revision operation.""" |
2619 | |
2620 | === modified file 'breezy/tests/per_interrepository/test_fetch.py' |
2621 | --- breezy/tests/per_interrepository/test_fetch.py 2017-11-16 00:39:04 +0000 |
2622 | +++ breezy/tests/per_interrepository/test_fetch.py 2017-11-19 19:02:26 +0000 |
2623 | @@ -77,10 +77,10 @@ |
2624 | tree = repo.revision_tree('rev1') |
2625 | tree.lock_read() |
2626 | self.addCleanup(tree.unlock) |
2627 | - tree.get_file_text('file1') |
2628 | + tree.get_file_text('foo') |
2629 | for file_id in tree.all_file_ids(): |
2630 | - if tree.kind(file_id) == "file": |
2631 | - tree.get_file(file_id).read() |
2632 | + if tree.kind(tree.id2path(file_id)) == "file": |
2633 | + tree.get_file(tree.id2path(file_id)).read() |
2634 | |
2635 | # makes a target version repo |
2636 | repo_b = self.make_to_repository('b') |
2637 | @@ -421,7 +421,7 @@ |
2638 | """If fetching a delta, we should die if a basis is not present.""" |
2639 | tree = self.make_branch_and_tree('tree') |
2640 | self.build_tree(['tree/a']) |
2641 | - tree.add(['a'], ['a-id']) |
2642 | + tree.add(['a']) |
2643 | tree.commit('one', rev_id='rev-one') |
2644 | self.build_tree_contents([('tree/a', 'new contents\n')]) |
2645 | tree.commit('two', rev_id='rev-two') |
2646 | @@ -465,7 +465,7 @@ |
2647 | try: |
2648 | rt = to_repo.revision_tree('rev-two') |
2649 | self.assertEqual('new contents\n', |
2650 | - rt.get_file_text('a-id')) |
2651 | + rt.get_file_text('a')) |
2652 | finally: |
2653 | to_repo.unlock() |
2654 | |
2655 | |
2656 | === modified file 'breezy/tests/per_intertree/test_compare.py' |
2657 | --- breezy/tests/per_intertree/test_compare.py 2017-10-08 02:49:53 +0000 |
2658 | +++ breezy/tests/per_intertree/test_compare.py 2017-11-19 19:02:26 +0000 |
2659 | @@ -789,13 +789,15 @@ |
2660 | tree1.mkdir('changing', 'parent-id') |
2661 | tree1.mkdir('changing/unchanging', 'mid-id') |
2662 | tree1.add(['changing/unchanging/file'], ['file-id'], ['file']) |
2663 | - tree1.put_file_bytes_non_atomic('file-id', 'a file') |
2664 | + tree1.put_file_bytes_non_atomic( |
2665 | + 'changing/unchanging/file', 'a file', file_id='file-id') |
2666 | tree2 = self.make_to_branch_and_tree('2') |
2667 | tree2.set_root_id(tree1.get_root_id()) |
2668 | tree2.mkdir('changed', 'parent-id') |
2669 | tree2.mkdir('changed/unchanging', 'mid-id') |
2670 | tree2.add(['changed/unchanging/file'], ['file-id'], ['file']) |
2671 | - tree2.put_file_bytes_non_atomic('file-id', 'changed content') |
2672 | + tree2.put_file_bytes_non_atomic( |
2673 | + 'changed/unchanging/file', 'changed content', file_id='file-id') |
2674 | tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2) |
2675 | # parent-id has changed, as has file-id |
2676 | root_id = tree1.path2id('') |
2677 | @@ -814,13 +816,16 @@ |
2678 | tree1.mkdir('changed', 'parent-id') |
2679 | tree1.mkdir('changed/unchanging', 'mid-id') |
2680 | tree1.add(['changed/unchanging/file'], ['file-id'], ['file']) |
2681 | - tree1.put_file_bytes_non_atomic('file-id', 'a file') |
2682 | + tree1.put_file_bytes_non_atomic( |
2683 | + 'changed/unchanging/file', 'a file', |
2684 | + 'file-id') |
2685 | tree2 = self.make_to_branch_and_tree('2') |
2686 | tree2.set_root_id('new') |
2687 | tree2.mkdir('changed', 'parent-id') |
2688 | tree2.mkdir('changed/unchanging', 'mid-id') |
2689 | tree2.add(['changed/unchanging/file'], ['file-id'], ['file']) |
2690 | - tree2.put_file_bytes_non_atomic('file-id', 'changed content') |
2691 | + tree2.put_file_bytes_non_atomic( |
2692 | + 'changed/unchanging/file', 'changed content', file_id='file-id') |
2693 | tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2) |
2694 | # old is gone, new is added, parent-id has changed(reparented), as has |
2695 | # file-id(content) |
2696 | @@ -866,12 +871,12 @@ |
2697 | # it must be emitted as a change. |
2698 | tree1 = self.make_branch_and_tree('1') |
2699 | tree1.add(['a'], ['a-id'], ['file']) |
2700 | - tree1.put_file_bytes_non_atomic('a-id', 'a file') |
2701 | + tree1.put_file_bytes_non_atomic('a', 'a file') |
2702 | tree2 = self.make_to_branch_and_tree('2') |
2703 | tree2.set_root_id(tree1.get_root_id()) |
2704 | tree2.mkdir('a', 'b-id') |
2705 | tree2.add(['a/c'], ['c-id'], ['file']) |
2706 | - tree2.put_file_bytes_non_atomic('c-id', 'another file') |
2707 | + tree2.put_file_bytes_non_atomic('a/c', 'another file') |
2708 | tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2) |
2709 | # a-id is gone, b-id and c-id are added. |
2710 | self.assertEqualIterChanges( |
2711 | @@ -892,7 +897,7 @@ |
2712 | tree2.mkdir('a', 'a-new-id') |
2713 | tree2.mkdir('a/reparented', 'reparented-id') |
2714 | tree2.add(['b'], ['a-old-id'], ['file']) |
2715 | - tree2.put_file_bytes_non_atomic('a-old-id', '') |
2716 | + tree2.put_file_bytes_non_atomic('b', '') |
2717 | tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2) |
2718 | # a-old-id is kind-changed, a-new-id is added, reparented-id is renamed, |
2719 | # deleted-id is gone |
2720 | |
2721 | === modified file 'breezy/tests/per_merger.py' |
2722 | --- breezy/tests/per_merger.py 2017-11-16 00:39:04 +0000 |
2723 | +++ breezy/tests/per_merger.py 2017-11-19 19:02:26 +0000 |
2724 | @@ -312,7 +312,7 @@ |
2725 | conflicts = builder.merge(self.merge_type) |
2726 | self.assertEqual(conflicts, []) |
2727 | self.assertEqual( |
2728 | - builder.this.get_file('1').read(), 'text-merged-by-hook') |
2729 | + builder.this.get_file('name1').read(), 'text-merged-by-hook') |
2730 | |
2731 | def test_change_vs_deleted(self): |
2732 | """Hook is used for (changed, deleted)""" |
2733 | @@ -324,7 +324,7 @@ |
2734 | conflicts = builder.merge(self.merge_type) |
2735 | self.assertEqual(conflicts, []) |
2736 | self.assertEqual( |
2737 | - builder.this.get_file('1').read(), 'text-merged-by-hook') |
2738 | + builder.this.get_file('name1').read(), 'text-merged-by-hook') |
2739 | |
2740 | def test_result_can_be_delete(self): |
2741 | """A hook's result can be the deletion of a file.""" |
2742 | @@ -346,7 +346,7 @@ |
2743 | # The hook still gets to set the file contents in this case, so that it |
2744 | # can insert custom conflict markers. |
2745 | self.assertEqual( |
2746 | - builder.this.get_file('1').read(), |
2747 | + builder.this.get_file('name1').read(), |
2748 | 'text-with-conflict-markers-from-hook') |
2749 | |
2750 | def test_can_access_this_other_and_base_versions(self): |
2751 | @@ -370,7 +370,7 @@ |
2752 | conflicts = builder.merge(self.merge_type) |
2753 | self.assertEqual(conflicts, []) |
2754 | self.assertEqual( |
2755 | - builder.this.get_file('1').read(), 'text-merged-by-hook') |
2756 | + builder.this.get_file('name1').read(), 'text-merged-by-hook') |
2757 | self.assertEqual([('inactive',), ('success',)], self.hook_log) |
2758 | |
2759 | def test_chain_when_not_applicable(self): |
2760 | @@ -384,7 +384,7 @@ |
2761 | conflicts = builder.merge(self.merge_type) |
2762 | self.assertEqual(conflicts, []) |
2763 | self.assertEqual( |
2764 | - builder.this.get_file('1').read(), 'text-merged-by-hook') |
2765 | + builder.this.get_file('name1').read(), 'text-merged-by-hook') |
2766 | self.assertEqual([('no-op',), ('success',)], self.hook_log) |
2767 | |
2768 | def test_chain_stops_after_success(self): |
2769 | |
2770 | === modified file 'breezy/tests/per_repository/test_commit_builder.py' |
2771 | --- breezy/tests/per_repository/test_commit_builder.py 2017-08-28 00:44:07 +0000 |
2772 | +++ breezy/tests/per_repository/test_commit_builder.py 2017-11-19 19:02:26 +0000 |
2773 | @@ -193,7 +193,7 @@ |
2774 | builder.commit('') |
2775 | builder_tree = builder.revision_tree() |
2776 | new_root_id = builder_tree.get_root_id() |
2777 | - new_root_revision = builder_tree.get_file_revision(new_root_id) |
2778 | + new_root_revision = builder_tree.get_file_revision(u'') |
2779 | if tree.branch.repository.supports_rich_root(): |
2780 | # We should not have seen a new root revision |
2781 | self.assertEqual(old_revision_id, new_root_revision) |
2782 | @@ -267,7 +267,7 @@ |
2783 | basis_tree.lock_read() |
2784 | self.addCleanup(basis_tree.unlock) |
2785 | self.assertEqual(rev_id, |
2786 | - basis_tree.get_file_revision(basis_tree.get_root_id())) |
2787 | + basis_tree.get_file_revision(u'', basis_tree.get_root_id())) |
2788 | |
2789 | def _get_revtrees(self, tree, revision_ids): |
2790 | tree.lock_read() |
2791 | @@ -287,13 +287,11 @@ |
2792 | rev1 = tree.commit('') |
2793 | rev2 = tree.commit('') |
2794 | tree1, tree2 = self._get_revtrees(tree, [rev1, rev2]) |
2795 | - self.assertEqual(rev1, tree1.get_file_revision(tree1.get_root_id())) |
2796 | + self.assertEqual(rev1, tree1.get_file_revision(u'')) |
2797 | if tree.branch.repository.supports_rich_root(): |
2798 | - self.assertEqual(rev1, |
2799 | - tree2.get_file_revision(tree2.get_root_id())) |
2800 | + self.assertEqual(rev1,tree2.get_file_revision(u'')) |
2801 | else: |
2802 | - self.assertEqual(rev2, |
2803 | - tree2.get_file_revision(tree2.get_root_id())) |
2804 | + self.assertEqual(rev2, tree2.get_file_revision(u'')) |
2805 | |
2806 | def _add_commit_check_unchanged(self, tree, name, mini_commit=None): |
2807 | tree.add([name]) |
2808 | @@ -304,8 +302,8 @@ |
2809 | rev1 = tree.commit('') |
2810 | rev2 = mini_commit(tree, name, name, False, False) |
2811 | tree1, tree2 = self._get_revtrees(tree, [rev1, rev2]) |
2812 | - self.assertEqual(rev1, tree1.get_file_revision(file_id)) |
2813 | - self.assertEqual(rev1, tree2.get_file_revision(file_id)) |
2814 | + self.assertEqual(rev1, tree1.get_file_revision(tree1.id2path(file_id))) |
2815 | + self.assertEqual(rev1, tree2.get_file_revision(tree2.id2path(file_id))) |
2816 | expected_graph = {} |
2817 | expected_graph[(file_id, rev1)] = () |
2818 | self.assertFileGraph(expected_graph, tree, (file_id, rev1)) |
2819 | @@ -329,8 +327,8 @@ |
2820 | tree.add(['dir/content']) |
2821 | rev2 = tree.commit('') |
2822 | tree1, tree2 = self._get_revtrees(tree, [rev1, rev2]) |
2823 | - self.assertEqual(rev1, tree1.get_file_revision(dir_id)) |
2824 | - self.assertEqual(rev1, tree2.get_file_revision(dir_id)) |
2825 | + self.assertEqual(rev1, tree1.get_file_revision('dir')) |
2826 | + self.assertEqual(rev1, tree2.get_file_revision('dir')) |
2827 | expected_graph = {} |
2828 | expected_graph[(dir_id, rev1)] = () |
2829 | self.assertFileGraph(expected_graph, tree, (dir_id, rev1)) |
2830 | @@ -459,8 +457,8 @@ |
2831 | rev2 = mini_commit(tree, name, tree.id2path(file_id), |
2832 | expect_fs_hash=expect_fs_hash) |
2833 | tree1, tree2 = self._get_revtrees(tree, [rev1, rev2]) |
2834 | - self.assertEqual(rev1, tree1.get_file_revision(file_id)) |
2835 | - self.assertEqual(rev2, tree2.get_file_revision(file_id)) |
2836 | + self.assertEqual(rev1, tree1.get_file_revision(tree1.id2path(file_id))) |
2837 | + self.assertEqual(rev2, tree2.get_file_revision(tree2.id2path(file_id))) |
2838 | expected_graph = {} |
2839 | expected_graph[(file_id, rev1)] = () |
2840 | expected_graph[(file_id, rev2)] = ((file_id, rev1),) |
2841 | @@ -500,12 +498,12 @@ |
2842 | changes)) |
2843 | file_id = tree.path2id(new_name) |
2844 | if expect_fs_hash: |
2845 | - tree_file_stat = tree.get_file_with_stat(file_id) |
2846 | + tree_file_stat = tree.get_file_with_stat(new_name) |
2847 | tree_file_stat[0].close() |
2848 | self.assertLength(1, result) |
2849 | result = result[0] |
2850 | self.assertEqual(result[:2], (file_id, new_name)) |
2851 | - self.assertEqual(result[2][0], tree.get_file_sha1(file_id)) |
2852 | + self.assertEqual(result[2][0], tree.get_file_sha1(new_name)) |
2853 | self.assertEqualStat(result[2][1], tree_file_stat[1]) |
2854 | else: |
2855 | self.assertEqual([], result) |
2856 | @@ -556,7 +554,7 @@ |
2857 | tree = self.make_branch_and_tree('.') |
2858 | self.build_tree(['file']) |
2859 | def change_file(): |
2860 | - tree.put_file_bytes_non_atomic(tree.path2id('file'), 'new content') |
2861 | + tree.put_file_bytes_non_atomic('file', 'new content') |
2862 | self._add_commit_change_check_changed(tree, 'file', change_file, |
2863 | expect_fs_hash=True, |
2864 | mini_commit=self.mini_commit_record_iter_changes) |
2865 | @@ -604,7 +602,7 @@ |
2866 | rev4 = mini_commit(tree1, 'new_' + name, 'new_' + name, |
2867 | expect_fs_hash=expect_fs_hash) |
2868 | tree3, = self._get_revtrees(tree1, [rev4]) |
2869 | - self.assertEqual(rev4, tree3.get_file_revision(file_id)) |
2870 | + self.assertEqual(rev4, tree3.get_file_revision(tree3.id2path(file_id))) |
2871 | expected_graph = {} |
2872 | expected_graph[(file_id, rev1)] = () |
2873 | expected_graph[(file_id, rev2)] = ((file_id, rev1),) |
2874 | @@ -649,7 +647,9 @@ |
2875 | rev3 = mini_commit(in_tree, name, 'new_' + name, False, |
2876 | delta_against_basis=changed_in_tree) |
2877 | tree3, = self._get_revtrees(in_tree, [rev2]) |
2878 | - self.assertEqual(rev2, tree3.get_file_revision(file_id)) |
2879 | + self.assertEqual( |
2880 | + rev2, |
2881 | + tree3.get_file_revision(tree3.id2path(file_id), file_id)) |
2882 | expected_graph = {} |
2883 | expected_graph[(file_id, rev1)] = () |
2884 | expected_graph[(file_id, rev2)] = ((file_id, rev1),) |
2885 | @@ -678,7 +678,7 @@ |
2886 | rev3 = mini_commit(tree1, None, 'name', False) |
2887 | tree3, = self._get_revtrees(tree1, [rev2]) |
2888 | # in rev2, name should be only changed in rev2 |
2889 | - self.assertEqual(rev2, tree3.get_file_revision(file_id)) |
2890 | + self.assertEqual(rev2, tree3.get_file_revision(tree3.id2path(file_id))) |
2891 | expected_graph = {} |
2892 | expected_graph[(file_id, rev2)] = () |
2893 | self.assertFileGraph(expected_graph, tree1, (file_id, rev2)) |
2894 | |
2895 | === modified file 'breezy/tests/per_repository/test_fetch.py' |
2896 | --- breezy/tests/per_repository/test_fetch.py 2017-11-16 00:39:04 +0000 |
2897 | +++ breezy/tests/per_repository/test_fetch.py 2017-11-19 19:02:26 +0000 |
2898 | @@ -87,7 +87,7 @@ |
2899 | rev1_tree = knit3_repo.revision_tree(rev1) |
2900 | rev1_tree.lock_read() |
2901 | try: |
2902 | - lines = rev1_tree.get_file_lines(rev1_tree.get_root_id()) |
2903 | + lines = rev1_tree.get_file_lines(u'', rev1_tree.get_root_id()) |
2904 | finally: |
2905 | rev1_tree.unlock() |
2906 | self.assertEqual([], lines) |
2907 | @@ -105,7 +105,7 @@ |
2908 | rev2_tree = knit3_repo.revision_tree(rev2) |
2909 | self.assertEqual( |
2910 | rev1, |
2911 | - rev2_tree.get_file_revision(rev2_tree.get_root_id())) |
2912 | + rev2_tree.get_file_revision(u'', rev2_tree.get_root_id())) |
2913 | |
2914 | def do_test_fetch_to_rich_root_sets_parents_correctly(self, result, |
2915 | snapshots, root_id=ROOT_ID, allow_lefthand_ghost=False): |
2916 | |
2917 | === modified file 'breezy/tests/per_repository/test_repository.py' |
2918 | --- breezy/tests/per_repository/test_repository.py 2017-11-16 00:39:04 +0000 |
2919 | +++ breezy/tests/per_repository/test_repository.py 2017-11-19 19:02:26 +0000 |
2920 | @@ -140,7 +140,7 @@ |
2921 | tree_b = repo_b.revision_tree(rev1) |
2922 | tree_b.lock_read() |
2923 | self.addCleanup(tree_b.unlock) |
2924 | - tree_b.get_file_text(file_id) |
2925 | + tree_b.get_file_text('foo') |
2926 | repo_b.get_revision(rev1) |
2927 | |
2928 | def test_supports_rich_root(self): |
2929 | @@ -150,7 +150,7 @@ |
2930 | rev_tree = tree.branch.repository.revision_tree(second_revision) |
2931 | rev_tree.lock_read() |
2932 | self.addCleanup(rev_tree.unlock) |
2933 | - root_revision = rev_tree.get_file_revision(rev_tree.get_root_id()) |
2934 | + root_revision = rev_tree.get_file_revision(u'', rev_tree.get_root_id()) |
2935 | rich_root = (root_revision != second_revision) |
2936 | self.assertEqual(rich_root, |
2937 | tree.branch.repository.supports_rich_root()) |
2938 | @@ -261,7 +261,7 @@ |
2939 | tree.lock_read() |
2940 | try: |
2941 | self.assertEqual(rev1, |
2942 | - tree.get_file_revision(tree.get_root_id())) |
2943 | + tree.get_file_revision(u'', tree.get_root_id())) |
2944 | expected = inventory.InventoryDirectory('fixed-root', '', None) |
2945 | expected.revision = rev1 |
2946 | self.assertEqual([('', 'V', 'directory', 'fixed-root', expected)], |
2947 | @@ -452,7 +452,7 @@ |
2948 | rev_tree.lock_read() |
2949 | self.addCleanup(rev_tree.unlock) |
2950 | root_id = rev_tree.get_root_id() |
2951 | - self.assertEqual(revid, rev_tree.get_file_revision(root_id)) |
2952 | + self.assertEqual(revid, rev_tree.get_file_revision(u'', root_id)) |
2953 | |
2954 | def test_pointless_commit(self): |
2955 | tree = self.make_branch_and_tree('.') |
2956 | @@ -568,24 +568,23 @@ |
2957 | def test_add_signature_text(self): |
2958 | builder = self.make_branch_builder('.') |
2959 | builder.start_series() |
2960 | - builder.build_snapshot(None, [ |
2961 | - ('add', ('', 'root-id', 'directory', None))], |
2962 | - revision_id='A') |
2963 | + rev_a = builder.build_snapshot(None, [ |
2964 | + ('add', ('', 'root-id', 'directory', None))]) |
2965 | builder.finish_series() |
2966 | b = builder.get_branch() |
2967 | b.lock_write() |
2968 | self.addCleanup(b.unlock) |
2969 | if b.repository._format.supports_revision_signatures: |
2970 | b.repository.start_write_group() |
2971 | - b.repository.add_signature_text('A', 'This might be a signature') |
2972 | + b.repository.add_signature_text(rev_a, 'This might be a signature') |
2973 | b.repository.commit_write_group() |
2974 | self.assertEqual('This might be a signature', |
2975 | - b.repository.get_signature_text('A')) |
2976 | + b.repository.get_signature_text(rev_a)) |
2977 | else: |
2978 | b.repository.start_write_group() |
2979 | self.addCleanup(b.repository.abort_write_group) |
2980 | self.assertRaises(errors.UnsupportedOperation, |
2981 | - b.repository.add_signature_text, 'A', |
2982 | + b.repository.add_signature_text, rev_a, |
2983 | 'This might be a signature') |
2984 | |
2985 | # XXX: this helper duplicated from tests.test_repository |
2986 | @@ -934,7 +933,7 @@ |
2987 | revtree = branch.repository.revision_tree(rev1) |
2988 | revtree.lock_read() |
2989 | self.addCleanup(revtree.unlock) |
2990 | - contents = revtree.get_file_text(FOO_ID) |
2991 | + contents = revtree.get_file_text(u'', FOO_ID) |
2992 | self.assertEqual(contents, 'contents of repo/foo\n') |
2993 | |
2994 | def test_create_bundle(self): |
2995 | |
2996 | === modified file 'breezy/tests/per_repository/test_revision.py' |
2997 | --- breezy/tests/per_repository/test_revision.py 2017-08-07 19:09:47 +0000 |
2998 | +++ breezy/tests/per_repository/test_revision.py 2017-11-19 19:02:26 +0000 |
2999 | @@ -84,7 +84,9 @@ |
3000 | timestamp=rev_a.timestamp, |
3001 | timezone=rev_a.timezone, |
3002 | committer=rev_a.committer, |
3003 | - rev_id=rev_a.revision_id, |
3004 | + rev_id=(rev_a.revision_id |
3005 | + if tree2.branch.repository._format.supports_setting_revision_ids |
3006 | + else None), |
3007 | revprops=rev_a.properties, |
3008 | allow_pointless=True, # there's nothing in this commit |
3009 | strict=True, |
3010 | |
3011 | === modified file 'breezy/tests/per_repository_vf/test_merge_directive.py' |
3012 | --- breezy/tests/per_repository_vf/test_merge_directive.py 2017-11-16 00:39:04 +0000 |
3013 | +++ breezy/tests/per_repository_vf/test_merge_directive.py 2017-11-19 19:02:26 +0000 |
3014 | @@ -77,5 +77,5 @@ |
3015 | directive.install_revisions(target_branch.repository) |
3016 | rt = target_branch.repository.revision_tree('B') |
3017 | rt.lock_read() |
3018 | - self.assertEqualDiff('new content\n', rt.get_file_text('f-id')) |
3019 | + self.assertEqualDiff('new content\n', rt.get_file_text('f', 'f-id')) |
3020 | rt.unlock() |
3021 | |
3022 | === modified file 'breezy/tests/per_repository_vf/test_repository.py' |
3023 | --- breezy/tests/per_repository_vf/test_repository.py 2017-06-10 16:40:42 +0000 |
3024 | +++ breezy/tests/per_repository_vf/test_repository.py 2017-11-19 19:02:26 +0000 |
3025 | @@ -271,7 +271,7 @@ |
3026 | try: |
3027 | self.assertEqual(set(), set(repo.texts.keys())) |
3028 | tree.add(['foo'], [file_id], ['file']) |
3029 | - tree.put_file_bytes_non_atomic(file_id, 'content\n') |
3030 | + tree.put_file_bytes_non_atomic('foo', 'content\n', file_id=file_id) |
3031 | try: |
3032 | rev_key = (tree.commit("foo"),) |
3033 | except errors.IllegalPath: |
3034 | @@ -294,16 +294,16 @@ |
3035 | tree.unlock() |
3036 | tree2 = self.make_branch_and_tree('tree2') |
3037 | tree2.pull(tree.branch) |
3038 | - tree2.put_file_bytes_non_atomic('Foo:Bar', 'right\n') |
3039 | + tree2.put_file_bytes_non_atomic('foo', 'right\n', file_id='Foo:Bar') |
3040 | right_key = (tree2.commit('right'),) |
3041 | keys.add(file_key + right_key) |
3042 | parents[file_key + right_key] = (file_key + rev_key,) |
3043 | - tree.put_file_bytes_non_atomic('Foo:Bar', 'left\n') |
3044 | + tree.put_file_bytes_non_atomic('foo', 'left\n', file_id='Foo:Bar') |
3045 | left_key = (tree.commit('left'),) |
3046 | keys.add(file_key + left_key) |
3047 | parents[file_key + left_key] = (file_key + rev_key,) |
3048 | tree.merge_from_branch(tree2.branch) |
3049 | - tree.put_file_bytes_non_atomic('Foo:Bar', 'merged\n') |
3050 | + tree.put_file_bytes_non_atomic('foo', 'merged\n', file_id='Foo:Bar') |
3051 | try: |
3052 | tree.auto_resolve() |
3053 | except errors.UnsupportedOperation: |
3054 | |
3055 | === modified file 'breezy/tests/per_repository_vf/test_write_group.py' |
3056 | --- breezy/tests/per_repository_vf/test_write_group.py 2017-11-16 00:39:04 +0000 |
3057 | +++ breezy/tests/per_repository_vf/test_write_group.py 2017-11-19 19:02:26 +0000 |
3058 | @@ -70,7 +70,9 @@ |
3059 | tree.add([''], ['TREE_ROOT'], ['directory']) |
3060 | tree.add(['dir'], ['dir-id'], ['directory']) |
3061 | tree.add(['filename'], ['file-id'], ['file']) |
3062 | - tree.put_file_bytes_non_atomic('file-id', 'content\n') |
3063 | + tree.put_file_bytes_non_atomic( |
3064 | + 'filename', 'content\n', |
3065 | + file_id='file-id') |
3066 | tree.commit('Trunk commit', rev_id='rev-0') |
3067 | tree.commit('Trunk commit', rev_id='rev-1') |
3068 | tree.unlock() |
3069 | |
3070 | === modified file 'breezy/tests/per_tree/test_annotate_iter.py' |
3071 | --- breezy/tests/per_tree/test_annotate_iter.py 2017-08-07 21:14:18 +0000 |
3072 | +++ breezy/tests/per_tree/test_annotate_iter.py 2017-11-19 19:02:26 +0000 |
3073 | @@ -45,11 +45,11 @@ |
3074 | tree.lock_read() |
3075 | self.addCleanup(tree.unlock) |
3076 | self.assertEqual([(revids[1], 'second\n'), (revids[0], 'content\n')], |
3077 | - list(tree.annotate_iter(tree.path2id('one')))) |
3078 | + list(tree.annotate_iter('one'))) |
3079 | |
3080 | def test_annotate_with_ghost(self): |
3081 | tree, revids = self.get_tree_with_ghost() |
3082 | tree.lock_read() |
3083 | self.addCleanup(tree.unlock) |
3084 | self.assertEqual([(revids[1], 'second\n'), (revids[0], 'content\n')], |
3085 | - list(tree.annotate_iter(tree.path2id('one')))) |
3086 | + list(tree.annotate_iter('one'))) |
3087 | |
3088 | === modified file 'breezy/tests/per_tree/test_get_file_mtime.py' |
3089 | --- breezy/tests/per_tree/test_get_file_mtime.py 2017-08-01 01:44:41 +0000 |
3090 | +++ breezy/tests/per_tree/test_get_file_mtime.py 2017-11-19 19:02:26 +0000 |
3091 | @@ -38,17 +38,15 @@ |
3092 | self.addCleanup(tree.unlock) |
3093 | # Committed trees return the time of the commit that last changed the |
3094 | # file, working trees return the on-disk time. |
3095 | - mtime_file_id = tree.get_file_mtime(file_id=tree.path2id('one')) |
3096 | + mtime_file_id = tree.get_file_mtime('one') |
3097 | self.assertIsInstance(mtime_file_id, (float, int)) |
3098 | self.assertTrue(now - 5 < mtime_file_id < now + 5, |
3099 | 'now: %f, mtime_file_id: %f' % (now, mtime_file_id )) |
3100 | - mtime_path = tree.get_file_mtime( |
3101 | - file_id=tree.path2id('one'), path='one') |
3102 | + mtime_path = tree.get_file_mtime('one') |
3103 | self.assertEqual(mtime_file_id, mtime_path) |
3104 | |
3105 | def test_nonexistant(self): |
3106 | tree = self.get_basic_tree() |
3107 | tree.lock_read() |
3108 | self.addCleanup(tree.unlock) |
3109 | - self.assertRaises(errors.NoSuchId, |
3110 | - tree.get_file_mtime, file_id='unexistant') |
3111 | + self.assertRaises(errors.NoSuchFile, tree.get_file_mtime, 'unexistant') |
3112 | |
3113 | === modified file 'breezy/tests/per_tree/test_get_file_with_stat.py' |
3114 | --- breezy/tests/per_tree/test_get_file_with_stat.py 2017-08-01 01:44:41 +0000 |
3115 | +++ breezy/tests/per_tree/test_get_file_with_stat.py 2017-11-19 19:02:26 +0000 |
3116 | @@ -31,8 +31,7 @@ |
3117 | tree = self._convert_tree(work_tree) |
3118 | tree.lock_read() |
3119 | self.addCleanup(tree.unlock) |
3120 | - file_obj, statvalue = tree.get_file_with_stat( |
3121 | - tree.path2id('foo')) |
3122 | + file_obj, statvalue = tree.get_file_with_stat('foo') |
3123 | self.addCleanup(file_obj.close) |
3124 | if statvalue is not None: |
3125 | expected = os.lstat('foo') |
3126 | @@ -46,8 +45,7 @@ |
3127 | tree = self._convert_tree(work_tree) |
3128 | tree.lock_read() |
3129 | self.addCleanup(tree.unlock) |
3130 | - file_obj, statvalue = tree.get_file_with_stat( |
3131 | - tree.path2id('foo'), 'foo') |
3132 | + file_obj, statvalue = tree.get_file_with_stat('foo') |
3133 | self.addCleanup(file_obj.close) |
3134 | if statvalue is not None: |
3135 | expected = os.lstat('foo') |
3136 | |
3137 | === modified file 'breezy/tests/per_tree/test_get_symlink_target.py' |
3138 | --- breezy/tests/per_tree/test_get_symlink_target.py 2017-08-01 01:44:41 +0000 |
3139 | +++ breezy/tests/per_tree/test_get_symlink_target.py 2017-11-19 19:02:26 +0000 |
3140 | @@ -44,13 +44,13 @@ |
3141 | tree = self.get_tree_with_symlinks() |
3142 | tree.lock_read() |
3143 | self.addCleanup(tree.unlock) |
3144 | - self.assertEqual('foo', tree.get_symlink_target(tree.path2id('link'))) |
3145 | + self.assertEqual('foo', tree.get_symlink_target('link')) |
3146 | self.assertEqual('../bar', |
3147 | - tree.get_symlink_target(tree.path2id('rel_link'))) |
3148 | + tree.get_symlink_target('rel_link')) |
3149 | self.assertEqual('/baz/bing', |
3150 | - tree.get_symlink_target(tree.path2id('abs_link'))) |
3151 | + tree.get_symlink_target('abs_link')) |
3152 | self.assertEqual('foo', |
3153 | - tree.get_symlink_target(tree.path2id('link'), 'link')) |
3154 | + tree.get_symlink_target('link', tree.path2id('link'))) |
3155 | |
3156 | def test_get_unicode_symlink_target(self): |
3157 | self.requireFeature(features.SymlinkFeature) |
3158 | @@ -62,6 +62,6 @@ |
3159 | file_id = tree.path2id(u'\u03b2_link') |
3160 | tree.lock_read() |
3161 | self.addCleanup(tree.unlock) |
3162 | - actual = tree.get_symlink_target(file_id) |
3163 | + actual = tree.get_symlink_target(u'\u03b2_link') |
3164 | self.assertEqual(target, actual) |
3165 | |
3166 | |
3167 | === modified file 'breezy/tests/per_tree/test_is_executable.py' |
3168 | --- breezy/tests/per_tree/test_is_executable.py 2017-08-01 01:44:41 +0000 |
3169 | +++ breezy/tests/per_tree/test_is_executable.py 2017-11-19 19:02:26 +0000 |
3170 | @@ -29,7 +29,7 @@ |
3171 | False) |
3172 | tree.lock_read() |
3173 | self.addCleanup(tree.unlock) |
3174 | - self.assertEqual(False, tree.is_executable(tree.path2id('1top-dir'))) |
3175 | + self.assertEqual(False, tree.is_executable('1top-dir')) |
3176 | |
3177 | def test_is_executable_symlink(self): |
3178 | self.requireFeature(SymlinkFeature) |
3179 | |
3180 | === modified file 'breezy/tests/per_tree/test_test_trees.py' |
3181 | --- breezy/tests/per_tree/test_test_trees.py 2017-10-08 02:49:53 +0000 |
3182 | +++ breezy/tests/per_tree/test_test_trees.py 2017-11-19 19:02:26 +0000 |
3183 | @@ -52,8 +52,8 @@ |
3184 | self.assertEqual( |
3185 | [(p, tree.path2id(p)) for p in ['', 'a', 'b', 'b/c']], |
3186 | [(path, node.file_id) for path, node in tree.iter_entries_by_dir()]) |
3187 | - self.assertEqualDiff('contents of a\n', tree.get_file_text(tree.path2id('a'))) |
3188 | - self.assertFalse(tree.is_executable(tree.path2id('b/c'), path='b/c')) |
3189 | + self.assertEqualDiff('contents of a\n', tree.get_file_text('a')) |
3190 | + self.assertFalse(tree.is_executable('b/c')) |
3191 | |
3192 | def test_abc_tree_content_2_no_parents(self): |
3193 | tree = self.make_branch_and_tree('.') |
3194 | @@ -70,8 +70,8 @@ |
3195 | self.assertEqual( |
3196 | [(p, tree.path2id(p)) for p in ['', 'a', 'b', 'b/c']], |
3197 | [(path, node.file_id) for path, node in tree.iter_entries_by_dir()]) |
3198 | - self.assertEqualDiff('foobar\n', tree.get_file_text(tree.path2id('a'))) |
3199 | - self.assertFalse(tree.is_executable(tree.path2id('b//c'))) |
3200 | + self.assertEqualDiff('foobar\n', tree.get_file_text('a')) |
3201 | + self.assertFalse(tree.is_executable('b//c')) |
3202 | |
3203 | def test_abc_tree_content_3_no_parents(self): |
3204 | tree = self.make_branch_and_tree('.') |
3205 | @@ -88,8 +88,8 @@ |
3206 | self.assertEqual( |
3207 | [(p, tree.path2id(p)) for p in ['', 'a', 'b', 'b/c']], |
3208 | [(path, node.file_id) for path, node in tree.iter_entries_by_dir()]) |
3209 | - self.assertEqualDiff('contents of a\n', tree.get_file_text(tree.path2id('a'))) |
3210 | - self.assertTrue(tree.is_executable(tree.path2id('b/c'))) |
3211 | + self.assertEqualDiff('contents of a\n', tree.get_file_text('a')) |
3212 | + self.assertTrue(tree.is_executable('b/c')) |
3213 | |
3214 | def test_abc_tree_content_4_no_parents(self): |
3215 | tree = self.make_branch_and_tree('.') |
3216 | @@ -106,8 +106,8 @@ |
3217 | self.assertEqual( |
3218 | [(p, tree.path2id(p)) for p in ['', 'b', 'd', 'b/c']], |
3219 | [(path, node.file_id) for path, node in tree.iter_entries_by_dir()]) |
3220 | - self.assertEqualDiff('contents of a\n', tree.get_file_text(tree.path2id('d'))) |
3221 | - self.assertFalse(tree.is_executable(tree.path2id('b/c'))) |
3222 | + self.assertEqualDiff('contents of a\n', tree.get_file_text('d')) |
3223 | + self.assertFalse(tree.is_executable('b/c')) |
3224 | |
3225 | def test_abc_tree_content_5_no_parents(self): |
3226 | tree = self.make_branch_and_tree('.') |
3227 | @@ -124,8 +124,8 @@ |
3228 | self.assertEqual( |
3229 | [(p, tree.path2id(p)) for p in ['', 'b', 'd', 'b/c']], |
3230 | [(path, node.file_id) for path, node in tree.iter_entries_by_dir()]) |
3231 | - self.assertEqualDiff('bar\n', tree.get_file_text(tree.path2id('d'))) |
3232 | - self.assertFalse(tree.is_executable(tree.path2id('b/c'))) |
3233 | + self.assertEqualDiff('bar\n', tree.get_file_text('d')) |
3234 | + self.assertFalse(tree.is_executable('b/c')) |
3235 | |
3236 | def test_abc_tree_content_6_no_parents(self): |
3237 | tree = self.make_branch_and_tree('.') |
3238 | @@ -142,8 +142,8 @@ |
3239 | self.assertEqual( |
3240 | [(p, tree.path2id(p)) for p in ['', 'a', 'b', 'e']], |
3241 | [(path, node.file_id) for path, node in tree.iter_entries_by_dir()]) |
3242 | - self.assertEqualDiff('contents of a\n', tree.get_file_text(tree.path2id('a'))) |
3243 | - self.assertTrue(tree.is_executable(tree.path2id('e'))) |
3244 | + self.assertEqualDiff('contents of a\n', tree.get_file_text('a')) |
3245 | + self.assertTrue(tree.is_executable('e')) |
3246 | |
3247 | def test_tree_with_subdirs_and_all_content_types(self): |
3248 | # currently this test tree requires unicode. It might be good |
3249 | |
3250 | === modified file 'breezy/tests/per_tree/test_tree.py' |
3251 | --- breezy/tests/per_tree/test_tree.py 2017-10-08 02:49:53 +0000 |
3252 | +++ breezy/tests/per_tree/test_tree.py 2017-11-19 19:02:26 +0000 |
3253 | @@ -36,12 +36,11 @@ |
3254 | tree_revision = getattr(tree, 'get_revision_id', lambda: 'current:')() |
3255 | tree.lock_read() |
3256 | self.addCleanup(tree.unlock) |
3257 | - a_id = tree.path2id('a') |
3258 | - for revision, line in tree.annotate_iter(a_id): |
3259 | + for revision, line in tree.annotate_iter('a'): |
3260 | self.assertEqual('contents of a\n', line) |
3261 | self.assertEqual(tree_revision, revision) |
3262 | tree_revision = getattr(tree, 'get_revision_id', lambda: 'random:')() |
3263 | - for revision, line in tree.annotate_iter(a_id, 'random:'): |
3264 | + for revision, line in tree.annotate_iter('a', default_revision='random:'): |
3265 | self.assertEqual('contents of a\n', line) |
3266 | self.assertEqual(tree_revision, revision) |
3267 | |
3268 | @@ -100,7 +99,7 @@ |
3269 | self.addCleanup(tree.unlock) |
3270 | path = tree.id2path('sub-root') |
3271 | self.assertEqual('sub-1', |
3272 | - tree.get_reference_revision('sub-root', path)) |
3273 | + tree.get_reference_revision(path, 'sub-root')) |
3274 | |
3275 | def test_iter_references(self): |
3276 | tree = self.create_nested() |
3277 | @@ -149,12 +148,10 @@ |
3278 | tree = self.make_branch_and_tree('tree') |
3279 | work_tree = self.make_branch_and_tree('wt') |
3280 | tree = self.get_tree_no_parents_abc_content(work_tree) |
3281 | - a_id = tree.path2id('a') |
3282 | - b_id = tree.path2id('b') |
3283 | tree.lock_read() |
3284 | self.addCleanup(tree.unlock) |
3285 | - self.assertEqual('file', tree.stored_kind(a_id)) |
3286 | - self.assertEqual('directory', tree.stored_kind(b_id)) |
3287 | + self.assertEqual('file', tree.stored_kind('a')) |
3288 | + self.assertEqual('directory', tree.stored_kind('b')) |
3289 | |
3290 | |
3291 | class TestFileContent(TestCaseWithTree): |
3292 | @@ -166,14 +163,14 @@ |
3293 | tree.lock_read() |
3294 | self.addCleanup(tree.unlock) |
3295 | # Test lookup without path works |
3296 | - file_without_path = tree.get_file(a_id) |
3297 | + file_without_path = tree.get_file('a') |
3298 | try: |
3299 | lines = file_without_path.readlines() |
3300 | self.assertEqual(['foobar\n'], lines) |
3301 | finally: |
3302 | file_without_path.close() |
3303 | # Test lookup with path works |
3304 | - file_with_path = tree.get_file(a_id, path='a') |
3305 | + file_with_path = tree.get_file('a', a_id) |
3306 | try: |
3307 | lines = file_with_path.readlines() |
3308 | self.assertEqual(['foobar\n'], lines) |
3309 | @@ -187,9 +184,9 @@ |
3310 | tree.lock_read() |
3311 | self.addCleanup(tree.unlock) |
3312 | # test read by file-id |
3313 | - self.assertEqual('foobar\n', tree.get_file_text(a_id)) |
3314 | + self.assertEqual('foobar\n', tree.get_file_text('a', a_id)) |
3315 | # test read by path |
3316 | - self.assertEqual('foobar\n', tree.get_file_text(a_id, path='a')) |
3317 | + self.assertEqual('foobar\n', tree.get_file_text('a')) |
3318 | |
3319 | def test_get_file_lines(self): |
3320 | work_tree = self.make_branch_and_tree('wt') |
3321 | @@ -198,9 +195,9 @@ |
3322 | tree.lock_read() |
3323 | self.addCleanup(tree.unlock) |
3324 | # test read by file-id |
3325 | - self.assertEqual(['foobar\n'], tree.get_file_lines(a_id)) |
3326 | + self.assertEqual(['foobar\n'], tree.get_file_lines('a', a_id)) |
3327 | # test read by path |
3328 | - self.assertEqual(['foobar\n'], tree.get_file_lines(a_id, path='a')) |
3329 | + self.assertEqual(['foobar\n'], tree.get_file_lines('a')) |
3330 | |
3331 | def test_get_file_lines_multi_line_breaks(self): |
3332 | work_tree = self.make_branch_and_tree('wt') |
3333 | @@ -210,7 +207,7 @@ |
3334 | tree.lock_read() |
3335 | self.addCleanup(tree.unlock) |
3336 | self.assertEqual(['a\rb\n', 'c\r\n', 'd'], |
3337 | - tree.get_file_lines(tree.path2id('foobar'))) |
3338 | + tree.get_file_lines('foobar')) |
3339 | |
3340 | |
3341 | class TestExtractFilesBytes(TestCaseWithTree): |
3342 | @@ -324,7 +321,7 @@ |
3343 | tree.lock_read() |
3344 | self.addCleanup(tree.unlock) |
3345 | expected = osutils.sha_strings('file content') |
3346 | - self.assertEqual(expected, tree.get_file_sha1(tree.path2id('file'))) |
3347 | + self.assertEqual(expected, tree.get_file_sha1('file')) |
3348 | |
3349 | |
3350 | class TestGetFileVerifier(TestCaseWithTree): |
3351 | @@ -338,10 +335,10 @@ |
3352 | tree = self._convert_tree(work_tree) |
3353 | tree.lock_read() |
3354 | self.addCleanup(tree.unlock) |
3355 | - (kind, data) = tree.get_file_verifier(tree.path2id('file1')) |
3356 | + (kind, data) = tree.get_file_verifier('file1') |
3357 | self.assertEqual( |
3358 | - tree.get_file_verifier(tree.path2id('file1')), |
3359 | - tree.get_file_verifier(tree.path2id('file2'))) |
3360 | + tree.get_file_verifier('file1'), |
3361 | + tree.get_file_verifier('file2')) |
3362 | if kind == "SHA1": |
3363 | expected = osutils.sha_strings('file content') |
3364 | self.assertEqual(expected, data) |
3365 | |
3366 | === modified file 'breezy/tests/per_workingtree/test_add.py' |
3367 | --- breezy/tests/per_workingtree/test_add.py 2017-10-08 02:49:53 +0000 |
3368 | +++ breezy/tests/per_workingtree/test_add.py 2017-11-19 19:02:26 +0000 |
3369 | @@ -46,7 +46,7 @@ |
3370 | """Adding an entry with a pre-existing id raises DuplicateFileId""" |
3371 | tree = self.make_branch_and_tree('.') |
3372 | if not tree.supports_setting_file_ids(): |
3373 | - self.skip("tree does not support setting file ids") |
3374 | + self.skipTest("tree does not support setting file ids") |
3375 | self.build_tree(['a', 'b']) |
3376 | tree.add(['a']) |
3377 | self.assertRaises(errors.DuplicateFileId, |
3378 | @@ -64,7 +64,7 @@ |
3379 | tree.commit('first') |
3380 | root_id = tree.get_root_id() |
3381 | # And the entry should not have been added. |
3382 | - tree.unversion([file_id]) |
3383 | + tree.unversion(['a']) |
3384 | tree.add(['b'], [file_id]) |
3385 | self.assertTreeLayout([('', root_id), ('b', file_id)], tree) |
3386 | self.assertTreeLayout([('', root_id), ('a', file_id)], |
3387 | @@ -103,7 +103,7 @@ |
3388 | def test_add_subdir_with_ids(self): |
3389 | tree = self.make_branch_and_tree('.') |
3390 | if not tree.supports_setting_file_ids(): |
3391 | - self.skip("tree does not support setting file ids") |
3392 | + self.skipTest("tree does not support setting file ids") |
3393 | self.build_tree(['dir/', 'dir/subdir/', 'dir/subdir/foo']) |
3394 | tree.add(['dir'], ['dir-id']) |
3395 | tree.add(['dir/subdir'], ['subdir-id']) |
3396 | @@ -143,7 +143,7 @@ |
3397 | def test_add_multiple_with_file_ids(self): |
3398 | tree = self.make_branch_and_tree('.') |
3399 | if not tree.supports_setting_file_ids(): |
3400 | - self.skip("tree does not support setting file ids") |
3401 | + self.skipTest("tree does not support setting file ids") |
3402 | self.build_tree(['a', 'b', 'dir/', 'dir/subdir/', 'dir/subdir/foo']) |
3403 | tree.add(['a', 'b', 'dir', 'dir/subdir', 'dir/subdir/foo'], |
3404 | ['a-id', 'b-id', 'dir-id', 'subdir-id', 'foo-id']) |
3405 | @@ -168,7 +168,7 @@ |
3406 | root_id = tree.get_root_id() |
3407 | tree.add(['dir']) |
3408 | tree.commit('dir') |
3409 | - tree.unversion([tree.path2id('dir')]) |
3410 | + tree.unversion(['dir']) |
3411 | self.assertRaises(errors.NotVersionedError, |
3412 | tree.add, ['dir/subdir']) |
3413 | |
3414 | @@ -188,7 +188,7 @@ |
3415 | tree = self.make_branch_and_tree('.') |
3416 | self.build_tree(['foo']) |
3417 | tree.add(['foo']) |
3418 | - tree.unversion([tree.path2id('foo')]) |
3419 | + tree.unversion(['foo']) |
3420 | tree.add(['foo']) |
3421 | self.assertTrue(tree.has_filename('foo')) |
3422 | |
3423 | @@ -196,10 +196,10 @@ |
3424 | # adding a path that was previously added should work |
3425 | tree = self.make_branch_and_tree('.') |
3426 | if not tree.supports_setting_file_ids(): |
3427 | - self.skip("tree does not support setting file ids") |
3428 | + self.skipTest("tree does not support setting file ids") |
3429 | self.build_tree(['foo']) |
3430 | tree.add(['foo'], ['foo-id']) |
3431 | - tree.unversion(['foo-id']) |
3432 | + tree.unversion(['foo']) |
3433 | tree.add(['foo'], ['foo-id']) |
3434 | self.assertEqual('foo-id', tree.path2id('foo')) |
3435 | |
3436 | @@ -209,7 +209,7 @@ |
3437 | self.build_tree(['foo']) |
3438 | tree.add(['foo']) |
3439 | tree.commit('add foo') |
3440 | - tree.unversion([tree.path2id('foo')]) |
3441 | + tree.unversion(['foo']) |
3442 | tree.add(['foo']) |
3443 | self.assertTrue(tree.has_filename('foo')) |
3444 | |
3445 | @@ -217,10 +217,10 @@ |
3446 | # adding a path that was present in the basis should work. |
3447 | tree = self.make_branch_and_tree('.') |
3448 | if not tree.supports_setting_file_ids(): |
3449 | - self.skip("tree does not support setting file ids") |
3450 | + self.skipTest("tree does not support setting file ids") |
3451 | self.build_tree(['foo']) |
3452 | tree.add(['foo'], ['foo-id']) |
3453 | tree.commit('add foo') |
3454 | - tree.unversion(['foo-id']) |
3455 | + tree.unversion(['foo']) |
3456 | tree.add(['foo'], ['foo-id']) |
3457 | self.assertEqual('foo-id', tree.path2id('foo')) |
3458 | |
3459 | === modified file 'breezy/tests/per_workingtree/test_add_reference.py' |
3460 | --- breezy/tests/per_workingtree/test_add_reference.py 2017-10-26 11:12:08 +0000 |
3461 | +++ breezy/tests/per_workingtree/test_add_reference.py 2017-11-19 19:02:26 +0000 |
3462 | @@ -52,15 +52,15 @@ |
3463 | tree.lock_write() |
3464 | try: |
3465 | self.assertEqual(tree.path2id('sub-tree'), sub_tree_root_id) |
3466 | - self.assertEqual(tree.kind(sub_tree_root_id), 'tree-reference') |
3467 | + self.assertEqual(tree.kind('sub-tree'), 'tree-reference') |
3468 | tree.commit('commit reference') |
3469 | basis = tree.basis_tree() |
3470 | basis.lock_read() |
3471 | try: |
3472 | - sub_tree = tree.get_nested_tree(sub_tree_root_id) |
3473 | + sub_tree = tree.get_nested_tree('sub-tree', sub_tree_root_id) |
3474 | self.assertEqual( |
3475 | sub_tree.last_revision(), |
3476 | - tree.get_reference_revision(sub_tree_root_id)) |
3477 | + tree.get_reference_revision('sub-tree', sub_tree_root_id)) |
3478 | finally: |
3479 | basis.unlock() |
3480 | finally: |
3481 | @@ -108,8 +108,9 @@ |
3482 | sub_tree_root_id = sub_tree.get_root_id() |
3483 | tree.lock_read() |
3484 | try: |
3485 | - sub_tree2 = tree.get_nested_tree(sub_tree_root_id) |
3486 | - self.assertEqual(sub_tree.basedir, sub_tree2.basedir) |
3487 | - sub_tree2 = tree.get_nested_tree(sub_tree_root_id, 'sub-tree') |
3488 | + sub_tree2 = tree.get_nested_tree('sub-tree', sub_tree_root_id) |
3489 | + self.assertEqual(sub_tree.basedir, sub_tree2.basedir) |
3490 | + sub_tree2 = tree.get_nested_tree('sub-tree') |
3491 | + self.assertEqual(sub_tree.basedir, sub_tree2.basedir) |
3492 | finally: |
3493 | tree.unlock() |
3494 | |
3495 | === modified file 'breezy/tests/per_workingtree/test_annotate_iter.py' |
3496 | --- breezy/tests/per_workingtree/test_annotate_iter.py 2017-11-16 00:39:04 +0000 |
3497 | +++ breezy/tests/per_workingtree/test_annotate_iter.py 2017-11-19 19:02:26 +0000 |
3498 | @@ -35,7 +35,7 @@ |
3499 | |
3500 | def test_annotate_same_as_parent(self): |
3501 | tree = self.make_single_rev_tree() |
3502 | - annotations = tree.annotate_iter('file-id') |
3503 | + annotations = tree.annotate_iter('file') |
3504 | self.assertEqual([('rev-1', 'initial content\n')], |
3505 | annotations) |
3506 | |
3507 | @@ -43,7 +43,7 @@ |
3508 | tree = self.make_single_rev_tree() |
3509 | self.build_tree_contents([('tree/file', |
3510 | 'initial content\nnew content\n')]) |
3511 | - annotations = tree.annotate_iter('file-id') |
3512 | + annotations = tree.annotate_iter('file') |
3513 | self.assertEqual([('rev-1', 'initial content\n'), |
3514 | ('current:', 'new content\n'), |
3515 | ], annotations) |
3516 | @@ -70,7 +70,7 @@ |
3517 | self.build_tree_contents([('tree/file', |
3518 | 'initial content\ncontent in 2\n' |
3519 | 'content in 3\nnew content\n')]) |
3520 | - annotations = tree.annotate_iter('file-id') |
3521 | + annotations = tree.annotate_iter('file') |
3522 | self.assertEqual([('rev-1', 'initial content\n'), |
3523 | ('rev-2', 'content in 2\n'), |
3524 | ('rev-3', 'content in 3\n'), |
3525 | @@ -95,7 +95,7 @@ |
3526 | tree.set_parent_ids(['rev-2', 'rev-3']) |
3527 | self.build_tree_contents([('tree/file', |
3528 | 'initial content\nnew content\n')]) |
3529 | - annotations = tree.annotate_iter('file-id') |
3530 | + annotations = tree.annotate_iter('file') |
3531 | self.assertEqual([('rev-2', 'initial content\n'), |
3532 | ('current:', 'new content\n'), |
3533 | ], annotations) |
3534 | @@ -120,7 +120,7 @@ |
3535 | tree.set_parent_ids(['rev-2', 'rev-3']) |
3536 | self.build_tree_contents([('tree/file', |
3537 | 'initial content\nnew content\n')]) |
3538 | - annotations = tree.annotate_iter('file-id') |
3539 | + annotations = tree.annotate_iter('file') |
3540 | self.assertEqual([('rev-2', 'initial content\n'), |
3541 | ('current:', 'new content\n'), |
3542 | ], annotations) |
3543 | @@ -145,7 +145,7 @@ |
3544 | tree.set_parent_ids(['rev-2', 'rev-3']) |
3545 | self.build_tree_contents([('tree/file', |
3546 | 'initial content\ncontent in 3\n')]) |
3547 | - annotations = tree.annotate_iter('file-id') |
3548 | + annotations = tree.annotate_iter('file') |
3549 | self.assertEqual([('rev-1', 'initial content\n'), |
3550 | ('rev-3', 'content in 3\n'), |
3551 | ], annotations) |
3552 | @@ -174,7 +174,7 @@ |
3553 | tree.lock_write() |
3554 | self.addCleanup(tree.unlock) |
3555 | tree.set_parent_ids(['rev-2', 'rev-4']) |
3556 | - annotations = tree.annotate_iter('file-id') |
3557 | + annotations = tree.annotate_iter('file') |
3558 | self.assertEqual([('rev-1', 'initial content\n'), |
3559 | ('rev-4', 'new content\n'), |
3560 | ], annotations) |
3561 | |
3562 | === modified file 'breezy/tests/per_workingtree/test_basis_tree.py' |
3563 | --- breezy/tests/per_workingtree/test_basis_tree.py 2017-05-21 18:10:28 +0000 |
3564 | +++ breezy/tests/per_workingtree/test_basis_tree.py 2017-11-19 19:02:26 +0000 |
3565 | @@ -59,7 +59,7 @@ |
3566 | |
3567 | self.build_tree(['new file', 'new dir/']) |
3568 | tree.rename_one('file', 'dir/new file') |
3569 | - tree.unversion([tree.path2id('dir/subfile')]) |
3570 | + tree.unversion(['dir/subfile']) |
3571 | tree.add(['new file', 'new dir']) |
3572 | |
3573 | basis_tree = tree.basis_tree() |
3574 | |
3575 | === modified file 'breezy/tests/per_workingtree/test_commit.py' |
3576 | --- breezy/tests/per_workingtree/test_commit.py 2017-08-10 00:51:26 +0000 |
3577 | +++ breezy/tests/per_workingtree/test_commit.py 2017-11-19 19:02:26 +0000 |
3578 | @@ -390,8 +390,9 @@ |
3579 | sub_basis = subtree.basis_tree() |
3580 | sub_basis.lock_read() |
3581 | self.addCleanup(sub_basis.unlock) |
3582 | - self.assertEqual(subsubtree.last_revision(), |
3583 | - sub_basis.get_reference_revision(sub_basis.path2id('subtree'))) |
3584 | + self.assertEqual( |
3585 | + subsubtree.last_revision(), |
3586 | + sub_basis.get_reference_revision('subtree')) |
3587 | # the intermediate tree has changed, so should have had a commit |
3588 | # take place. |
3589 | self.assertNotEqual(None, subtree.last_revision()) |
3590 | @@ -401,7 +402,7 @@ |
3591 | basis.lock_read() |
3592 | self.addCleanup(basis.unlock) |
3593 | self.assertEqual(subtree.last_revision(), |
3594 | - basis.get_reference_revision(basis.path2id('subtree'))) |
3595 | + basis.get_reference_revision('subtree')) |
3596 | # the outer tree must have have changed too. |
3597 | self.assertNotEqual(None, rev_id) |
3598 | |
3599 | @@ -417,7 +418,7 @@ |
3600 | self.build_tree(['subtree/file']) |
3601 | subtree.add(['file']) |
3602 | rev_id = tree.commit('added reference', allow_pointless=False) |
3603 | - tree.get_reference_revision(tree.path2id('subtree')) |
3604 | + tree.get_reference_revision('subtree') |
3605 | child_revid = subtree.last_revision() |
3606 | # now change the child tree |
3607 | self.build_tree_contents([('subtree/file', 'new-content')]) |
3608 | @@ -435,7 +436,7 @@ |
3609 | basis.lock_read() |
3610 | self.addCleanup(basis.unlock) |
3611 | self.assertEqual(subtree.last_revision(), |
3612 | - basis.get_reference_revision(basis.path2id('subtree'))) |
3613 | + basis.get_reference_revision('subtree')) |
3614 | self.assertNotEqual(rev_id, rev_id2) |
3615 | |
3616 | def test_nested_pointless_commits_are_pointless(self): |
3617 | |
3618 | === modified file 'breezy/tests/per_workingtree/test_content_filters.py' |
3619 | --- breezy/tests/per_workingtree/test_content_filters.py 2017-05-21 18:10:28 +0000 |
3620 | +++ breezy/tests/per_workingtree/test_content_filters.py 2017-11-19 19:02:26 +0000 |
3621 | @@ -136,7 +136,9 @@ |
3622 | basis = branch.basis_tree() |
3623 | basis.lock_read() |
3624 | try: |
3625 | - self.assertEqual(expected_content, basis.get_file_text(file_id)) |
3626 | + self.assertEqual( |
3627 | + expected_content, |
3628 | + basis.get_file_text(basis.id2path(file_id), file_id)) |
3629 | finally: |
3630 | basis.unlock() |
3631 | |
3632 | @@ -152,14 +154,18 @@ |
3633 | expected = "fOO tXT" |
3634 | else: |
3635 | expected = "Foo Txt" |
3636 | - self.assertEqual(expected, basis.get_file_text(txt_fileid)) |
3637 | - self.assertEqual('Foo Bin', basis.get_file_text(bin_fileid)) |
3638 | + self.assertEqual( |
3639 | + expected, |
3640 | + basis.get_file_text(basis.id2path(txt_fileid))) |
3641 | + self.assertEqual( |
3642 | + 'Foo Bin', |
3643 | + basis.get_file_text(basis.id2path(bin_fileid))) |
3644 | # Check that the working tree has the original content |
3645 | tree.lock_read() |
3646 | self.addCleanup(tree.unlock) |
3647 | - self.assertEqual('Foo Txt', tree.get_file(txt_fileid, |
3648 | + self.assertEqual('Foo Txt', tree.get_file(tree.id2path(txt_fileid), |
3649 | filtered=False).read()) |
3650 | - self.assertEqual('Foo Bin', tree.get_file(bin_fileid, |
3651 | + self.assertEqual('Foo Bin', tree.get_file(tree.id2path(bin_fileid), |
3652 | filtered=False).read()) |
3653 | |
3654 | def test_readonly_content_filtering(self): |
3655 | @@ -174,14 +180,14 @@ |
3656 | expected = "FOO TXT" |
3657 | else: |
3658 | expected = "Foo Txt" |
3659 | - self.assertEqual(expected, basis.get_file_text(txt_fileid)) |
3660 | - self.assertEqual('Foo Bin', basis.get_file_text(bin_fileid)) |
3661 | + self.assertEqual(expected, basis.get_file_text(basis.id2path(txt_fileid))) |
3662 | + self.assertEqual('Foo Bin', basis.get_file_text(basis.id2path(bin_fileid))) |
3663 | # We expect the workingtree content to be unchanged (for now at least) |
3664 | tree.lock_read() |
3665 | self.addCleanup(tree.unlock) |
3666 | - self.assertEqual('Foo Txt', tree.get_file(txt_fileid, |
3667 | + self.assertEqual('Foo Txt', tree.get_file(tree.id2path(txt_fileid), |
3668 | filtered=False).read()) |
3669 | - self.assertEqual('Foo Bin', tree.get_file(bin_fileid, |
3670 | + self.assertEqual('Foo Bin', tree.get_file(tree.id2path(bin_fileid), |
3671 | filtered=False).read()) |
3672 | |
3673 | def test_branch_source_filtered_target_not(self): |
3674 | @@ -237,9 +243,11 @@ |
3675 | self.addCleanup(source.unlock) |
3676 | |
3677 | expected_canonical_form = 'Foo Txt\nend string\n' |
3678 | - self.assertEqual(source.get_file(txt_fileid, filtered=True).read(), |
3679 | + self.assertEqual( |
3680 | + source.get_file(source.id2path(txt_fileid), filtered=True).read(), |
3681 | expected_canonical_form) |
3682 | - self.assertEqual(source.get_file(txt_fileid, filtered=False).read(), |
3683 | + self.assertEqual( |
3684 | + source.get_file(source.id2path(txt_fileid), filtered=False).read(), |
3685 | 'Foo Txt') |
3686 | |
3687 | # results are: kind, size, executable, sha1_or_link_target |
3688 | |
3689 | === modified file 'breezy/tests/per_workingtree/test_eol_conversion.py' |
3690 | --- breezy/tests/per_workingtree/test_eol_conversion.py 2017-06-10 00:17:06 +0000 |
3691 | +++ breezy/tests/per_workingtree/test_eol_conversion.py 2017-11-19 19:02:26 +0000 |
3692 | @@ -92,7 +92,7 @@ |
3693 | self.patch_rules_searcher(eol) |
3694 | wt2 = wt.controldir.sprout('tree-%s' % eol).open_workingtree() |
3695 | # To see exactly what got written to disk, we need an unfiltered read |
3696 | - content = wt2.get_file('file1-id', filtered=False).read() |
3697 | + content = wt2.get_file('file1', filtered=False).read() |
3698 | if sys.platform == 'win32': |
3699 | self.assertEqual(expected_win, content) |
3700 | else: |
3701 | @@ -110,7 +110,7 @@ |
3702 | :param roundtrip_to: the set of formats (excluding exact) we |
3703 | can round-trip to or None for all |
3704 | """ |
3705 | - basis_content = basis.get_file('file1-id').read() |
3706 | + basis_content = basis.get_file('file1').read() |
3707 | self.assertEqual(expected_raw, basis_content) |
3708 | |
3709 | # No setting and exact should always roundtrip |
3710 | |
3711 | === modified file 'breezy/tests/per_workingtree/test_executable.py' |
3712 | --- breezy/tests/per_workingtree/test_executable.py 2017-06-10 00:17:06 +0000 |
3713 | +++ breezy/tests/per_workingtree/test_executable.py 2017-11-19 19:02:26 +0000 |
3714 | @@ -43,9 +43,9 @@ |
3715 | def check_exist(self, tree): |
3716 | """Just check that both files have the right executable bits set""" |
3717 | tree.lock_read() |
3718 | - self.assertTrue(tree.is_executable(self.a_id), |
3719 | + self.assertTrue(tree.is_executable('a'), |
3720 | "'a' lost the execute bit") |
3721 | - self.assertFalse(tree.is_executable(self.b_id), |
3722 | + self.assertFalse(tree.is_executable('b'), |
3723 | "'b' gained an execute bit") |
3724 | tree.unlock() |
3725 | |
3726 | @@ -190,5 +190,5 @@ |
3727 | def test_use_exec_from_basis(self): |
3728 | self.wt._supports_executable = lambda: False |
3729 | self.addCleanup(self.wt.lock_read().unlock) |
3730 | - self.assertTrue(self.wt.is_executable(self.a_id)) |
3731 | - self.assertFalse(self.wt.is_executable(self.b_id)) |
3732 | + self.assertTrue(self.wt.is_executable('a')) |
3733 | + self.assertFalse(self.wt.is_executable('b')) |
3734 | |
3735 | === modified file 'breezy/tests/per_workingtree/test_get_file_mtime.py' |
3736 | --- breezy/tests/per_workingtree/test_get_file_mtime.py 2017-10-08 02:49:53 +0000 |
3737 | +++ breezy/tests/per_workingtree/test_get_file_mtime.py 2017-11-19 19:02:26 +0000 |
3738 | @@ -43,10 +43,10 @@ |
3739 | st = os.lstat('tree/one') |
3740 | tree.lock_read() |
3741 | try: |
3742 | - mtime_file_id = tree.get_file_mtime(file_id=one_id) |
3743 | + mtime_file_id = tree.get_file_mtime('one') |
3744 | self.assertIsInstance(mtime_file_id, (float, int)) |
3745 | self.assertAlmostEqual(st.st_mtime, mtime_file_id) |
3746 | - mtime_path = tree.get_file_mtime(file_id=one_id, path='one') |
3747 | + mtime_path = tree.get_file_mtime('one', file_id=one_id) |
3748 | self.assertAlmostEqual(mtime_file_id, mtime_path) |
3749 | finally: |
3750 | tree.unlock() |
3751 | @@ -61,10 +61,10 @@ |
3752 | |
3753 | tree.lock_read() |
3754 | try: |
3755 | - mtime = tree.get_file_mtime(file_id=one_id) |
3756 | + mtime = tree.get_file_mtime('one') |
3757 | self.assertAlmostEqual(st.st_mtime, mtime) |
3758 | |
3759 | - mtime = tree.get_file_mtime(file_id=one_id, path='one') |
3760 | + mtime = tree.get_file_mtime('one', one_id) |
3761 | self.assertAlmostEqual(st.st_mtime, mtime) |
3762 | finally: |
3763 | tree.unlock() |
3764 | @@ -79,9 +79,9 @@ |
3765 | |
3766 | tree.lock_read() |
3767 | try: |
3768 | - mtime = tree.get_file_mtime(file_id=one_id) |
3769 | + mtime = tree.get_file_mtime('two') |
3770 | self.assertAlmostEqual(st.st_mtime, mtime) |
3771 | - mtime = tree.get_file_mtime(file_id=one_id, path='two') |
3772 | + mtime = tree.get_file_mtime('two', one_id) |
3773 | self.assertAlmostEqual(st.st_mtime, mtime) |
3774 | finally: |
3775 | tree.unlock() |
3776 | @@ -98,9 +98,9 @@ |
3777 | st = os.lstat('tree/e/a') |
3778 | tree.lock_read() |
3779 | try: |
3780 | - mtime = tree.get_file_mtime(file_id='a-id') |
3781 | + mtime = tree.get_file_mtime('e/a') |
3782 | self.assertAlmostEqual(st.st_mtime, mtime) |
3783 | - mtime = tree.get_file_mtime(file_id='a-id', path='e/a') |
3784 | + mtime = tree.get_file_mtime('e/a', 'a-id') |
3785 | self.assertAlmostEqual(st.st_mtime, mtime) |
3786 | finally: |
3787 | tree.unlock() |
3788 | @@ -112,8 +112,7 @@ |
3789 | os.remove('tree/one') |
3790 | tree.lock_read() |
3791 | try: |
3792 | - self.assertRaises(FileTimestampUnavailable, |
3793 | - tree.get_file_mtime, file_id=one_id) |
3794 | + self.assertRaises(errors.NoSuchFile, tree.get_file_mtime, 'one') |
3795 | finally: |
3796 | tree.unlock() |
3797 | |
3798 | |
3799 | === modified file 'breezy/tests/per_workingtree/test_merge_from_branch.py' |
3800 | --- breezy/tests/per_workingtree/test_merge_from_branch.py 2017-11-16 00:39:04 +0000 |
3801 | +++ breezy/tests/per_workingtree/test_merge_from_branch.py 2017-11-19 19:02:26 +0000 |
3802 | @@ -103,7 +103,7 @@ |
3803 | def test_merge_type(self): |
3804 | this = self.make_branch_and_tree('this') |
3805 | self.build_tree_contents([('this/foo', 'foo')]) |
3806 | - this.add('foo', 'foo-id') |
3807 | + this.add('foo') |
3808 | this.commit('added foo') |
3809 | other = this.controldir.sprout('other').open_workingtree() |
3810 | self.build_tree_contents([('other/foo', 'bar')]) |
3811 | @@ -114,7 +114,7 @@ |
3812 | def text_merge(self, file_id, trans_id): |
3813 | self.tt.create_file('qux', trans_id) |
3814 | this.merge_from_branch(other.branch, merge_type=QuxMerge) |
3815 | - self.assertEqual('qux', this.get_file_text('foo-id')) |
3816 | + self.assertEqual('qux', this.get_file_text('foo')) |
3817 | |
3818 | |
3819 | class TestMergedBranch(per_workingtree.TestCaseWithWorkingTree): |
3820 | |
3821 | === modified file 'breezy/tests/per_workingtree/test_mkdir.py' |
3822 | --- breezy/tests/per_workingtree/test_mkdir.py 2017-05-21 18:10:28 +0000 |
3823 | +++ breezy/tests/per_workingtree/test_mkdir.py 2017-11-19 19:02:26 +0000 |
3824 | @@ -27,7 +27,7 @@ |
3825 | t.lock_write() |
3826 | self.addCleanup(t.unlock) |
3827 | file_id = t.mkdir('path') |
3828 | - self.assertEqual('directory', t.kind(file_id)) |
3829 | + self.assertEqual('directory', t.kind('path', file_id)) |
3830 | |
3831 | def test_mkdir_with_id(self): |
3832 | t = self.make_branch_and_tree('t1') |
3833 | @@ -35,4 +35,4 @@ |
3834 | self.addCleanup(t.unlock) |
3835 | file_id = t.mkdir('path', 'my-id') |
3836 | self.assertEqual('my-id', file_id) |
3837 | - self.assertEqual('directory', t.kind(file_id)) |
3838 | + self.assertEqual('directory', t.kind('path', file_id)) |
3839 | |
3840 | === modified file 'breezy/tests/per_workingtree/test_move.py' |
3841 | --- breezy/tests/per_workingtree/test_move.py 2017-08-07 19:09:47 +0000 |
3842 | +++ breezy/tests/per_workingtree/test_move.py 2017-11-19 19:02:26 +0000 |
3843 | @@ -160,7 +160,7 @@ |
3844 | ('b/c', 'c-id')], tree) |
3845 | self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id'), |
3846 | ('b/c', 'c-id')], tree.basis_tree()) |
3847 | - a_contents = tree.get_file_text('a-id') |
3848 | + a_contents = tree.get_file_text('a', 'a-id') |
3849 | self.assertEqual([('a', 'b/a')], |
3850 | tree.move(['a'], 'b')) |
3851 | self.assertTreeLayout([('', root_id), ('b/', 'b-id'), ('b/a', 'a-id'), |
3852 | @@ -177,7 +177,7 @@ |
3853 | tree.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id']) |
3854 | tree.commit('initial') |
3855 | root_id = tree.get_root_id() |
3856 | - c_contents = tree.get_file_text('c-id') |
3857 | + c_contents = tree.get_file_text('b/c', 'c-id') |
3858 | self.assertEqual([('b/c', 'c')], |
3859 | tree.move(['b/c'], '')) |
3860 | self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id'), |
3861 | |
3862 | === modified file 'breezy/tests/per_workingtree/test_nested_specifics.py' |
3863 | --- breezy/tests/per_workingtree/test_nested_specifics.py 2017-06-10 16:40:42 +0000 |
3864 | +++ breezy/tests/per_workingtree/test_nested_specifics.py 2017-11-19 19:02:26 +0000 |
3865 | @@ -64,7 +64,7 @@ |
3866 | |
3867 | def test_kind_does_not_autodetect_subtree(self): |
3868 | tree = self.prepare_with_subtree() |
3869 | - self.assertEqual('directory', tree.kind('subtree-id')) |
3870 | + self.assertEqual('directory', tree.kind('subtree', 'subtree-id')) |
3871 | |
3872 | def test_comparison_data_does_not_autodetect_subtree(self): |
3873 | tree = self.prepare_with_subtree() |
3874 | @@ -75,7 +75,7 @@ |
3875 | |
3876 | def test_inventory_does_not_autodetect_subtree(self): |
3877 | tree = self.prepare_with_subtree() |
3878 | - self.assertEqual('directory', tree.kind('subtree-id')) |
3879 | + self.assertEqual('directory', tree.kind('subtree', 'subtree-id')) |
3880 | |
3881 | def test_iter_entries_by_dir_autodetects_subtree(self): |
3882 | tree = self.prepare_with_subtree() |
3883 | |
3884 | === modified file 'breezy/tests/per_workingtree/test_parents.py' |
3885 | --- breezy/tests/per_workingtree/test_parents.py 2017-06-11 01:22:16 +0000 |
3886 | +++ breezy/tests/per_workingtree/test_parents.py 2017-11-19 19:02:26 +0000 |
3887 | @@ -250,9 +250,9 @@ |
3888 | tree.lock_read() |
3889 | self.addCleanup(tree.unlock) |
3890 | # Check that the symlink target is safely round-tripped in the trees. |
3891 | - self.assertEqual(target, tree.get_symlink_target('link-id')) |
3892 | + self.assertEqual(target, tree.get_symlink_target(link_name)) |
3893 | basis = tree.basis_tree() |
3894 | - self.assertEqual(target, basis.get_symlink_target('link-id')) |
3895 | + self.assertEqual(target, basis.get_symlink_target(link_name)) |
3896 | |
3897 | |
3898 | class TestAddParent(TestParents): |
3899 | @@ -395,14 +395,16 @@ |
3900 | self._repository = tree.branch.repository |
3901 | self._inventory = shape |
3902 | |
3903 | - def get_file_text(self, file_id, path=None): |
3904 | + def get_file_text(self, path, file_id=None): |
3905 | + if file_id is None: |
3906 | + file_id = self.path2id(path) |
3907 | ie = self.root_inventory[file_id] |
3908 | if ie.kind != "file": |
3909 | return "" |
3910 | return 'a' * ie.text_size |
3911 | |
3912 | - def get_file(self, file_id, path=None): |
3913 | - return BytesIO(self.get_file_text(file_id)) |
3914 | + def get_file(self, path, file_id=None): |
3915 | + return BytesIO(self.get_file_text(path, file_id)) |
3916 | |
3917 | tree.lock_write() |
3918 | try: |
3919 | |
3920 | === modified file 'breezy/tests/per_workingtree/test_paths2ids.py' |
3921 | --- breezy/tests/per_workingtree/test_paths2ids.py 2017-06-10 00:17:06 +0000 |
3922 | +++ breezy/tests/per_workingtree/test_paths2ids.py 2017-11-19 19:02:26 +0000 |
3923 | @@ -137,7 +137,7 @@ |
3924 | ['dir', 'child-moves', 'child-stays', 'child-goes']) |
3925 | tree.commit('create basis') |
3926 | basis = tree.basis_tree() |
3927 | - tree.unversion(['child-goes']) |
3928 | + tree.unversion(['dir/child-goes']) |
3929 | tree.rename_one('dir/child-moves', 'child-moves') |
3930 | self.build_tree(['tree/newdir/']) |
3931 | tree.add(['newdir'], ['newdir']) |
3932 | |
3933 | === modified file 'breezy/tests/per_workingtree/test_put_file.py' |
3934 | --- breezy/tests/per_workingtree/test_put_file.py 2017-05-21 18:10:28 +0000 |
3935 | +++ breezy/tests/per_workingtree/test_put_file.py 2017-11-19 19:02:26 +0000 |
3936 | @@ -24,14 +24,14 @@ |
3937 | |
3938 | def test_put_new_file(self): |
3939 | t = self.make_branch_and_tree('t1') |
3940 | - t.add(['foo'], ids=['foo-id'], kinds=['file']) |
3941 | - t.put_file_bytes_non_atomic('foo-id', 'barshoom') |
3942 | - self.assertEqual('barshoom', t.get_file('foo-id').read()) |
3943 | + t.add(['foo'], kinds=['file']) |
3944 | + t.put_file_bytes_non_atomic('foo', 'barshoom') |
3945 | + self.assertEqual('barshoom', t.get_file('foo').read()) |
3946 | |
3947 | def test_put_existing_file(self): |
3948 | t = self.make_branch_and_tree('t1') |
3949 | - t.add(['foo'], ids=['foo-id'], kinds=['file']) |
3950 | - t.put_file_bytes_non_atomic('foo-id', 'first-content') |
3951 | - t.put_file_bytes_non_atomic('foo-id', 'barshoom') |
3952 | - self.assertEqual('barshoom', t.get_file('foo-id').read()) |
3953 | + t.add(['foo'], kinds=['file']) |
3954 | + t.put_file_bytes_non_atomic('foo', 'first-content') |
3955 | + t.put_file_bytes_non_atomic('foo', 'barshoom') |
3956 | + self.assertEqual('barshoom', t.get_file('foo').read()) |
3957 | |
3958 | |
3959 | === modified file 'breezy/tests/per_workingtree/test_readonly.py' |
3960 | --- breezy/tests/per_workingtree/test_readonly.py 2017-06-10 12:49:41 +0000 |
3961 | +++ breezy/tests/per_workingtree/test_readonly.py 2017-11-19 19:02:26 +0000 |
3962 | @@ -110,7 +110,7 @@ |
3963 | tree._dirstate._sha_cutoff_time = self._custom_cutoff_time |
3964 | # Make sure we check all the files |
3965 | for file_id in tree.all_file_ids(): |
3966 | - size = tree.get_file_size(file_id) |
3967 | - sha1 = tree.get_file_sha1(file_id) |
3968 | + size = tree.get_file_size(tree.id2path(file_id)) |
3969 | + sha1 = tree.get_file_sha1(tree.id2path(file_id)) |
3970 | finally: |
3971 | tree.unlock() |
3972 | |
3973 | === modified file 'breezy/tests/per_workingtree/test_rename_one.py' |
3974 | --- breezy/tests/per_workingtree/test_rename_one.py 2017-08-29 23:18:16 +0000 |
3975 | +++ breezy/tests/per_workingtree/test_rename_one.py 2017-11-19 19:02:26 +0000 |
3976 | @@ -81,7 +81,7 @@ |
3977 | tree.commit('initial') |
3978 | root_id = tree.get_root_id() |
3979 | |
3980 | - a_contents = tree.get_file_text(a_id) |
3981 | + a_contents = tree.get_file_text('a', a_id) |
3982 | tree.rename_one('a', 'foo') |
3983 | self.assertTreeLayout([('', root_id), ('b/', b_id), ('foo', a_id)], |
3984 | tree) |
3985 | @@ -99,7 +99,7 @@ |
3986 | tree.commit('initial') |
3987 | root_id = tree.get_root_id() |
3988 | |
3989 | - a_contents = tree.get_file_text(a_id) |
3990 | + a_contents = tree.get_file_text('a', a_id) |
3991 | tree.rename_one('a', 'b/foo') |
3992 | self.assertTreeLayout([('', root_id), ('b/', b_id), ('b/foo', a_id)], |
3993 | tree) |
3994 | @@ -121,7 +121,7 @@ |
3995 | ('b/c', c_id)], tree) |
3996 | self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id), |
3997 | ('b/c', c_id)], tree.basis_tree()) |
3998 | - a_contents = tree.get_file_text(a_id) |
3999 | + a_contents = tree.get_file_text('a', a_id) |
4000 | tree.rename_one('a', 'b/d') |
4001 | self.assertTreeLayout([('', root_id), ('b/', b_id), ('b/c', c_id), |
4002 | ('b/d', a_id)], tree) |
4003 | @@ -139,7 +139,7 @@ |
4004 | c_id = tree.path2id('b/c') |
4005 | tree.commit('initial') |
4006 | root_id = tree.get_root_id() |
4007 | - c_contents = tree.get_file_text(c_id) |
4008 | + c_contents = tree.get_file_text('b/c', c_id) |
4009 | tree.rename_one('b/c', 'd') |
4010 | self.assertTreeLayout([('', root_id), ('a', a_id), ('b/', b_id), |
4011 | ('d', c_id)], tree) |
4012 | |
4013 | === modified file 'breezy/tests/per_workingtree/test_revision_tree.py' |
4014 | --- breezy/tests/per_workingtree/test_revision_tree.py 2017-06-10 00:17:06 +0000 |
4015 | +++ breezy/tests/per_workingtree/test_revision_tree.py 2017-11-19 19:02:26 +0000 |
4016 | @@ -119,9 +119,9 @@ |
4017 | basis = tree.revision_tree(parents[0]) |
4018 | basis.lock_read() |
4019 | self.addCleanup(basis.unlock) |
4020 | - self.assertRaises(errors.NoSuchId, basis.kind, 'a-id') |
4021 | + self.assertRaises(errors.NoSuchId, basis.kind, 'a') |
4022 | self.assertEqual(['directory', 'file'], |
4023 | - [basis.kind('b-id'), basis.kind('c-id')]) |
4024 | + [basis.kind('b'), basis.kind('b/c')]) |
4025 | try: |
4026 | other = tree.revision_tree(parents[1]) |
4027 | except errors.NoSuchRevisionInTree: |
4028 | @@ -130,6 +130,6 @@ |
4029 | % type(tree)) |
4030 | other.lock_read() |
4031 | self.addCleanup(other.unlock) |
4032 | - self.assertRaises(errors.NoSuchId, other.kind, 'b-id') |
4033 | - self.assertRaises(errors.NoSuchId, other.kind, 'c-id') |
4034 | - self.assertEqual('file', other.kind('a-id')) |
4035 | + self.assertRaises(errors.NoSuchId, other.kind, 'b') |
4036 | + self.assertRaises(errors.NoSuchId, other.kind, 'c') |
4037 | + self.assertEqual('file', other.kind('a')) |
4038 | |
4039 | === modified file 'breezy/tests/per_workingtree/test_symlinks.py' |
4040 | --- breezy/tests/per_workingtree/test_symlinks.py 2017-05-21 18:10:28 +0000 |
4041 | +++ breezy/tests/per_workingtree/test_symlinks.py 2017-11-19 19:02:26 +0000 |
4042 | @@ -44,8 +44,7 @@ |
4043 | tree.smart_add(['tree/link']) |
4044 | self.assertIsNot(None, tree.path2id('link')) |
4045 | self.assertIs(None, tree.path2id('target')) |
4046 | - self.assertEqual('symlink', |
4047 | - tree.kind(tree.path2id('link'))) |
4048 | + self.assertEqual('symlink', tree.kind('link')) |
4049 | |
4050 | def test_smart_add_symlink_pointing_outside(self): |
4051 | tree = self.make_branch_and_tree('tree') |
4052 | @@ -55,8 +54,7 @@ |
4053 | tree.smart_add(['tree/link']) |
4054 | self.assertIsNot(None, tree.path2id('link')) |
4055 | self.assertIs(None, tree.path2id('target')) |
4056 | - self.assertEqual('symlink', |
4057 | - tree.kind(tree.path2id('link'))) |
4058 | + self.assertEqual('symlink', tree.kind('link')) |
4059 | |
4060 | def test_add_file_under_symlink(self): |
4061 | # similar to |
4062 | |
4063 | === modified file 'breezy/tests/per_workingtree/test_unversion.py' |
4064 | --- breezy/tests/per_workingtree/test_unversion.py 2017-06-10 00:17:06 +0000 |
4065 | +++ breezy/tests/per_workingtree/test_unversion.py 2017-11-19 19:02:26 +0000 |
4066 | @@ -32,9 +32,9 @@ |
4067 | tree.unlock() |
4068 | |
4069 | def test_unversion_missing_file(self): |
4070 | - """WT.unversion(['missing-id']) raises NoSuchId.""" |
4071 | + """WT.unversion(['missing']) raises NoSuchId.""" |
4072 | tree = self.make_branch_and_tree('.') |
4073 | - self.assertRaises(errors.NoSuchId, tree.unversion, ['missing-id']) |
4074 | + self.assertRaises(errors.NoSuchFile, tree.unversion, ['missing']) |
4075 | |
4076 | def test_unversion_parent_and_child_renamed_bug_187207(self): |
4077 | # When unversioning dirstate trees show a bug in dealing with |
4078 | @@ -47,7 +47,7 @@ |
4079 | tree.commit('setup') |
4080 | tree.rename_one('del/sub', 'sub') |
4081 | self.assertEqual('sub/b', tree.id2path('b')) |
4082 | - tree.unversion(['del', 'b']) |
4083 | + tree.unversion(['del', 'sub/b']) |
4084 | self.assertRaises(errors.NoSuchId, tree.id2path, 'b') |
4085 | |
4086 | def test_unversion_several_files(self): |
4087 | @@ -57,7 +57,7 @@ |
4088 | tree.add(['a', 'b', 'c'], ['a-id', 'b-id', 'c-id']) |
4089 | # within a lock unversion should take effect |
4090 | tree.lock_write() |
4091 | - tree.unversion(['a-id', 'b-id']) |
4092 | + tree.unversion(['a', 'b']) |
4093 | self.assertFalse(tree.has_id('a-id')) |
4094 | self.assertFalse(tree.has_id('b-id')) |
4095 | self.assertTrue(tree.has_id('c-id')) |
4096 | @@ -84,7 +84,7 @@ |
4097 | tree.add(['a', 'a/b', 'c'], ['a-id', 'b-id', 'c-id']) |
4098 | # within a lock unversion should take effect |
4099 | tree.lock_write() |
4100 | - tree.unversion(['a-id']) |
4101 | + tree.unversion(['a']) |
4102 | self.assertFalse(tree.has_id('a-id')) |
4103 | self.assertFalse(tree.has_id('b-id')) |
4104 | self.assertTrue(tree.has_id('c-id')) |
4105 | @@ -103,7 +103,7 @@ |
4106 | tree.add(['a', 'a/b', 'a/c', 'd'], ['a-id', 'b-id', 'c-id', 'd-id']) |
4107 | tree.lock_write() |
4108 | try: |
4109 | - tree.unversion(['b-id', 'a-id']) |
4110 | + tree.unversion(['a/b', 'a']) |
4111 | self.assertFalse(tree.has_id('a-id')) |
4112 | self.assertFalse(tree.has_id('b-id')) |
4113 | self.assertFalse(tree.has_id('c-id')) |
4114 | @@ -144,7 +144,7 @@ |
4115 | ('dir2/f3', 'f3-id'), |
4116 | ], paths) |
4117 | |
4118 | - tree.unversion({'dir-id'}) |
4119 | + tree.unversion({'dir'}) |
4120 | paths = [(path, ie.file_id) |
4121 | for path, ie in tree.iter_entries_by_dir()] |
4122 | |
4123 | @@ -170,7 +170,7 @@ |
4124 | self.build_tree(['B/xyz/']) |
4125 | tree_b.add(['xyz'], ['xyz-id']) |
4126 | tree_b.rename_one('a/m', 'xyz/m') |
4127 | - tree_b.unversion(['a-id']) |
4128 | + tree_b.unversion(['a']) |
4129 | tree_b.commit('delete in B') |
4130 | |
4131 | paths = [(path, ie.file_id) |
4132 | @@ -196,7 +196,7 @@ |
4133 | ('a/n.OTHER', 'n-id'), |
4134 | ('xyz/m', 'm-id'), |
4135 | ], paths) |
4136 | - tree_b.unversion(['a-id']) |
4137 | + tree_b.unversion(['a']) |
4138 | paths = [(path, ie.file_id) |
4139 | for path, ie in tree_b.iter_entries_by_dir()] |
4140 | self.assertEqual([('', root_id), |
4141 | |
4142 | === modified file 'breezy/tests/per_workingtree/test_workingtree.py' |
4143 | --- breezy/tests/per_workingtree/test_workingtree.py 2017-11-19 17:46:48 +0000 |
4144 | +++ breezy/tests/per_workingtree/test_workingtree.py 2017-11-19 19:02:26 +0000 |
4145 | @@ -912,11 +912,11 @@ |
4146 | if has_symlinks(): |
4147 | os.symlink('target', 'symlink') |
4148 | names.append('symlink') |
4149 | - tree.add(names, [n + '-id' for n in names]) |
4150 | + tree.add(names) |
4151 | # now when we first look, we should see everything with the same kind |
4152 | # with which they were initially added |
4153 | for n in names: |
4154 | - actual_kind = tree.kind(n + '-id') |
4155 | + actual_kind = tree.kind(n) |
4156 | self.assertEqual(n, actual_kind) |
4157 | # move them around so the names no longer correspond to the types |
4158 | os.rename(names[0], 'tmp') |
4159 | @@ -925,7 +925,7 @@ |
4160 | os.rename('tmp', names[-1]) |
4161 | # now look and expect to see the correct types again |
4162 | for i in range(len(names)): |
4163 | - actual_kind = tree.kind(names[i-1] + '-id') |
4164 | + actual_kind = tree.kind(names[i-1]) |
4165 | expected_kind = names[i] |
4166 | self.assertEqual(expected_kind, actual_kind) |
4167 | |
4168 | @@ -937,9 +937,9 @@ |
4169 | tree.add(['a', 'b']) |
4170 | os.unlink('tree/a') |
4171 | os.rmdir('tree/b') |
4172 | - self.assertEqual('file', tree.stored_kind(tree.path2id('a'))) |
4173 | + self.assertEqual('file', tree.stored_kind('a')) |
4174 | if tree.branch.repository._format.supports_versioned_directories: |
4175 | - self.assertEqual('directory', tree.stored_kind(tree.path2id('b'))) |
4176 | + self.assertEqual('directory', tree.stored_kind('b')) |
4177 | |
4178 | def test_missing_file_sha1(self): |
4179 | """If a file is missing, its sha1 should be reported as None.""" |
4180 | @@ -950,22 +950,22 @@ |
4181 | tree.add('file') |
4182 | tree.commit('file added') |
4183 | os.unlink('file') |
4184 | - self.assertIs(None, tree.get_file_sha1(tree.path2id('file'))) |
4185 | + self.assertIs(None, tree.get_file_sha1('file')) |
4186 | |
4187 | def test_no_file_sha1(self): |
4188 | - """If a file is not present, get_file_sha1 should raise NoSuchId""" |
4189 | + """If a file is not present, get_file_sha1 should raise NoSuchFile""" |
4190 | tree = self.make_branch_and_tree('.') |
4191 | tree.lock_write() |
4192 | self.addCleanup(tree.unlock) |
4193 | - self.assertRaises(errors.NoSuchId, tree.get_file_sha1, |
4194 | + self.assertRaises(errors.NoSuchFile, tree.get_file_sha1, |
4195 | 'nonexistant') |
4196 | self.build_tree(['file']) |
4197 | tree.add('file') |
4198 | file_id = tree.path2id('file') |
4199 | tree.commit('foo') |
4200 | tree.remove('file') |
4201 | - self.assertRaises(errors.NoSuchId, tree.get_file_sha1, |
4202 | - file_id) |
4203 | + self.assertRaises(errors.NoSuchFile, tree.get_file_sha1, |
4204 | + 'file') |
4205 | |
4206 | def test_case_sensitive(self): |
4207 | """If filesystem is case-sensitive, tree should report this. |
4208 | @@ -1002,15 +1002,15 @@ |
4209 | if tree._supports_executable(): |
4210 | tree.lock_read() |
4211 | try: |
4212 | - self.assertFalse(tree.is_executable(tree.path2id('filename'))) |
4213 | + self.assertFalse(tree.is_executable('filename')) |
4214 | finally: |
4215 | tree.unlock() |
4216 | os.chmod('filename', 0o755) |
4217 | self.addCleanup(tree.lock_read().unlock) |
4218 | - self.assertTrue(tree.is_executable(tree.path2id('filename'))) |
4219 | + self.assertTrue(tree.is_executable('filename')) |
4220 | else: |
4221 | self.addCleanup(tree.lock_read().unlock) |
4222 | - self.assertFalse(tree.is_executable(tree.path2id('filename'))) |
4223 | + self.assertFalse(tree.is_executable('filename')) |
4224 | |
4225 | def test_all_file_ids_with_missing(self): |
4226 | tree = self.make_branch_and_tree('tree') |
4227 | |
4228 | === modified file 'breezy/tests/test_annotate.py' |
4229 | --- breezy/tests/test_annotate.py 2017-11-16 00:39:04 +0000 |
4230 | +++ breezy/tests/test_annotate.py 2017-11-19 19:02:26 +0000 |
4231 | @@ -283,17 +283,17 @@ |
4232 | self.assertEqualDiff(''.join('\t'.join(l) for l in expected), |
4233 | ''.join('\t'.join(l) for l in actual)) |
4234 | |
4235 | - def assertBranchAnnotate(self, expected, branch, file_id, revision_id, |
4236 | + def assertBranchAnnotate(self, expected, branch, path, revision_id, |
4237 | verbose=False, full=False, show_ids=False): |
4238 | tree = branch.repository.revision_tree(revision_id) |
4239 | to_file = BytesIO() |
4240 | - annotate.annotate_file_tree(tree, file_id, to_file, |
4241 | + annotate.annotate_file_tree(tree, path, to_file, |
4242 | verbose=verbose, full=full, show_ids=show_ids, branch=branch) |
4243 | self.assertAnnotateEqualDiff(to_file.getvalue(), expected) |
4244 | |
4245 | - def assertRepoAnnotate(self, expected, repo, file_id, revision_id): |
4246 | + def assertRepoAnnotate(self, expected, repo, path, revision_id): |
4247 | """Assert that the revision is properly annotated.""" |
4248 | - actual = list(repo.revision_tree(revision_id).annotate_iter(file_id)) |
4249 | + actual = list(repo.revision_tree(revision_id).annotate_iter(path)) |
4250 | self.assertAnnotateEqualDiff(actual, expected) |
4251 | |
4252 | def test_annotate_duplicate_lines(self): |
4253 | @@ -302,12 +302,12 @@ |
4254 | repo = builder.get_branch().repository |
4255 | repo.lock_read() |
4256 | self.addCleanup(repo.unlock) |
4257 | - self.assertRepoAnnotate(duplicate_base, repo, 'file-id', 'rev-base') |
4258 | - self.assertRepoAnnotate(duplicate_A, repo, 'file-id', 'rev-A') |
4259 | - self.assertRepoAnnotate(duplicate_B, repo, 'file-id', 'rev-B') |
4260 | - self.assertRepoAnnotate(duplicate_C, repo, 'file-id', 'rev-C') |
4261 | - self.assertRepoAnnotate(duplicate_D, repo, 'file-id', 'rev-D') |
4262 | - self.assertRepoAnnotate(duplicate_E, repo, 'file-id', 'rev-E') |
4263 | + self.assertRepoAnnotate(duplicate_base, repo, 'file', 'rev-base') |
4264 | + self.assertRepoAnnotate(duplicate_A, repo, 'file', 'rev-A') |
4265 | + self.assertRepoAnnotate(duplicate_B, repo, 'file', 'rev-B') |
4266 | + self.assertRepoAnnotate(duplicate_C, repo, 'file', 'rev-C') |
4267 | + self.assertRepoAnnotate(duplicate_D, repo, 'file', 'rev-D') |
4268 | + self.assertRepoAnnotate(duplicate_E, repo, 'file', 'rev-E') |
4269 | |
4270 | def test_annotate_shows_dotted_revnos(self): |
4271 | builder = self.create_merged_trees() |
4272 | @@ -315,7 +315,7 @@ |
4273 | self.assertBranchAnnotate('1 joe@foo | first\n' |
4274 | '2 joe@foo | second\n' |
4275 | '1.1.1 barry@f | third\n', |
4276 | - builder.get_branch(), 'a-id', 'rev-3') |
4277 | + builder.get_branch(), 'a', 'rev-3') |
4278 | |
4279 | def test_annotate_limits_dotted_revnos(self): |
4280 | """Annotate should limit dotted revnos to a depth of 12""" |
4281 | @@ -327,7 +327,7 @@ |
4282 | '1.2.1 jerry@f | fourth\n' |
4283 | '1.3.1 george@ | fifth\n' |
4284 | ' | sixth\n', |
4285 | - builder.get_branch(), 'a-id', 'rev-6', |
4286 | + builder.get_branch(), 'a', 'rev-6', |
4287 | verbose=False, full=False) |
4288 | |
4289 | self.assertBranchAnnotate('1 joe@foo | first\n' |
4290 | @@ -336,7 +336,7 @@ |
4291 | '1.2.1 jerry@f | fourth\n' |
4292 | '1.3.1 george@ | fifth\n' |
4293 | '1.3.1 george@ | sixth\n', |
4294 | - builder.get_branch(), 'a-id', 'rev-6', |
4295 | + builder.get_branch(), 'a', 'rev-6', |
4296 | verbose=False, full=True) |
4297 | |
4298 | # verbose=True shows everything, the full revno, user id, and date |
4299 | @@ -346,7 +346,7 @@ |
4300 | '1.2.1 jerry@foo.com 20061213 | fourth\n' |
4301 | '1.3.1 george@foo.com 20061213 | fifth\n' |
4302 | ' | sixth\n', |
4303 | - builder.get_branch(), 'a-id', 'rev-6', |
4304 | + builder.get_branch(), 'a', 'rev-6', |
4305 | verbose=True, full=False) |
4306 | |
4307 | self.assertBranchAnnotate('1 joe@foo.com 20061213 | first\n' |
4308 | @@ -355,7 +355,7 @@ |
4309 | '1.2.1 jerry@foo.com 20061213 | fourth\n' |
4310 | '1.3.1 george@foo.com 20061213 | fifth\n' |
4311 | '1.3.1 george@foo.com 20061213 | sixth\n', |
4312 | - builder.get_branch(), 'a-id', 'rev-6', |
4313 | + builder.get_branch(), 'a', 'rev-6', |
4314 | verbose=True, full=True) |
4315 | |
4316 | def test_annotate_uses_branch_context(self): |
4317 | @@ -371,7 +371,7 @@ |
4318 | '1.2.1 jerry@f | fourth\n' |
4319 | '1.3.1 george@ | fifth\n' |
4320 | ' | sixth\n', |
4321 | - builder.get_branch(), 'a-id', 'rev-1_3_1', |
4322 | + builder.get_branch(), 'a', 'rev-1_3_1', |
4323 | verbose=False, full=False) |
4324 | |
4325 | def test_annotate_show_ids(self): |
4326 | @@ -384,7 +384,7 @@ |
4327 | 'rev-1_2_1 | fourth\n' |
4328 | 'rev-1_3_1 | fifth\n' |
4329 | ' | sixth\n', |
4330 | - builder.get_branch(), 'a-id', 'rev-6', |
4331 | + builder.get_branch(), 'a', 'rev-6', |
4332 | show_ids=True, full=False) |
4333 | |
4334 | self.assertBranchAnnotate(' rev-1 | first\n' |
4335 | @@ -393,7 +393,7 @@ |
4336 | 'rev-1_2_1 | fourth\n' |
4337 | 'rev-1_3_1 | fifth\n' |
4338 | 'rev-1_3_1 | sixth\n', |
4339 | - builder.get_branch(), 'a-id', 'rev-6', |
4340 | + builder.get_branch(), 'a', 'rev-6', |
4341 | show_ids=True, full=True) |
4342 | |
4343 | def test_annotate_unicode_author(self): |
4344 | @@ -419,18 +419,18 @@ |
4345 | |
4346 | # this passes if no exception is raised |
4347 | to_file = BytesIO() |
4348 | - annotate.annotate_file_tree(revtree_1, 'a-id', |
4349 | + annotate.annotate_file_tree(revtree_1, 'a', |
4350 | to_file=to_file, branch=tree1.branch) |
4351 | |
4352 | sio = BytesIO() |
4353 | to_file = codecs.getwriter('ascii')(sio, 'replace') |
4354 | - annotate.annotate_file_tree(revtree_2, 'b-id', |
4355 | + annotate.annotate_file_tree(revtree_2, 'b', |
4356 | to_file=to_file, branch=tree1.branch) |
4357 | self.assertEqualDiff('2 p?rez | bye\n', sio.getvalue()) |
4358 | |
4359 | # test now with unicode file-like |
4360 | to_file = StringIOWithEncoding() |
4361 | - annotate.annotate_file_tree(revtree_2, 'b-id', |
4362 | + annotate.annotate_file_tree(revtree_2, 'b', |
4363 | to_file=to_file, branch=tree1.branch) |
4364 | self.assertContainsRe(u'2 p\xe9rez | bye\n', to_file.getvalue()) |
4365 | |
4366 | @@ -454,11 +454,11 @@ |
4367 | self.addCleanup(tree1.unlock) |
4368 | |
4369 | self.assertBranchAnnotate('1 committ | hello\n', tree1.branch, |
4370 | - 'a-id', 'rev-1') |
4371 | + 'a', 'rev-1') |
4372 | |
4373 | to_file = BytesIO() |
4374 | self.assertBranchAnnotate('2 author@ | bye\n', tree1.branch, |
4375 | - 'b-id', 'rev-2') |
4376 | + 'b', 'rev-2') |
4377 | |
4378 | |
4379 | class TestReannotate(tests.TestCase): |
4380 | |
4381 | === modified file 'breezy/tests/test_bisect.py' |
4382 | --- breezy/tests/test_bisect.py 2017-09-26 00:55:04 +0000 |
4383 | +++ breezy/tests/test_bisect.py 2017-11-19 19:02:26 +0000 |
4384 | @@ -115,7 +115,7 @@ |
4385 | repo = self.tree.branch.repository |
4386 | top_revtree = repo.revision_tree(self.tree.last_revision()) |
4387 | top_revtree.lock_read() |
4388 | - top_file = top_revtree.get_file(top_revtree.path2id("test_file")) |
4389 | + top_file = top_revtree.get_file("test_file") |
4390 | test_content = top_file.read().strip() |
4391 | top_file.close() |
4392 | top_revtree.unlock() |
4393 | @@ -126,7 +126,7 @@ |
4394 | repo = self.tree.branch.repository |
4395 | sub_revtree = repo.revision_tree(self.subtree_rev) |
4396 | sub_revtree.lock_read() |
4397 | - sub_file = sub_revtree.get_file(sub_revtree.path2id("test_file")) |
4398 | + sub_file = sub_revtree.get_file("test_file") |
4399 | test_content = sub_file.read().strip() |
4400 | sub_file.close() |
4401 | sub_revtree.unlock() |
4402 | |
4403 | === modified file 'breezy/tests/test_branchbuilder.py' |
4404 | --- breezy/tests/test_branchbuilder.py 2017-11-16 10:35:32 +0000 |
4405 | +++ breezy/tests/test_branchbuilder.py 2017-11-19 19:02:26 +0000 |
4406 | @@ -132,7 +132,7 @@ |
4407 | self.addCleanup(rev_tree.unlock) |
4408 | self.assertTreeShape([(u'', 'a-root-id', 'directory'), |
4409 | (u'a', 'a-id', 'file')], rev_tree) |
4410 | - self.assertEqual('contents', rev_tree.get_file_text('a-id')) |
4411 | + self.assertEqual('contents', rev_tree.get_file_text('a')) |
4412 | |
4413 | def test_add_second_file(self): |
4414 | builder = self.build_a_rev() |
4415 | @@ -148,7 +148,7 @@ |
4416 | self.assertTreeShape([(u'', 'a-root-id', 'directory'), |
4417 | (u'a', 'a-id', 'file'), |
4418 | (u'b', 'b-id', 'file')], rev_tree) |
4419 | - self.assertEqual('content_b', rev_tree.get_file_text('b-id')) |
4420 | + self.assertEqual('content_b', rev_tree.get_file_text('b')) |
4421 | |
4422 | def test_add_empty_dir(self): |
4423 | builder = self.build_a_rev() |
4424 | @@ -207,7 +207,8 @@ |
4425 | rev_tree = branch.repository.revision_tree(rev_id2) |
4426 | rev_tree.lock_read() |
4427 | self.addCleanup(rev_tree.unlock) |
4428 | - self.assertEqual('new\ncontent\n', rev_tree.get_file_text('a-id')) |
4429 | + self.assertEqual('new\ncontent\n', |
4430 | + rev_tree.get_file_text(rev_tree.id2path('a-id'))) |
4431 | |
4432 | def test_delete_file(self): |
4433 | builder = self.build_a_rev() |
4434 | @@ -304,7 +305,7 @@ |
4435 | self.assertTreeShape([(u'', 'a-root-id', 'directory'), |
4436 | (u'a', 'a-id', 'file'), |
4437 | ], b_tree) |
4438 | - self.assertEqual('new\ncontent\n', b_tree.get_file_text('a-id')) |
4439 | + self.assertEqual('new\ncontent\n', b_tree.get_file_text('a')) |
4440 | |
4441 | # We should still be using the content from A in C, not from B |
4442 | c_tree = repo.revision_tree('C-id') |
4443 | @@ -312,8 +313,8 @@ |
4444 | (u'a', 'a-id', 'file'), |
4445 | (u'c', 'c-id', 'file'), |
4446 | ], c_tree) |
4447 | - self.assertEqual('contents', c_tree.get_file_text('a-id')) |
4448 | - self.assertEqual('alt\ncontent\n', c_tree.get_file_text('c-id')) |
4449 | + self.assertEqual('contents', c_tree.get_file_text('a')) |
4450 | + self.assertEqual('alt\ncontent\n', c_tree.get_file_text('c')) |
4451 | |
4452 | def test_set_merge_parent(self): |
4453 | builder = self.build_a_rev() |
4454 | @@ -363,7 +364,7 @@ |
4455 | ], d_tree) |
4456 | # Because we copied the exact text into *this* tree, the 'c' file |
4457 | # should look like it was not modified in the merge |
4458 | - self.assertEqual('C-id', d_tree.get_file_revision('c-id')) |
4459 | + self.assertEqual('C-id', d_tree.get_file_revision('c')) |
4460 | |
4461 | def test_set_parent_to_null(self): |
4462 | builder = self.build_a_rev() |
4463 | |
4464 | === modified file 'breezy/tests/test_bundle.py' |
4465 | --- breezy/tests/test_bundle.py 2017-11-16 00:39:04 +0000 |
4466 | +++ breezy/tests/test_bundle.py 2017-11-19 19:02:26 +0000 |
4467 | @@ -90,7 +90,7 @@ |
4468 | def all_file_ids(self): |
4469 | return set(self.paths.keys()) |
4470 | |
4471 | - def is_executable(self, file_id): |
4472 | + def is_executable(self, path, file_id): |
4473 | # Not all the files are executable. |
4474 | return False |
4475 | |
4476 | @@ -110,7 +110,9 @@ |
4477 | for path, file_id in self.ids.items(): |
4478 | yield path, self[file_id] |
4479 | |
4480 | - def kind(self, file_id): |
4481 | + def kind(self, path, file_id=None): |
4482 | + if file_id is None: |
4483 | + file_id = self.path2id(path) |
4484 | if file_id in self.contents: |
4485 | kind = 'file' |
4486 | else: |
4487 | @@ -121,9 +123,9 @@ |
4488 | from ..bzr.inventory import (InventoryFile, InventoryDirectory, |
4489 | InventoryLink) |
4490 | name = os.path.basename(path) |
4491 | - kind = self.kind(file_id) |
4492 | + kind = self.kind(path, file_id) |
4493 | parent_id = self.parent_id(file_id) |
4494 | - text_sha_1, text_size = self.contents_stats(file_id) |
4495 | + text_sha_1, text_size = self.contents_stats(path, file_id) |
4496 | if kind == 'directory': |
4497 | ie = InventoryDirectory(file_id, name, parent_id) |
4498 | elif kind == 'file': |
4499 | @@ -153,25 +155,36 @@ |
4500 | def has_id(self, file_id): |
4501 | return self.id2path(file_id) is not None |
4502 | |
4503 | - def get_file(self, file_id): |
4504 | + def get_file(self, path, file_id=None): |
4505 | + if file_id is None: |
4506 | + file_id = self.path2id(path) |
4507 | result = BytesIO() |
4508 | - result.write(self.contents[file_id]) |
4509 | + try: |
4510 | + result.write(self.contents[file_id]) |
4511 | + except KeyError: |
4512 | + raise errors.NoSuchFile(path) |
4513 | result.seek(0, 0) |
4514 | return result |
4515 | |
4516 | - def get_file_revision(self, file_id): |
4517 | + def get_file_revision(self, path, file_id=None): |
4518 | + if file_id is None: |
4519 | + file_id = self.path2id(path) |
4520 | return self.inventory[file_id].revision |
4521 | |
4522 | - def get_file_size(self, file_id): |
4523 | + def get_file_size(self, path, file_id=None): |
4524 | + if file_id is None: |
4525 | + file_id = self.path2id(path) |
4526 | return self.inventory[file_id].text_size |
4527 | |
4528 | - def get_file_sha1(self, file_id): |
4529 | + def get_file_sha1(self, path, file_id=None): |
4530 | + if file_id is None: |
4531 | + file_id = self.path2id(path) |
4532 | return self.inventory[file_id].text_sha1 |
4533 | |
4534 | - def contents_stats(self, file_id): |
4535 | + def contents_stats(self, path, file_id): |
4536 | if file_id not in self.contents: |
4537 | return None, None |
4538 | - text_sha1 = osutils.sha_file(self.get_file(file_id)) |
4539 | + text_sha1 = osutils.sha_file(self.get_file(path, file_id)) |
4540 | return text_sha1, len(self.contents[file_id]) |
4541 | |
4542 | |
4543 | @@ -284,8 +297,10 @@ |
4544 | def adds_test(self, btree): |
4545 | self.assertEqual(btree.id2path("e"), "grandparent/parent/file") |
4546 | self.assertEqual(btree.path2id("grandparent/parent/file"), "e") |
4547 | - self.assertEqual(btree.get_file("e").read(), "Extra cheese\n") |
4548 | - self.assertEqual(btree.get_symlink_target('f'), 'venus') |
4549 | + self.assertEqual(btree.get_file("grandparent/parent/file").read(), |
4550 | + "Extra cheese\n") |
4551 | + self.assertEqual( |
4552 | + btree.get_symlink_target('grandparent/parent/symlink'), 'venus') |
4553 | |
4554 | def test_adds2(self): |
4555 | """File/inventory adds, with patch-compatibile renames""" |
4556 | @@ -307,8 +322,8 @@ |
4557 | return btree |
4558 | |
4559 | def get_file_test(self, btree): |
4560 | - self.assertEqual(btree.get_file("e").read(), "Lemon\n") |
4561 | - self.assertEqual(btree.get_file("c").read(), "Hello\n") |
4562 | + self.assertEqual(btree.get_file(btree.id2path("e")).read(), "Lemon\n") |
4563 | + self.assertEqual(btree.get_file(btree.id2path("c")).read(), "Hello\n") |
4564 | |
4565 | def test_get_file(self): |
4566 | """Get file contents""" |
4567 | @@ -318,7 +333,7 @@ |
4568 | self.get_file_test(btree) |
4569 | |
4570 | def test_get_file2(self): |
4571 | - """Get file contents, with patch-compatibile renames""" |
4572 | + """Get file contents, with patch-compatible renames""" |
4573 | btree = self.make_tree_3() |
4574 | btree.contents_by_id = False |
4575 | mod_patch = self.unified_diff([], ["Lemon\n"]) |
4576 | @@ -330,7 +345,7 @@ |
4577 | def test_delete(self): |
4578 | "Deletion by bundle" |
4579 | btree = self.make_tree_1()[0] |
4580 | - self.assertEqual(btree.get_file("c").read(), "Hello\n") |
4581 | + self.assertEqual(btree.get_file(btree.id2path("c")).read(), "Hello\n") |
4582 | btree.note_deletion("grandparent/parent/file") |
4583 | self.assertTrue(btree.id2path("c") is None) |
4584 | self.assertTrue(btree.path2id("grandparent/parent/file") is None) |
4585 | @@ -516,13 +531,14 @@ |
4586 | # Now check that the file contents are all correct |
4587 | for inventory_id in old.all_file_ids(): |
4588 | try: |
4589 | - old_file = old.get_file(inventory_id) |
4590 | + old_file = old.get_file(old.id2path(inventory_id)) |
4591 | except errors.NoSuchFile: |
4592 | continue |
4593 | if old_file is None: |
4594 | continue |
4595 | - self.assertEqual(old_file.read(), |
4596 | - new.get_file(inventory_id).read()) |
4597 | + self.assertEqual( |
4598 | + old_file.read(), |
4599 | + new.get_file(new.id2path(inventory_id)).read()) |
4600 | finally: |
4601 | new.unlock() |
4602 | old.unlock() |
4603 | @@ -582,10 +598,10 @@ |
4604 | |
4605 | for path, status, kind, fileid, entry in base_files: |
4606 | # Check that the meta information is the same |
4607 | - self.assertEqual(base_tree.get_file_size(fileid), |
4608 | - to_tree.get_file_size(fileid)) |
4609 | - self.assertEqual(base_tree.get_file_sha1(fileid), |
4610 | - to_tree.get_file_sha1(fileid)) |
4611 | + self.assertEqual(base_tree.get_file_size(path, fileid), |
4612 | + to_tree.get_file_size(to_tree.id2path(fileid))) |
4613 | + self.assertEqual(base_tree.get_file_sha1(path, fileid), |
4614 | + to_tree.get_file_sha1(to_tree.id2path(fileid))) |
4615 | # Check that the contents are the same |
4616 | # This is pretty expensive |
4617 | # self.assertEqual(base_tree.get_file(fileid).read(), |
4618 | @@ -712,7 +728,7 @@ |
4619 | if getattr(bundle, 'revision_tree', None) is not None: |
4620 | # Not all bundle formats supports revision_tree |
4621 | bund_tree = bundle.revision_tree(self.b1.repository, 'l@cset-0-1') |
4622 | - self.assertEqual(link_target, bund_tree.get_symlink_target(link_id)) |
4623 | + self.assertEqual(link_target, bund_tree.get_symlink_target(link_name)) |
4624 | |
4625 | tt = TreeTransform(self.tree1) |
4626 | trans_id = tt.trans_id_tree_file_id(link_id) |
4627 | @@ -726,7 +742,7 @@ |
4628 | # Not all bundle formats supports revision_tree |
4629 | bund_tree = bundle.revision_tree(self.b1.repository, 'l@cset-0-2') |
4630 | self.assertEqual(new_link_target, |
4631 | - bund_tree.get_symlink_target(link_id)) |
4632 | + bund_tree.get_symlink_target('link2')) |
4633 | |
4634 | tt = TreeTransform(self.tree1) |
4635 | trans_id = tt.trans_id_tree_file_id(link_id) |
4636 | @@ -965,7 +981,7 @@ |
4637 | self.tree1.commit('message', rev_id='revid1') |
4638 | bundle = self.get_valid_bundle('null:', 'revid1') |
4639 | tree = self.get_bundle_tree(bundle, 'revid1') |
4640 | - root_revision = tree.get_file_revision(tree.get_root_id()) |
4641 | + root_revision = tree.get_file_revision(u'', tree.get_root_id()) |
4642 | self.assertEqual('revid1', root_revision) |
4643 | |
4644 | def test_install_revisions(self): |
4645 | |
4646 | === modified file 'breezy/tests/test_bzrdir.py' |
4647 | --- breezy/tests/test_bzrdir.py 2017-10-27 00:18:42 +0000 |
4648 | +++ breezy/tests/test_bzrdir.py 2017-11-19 19:02:26 +0000 |
4649 | @@ -840,7 +840,9 @@ |
4650 | tree2.lock_read() |
4651 | self.addCleanup(tree2.unlock) |
4652 | self.assertPathExists('tree2/subtree/file') |
4653 | - self.assertEqual('tree-reference', tree2.kind('subtree-root')) |
4654 | + self.assertEqual( |
4655 | + 'tree-reference', |
4656 | + tree2.kind('subtree', 'subtree-root')) |
4657 | |
4658 | def test_cloning_metadir(self): |
4659 | """Ensure that cloning metadir is suitable""" |
4660 | |
4661 | === modified file 'breezy/tests/test_commit.py' |
4662 | --- breezy/tests/test_commit.py 2017-11-12 18:17:03 +0000 |
4663 | +++ breezy/tests/test_commit.py 2017-11-19 19:02:26 +0000 |
4664 | @@ -101,13 +101,13 @@ |
4665 | |
4666 | tree1 = b.repository.revision_tree(rev1) |
4667 | tree1.lock_read() |
4668 | - text = tree1.get_file_text(file_id) |
4669 | + text = tree1.get_file_text('hello') |
4670 | tree1.unlock() |
4671 | self.assertEqual('hello world', text) |
4672 | |
4673 | tree2 = b.repository.revision_tree(rev2) |
4674 | tree2.lock_read() |
4675 | - text = tree2.get_file_text(file_id) |
4676 | + text = tree2.get_file_text('hello') |
4677 | tree2.unlock() |
4678 | self.assertEqual('version 2', text) |
4679 | |
4680 | @@ -243,14 +243,14 @@ |
4681 | tree2.lock_read() |
4682 | self.addCleanup(tree2.unlock) |
4683 | self.assertTrue(tree2.has_filename('hello')) |
4684 | - self.assertEqual(tree2.get_file_text('hello-id'), 'hello') |
4685 | - self.assertEqual(tree2.get_file_text('buongia-id'), 'new text') |
4686 | + self.assertEqual(tree2.get_file_text('hello'), 'hello') |
4687 | + self.assertEqual(tree2.get_file_text('buongia'), 'new text') |
4688 | |
4689 | tree3 = b.repository.revision_tree('test@rev-3') |
4690 | tree3.lock_read() |
4691 | self.addCleanup(tree3.unlock) |
4692 | self.assertFalse(tree3.has_filename('hello')) |
4693 | - self.assertEqual(tree3.get_file_text('buongia-id'), 'new text') |
4694 | + self.assertEqual(tree3.get_file_text('buongia'), 'new text') |
4695 | |
4696 | def test_commit_rename(self): |
4697 | """Test commit of a revision where a file is renamed.""" |
4698 | @@ -268,18 +268,18 @@ |
4699 | tree1.lock_read() |
4700 | self.addCleanup(tree1.unlock) |
4701 | eq(tree1.id2path('hello-id'), 'hello') |
4702 | - eq(tree1.get_file_text('hello-id'), 'contents of hello\n') |
4703 | + eq(tree1.get_file_text('hello'), 'contents of hello\n') |
4704 | self.assertFalse(tree1.has_filename('fruity')) |
4705 | self.check_tree_shape(tree1, ['hello']) |
4706 | - eq(tree1.get_file_revision('hello-id'), 'test@rev-1') |
4707 | + eq(tree1.get_file_revision('hello'), 'test@rev-1') |
4708 | |
4709 | tree2 = b.repository.revision_tree('test@rev-2') |
4710 | tree2.lock_read() |
4711 | self.addCleanup(tree2.unlock) |
4712 | eq(tree2.id2path('hello-id'), 'fruity') |
4713 | - eq(tree2.get_file_text('hello-id'), 'contents of hello\n') |
4714 | + eq(tree2.get_file_text('fruity'), 'contents of hello\n') |
4715 | self.check_tree_shape(tree2, ['fruity']) |
4716 | - eq(tree2.get_file_revision('hello-id'), 'test@rev-2') |
4717 | + eq(tree2.get_file_revision('fruity'), 'test@rev-2') |
4718 | |
4719 | def test_reused_rev_id(self): |
4720 | """Test that a revision id cannot be reused in a branch""" |
4721 | @@ -646,11 +646,11 @@ |
4722 | timestamp_1ms = round(timestamp, 3) |
4723 | self.assertEqual(timestamp_1ms, timestamp) |
4724 | |
4725 | - def assertBasisTreeKind(self, kind, tree, file_id): |
4726 | + def assertBasisTreeKind(self, kind, tree, path): |
4727 | basis = tree.basis_tree() |
4728 | basis.lock_read() |
4729 | try: |
4730 | - self.assertEqual(kind, basis.kind(file_id)) |
4731 | + self.assertEqual(kind, basis.kind(path)) |
4732 | finally: |
4733 | basis.unlock() |
4734 | |
4735 | @@ -660,43 +660,43 @@ |
4736 | os.symlink('target', 'name') |
4737 | tree.add('name', 'a-file-id') |
4738 | tree.commit('Added a symlink') |
4739 | - self.assertBasisTreeKind('symlink', tree, 'a-file-id') |
4740 | + self.assertBasisTreeKind('symlink', tree, 'name') |
4741 | |
4742 | os.unlink('name') |
4743 | self.build_tree(['name']) |
4744 | tree.commit('Changed symlink to file') |
4745 | - self.assertBasisTreeKind('file', tree, 'a-file-id') |
4746 | + self.assertBasisTreeKind('file', tree, 'name') |
4747 | |
4748 | os.unlink('name') |
4749 | os.symlink('target', 'name') |
4750 | tree.commit('file to symlink') |
4751 | - self.assertBasisTreeKind('symlink', tree, 'a-file-id') |
4752 | + self.assertBasisTreeKind('symlink', tree, 'name') |
4753 | |
4754 | os.unlink('name') |
4755 | os.mkdir('name') |
4756 | tree.commit('symlink to directory') |
4757 | - self.assertBasisTreeKind('directory', tree, 'a-file-id') |
4758 | + self.assertBasisTreeKind('directory', tree, 'name') |
4759 | |
4760 | os.rmdir('name') |
4761 | os.symlink('target', 'name') |
4762 | tree.commit('directory to symlink') |
4763 | - self.assertBasisTreeKind('symlink', tree, 'a-file-id') |
4764 | + self.assertBasisTreeKind('symlink', tree, 'name') |
4765 | |
4766 | # prepare for directory <-> file tests |
4767 | os.unlink('name') |
4768 | os.mkdir('name') |
4769 | tree.commit('symlink to directory') |
4770 | - self.assertBasisTreeKind('directory', tree, 'a-file-id') |
4771 | + self.assertBasisTreeKind('directory', tree, 'name') |
4772 | |
4773 | os.rmdir('name') |
4774 | self.build_tree(['name']) |
4775 | tree.commit('Changed directory to file') |
4776 | - self.assertBasisTreeKind('file', tree, 'a-file-id') |
4777 | + self.assertBasisTreeKind('file', tree, 'name') |
4778 | |
4779 | os.unlink('name') |
4780 | os.mkdir('name') |
4781 | tree.commit('file to directory') |
4782 | - self.assertBasisTreeKind('directory', tree, 'a-file-id') |
4783 | + self.assertBasisTreeKind('directory', tree, 'name') |
4784 | |
4785 | def test_commit_unversioned_specified(self): |
4786 | """Commit should raise if specified files isn't in basis or worktree""" |
4787 | |
4788 | === modified file 'breezy/tests/test_commit_merge.py' |
4789 | --- breezy/tests/test_commit_merge.py 2017-07-30 23:53:38 +0000 |
4790 | +++ breezy/tests/test_commit_merge.py 2017-11-19 19:02:26 +0000 |
4791 | @@ -98,8 +98,8 @@ |
4792 | |
4793 | wty.commit('merge from x', rev_id='y@u-0-2', allow_pointless=False) |
4794 | tree = by.repository.revision_tree('y@u-0-2') |
4795 | - self.assertEqual(tree.get_file_revision('ecks-id'), 'x@u-0-1') |
4796 | - self.assertEqual(tree.get_file_revision('why-id'), 'y@u-0-1') |
4797 | + self.assertEqual(tree.get_file_revision('ecks'), 'x@u-0-1') |
4798 | + self.assertEqual(tree.get_file_revision('why'), 'y@u-0-1') |
4799 | |
4800 | check.check_dwim(bx.base, False, True, True) |
4801 | check.check_dwim(by.base, False, True, True) |
4802 | |
4803 | === modified file 'breezy/tests/test_diff.py' |
4804 | --- breezy/tests/test_diff.py 2017-11-12 13:53:51 +0000 |
4805 | +++ breezy/tests/test_diff.py 2017-11-19 19:02:26 +0000 |
4806 | @@ -700,10 +700,9 @@ |
4807 | |
4808 | def diff(self, file_id, old_path, new_path, old_kind, new_kind): |
4809 | self.to_file.write('was: ') |
4810 | - self.to_file.write(self.old_tree.get_file(file_id).read()) |
4811 | + self.to_file.write(self.old_tree.get_file(old_path).read()) |
4812 | self.to_file.write('is: ') |
4813 | - self.to_file.write(self.new_tree.get_file(file_id).read()) |
4814 | - pass |
4815 | + self.to_file.write(self.new_tree.get_file(new_path).read()) |
4816 | |
4817 | |
4818 | class TestDiffTree(tests.TestCaseWithTransport): |
4819 | @@ -728,17 +727,20 @@ |
4820 | self.new_tree.add('newdir') |
4821 | self.new_tree.add('newdir/newfile', 'file-id') |
4822 | differ = diff.DiffText(self.old_tree, self.new_tree, BytesIO()) |
4823 | - differ.diff_text('file-id', None, 'old label', 'new label') |
4824 | + differ.diff_text('olddir/oldfile', None, 'old label', |
4825 | + 'new label', 'file-id', None) |
4826 | self.assertEqual( |
4827 | '--- old label\n+++ new label\n@@ -1,1 +0,0 @@\n-old\n\n', |
4828 | differ.to_file.getvalue()) |
4829 | differ.to_file.seek(0) |
4830 | - differ.diff_text(None, 'file-id', 'old label', 'new label') |
4831 | + differ.diff_text(None, 'newdir/newfile', |
4832 | + 'old label', 'new label', None, 'file-id') |
4833 | self.assertEqual( |
4834 | '--- old label\n+++ new label\n@@ -0,0 +1,1 @@\n+new\n\n', |
4835 | differ.to_file.getvalue()) |
4836 | differ.to_file.seek(0) |
4837 | - differ.diff_text('file-id', 'file-id', 'old label', 'new label') |
4838 | + differ.diff_text('olddir/oldfile', 'newdir/newfile', |
4839 | + 'old label', 'new label', 'file-id', 'file-id') |
4840 | self.assertEqual( |
4841 | '--- old label\n+++ new label\n@@ -1,1 +1,1 @@\n-old\n+new\n\n', |
4842 | differ.to_file.getvalue()) |
4843 | @@ -1454,7 +1456,7 @@ |
4844 | diff_obj = diff.DiffFromTool(['python', '-c', |
4845 | 'print "@old_path @new_path"'], |
4846 | basis_tree, tree, output) |
4847 | - diff_obj._prepare_files('file-id', 'file', 'file') |
4848 | + diff_obj._prepare_files('file', 'file', file_id='file-id') |
4849 | # The old content should be readonly |
4850 | self.assertReadableByAttrib(diff_obj._root, 'old\\file', |
4851 | r'R.*old\\file$') |
4852 | @@ -1492,8 +1494,8 @@ |
4853 | old_tree, tree, output) |
4854 | self.addCleanup(diff_obj.finish) |
4855 | self.assertContainsRe(diff_obj._root, 'brz-diff-[^/]*') |
4856 | - old_path, new_path = diff_obj._prepare_files('file-id', 'oldname', |
4857 | - 'newname') |
4858 | + old_path, new_path = diff_obj._prepare_files( |
4859 | + 'oldname', 'newname', file_id='file-id') |
4860 | self.assertContainsRe(old_path, 'old/oldname$') |
4861 | self.assertEqual(315532800, os.stat(old_path).st_mtime) |
4862 | self.assertContainsRe(new_path, 'tree/newname$') |
4863 | @@ -1502,7 +1504,7 @@ |
4864 | if osutils.host_os_dereferences_symlinks(): |
4865 | self.assertTrue(os.path.samefile('tree/newname', new_path)) |
4866 | # make sure we can create files with the same parent directories |
4867 | - diff_obj._prepare_files('file2-id', 'oldname2', 'newname2') |
4868 | + diff_obj._prepare_files('oldname2', 'newname2', file_id='file2-id') |
4869 | |
4870 | |
4871 | class TestDiffFromToolEncodedFilename(tests.TestCaseWithTransport): |
4872 | |
4873 | === modified file 'breezy/tests/test_dirstate.py' |
4874 | --- breezy/tests/test_dirstate.py 2017-11-12 13:53:51 +0000 |
4875 | +++ breezy/tests/test_dirstate.py 2017-11-19 19:02:26 +0000 |
4876 | @@ -315,7 +315,7 @@ |
4877 | tree, state, expected = self.create_basic_dirstate() |
4878 | # Now we will just remove and add every file so we get an extra entry |
4879 | # per entry. Unversion in reverse order so we handle subdirs |
4880 | - tree.unversion(['f-id', 'b-c-id', 'e-id', 'd-id', 'c-id', 'b-id', 'a-id']) |
4881 | + tree.unversion(['f', 'b-c', 'b/d/e', 'b/d', 'b/c', 'b', 'a']) |
4882 | tree.add(['a', 'b', 'b/c', 'b/d', 'b/d/e', 'b-c', 'f'], |
4883 | ['a-id2', 'b-id2', 'c-id2', 'd-id2', 'e-id2', 'b-c-id2', 'f-id2']) |
4884 | |
4885 | @@ -1105,7 +1105,7 @@ |
4886 | try: |
4887 | tree1.add('') |
4888 | tree1.add(['a file'], ['file-id'], ['file']) |
4889 | - tree1.put_file_bytes_non_atomic('file-id', 'file-content') |
4890 | + tree1.put_file_bytes_non_atomic('a file', 'file-content') |
4891 | revid1 = tree1.commit('foo') |
4892 | finally: |
4893 | tree1.unlock() |
4894 | @@ -1113,7 +1113,7 @@ |
4895 | tree2 = memorytree.MemoryTree.create_on_branch(branch2) |
4896 | tree2.lock_write() |
4897 | try: |
4898 | - tree2.put_file_bytes_non_atomic('file-id', 'new file-content') |
4899 | + tree2.put_file_bytes_non_atomic('a file', 'new file-content') |
4900 | revid2 = tree2.commit('foo') |
4901 | root_id = tree2.get_root_id() |
4902 | finally: |
4903 | |
4904 | === modified file 'breezy/tests/test_fetch.py' |
4905 | --- breezy/tests/test_fetch.py 2017-11-16 00:39:04 +0000 |
4906 | +++ breezy/tests/test_fetch.py 2017-11-19 19:02:26 +0000 |
4907 | @@ -251,7 +251,7 @@ |
4908 | ('2-2', 'agreement\n')]: |
4909 | self.assertEqualDiff( |
4910 | br2.repository.revision_tree( |
4911 | - rev_id).get_file_text('this-file-id'), text) |
4912 | + rev_id).get_file_text('file'), text) |
4913 | |
4914 | |
4915 | class TestKnitToPackFetch(TestCaseWithTransport): |
4916 | |
4917 | === modified file 'breezy/tests/test_filter_tree.py' |
4918 | --- breezy/tests/test_filter_tree.py 2017-05-22 00:56:52 +0000 |
4919 | +++ breezy/tests/test_filter_tree.py 2017-11-19 19:02:26 +0000 |
4920 | @@ -44,10 +44,10 @@ |
4921 | def test_get_file_text(self): |
4922 | self.make_tree() |
4923 | self.assertEqual( |
4924 | - self.underlying_tree.get_file_text('hello-id'), |
4925 | + self.underlying_tree.get_file_text('hello'), |
4926 | 'hello world') |
4927 | self.assertEqual( |
4928 | - self.filter_tree.get_file_text('hello-id'), |
4929 | + self.filter_tree.get_file_text('hello'), |
4930 | 'HELLO WORLD') |
4931 | |
4932 | def test_tar_export_content_filter_tree(self): |
4933 | |
4934 | === modified file 'breezy/tests/test_foreign.py' |
4935 | --- breezy/tests/test_foreign.py 2017-11-12 13:53:51 +0000 |
4936 | +++ breezy/tests/test_foreign.py 2017-11-19 19:02:26 +0000 |
4937 | @@ -193,8 +193,8 @@ |
4938 | for revid in todo: |
4939 | rev = self.source.repository.get_revision(revid) |
4940 | tree = self.source.repository.revision_tree(revid) |
4941 | - def get_file_with_stat(file_id, path=None): |
4942 | - return (tree.get_file(file_id), None) |
4943 | + def get_file_with_stat(path, file_id=None): |
4944 | + return (tree.get_file(path, file_id), None) |
4945 | tree.get_file_with_stat = get_file_with_stat |
4946 | new_revid = self.target.mapping.revision_id_foreign_to_bzr( |
4947 | (str(rev.timestamp), str(rev.timezone), |
4948 | @@ -423,7 +423,7 @@ |
4949 | wt.commit('bla-a') |
4950 | root_id = wt.get_root_id() |
4951 | target = wt.controldir.sprout('br2').open_workingtree() |
4952 | - target.unversion(['bla-a']) |
4953 | + target.unversion(['bla']) |
4954 | target.add('bla', 'bla-b') |
4955 | target.commit('bla-b') |
4956 | target_basis = target.basis_tree() |
4957 | |
4958 | === modified file 'breezy/tests/test_memorytree.py' |
4959 | --- breezy/tests/test_memorytree.py 2017-06-10 00:17:06 +0000 |
4960 | +++ breezy/tests/test_memorytree.py 2017-11-19 19:02:26 +0000 |
4961 | @@ -49,7 +49,7 @@ |
4962 | tree.lock_read() |
4963 | self.assertEqual([rev_id], tree.get_parent_ids()) |
4964 | self.assertEqual('contents of foo\n', |
4965 | - tree.get_file(tree.path2id('foo')).read()) |
4966 | + tree.get_file('foo').read()) |
4967 | tree.unlock() |
4968 | |
4969 | def test_get_root_id(self): |
4970 | @@ -110,8 +110,8 @@ |
4971 | tree.lock_write() |
4972 | tree.add(['', 'foo'], ids=['root-id', 'foo-id'], |
4973 | kinds=['directory', 'file']) |
4974 | - tree.put_file_bytes_non_atomic('foo-id', 'barshoom') |
4975 | - self.assertEqual('barshoom', tree.get_file('foo-id').read()) |
4976 | + tree.put_file_bytes_non_atomic('foo', 'barshoom') |
4977 | + self.assertEqual('barshoom', tree.get_file('foo').read()) |
4978 | tree.unlock() |
4979 | |
4980 | def test_put_existing_file(self): |
4981 | @@ -120,9 +120,9 @@ |
4982 | tree.lock_write() |
4983 | tree.add(['', 'foo'], ids=['root-id', 'foo-id'], |
4984 | kinds=['directory', 'file']) |
4985 | - tree.put_file_bytes_non_atomic('foo-id', 'first-content') |
4986 | - tree.put_file_bytes_non_atomic('foo-id', 'barshoom') |
4987 | - self.assertEqual('barshoom', tree.get_file('foo-id').read()) |
4988 | + tree.put_file_bytes_non_atomic('foo', 'first-content') |
4989 | + tree.put_file_bytes_non_atomic('foo', 'barshoom') |
4990 | + self.assertEqual('barshoom', tree.get_file('foo').read()) |
4991 | tree.unlock() |
4992 | |
4993 | def test_add_in_subdir(self): |
4994 | @@ -139,7 +139,7 @@ |
4995 | tree.add(['adir/afile'], ['file-id'], ['file']) |
4996 | self.assertEqual('adir/afile', tree.id2path('file-id')) |
4997 | self.assertEqual('adir', tree.id2path('dir-id')) |
4998 | - tree.put_file_bytes_non_atomic('file-id', 'barshoom') |
4999 | + tree.put_file_bytes_non_atomic('adir/afile', 'barshoom') |
5000 |
The diff has been truncated for viewing.
Should have prerequ branch lp:~jelmer/brz/swap-arguments marked.
The new revisions all look good to me.