Merge lp:~jelmer/brz/objects-2b into lp:brz

Proposed by Jelmer Vernooij on 2019-06-17
Status: Merged
Approved by: Jelmer Vernooij on 2019-06-22
Approved revision: 7351
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/objects-2b
Merge into: lp:brz
Diff against target: 178 lines (+23/-24)
6 files modified
breezy/conflicts.py (+1/-1)
breezy/merge.py (+14/-14)
breezy/shelf.py (+2/-3)
breezy/tests/test_transform.py (+4/-5)
breezy/transform.py (+1/-1)
breezy/tree.py (+1/-0)
To merge this branch: bzr merge lp:~jelmer/brz/objects-2b
Reviewer Review Type Date Requested Status
Martin Packman 2019-06-17 Approve on 2019-06-21
Review via email: mp+368930@code.launchpad.net

Commit message

Remove file_id from transform's create_from_tree, get filter tree paths by path.

Description of the change

Remove file_id from transform's create_from_tree, get filter tree paths by path.

To post a comment you must log in.
Martin Packman (gz) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/conflicts.py'
2--- breezy/conflicts.py 2018-11-11 04:08:32 +0000
3+++ breezy/conflicts.py 2019-06-17 18:22:03 +0000
4@@ -525,7 +525,7 @@
5 tid = tt.trans_id_tree_path(path_to_create)
6 tree = self._revision_tree(tt._tree, revid)
7 transform.create_from_tree(
8- tt, tid, tree, tree.id2path(file_id), file_id=file_id)
9+ tt, tid, tree, tree.id2path(file_id))
10 tt.version_file(file_id, tid)
11 else:
12 tid = tt.trans_id_file_id(file_id)
13
14=== modified file 'breezy/merge.py'
15--- breezy/merge.py 2019-06-15 12:04:34 +0000
16+++ breezy/merge.py 2019-06-17 18:22:03 +0000
17@@ -1307,8 +1307,8 @@
18 self.tt.version_file(file_id, trans_id)
19 transform.create_from_tree(
20 self.tt, trans_id, self.other_tree,
21- other_path, file_id=file_id,
22- filter_tree_path=self._get_filter_tree_path(file_id))
23+ other_path,
24+ filter_tree_path=self._get_filter_tree_path(other_path))
25 inhibit_content_conflict = True
26 elif params.other_kind is None: # file_id is not in OTHER
27 # Is the name used for a different file_id ?
28@@ -1360,14 +1360,13 @@
29
30 def _default_other_winner_merge(self, merge_hook_params):
31 """Replace this contents with other."""
32- file_id = merge_hook_params.file_id
33 trans_id = merge_hook_params.trans_id
34 if merge_hook_params.other_path is not None:
35 # OTHER changed the file
36 transform.create_from_tree(
37 self.tt, trans_id, self.other_tree,
38- merge_hook_params.other_path, file_id=file_id,
39- filter_tree_path=self._get_filter_tree_path(file_id))
40+ merge_hook_params.other_path,
41+ filter_tree_path=self._get_filter_tree_path(merge_hook_params.other_path))
42 return 'done', None
43 elif merge_hook_params.this_path is not None:
44 # OTHER deleted the file
45@@ -1452,17 +1451,18 @@
46 other_lines)
47 file_group.append(trans_id)
48
49- def _get_filter_tree_path(self, file_id):
50+ def _get_filter_tree_path(self, path):
51 if self.this_tree.supports_content_filtering():
52 # We get the path from the working tree if it exists.
53 # That fails though when OTHER is adding a file, so
54 # we fall back to the other tree to find the path if
55 # it doesn't exist locally.
56- try:
57- return self.this_tree.id2path(file_id)
58- except errors.NoSuchId:
59- return self.other_tree.id2path(file_id)
60- # Skip the id2path lookup for older formats
61+ filter_path = _mod_tree.find_previous_path(
62+ self.other_tree, self.working_tree, path)
63+ if filter_path is None:
64+ filter_path = path
65+ return filter_path
66+ # Skip the lookup for older formats
67 return None
68
69 def _dump_conflicts(self, name, paths, parent_id, file_id, this_lines=None,
70@@ -1497,7 +1497,7 @@
71 for suffix, tree, path, lines in data:
72 if path is not None:
73 trans_id = self._conflict_file(
74- name, parent_id, path, tree, file_id, suffix, lines,
75+ name, parent_id, path, tree, suffix, lines,
76 filter_tree_path)
77 file_group.append(trans_id)
78 if set_version and not versioned:
79@@ -1505,14 +1505,14 @@
80 versioned = True
81 return file_group
82
83- def _conflict_file(self, name, parent_id, path, tree, file_id, suffix,
84+ def _conflict_file(self, name, parent_id, path, tree, suffix,
85 lines=None, filter_tree_path=None):
86 """Emit a single conflict file."""
87 name = name + '.' + suffix
88 trans_id = self.tt.create_path(name, parent_id)
89 transform.create_from_tree(
90 self.tt, trans_id, tree, path,
91- file_id=file_id, chunks=lines,
92+ chunks=lines,
93 filter_tree_path=filter_tree_path)
94 return trans_id
95
96
97=== modified file 'breezy/shelf.py'
98--- breezy/shelf.py 2019-06-15 12:04:34 +0000
99+++ breezy/shelf.py 2019-06-17 18:22:03 +0000
100@@ -208,8 +208,7 @@
101 def _content_from_tree(tt, tree, file_id):
102 trans_id = tt.trans_id_file_id(file_id)
103 tt.delete_contents(trans_id)
104- transform.create_from_tree(tt, trans_id, tree, tree.id2path(file_id),
105- file_id)
106+ transform.create_from_tree(tt, trans_id, tree, tree.id2path(file_id))
107
108 def shelve_content_change(self, file_id):
109 """Shelve a kind change or binary file content change.
110@@ -267,7 +266,7 @@
111 else:
112 transform.create_from_tree(
113 to_transform, s_trans_id, tree,
114- tree.id2path(file_id), file_id)
115+ tree.id2path(file_id))
116 if version:
117 to_transform.version_file(file_id, s_trans_id)
118
119
120=== modified file 'breezy/tests/test_transform.py'
121--- breezy/tests/test_transform.py 2019-06-15 15:59:17 +0000
122+++ breezy/tests/test_transform.py 2019-06-17 18:22:03 +0000
123@@ -1666,9 +1666,9 @@
124 tree2 = self.make_branch_and_tree('tree2')
125 tt = TreeTransform(tree2)
126 foo_trans_id = tt.create_path('foo', tt.root)
127- create_from_tree(tt, foo_trans_id, tree1, 'foo', file_id=b'foo-id')
128+ create_from_tree(tt, foo_trans_id, tree1, 'foo')
129 bar_trans_id = tt.create_path('bar', tt.root)
130- create_from_tree(tt, bar_trans_id, tree1, 'bar', file_id=b'bar-id')
131+ create_from_tree(tt, bar_trans_id, tree1, 'bar')
132 tt.apply()
133 self.assertEqual('directory', osutils.file_kind('tree2/foo'))
134 self.assertFileEqual(b'baz', 'tree2/bar')
135@@ -1681,8 +1681,7 @@
136 tree2 = self.make_branch_and_tree('tree2')
137 tt = TreeTransform(tree2)
138 foo_trans_id = tt.create_path('foo', tt.root)
139- create_from_tree(tt, foo_trans_id, tree1, 'foo', file_id=b'foo-id',
140- chunks=[b'qux'])
141+ create_from_tree(tt, foo_trans_id, tree1, 'foo', chunks=[b'qux'])
142 tt.apply()
143 self.assertFileEqual(b'qux', 'tree2/foo')
144
145@@ -1693,7 +1692,7 @@
146 tree1.add('foo', b'foo-id')
147 tt = TreeTransform(self.make_branch_and_tree('tree2'))
148 foo_trans_id = tt.create_path('foo', tt.root)
149- create_from_tree(tt, foo_trans_id, tree1, 'foo', file_id=b'foo-id')
150+ create_from_tree(tt, foo_trans_id, tree1, 'foo')
151 tt.apply()
152 self.assertEqual('bar', os.readlink('tree2/foo'))
153
154
155=== modified file 'breezy/transform.py'
156--- breezy/transform.py 2019-06-15 15:59:17 +0000
157+++ breezy/transform.py 2019-06-17 18:22:03 +0000
158@@ -2814,7 +2814,7 @@
159 raise errors.BadFileKindError(name, kind)
160
161
162-def create_from_tree(tt, trans_id, tree, path, file_id=None, chunks=None,
163+def create_from_tree(tt, trans_id, tree, path, chunks=None,
164 filter_tree_path=None):
165 """Create new file contents according to tree contents.
166
167
168=== modified file 'breezy/tree.py'
169--- breezy/tree.py 2019-06-16 02:23:42 +0000
170+++ breezy/tree.py 2019-06-17 18:22:03 +0000
171@@ -1184,6 +1184,7 @@
172 :param to_tree: To tree
173 :param path: Path to search for (exists in from_tree)
174 :return: path in to_tree, or None if there is no equivalent path.
175+ :raise NoSuchFile: If the path doesn't exist in from_tree
176 """
177 if file_id is None:
178 file_id = from_tree.path2id(path)

Subscribers

People subscribed via source and target branches