Merge lp:~jelmer/brz/remove-more-file-ids into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 7194
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/remove-more-file-ids
Merge into: lp:brz
Diff against target: 772 lines (+99/-119)
22 files modified
breezy/bundle/bundle_data.py (+1/-1)
breezy/bzr/inventorytree.py (+1/-1)
breezy/bzr/remote.py (+4/-4)
breezy/bzr/workingtree.py (+1/-1)
breezy/git/memorytree.py (+5/-5)
breezy/git/object_store.py (+12/-13)
breezy/git/remote.py (+2/-2)
breezy/git/tree.py (+1/-1)
breezy/hashcache.py (+1/-1)
breezy/memorytree.py (+12/-18)
breezy/merge.py (+19/-19)
breezy/mutabletree.py (+1/-1)
breezy/plugins/weave_fmt/test_repository.py (+1/-1)
breezy/tests/per_intertree/test_compare.py (+4/-8)
breezy/tests/per_repository_vf/test_repository.py (+4/-5)
breezy/tests/per_repository_vf/test_write_group.py (+1/-3)
breezy/tests/per_workingtree/test_parents.py (+4/-5)
breezy/tests/test_transform.py (+7/-7)
breezy/transform.py (+3/-5)
breezy/tree.py (+1/-4)
breezy/workingtree.py (+13/-13)
tools/win32/brz_postinstall.py (+1/-1)
To merge this branch: bzr merge lp:~jelmer/brz/remove-more-file-ids
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+358950@code.launchpad.net

Commit message

Stop actually accepting optional file_id in many Tree methods.

Description of the change

Stop actually accepting optional file_id in many Tree methods.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/bundle/bundle_data.py'
--- breezy/bundle/bundle_data.py 2018-11-16 18:33:17 +0000
+++ breezy/bundle/bundle_data.py 2018-11-18 01:05:05 +0000
@@ -682,7 +682,7 @@
682 old_path = self.old_path(path)682 old_path = self.old_path(path)
683 return self.base_tree.get_file_revision(old_path)683 return self.base_tree.get_file_revision(old_path)
684684
685 def get_size_and_sha1(self, new_path, file_id=None):685 def get_size_and_sha1(self, new_path):
686 """Return the size and sha1 hash of the given file id.686 """Return the size and sha1 hash of the given file id.
687 If the file was not locally modified, this is extracted687 If the file was not locally modified, this is extracted
688 from the base_tree. Rather than re-reading the file.688 from the base_tree. Rather than re-reading the file.
689689
=== modified file 'breezy/bzr/inventorytree.py'
--- breezy/bzr/inventorytree.py 2018-11-17 16:53:10 +0000
+++ breezy/bzr/inventorytree.py 2018-11-18 01:05:05 +0000
@@ -207,7 +207,7 @@
207 return self.root_inventory.iter_entries_by_dir(207 return self.root_inventory.iter_entries_by_dir(
208 specific_file_ids=inventory_file_ids)208 specific_file_ids=inventory_file_ids)
209209
210 def iter_child_entries(self, path, file_id=None):210 def iter_child_entries(self, path):
211 with self.lock_read():211 with self.lock_read():
212 ie = self._path2ie(path)212 ie = self._path2ie(path)
213 if ie.kind != 'directory':213 if ie.kind != 'directory':
214214
=== modified file 'breezy/bzr/remote.py'
--- breezy/bzr/remote.py 2018-11-17 16:53:10 +0000
+++ breezy/bzr/remote.py 2018-11-18 01:05:05 +0000
@@ -961,23 +961,23 @@
961 format, name, root, subdir, force_mtime=force_mtime)961 format, name, root, subdir, force_mtime=force_mtime)
962 return ret962 return ret
963963
964 def annotate_iter(self, path, file_id=None,964 def annotate_iter(self, path,
965 default_revision=_mod_revision.CURRENT_REVISION):965 default_revision=_mod_revision.CURRENT_REVISION):
966 """Return an iterator of revision_id, line tuples.966 """Return an iterator of revision_id, line tuples.
967967
968 For working trees (and mutable trees in general), the special968 For working trees (and mutable trees in general), the special
969 revision_id 'current:' will be used for lines that are new in this969 revision_id 'current:' will be used for lines that are new in this
970 tree, e.g. uncommitted changes.970 tree, e.g. uncommitted changes.
971 :param file_id: The file to produce an annotated version from
972 :param default_revision: For lines that don't match a basis, mark them971 :param default_revision: For lines that don't match a basis, mark them
973 with this revision id. Not all implementations will make use of972 with this revision id. Not all implementations will make use of
974 this value.973 this value.
975 """974 """
976 ret = self._repository._annotate_file_revision(975 ret = self._repository._annotate_file_revision(
977 self.get_revision_id(), path, file_id, default_revision)976 self.get_revision_id(), path, file_id=None,
977 default_revision=default_revision)
978 if ret is None:978 if ret is None:
979 return super(RemoteInventoryTree, self).annotate_iter(979 return super(RemoteInventoryTree, self).annotate_iter(
980 path, file_id, default_revision=default_revision)980 path, default_revision=default_revision)
981 return ret981 return ret
982982
983983
984984
=== modified file 'breezy/bzr/workingtree.py'
--- breezy/bzr/workingtree.py 2018-11-16 18:33:17 +0000
+++ breezy/bzr/workingtree.py 2018-11-18 01:05:05 +0000
@@ -1458,7 +1458,7 @@
1458 # indeed dirty. - RBC 200609071458 # indeed dirty. - RBC 20060907
1459 self._write_inventory(self._inventory)1459 self._write_inventory(self._inventory)
14601460
1461 def stored_kind(self, path, file_id=None):1461 def stored_kind(self, path):
1462 """See Tree.stored_kind"""1462 """See Tree.stored_kind"""
1463 return self._path2ie(path).kind1463 return self._path2ie(path).kind
14641464
14651465
=== modified file 'breezy/git/memorytree.py'
--- breezy/git/memorytree.py 2018-11-11 14:23:06 +0000
+++ breezy/git/memorytree.py 2018-11-18 01:05:05 +0000
@@ -73,7 +73,7 @@
73 if kinds[pos] is None:73 if kinds[pos] is None:
74 kinds[pos] = self.kind(f)74 kinds[pos] = self.kind(f)
7575
76 def put_file_bytes_non_atomic(self, path, bytes, file_id=None):76 def put_file_bytes_non_atomic(self, path, bytes):
77 """See MutableTree.put_file_bytes_non_atomic."""77 """See MutableTree.put_file_bytes_non_atomic."""
78 self._file_transport.put_bytes(path, bytes)78 self._file_transport.put_bytes(path, bytes)
7979
@@ -192,14 +192,14 @@
192 raise AssertionError('unknown type %d' % stat_val.st_mode)192 raise AssertionError('unknown type %d' % stat_val.st_mode)
193 return index_entry_from_stat(stat_val, blob.id, 0)193 return index_entry_from_stat(stat_val, blob.id, 0)
194194
195 def get_file_with_stat(self, path, file_id=None):195 def get_file_with_stat(self, path):
196 return (self.get_file(path, file_id), self._lstat(path))196 return (self.get_file(path), self._lstat(path))
197197
198 def get_file(self, path, file_id=None):198 def get_file(self, path):
199 """See Tree.get_file."""199 """See Tree.get_file."""
200 return self._file_transport.get(path)200 return self._file_transport.get(path)
201201
202 def get_file_sha1(self, path, file_id=None, stat_value=None):202 def get_file_sha1(self, path, stat_value=None):
203 """See Tree.get_file_sha1()."""203 """See Tree.get_file_sha1()."""
204 stream = self._file_transport.get(path)204 stream = self._file_transport.get(path)
205 return osutils.sha_file(stream)205 return osutils.sha_file(stream)
206206
=== modified file 'breezy/git/object_store.py'
--- breezy/git/object_store.py 2018-11-16 18:33:17 +0000
+++ breezy/git/object_store.py 2018-11-18 01:05:05 +0000
@@ -235,17 +235,17 @@
235 except errors.NoSuchId:235 except errors.NoSuchId:
236 pass236 pass
237 else:237 else:
238 pkind = ptree.kind(ppath, file_id)238 pkind = ptree.kind(ppath)
239 if kind == "file":239 if kind == "file":
240 if (pkind == "file" and240 if (pkind == "file" and
241 ptree.get_file_sha1(ppath, file_id) == other):241 ptree.get_file_sha1(ppath) == other):
242 return (242 return (
243 file_id, ptree.get_file_revision(ppath, file_id))243 file_id, ptree.get_file_revision(ppath))
244 if kind == "symlink":244 if kind == "symlink":
245 if (pkind == "symlink" and245 if (pkind == "symlink" and
246 ptree.get_symlink_target(ppath, file_id) == other):246 ptree.get_symlink_target(ppath) == other):
247 return (247 return (
248 file_id, ptree.get_file_revision(ppath, file_id))248 file_id, ptree.get_file_revision(ppath))
249 raise KeyError249 raise KeyError
250250
251 # Find all the changed blobs251 # Find all the changed blobs
@@ -254,7 +254,7 @@
254 if name[1] in BANNED_FILENAMES:254 if name[1] in BANNED_FILENAMES:
255 continue255 continue
256 if kind[1] == "file":256 if kind[1] == "file":
257 sha1 = tree.get_file_sha1(path[1], file_id)257 sha1 = tree.get_file_sha1(path[1])
258 blob_id = None258 blob_id = None
259 try:259 try:
260 (pfile_id, prevision) = find_unchanged_parent_ie(260 (pfile_id, prevision) = find_unchanged_parent_ie(
@@ -271,7 +271,7 @@
271 if not changed_content:271 if not changed_content:
272 # no-change merge ?272 # no-change merge ?
273 blob = Blob()273 blob = Blob()
274 blob.data = tree.get_file_text(path[1], file_id)274 blob.data = tree.get_file_text(path[1])
275 blob_id = blob.id275 blob_id = blob.id
276 if blob_id is None:276 if blob_id is None:
277 new_blobs.append((path[1], file_id))277 new_blobs.append((path[1], file_id))
@@ -282,7 +282,7 @@
282 ("blob", blob_id),282 ("blob", blob_id),
283 (file_id, tree.get_file_revision(path[1])), path[1])283 (file_id, tree.get_file_revision(path[1])), path[1])
284 elif kind[1] == "symlink":284 elif kind[1] == "symlink":
285 target = tree.get_symlink_target(path[1], file_id)285 target = tree.get_symlink_target(path[1])
286 blob = symlink_to_blob(target)286 blob = symlink_to_blob(target)
287 shamap[path[1]] = blob.id287 shamap[path[1]] = blob.id
288 if add_cache_entry is not None:288 if add_cache_entry is not None:
@@ -294,7 +294,7 @@
294 except KeyError:294 except KeyError:
295 if changed_content:295 if changed_content:
296 yield (path[1], blob,296 yield (path[1], blob,
297 (file_id, tree.get_file_revision(path[1], file_id)))297 (file_id, tree.get_file_revision(path[1])))
298 elif kind[1] is None:298 elif kind[1] is None:
299 shamap[path[1]] = None299 shamap[path[1]] = None
300 elif kind[1] != 'directory':300 elif kind[1] != 'directory':
@@ -338,7 +338,7 @@
338 except KeyError:338 except KeyError:
339 # no-change merge ?339 # no-change merge ?
340 blob = Blob()340 blob = Blob()
341 blob.data = tree.get_file_text(path, ie.file_id)341 blob.data = tree.get_file_text(path)
342 if add_cache_entry is not None:342 if add_cache_entry is not None:
343 add_cache_entry(blob, (ie.file_id, ie.revision), path)343 add_cache_entry(blob, (ie.file_id, ie.revision), path)
344 return blob.id344 return blob.id
@@ -593,9 +593,8 @@
593 # Perhaps it's a symlink ?593 # Perhaps it's a symlink ?
594 tree = self.tree_cache.revision_tree(revision)594 tree = self.tree_cache.revision_tree(revision)
595 path = tree.id2path(file_id)595 path = tree.id2path(file_id)
596 if tree.kind(path, file_id) == 'symlink':596 if tree.kind(path) == 'symlink':
597 blob = symlink_to_blob(597 blob = symlink_to_blob(tree.get_symlink_target(path))
598 tree.get_symlink_target(path, file_id))
599 _check_expected_sha(expected_sha, blob)598 _check_expected_sha(expected_sha, blob)
600 yield blob599 yield blob
601600
602601
=== modified file 'breezy/git/remote.py'
--- breezy/git/remote.py 2018-11-16 18:35:30 +0000
+++ breezy/git/remote.py 2018-11-18 01:05:05 +0000
@@ -816,13 +816,13 @@
816 f.seek(0)816 f.seek(0)
817 return osutils.file_iterator(f)817 return osutils.file_iterator(f)
818818
819 def is_versioned(self, path, file_id=None):819 def is_versioned(self, path):
820 raise GitSmartRemoteNotSupported(self.is_versioned, self)820 raise GitSmartRemoteNotSupported(self.is_versioned, self)
821821
822 def has_filename(self, path):822 def has_filename(self, path):
823 raise GitSmartRemoteNotSupported(self.has_filename, self)823 raise GitSmartRemoteNotSupported(self.has_filename, self)
824824
825 def get_file_text(self, path, file_id=None):825 def get_file_text(self, path):
826 raise GitSmartRemoteNotSupported(self.get_file_text, self)826 raise GitSmartRemoteNotSupported(self.get_file_text, self)
827827
828828
829829
=== modified file 'breezy/git/tree.py'
--- breezy/git/tree.py 2018-11-16 23:21:31 +0000
+++ breezy/git/tree.py 2018-11-18 01:05:05 +0000
@@ -461,7 +461,7 @@
461 file_id = self._fileid_map.lookup_file_id(path)461 file_id = self._fileid_map.lookup_file_id(path)
462 return GitTreeDirectory(file_id, posixpath.basename(path), parent_id)462 return GitTreeDirectory(file_id, posixpath.basename(path), parent_id)
463463
464 def iter_child_entries(self, path, file_id=None):464 def iter_child_entries(self, path):
465 (store, mode, tree_sha) = self._lookup_path(path)465 (store, mode, tree_sha) = self._lookup_path(path)
466466
467 if mode is not None and not stat.S_ISDIR(mode):467 if mode is not None and not stat.S_ISDIR(mode):
468468
=== modified file 'breezy/hashcache.py'
--- breezy/hashcache.py 2018-11-12 01:41:38 +0000
+++ breezy/hashcache.py 2018-11-18 01:05:05 +0000
@@ -173,7 +173,7 @@
173 if self._filter_provider is None:173 if self._filter_provider is None:
174 filters = []174 filters = []
175 else:175 else:
176 filters = self._filter_provider(path=path, file_id=None)176 filters = self._filter_provider(path=path)
177 digest = self._really_sha1_file(abspath, filters)177 digest = self._really_sha1_file(abspath, filters)
178 elif stat.S_ISLNK(mode):178 elif stat.S_ISLNK(mode):
179 target = osutils.readlink(abspath)179 target = osutils.readlink(abspath)
180180
=== modified file 'breezy/memorytree.py'
--- breezy/memorytree.py 2018-11-16 18:33:17 +0000
+++ breezy/memorytree.py 2018-11-18 01:05:05 +0000
@@ -85,11 +85,11 @@
85 missing files, so is a no-op.85 missing files, so is a no-op.
86 """86 """
8787
88 def get_file(self, path, file_id=None):88 def get_file(self, path):
89 """See Tree.get_file."""89 """See Tree.get_file."""
90 return self._file_transport.get(path)90 return self._file_transport.get(path)
9191
92 def get_file_sha1(self, path, file_id=None, stat_value=None):92 def get_file_sha1(self, path, stat_value=None):
93 """See Tree.get_file_sha1()."""93 """See Tree.get_file_sha1()."""
94 stream = self._file_transport.get(path)94 stream = self._file_transport.get(path)
95 return sha_file(stream)95 return sha_file(stream)
@@ -147,9 +147,8 @@
147 def is_executable(self, path):147 def is_executable(self, path):
148 return self._inventory.get_entry_by_path(path).executable148 return self._inventory.get_entry_by_path(path).executable
149149
150 def kind(self, path, file_id=None):150 def kind(self, path):
151 if file_id is None:151 file_id = self.path2id(path)
152 file_id = self.path2id(path)
153 return self._inventory[file_id].kind152 return self._inventory[file_id].kind
154153
155 def mkdir(self, path, file_id=None):154 def mkdir(self, path, file_id=None):
@@ -234,7 +233,7 @@
234 else:233 else:
235 raise NotImplementedError(self._populate_from_branch)234 raise NotImplementedError(self._populate_from_branch)
236235
237 def put_file_bytes_non_atomic(self, path, bytes, file_id=None):236 def put_file_bytes_non_atomic(self, path, bytes):
238 """See MutableTree.put_file_bytes_non_atomic."""237 """See MutableTree.put_file_bytes_non_atomic."""
239 self._file_transport.put_bytes(path, bytes)238 self._file_transport.put_bytes(path, bytes)
240239
@@ -256,7 +255,7 @@
256 else:255 else:
257 self._locks -= 1256 self._locks -= 1
258257
259 def unversion(self, paths, file_ids=None):258 def unversion(self, paths):
260 """Remove the paths from the current versioned set.259 """Remove the paths from the current versioned set.
261260
262 When a file_id is unversioned, all of its children are automatically261 When a file_id is unversioned, all of its children are automatically
@@ -269,17 +268,12 @@
269 # XXX: This should be in mutabletree, but the inventory-save action268 # XXX: This should be in mutabletree, but the inventory-save action
270 # is not relevant to memory tree. Until that is done in unlock by269 # is not relevant to memory tree. Until that is done in unlock by
271 # working tree, we cannot share the implementation.270 # working tree, we cannot share the implementation.
272 if file_ids is None:271 file_ids = set()
273 file_ids = set()272 for path in paths:
274 for path in paths:273 file_id = self.path2id(path)
275 file_id = self.path2id(path)274 if file_id is None:
276 if file_id is None:275 raise errors.NoSuchFile(path)
277 raise errors.NoSuchFile(path)276 file_ids.add(file_id)
278 file_ids.add(file_id)
279 else:
280 for file_id in file_ids:
281 if not self._inventory.has_id(file_id):
282 raise errors.NoSuchId(self, file_id)
283 for file_id in file_ids:277 for file_id in file_ids:
284 if self._inventory.has_id(file_id):278 if self._inventory.has_id(file_id):
285 self._inventory.remove_recursive_id(file_id)279 self._inventory.remove_recursive_id(file_id)
286280
=== modified file 'breezy/merge.py'
--- breezy/merge.py 2018-11-16 18:33:17 +0000
+++ breezy/merge.py 2018-11-18 01:05:05 +0000
@@ -250,17 +250,17 @@
250 @decorators.cachedproperty250 @decorators.cachedproperty
251 def base_lines(self):251 def base_lines(self):
252 """The lines of the 'base' version of the file."""252 """The lines of the 'base' version of the file."""
253 return self._merger.get_lines(self._merger.base_tree, self.base_path, self.file_id)253 return self._merger.get_lines(self._merger.base_tree, self.base_path)
254254
255 @decorators.cachedproperty255 @decorators.cachedproperty
256 def this_lines(self):256 def this_lines(self):
257 """The lines of the 'this' version of the file."""257 """The lines of the 'this' version of the file."""
258 return self._merger.get_lines(self._merger.this_tree, self.this_path, self.file_id)258 return self._merger.get_lines(self._merger.this_tree, self.this_path)
259259
260 @decorators.cachedproperty260 @decorators.cachedproperty
261 def other_lines(self):261 def other_lines(self):
262 """The lines of the 'other' version of the file."""262 """The lines of the 'other' version of the file."""
263 return self._merger.get_lines(self._merger.other_tree, self.other_path, self.file_id)263 return self._merger.get_lines(self._merger.other_tree, self.other_path)
264264
265265
266class Merger(object):266class Merger(object):
@@ -1080,42 +1080,42 @@
1080 self.working_tree.set_merge_modified(modified_hashes)1080 self.working_tree.set_merge_modified(modified_hashes)
10811081
1082 @staticmethod1082 @staticmethod
1083 def parent(entry, file_id):1083 def parent(entry):
1084 """Determine the parent for a file_id (used as a key method)"""1084 """Determine the parent for a file_id (used as a key method)"""
1085 if entry is None:1085 if entry is None:
1086 return None1086 return None
1087 return entry.parent_id1087 return entry.parent_id
10881088
1089 @staticmethod1089 @staticmethod
1090 def name(entry, file_id):1090 def name(entry):
1091 """Determine the name for a file_id (used as a key method)"""1091 """Determine the name for a file_id (used as a key method)"""
1092 if entry is None:1092 if entry is None:
1093 return None1093 return None
1094 return entry.name1094 return entry.name
10951095
1096 @staticmethod1096 @staticmethod
1097 def contents_sha1(tree, path, file_id=None):1097 def contents_sha1(tree, path):
1098 """Determine the sha1 of the file contents (used as a key method)."""1098 """Determine the sha1 of the file contents (used as a key method)."""
1099 try:1099 try:
1100 return tree.get_file_sha1(path, file_id)1100 return tree.get_file_sha1(path)
1101 except errors.NoSuchFile:1101 except errors.NoSuchFile:
1102 return None1102 return None
11031103
1104 @staticmethod1104 @staticmethod
1105 def executable(tree, path, file_id=None):1105 def executable(tree, path):
1106 """Determine the executability of a file-id (used as a key method)."""1106 """Determine the executability of a file-id (used as a key method)."""
1107 try:1107 try:
1108 if tree.kind(path, file_id) != "file":1108 if tree.kind(path) != "file":
1109 return False1109 return False
1110 except errors.NoSuchFile:1110 except errors.NoSuchFile:
1111 return None1111 return None
1112 return tree.is_executable(path)1112 return tree.is_executable(path)
11131113
1114 @staticmethod1114 @staticmethod
1115 def kind(tree, path, file_id=None):1115 def kind(tree, path):
1116 """Determine the kind of a file-id (used as a key method)."""1116 """Determine the kind of a file-id (used as a key method)."""
1117 try:1117 try:
1118 return tree.kind(path, file_id)1118 return tree.kind(path)
1119 except errors.NoSuchFile:1119 except errors.NoSuchFile:
1120 return None1120 return None
11211121
@@ -1400,7 +1400,7 @@
1400 else:1400 else:
1401 return 'not_applicable', None1401 return 'not_applicable', None
14021402
1403 def get_lines(self, tree, path, file_id=None):1403 def get_lines(self, tree, path):
1404 """Return the lines in a file, or an empty list."""1404 """Return the lines in a file, or an empty list."""
1405 if path is None:1405 if path is None:
1406 return []1406 return []
@@ -1418,9 +1418,9 @@
1418 # it's possible that we got here with base as a different type.1418 # it's possible that we got here with base as a different type.
1419 # if so, we just want two-way text conflicts.1419 # if so, we just want two-way text conflicts.
1420 base_path, other_path, this_path = paths1420 base_path, other_path, this_path = paths
1421 base_lines = self.get_lines(self.base_tree, base_path, file_id)1421 base_lines = self.get_lines(self.base_tree, base_path)
1422 other_lines = self.get_lines(self.other_tree, other_path, file_id)1422 other_lines = self.get_lines(self.other_tree, other_path)
1423 this_lines = self.get_lines(self.this_tree, this_path, file_id)1423 this_lines = self.get_lines(self.this_tree, this_path)
1424 m3 = merge3.Merge3(base_lines, this_lines, other_lines,1424 m3 = merge3.Merge3(base_lines, this_lines, other_lines,
1425 is_cherrypick=self.cherrypick)1425 is_cherrypick=self.cherrypick)
1426 start_marker = b"!START OF MERGE CONFLICT!" + b"I HOPE THIS IS UNIQUE"1426 start_marker = b"!START OF MERGE CONFLICT!" + b"I HOPE THIS IS UNIQUE"
@@ -1703,7 +1703,7 @@
17031703
1704 requires_file_merge_plan = False1704 requires_file_merge_plan = False
17051705
1706 def dump_file(self, temp_dir, name, tree, path, file_id=None):1706 def dump_file(self, temp_dir, name, tree, path):
1707 out_path = osutils.pathjoin(temp_dir, name)1707 out_path = osutils.pathjoin(temp_dir, name)
1708 with open(out_path, "wb") as out_file:1708 with open(out_path, "wb") as out_file:
1709 in_file = tree.get_file(path)1709 in_file = tree.get_file(path)
@@ -1722,11 +1722,11 @@
1722 try:1722 try:
1723 new_file = osutils.pathjoin(temp_dir, "new")1723 new_file = osutils.pathjoin(temp_dir, "new")
1724 this = self.dump_file(1724 this = self.dump_file(
1725 temp_dir, "this", self.this_tree, this_path, file_id)1725 temp_dir, "this", self.this_tree, this_path)
1726 base = self.dump_file(1726 base = self.dump_file(
1727 temp_dir, "base", self.base_tree, base_path, file_id)1727 temp_dir, "base", self.base_tree, base_path)
1728 other = self.dump_file(1728 other = self.dump_file(
1729 temp_dir, "other", self.other_tree, other_path, file_id)1729 temp_dir, "other", self.other_tree, other_path)
1730 status = breezy.patch.diff3(new_file, this, base, other)1730 status = breezy.patch.diff3(new_file, this, base, other)
1731 if status not in (0, 1):1731 if status not in (0, 1):
1732 raise errors.BzrError("Unhandled diff3 exit code")1732 raise errors.BzrError("Unhandled diff3 exit code")
17331733
=== modified file 'breezy/mutabletree.py'
--- breezy/mutabletree.py 2018-11-16 18:33:17 +0000
+++ breezy/mutabletree.py 2018-11-18 01:05:05 +0000
@@ -304,7 +304,7 @@
304 :return: None304 :return: None
305 """305 """
306306
307 def put_file_bytes_non_atomic(self, path, bytes, file_id=None):307 def put_file_bytes_non_atomic(self, path, bytes):
308 """Update the content of a file in the tree.308 """Update the content of a file in the tree.
309309
310 Note that the file is written in-place rather than being310 Note that the file is written in-place rather than being
311311
=== modified file 'breezy/plugins/weave_fmt/test_repository.py'
--- breezy/plugins/weave_fmt/test_repository.py 2018-11-11 04:08:32 +0000
+++ breezy/plugins/weave_fmt/test_repository.py 2018-11-18 01:05:05 +0000
@@ -143,7 +143,7 @@
143 control.create_branch()143 control.create_branch()
144 tree = control.create_workingtree()144 tree = control.create_workingtree()
145 tree.add(['foo'], [b'Foo:Bar'], ['file'])145 tree.add(['foo'], [b'Foo:Bar'], ['file'])
146 tree.put_file_bytes_non_atomic('foo', b'content\n', b'Foo:Bar')146 tree.put_file_bytes_non_atomic('foo', b'content\n')
147 try:147 try:
148 tree.commit('first post', rev_id=b'first')148 tree.commit('first post', rev_id=b'first')
149 except IllegalPath:149 except IllegalPath:
150150
=== modified file 'breezy/tests/per_intertree/test_compare.py'
--- breezy/tests/per_intertree/test_compare.py 2018-11-11 04:08:32 +0000
+++ breezy/tests/per_intertree/test_compare.py 2018-11-18 01:05:05 +0000
@@ -805,15 +805,13 @@
805 tree1.mkdir('changing', b'parent-id')805 tree1.mkdir('changing', b'parent-id')
806 tree1.mkdir('changing/unchanging', b'mid-id')806 tree1.mkdir('changing/unchanging', b'mid-id')
807 tree1.add(['changing/unchanging/file'], [b'file-id'], ['file'])807 tree1.add(['changing/unchanging/file'], [b'file-id'], ['file'])
808 tree1.put_file_bytes_non_atomic(808 tree1.put_file_bytes_non_atomic('changing/unchanging/file', b'a file')
809 'changing/unchanging/file', b'a file', file_id=b'file-id')
810 tree2 = self.make_to_branch_and_tree('2')809 tree2 = self.make_to_branch_and_tree('2')
811 tree2.set_root_id(tree1.get_root_id())810 tree2.set_root_id(tree1.get_root_id())
812 tree2.mkdir('changed', b'parent-id')811 tree2.mkdir('changed', b'parent-id')
813 tree2.mkdir('changed/unchanging', b'mid-id')812 tree2.mkdir('changed/unchanging', b'mid-id')
814 tree2.add(['changed/unchanging/file'], [b'file-id'], ['file'])813 tree2.add(['changed/unchanging/file'], [b'file-id'], ['file'])
815 tree2.put_file_bytes_non_atomic(814 tree2.put_file_bytes_non_atomic('changed/unchanging/file', b'changed content')
816 'changed/unchanging/file', b'changed content', file_id=b'file-id')
817 tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)815 tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
818 # parent-id has changed, as has file-id816 # parent-id has changed, as has file-id
819 root_id = tree1.path2id('')817 root_id = tree1.path2id('')
@@ -832,16 +830,14 @@
832 tree1.mkdir('changed', b'parent-id')830 tree1.mkdir('changed', b'parent-id')
833 tree1.mkdir('changed/unchanging', b'mid-id')831 tree1.mkdir('changed/unchanging', b'mid-id')
834 tree1.add(['changed/unchanging/file'], [b'file-id'], ['file'])832 tree1.add(['changed/unchanging/file'], [b'file-id'], ['file'])
835 tree1.put_file_bytes_non_atomic(833 tree1.put_file_bytes_non_atomic('changed/unchanging/file', b'a file')
836 'changed/unchanging/file', b'a file',
837 b'file-id')
838 tree2 = self.make_to_branch_and_tree('2')834 tree2 = self.make_to_branch_and_tree('2')
839 tree2.set_root_id(b'new')835 tree2.set_root_id(b'new')
840 tree2.mkdir('changed', b'parent-id')836 tree2.mkdir('changed', b'parent-id')
841 tree2.mkdir('changed/unchanging', b'mid-id')837 tree2.mkdir('changed/unchanging', b'mid-id')
842 tree2.add(['changed/unchanging/file'], [b'file-id'], ['file'])838 tree2.add(['changed/unchanging/file'], [b'file-id'], ['file'])
843 tree2.put_file_bytes_non_atomic(839 tree2.put_file_bytes_non_atomic(
844 'changed/unchanging/file', b'changed content', file_id=b'file-id')840 'changed/unchanging/file', b'changed content')
845 tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)841 tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
846 # old is gone, new is added, parent-id has changed(reparented), as has842 # old is gone, new is added, parent-id has changed(reparented), as has
847 # file-id(content)843 # file-id(content)
848844
=== modified file 'breezy/tests/per_repository_vf/test_repository.py'
--- breezy/tests/per_repository_vf/test_repository.py 2018-11-11 04:08:32 +0000
+++ breezy/tests/per_repository_vf/test_repository.py 2018-11-18 01:05:05 +0000
@@ -271,8 +271,7 @@
271 with tree.lock_write():271 with tree.lock_write():
272 self.assertEqual(set(), set(repo.texts.keys()))272 self.assertEqual(set(), set(repo.texts.keys()))
273 tree.add(['foo'], [file_id], ['file'])273 tree.add(['foo'], [file_id], ['file'])
274 tree.put_file_bytes_non_atomic(274 tree.put_file_bytes_non_atomic('foo', b'content\n')
275 'foo', b'content\n', file_id=file_id)
276 try:275 try:
277 rev_key = (tree.commit("foo"),)276 rev_key = (tree.commit("foo"),)
278 except errors.IllegalPath:277 except errors.IllegalPath:
@@ -293,16 +292,16 @@
293 repo.texts.get_parent_map(repo.texts.keys()))292 repo.texts.get_parent_map(repo.texts.keys()))
294 tree2 = self.make_branch_and_tree('tree2')293 tree2 = self.make_branch_and_tree('tree2')
295 tree2.pull(tree.branch)294 tree2.pull(tree.branch)
296 tree2.put_file_bytes_non_atomic('foo', b'right\n', file_id=b'Foo:Bar')295 tree2.put_file_bytes_non_atomic('foo', b'right\n')
297 right_key = (tree2.commit('right'),)296 right_key = (tree2.commit('right'),)
298 keys.add(file_key + right_key)297 keys.add(file_key + right_key)
299 parents[file_key + right_key] = (file_key + rev_key,)298 parents[file_key + right_key] = (file_key + rev_key,)
300 tree.put_file_bytes_non_atomic('foo', b'left\n', file_id=b'Foo:Bar')299 tree.put_file_bytes_non_atomic('foo', b'left\n')
301 left_key = (tree.commit('left'),)300 left_key = (tree.commit('left'),)
302 keys.add(file_key + left_key)301 keys.add(file_key + left_key)
303 parents[file_key + left_key] = (file_key + rev_key,)302 parents[file_key + left_key] = (file_key + rev_key,)
304 tree.merge_from_branch(tree2.branch)303 tree.merge_from_branch(tree2.branch)
305 tree.put_file_bytes_non_atomic('foo', b'merged\n', file_id=b'Foo:Bar')304 tree.put_file_bytes_non_atomic('foo', b'merged\n')
306 try:305 try:
307 tree.auto_resolve()306 tree.auto_resolve()
308 except errors.UnsupportedOperation:307 except errors.UnsupportedOperation:
309308
=== modified file 'breezy/tests/per_repository_vf/test_write_group.py'
--- breezy/tests/per_repository_vf/test_write_group.py 2018-11-11 04:08:32 +0000
+++ breezy/tests/per_repository_vf/test_write_group.py 2018-11-18 01:05:05 +0000
@@ -70,9 +70,7 @@
70 tree.add([''], [b'TREE_ROOT'], ['directory'])70 tree.add([''], [b'TREE_ROOT'], ['directory'])
71 tree.add(['dir'], [b'dir-id'], ['directory'])71 tree.add(['dir'], [b'dir-id'], ['directory'])
72 tree.add(['filename'], [b'file-id'], ['file'])72 tree.add(['filename'], [b'file-id'], ['file'])
73 tree.put_file_bytes_non_atomic(73 tree.put_file_bytes_non_atomic('filename', b'content\n')
74 'filename', b'content\n',
75 file_id=b'file-id')
76 tree.commit('Trunk commit', rev_id=b'rev-0')74 tree.commit('Trunk commit', rev_id=b'rev-0')
77 tree.commit('Trunk commit', rev_id=b'rev-1')75 tree.commit('Trunk commit', rev_id=b'rev-1')
78 tree.unlock()76 tree.unlock()
7977
=== modified file 'breezy/tests/per_workingtree/test_parents.py'
--- breezy/tests/per_workingtree/test_parents.py 2018-11-11 04:08:32 +0000
+++ breezy/tests/per_workingtree/test_parents.py 2018-11-18 01:05:05 +0000
@@ -442,16 +442,15 @@
442 self._repository = tree.branch.repository442 self._repository = tree.branch.repository
443 self._inventory = shape443 self._inventory = shape
444444
445 def get_file_text(self, path, file_id=None):445 def get_file_text(self, path):
446 if file_id is None:446 file_id = self.path2id(path)
447 file_id = self.path2id(path)
448 ie = self.root_inventory.get_entry(file_id)447 ie = self.root_inventory.get_entry(file_id)
449 if ie.kind != "file":448 if ie.kind != "file":
450 return b""449 return b""
451 return b'a' * ie.text_size450 return b'a' * ie.text_size
452451
453 def get_file(self, path, file_id=None):452 def get_file(self, path):
454 return BytesIO(self.get_file_text(path, file_id))453 return BytesIO(self.get_file_text(path))
455454
456 with tree.lock_write():455 with tree.lock_write():
457 if shape.root.revision is None:456 if shape.root.revision is None:
458457
=== modified file 'breezy/tests/test_transform.py'
--- breezy/tests/test_transform.py 2018-11-16 18:33:17 +0000
+++ breezy/tests/test_transform.py 2018-11-18 01:05:05 +0000
@@ -2094,16 +2094,16 @@
2094 calls = []2094 calls = []
2095 real_source_get_file = source.get_file2095 real_source_get_file = source.get_file
20962096
2097 def get_file(path, file_id=None):2097 def get_file(path):
2098 calls.append(file_id)2098 calls.append(path)
2099 return real_source_get_file(path, file_id)2099 return real_source_get_file(path)
2100 source.get_file = get_file2100 source.get_file = get_file
2101 target = self.make_branch_and_tree('target')2101 target = self.make_branch_and_tree('target')
2102 revision_tree = source.basis_tree()2102 revision_tree = source.basis_tree()
2103 revision_tree.lock_read()2103 revision_tree.lock_read()
2104 self.addCleanup(revision_tree.unlock)2104 self.addCleanup(revision_tree.unlock)
2105 build_tree(revision_tree, target, source)2105 build_tree(revision_tree, target, source)
2106 self.assertEqual([b'file1-id'], calls)2106 self.assertEqual(['file1'], calls)
2107 target.lock_read()2107 target.lock_read()
2108 self.addCleanup(target.unlock)2108 self.addCleanup(target.unlock)
2109 self.assertEqual([], list(target.iter_changes(revision_tree)))2109 self.assertEqual([], list(target.iter_changes(revision_tree)))
@@ -2147,9 +2147,9 @@
2147 calls = []2147 calls = []
2148 real_source_get_file = source.get_file2148 real_source_get_file = source.get_file
21492149
2150 def get_file(path, file_id=None):2150 def get_file(path):
2151 calls.append(file_id)2151 calls.append(path)
2152 return real_source_get_file(path, file_id)2152 return real_source_get_file(path)
2153 source.get_file = get_file2153 source.get_file = get_file
2154 target = self.make_branch_and_tree('target')2154 target = self.make_branch_and_tree('target')
2155 revision_tree = source.basis_tree()2155 revision_tree = source.basis_tree()
21562156
=== modified file 'breezy/transform.py'
--- breezy/transform.py 2018-11-16 23:21:31 +0000
+++ breezy/transform.py 2018-11-18 01:05:05 +0000
@@ -1796,8 +1796,7 @@
1796 continue1796 continue
1797 kind = self.final_kind(trans_id)1797 kind = self.final_kind(trans_id)
1798 if kind is None:1798 if kind is None:
1799 kind = self._tree.stored_kind(1799 kind = self._tree.stored_kind(self._tree.id2path(file_id))
1800 self._tree.id2path(file_id), file_id)
1801 parent_trans_id = self.final_parent(trans_id)1800 parent_trans_id = self.final_parent(trans_id)
1802 parent_file_id = new_path_file_ids.get(parent_trans_id)1801 parent_file_id = new_path_file_ids.get(parent_trans_id)
1803 if parent_file_id is None:1802 if parent_file_id is None:
@@ -2167,8 +2166,7 @@
2167 kind = self._transform.final_kind(trans_id)2166 kind = self._transform.final_kind(trans_id)
2168 if kind is None:2167 if kind is None:
2169 kind = self._transform._tree.stored_kind(2168 kind = self._transform._tree.stored_kind(
2170 self._transform._tree.id2path(file_id),2169 self._transform._tree.id2path(file_id))
2171 file_id)
2172 new_entry = inventory.make_entry(2170 new_entry = inventory.make_entry(
2173 kind,2171 kind,
2174 self._transform.final_name(trans_id),2172 self._transform.final_name(trans_id),
@@ -2709,7 +2707,7 @@
2709 tt.create_hardlink(accelerator_tree.abspath(accelerator_path),2707 tt.create_hardlink(accelerator_tree.abspath(accelerator_path),
2710 trans_id)2708 trans_id)
2711 else:2709 else:
2712 with accelerator_tree.get_file(accelerator_path, file_id) as f:2710 with accelerator_tree.get_file(accelerator_path) as f:
2713 chunks = osutils.file_iterator(f)2711 chunks = osutils.file_iterator(f)
2714 if wt.supports_content_filtering():2712 if wt.supports_content_filtering():
2715 filters = wt._content_filter_stack(tree_path)2713 filters = wt._content_filter_stack(tree_path)
27162714
=== modified file 'breezy/tree.py'
--- breezy/tree.py 2018-11-16 18:40:46 +0000
+++ breezy/tree.py 2018-11-18 01:05:05 +0000
@@ -1352,25 +1352,22 @@
1352 :return: The canonical path1352 :return: The canonical path
1353 """1353 """
1354 # go walkin...1354 # go walkin...
1355 cur_id = tree.get_root_id()
1356 cur_path = ''1355 cur_path = ''
1357 bit_iter = iter(path.split("/"))1356 bit_iter = iter(path.split("/"))
1358 for elt in bit_iter:1357 for elt in bit_iter:
1359 lelt = normalize(elt)1358 lelt = normalize(elt)
1360 new_path = None1359 new_path = None
1361 try:1360 try:
1362 for child in tree.iter_child_entries(cur_path, cur_id):1361 for child in tree.iter_child_entries(cur_path):
1363 try:1362 try:
1364 if child.name == elt:1363 if child.name == elt:
1365 # if we found an exact match, we can stop now; if1364 # if we found an exact match, we can stop now; if
1366 # we found an approximate match we need to keep1365 # we found an approximate match we need to keep
1367 # searching because there might be an exact match1366 # searching because there might be an exact match
1368 # later.1367 # later.
1369 cur_id = child.file_id
1370 new_path = osutils.pathjoin(cur_path, child.name)1368 new_path = osutils.pathjoin(cur_path, child.name)
1371 break1369 break
1372 elif normalize(child.name) == lelt:1370 elif normalize(child.name) == lelt:
1373 cur_id = child.file_id
1374 new_path = osutils.pathjoin(cur_path, child.name)1371 new_path = osutils.pathjoin(cur_path, child.name)
1375 except errors.NoSuchId:1372 except errors.NoSuchId:
1376 # before a change is committed we can see this error...1373 # before a change is committed we can see this error...
13771374
=== modified file 'breezy/workingtree.py'
--- breezy/workingtree.py 2018-11-16 18:33:17 +0000
+++ breezy/workingtree.py 2018-11-18 01:05:05 +0000
@@ -362,10 +362,10 @@
362 def has_filename(self, filename):362 def has_filename(self, filename):
363 return osutils.lexists(self.abspath(filename))363 return osutils.lexists(self.abspath(filename))
364364
365 def get_file(self, path, file_id=None, filtered=True):365 def get_file(self, path, filtered=True):
366 return self.get_file_with_stat(path, file_id, filtered=filtered)[0]366 return self.get_file_with_stat(path, filtered=filtered)[0]
367367
368 def get_file_with_stat(self, path, file_id=None, filtered=True,368 def get_file_with_stat(self, path, filtered=True,
369 _fstat=osutils.fstat):369 _fstat=osutils.fstat):
370 """See Tree.get_file_with_stat."""370 """See Tree.get_file_with_stat."""
371 abspath = self.abspath(path)371 abspath = self.abspath(path)
@@ -381,13 +381,13 @@
381 file_obj = _mod_filters.filtered_input_file(file_obj, filters)381 file_obj = _mod_filters.filtered_input_file(file_obj, filters)
382 return (file_obj, stat_value)382 return (file_obj, stat_value)
383383
384 def get_file_text(self, path, file_id=None, filtered=True):384 def get_file_text(self, path, filtered=True):
385 with self.get_file(path, file_id, filtered=filtered) as my_file:385 with self.get_file(path, filtered=filtered) as my_file:
386 return my_file.read()386 return my_file.read()
387387
388 def get_file_lines(self, path, file_id=None, filtered=True):388 def get_file_lines(self, path, filtered=True):
389 """See Tree.get_file_lines()"""389 """See Tree.get_file_lines()"""
390 with self.get_file(path, file_id, filtered=filtered) as file:390 with self.get_file(path, filtered=filtered) as file:
391 return file.readlines()391 return file.readlines()
392392
393 def get_parent_ids(self):393 def get_parent_ids(self):
@@ -456,7 +456,7 @@
456 new_parents = [revision_id]456 new_parents = [revision_id]
457 tree.set_parent_ids(new_parents)457 tree.set_parent_ids(new_parents)
458458
459 def get_file_size(self, path, file_id=None):459 def get_file_size(self, path):
460 """See Tree.get_file_size"""460 """See Tree.get_file_size"""
461 # XXX: this returns the on-disk size; it should probably return the461 # XXX: this returns the on-disk size; it should probably return the
462 # canonical size462 # canonical size
@@ -719,7 +719,7 @@
719 self.add(path, file_id, 'directory')719 self.add(path, file_id, 'directory')
720 return file_id720 return file_id
721721
722 def get_symlink_target(self, path, file_id=None):722 def get_symlink_target(self, path):
723 abspath = self.abspath(path)723 abspath = self.abspath(path)
724 target = osutils.readlink(abspath)724 target = osutils.readlink(abspath)
725 return target725 return target
@@ -753,7 +753,7 @@
753 # checkout in a subdirectory. This can be avoided by not adding753 # checkout in a subdirectory. This can be avoided by not adding
754 # it. mbp 20070306754 # it. mbp 20070306
755755
756 def extract(self, path, file_id=None, format=None):756 def extract(self, path, format=None):
757 """Extract a subtree from this tree.757 """Extract a subtree from this tree.
758758
759 A new branch will be created, relative to the path for this tree.759 A new branch will be created, relative to the path for this tree.
@@ -764,7 +764,7 @@
764 """Write the in memory meta data to disk."""764 """Write the in memory meta data to disk."""
765 raise NotImplementedError(self.flush)765 raise NotImplementedError(self.flush)
766766
767 def kind(self, relpath, file_id=None):767 def kind(self, relpath):
768 return osutils.file_kind(self.abspath(relpath))768 return osutils.file_kind(self.abspath(relpath))
769769
770 def list_files(self, include_root=False, from_dir=None, recursive=True):770 def list_files(self, include_root=False, from_dir=None, recursive=True):
@@ -900,7 +900,7 @@
900 self.set_parent_trees(parent_trees)900 self.set_parent_trees(parent_trees)
901 return count901 return count
902902
903 def put_file_bytes_non_atomic(self, path, bytes, file_id=None):903 def put_file_bytes_non_atomic(self, path, bytes):
904 """See MutableTree.put_file_bytes_non_atomic."""904 """See MutableTree.put_file_bytes_non_atomic."""
905 with self.lock_write(), open(self.abspath(path), 'wb') as stream:905 with self.lock_write(), open(self.abspath(path), 'wb') as stream:
906 stream.write(bytes)906 stream.write(bytes)
@@ -929,7 +929,7 @@
929 """929 """
930 raise NotImplementedError(self.is_ignored)930 raise NotImplementedError(self.is_ignored)
931931
932 def stored_kind(self, path, file_id=None):932 def stored_kind(self, path):
933 """See Tree.stored_kind"""933 """See Tree.stored_kind"""
934 raise NotImplementedError(self.stored_kind)934 raise NotImplementedError(self.stored_kind)
935935
936936
=== modified file 'tools/win32/brz_postinstall.py'
--- tools/win32/brz_postinstall.py 2018-11-17 17:37:42 +0000
+++ tools/win32/brz_postinstall.py 2018-11-18 01:05:05 +0000
@@ -305,7 +305,7 @@
305 'EnvironmentError',305 'EnvironmentError',
306 MB_OK | MB_ICONERROR)306 MB_OK | MB_ICONERROR)
307307
308 if hkey not is None:308 if hkey is not None:
309 _winreg.SetValue(hkey, '', _winreg.REG_SZ, 'Brz Here')309 _winreg.SetValue(hkey, '', _winreg.REG_SZ, 'Brz Here')
310 hkey2 = _winreg.CreateKey(hkey, 'command')310 hkey2 = _winreg.CreateKey(hkey, 'command')
311 _winreg.SetValue(hkey2, '', _winreg.REG_SZ,311 _winreg.SetValue(hkey2, '', _winreg.REG_SZ,

Subscribers

People subscribed via source and target branches