Merge lp:~jelmer/bzr/mutableinventorytree into lp:bzr
- mutableinventorytree
- Merge into bzr.dev
Status: | Merged |
---|---|
Approved by: | Martin Pool |
Approved revision: | no longer in the source branch. |
Merged at revision: | 5782 |
Proposed branch: | lp:~jelmer/bzr/mutableinventorytree |
Merge into: | lp:bzr |
Prerequisite: | lp:~jelmer/bzr/inventorytree |
Diff against target: |
222 lines (+78/-24) 6 files modified
bzrlib/memorytree.py (+1/-3) bzrlib/mutabletree.py (+74/-13) bzrlib/tests/per_repository/test_iter_reverse_revision_history.py (+0/-1) bzrlib/tests/per_tree/test_inv.py (+1/-5) bzrlib/tests/test_smart_add.py (+1/-1) bzrlib/workingtree.py (+1/-1) |
To merge this branch: | bzr merge lp:~jelmer/bzr/mutableinventorytree |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Pool | Approve | ||
Review via email: mp+57061@code.launchpad.net |
Commit message
Split inventory-specific bits out of MutableTree into MutableInventor
Description of the change
Split inventory-specific bits out of MutableTree into MutableInventor
Martin Pool (mbp) : | # |
Martin Pool (mbp) wrote : | # |
Martin Pool (mbp) wrote : | # |
(I'm using this to test the pqm lucid upgrade so this might have some spurious rejections.)
Martin Pool (mbp) wrote : | # |
sent to pqm by email
Martin Pool (mbp) wrote : | # |
This fails run on the lucid pqm, as shown below. I don't know yet if
those are problems with pqm or with this patch; off hand it could be
either
time: 2011-04-11 06:28:10.817604Z
error: bzrlib.
Content-Type: text/plain;
log
0
Content-Type: text/x-
traceback
24A
Traceback (most recent call last):
File "/usr/lib/
144, in _run_user
return fn(*args)
File "/usr/lib/
465, in _run_test_method
testMethod()
File "/home/
line 152, in test__print
self.
File "/home/
line 155, in run_action
from bzrlib.workingtree import _FastPath
ImportError: cannot import name _FastPath
0
]
time: 2011-04-11 06:28:10.817768Z
time: 2011-04-11 06:28:10.817818Z
test: bzrlib.
time: 2011-04-11 06:28:10.819279Z
error: bzrlib.
Content-Type: text/plain;
log
0
Content-Type: text/x-
traceback
23C
Traceback (most recent call last):
File "/usr/lib/
144, in _run_user
return fn(*args)
File "/usr/lib/
465, in _run_test_method
testMethod()
File "/home/
line 149, in test_quiet
self.
File "/home/
line 155, in run_action
from bzrlib.workingtree import _FastPath
ImportError: cannot import name _FastPath
0
]
John A Meinel (jameinel) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 4/11/2011 8:46 AM, Martin Pool wrote:
> This fails run on the lucid pqm, as shown below. I don't know yet if
> those are problems with pqm or with this patch; off hand it could be
> either
>
...
> from bzrlib.workingtree import _FastPath
> ImportError: cannot import name _FastPath
> 0
> ]
> time: 2011-04-11 06:28:10.817768Z
> time: 2011-04-11 06:28:10.817818Z
> test: bzrlib.
> time: 2011-04-11 06:28:10.819279Z
> error: bzrlib.
> Content-Type: text/plain;
> log
> 0
> Content-Type: text/x-
> traceback
> 23C
> Traceback (most recent call last):
> File "/usr/lib/
> 144, in _run_user
> return fn(*args)
> File "/usr/lib/
> 465, in _run_test_method
> testMethod()
> File "/home/
> line 149, in test_quiet
> self.run_action("")
> File "/home/
> line 155, in run_action
> from bzrlib.workingtree import _FastPath
> ImportError: cannot import name _FastPath
> 0
> ]
>
That sounds like an import ordering failure, which seems pretty strange.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAk2
L+EAoMfffQWhlfv
=Q/Zr
-----END PGP SIGNATURE-----
Jelmer Vernooij (jelmer) wrote : | # |
sent to pqm by email
Jelmer Vernooij (jelmer) wrote : | # |
sent to pqm by email
Jelmer Vernooij (jelmer) wrote : | # |
sent to pqm by email
Preview Diff
1 | === modified file 'bzrlib/memorytree.py' | |||
2 | --- bzrlib/memorytree.py 2011-04-11 10:06:39 +0000 | |||
3 | +++ bzrlib/memorytree.py 2011-04-11 10:06:39 +0000 | |||
4 | @@ -26,8 +26,6 @@ | |||
5 | 26 | errors, | 26 | errors, |
6 | 27 | mutabletree, | 27 | mutabletree, |
7 | 28 | revision as _mod_revision, | 28 | revision as _mod_revision, |
8 | 29 | revisiontree, | ||
9 | 30 | tree, | ||
10 | 31 | ) | 29 | ) |
11 | 32 | from bzrlib.decorators import needs_read_lock | 30 | from bzrlib.decorators import needs_read_lock |
12 | 33 | from bzrlib.osutils import sha_file | 31 | from bzrlib.osutils import sha_file |
13 | @@ -35,7 +33,7 @@ | |||
14 | 35 | from bzrlib.transport.memory import MemoryTransport | 33 | from bzrlib.transport.memory import MemoryTransport |
15 | 36 | 34 | ||
16 | 37 | 35 | ||
18 | 38 | class MemoryTree(mutabletree.MutableTree, tree.InventoryTree): | 36 | class MemoryTree(mutabletree.MutableInventoryTree): |
19 | 39 | """A MemoryTree is a specialisation of MutableTree. | 37 | """A MemoryTree is a specialisation of MutableTree. |
20 | 40 | 38 | ||
21 | 41 | It maintains nearly no state outside of read_lock and write_lock | 39 | It maintains nearly no state outside of read_lock and write_lock |
22 | 42 | 40 | ||
23 | === modified file 'bzrlib/mutabletree.py' | |||
24 | --- bzrlib/mutabletree.py 2011-04-11 10:06:39 +0000 | |||
25 | +++ bzrlib/mutabletree.py 2011-04-11 10:06:39 +0000 | |||
26 | @@ -54,7 +54,7 @@ | |||
27 | 54 | return tree_write_locked | 54 | return tree_write_locked |
28 | 55 | 55 | ||
29 | 56 | 56 | ||
31 | 57 | class MutableTree(tree.InventoryTree): | 57 | class MutableTree(tree.Tree): |
32 | 58 | """A MutableTree is a specialisation of Tree which is able to be mutated. | 58 | """A MutableTree is a specialisation of Tree which is able to be mutated. |
33 | 59 | 59 | ||
34 | 60 | Generally speaking these mutations are only possible within a lock_write | 60 | Generally speaking these mutations are only possible within a lock_write |
35 | @@ -160,7 +160,7 @@ | |||
36 | 160 | if sub_tree_id == self.get_root_id(): | 160 | if sub_tree_id == self.get_root_id(): |
37 | 161 | raise errors.BadReferenceTarget(self, sub_tree, | 161 | raise errors.BadReferenceTarget(self, sub_tree, |
38 | 162 | 'Trees have the same root id.') | 162 | 'Trees have the same root id.') |
40 | 163 | if sub_tree_id in self.inventory: | 163 | if sub_tree_id in self: |
41 | 164 | raise errors.BadReferenceTarget(self, sub_tree, | 164 | raise errors.BadReferenceTarget(self, sub_tree, |
42 | 165 | 'Root id already present in tree') | 165 | 'Root id already present in tree') |
43 | 166 | self._add([sub_tree_path], [sub_tree_id], ['tree-reference']) | 166 | self._add([sub_tree_path], [sub_tree_id], ['tree-reference']) |
44 | @@ -175,7 +175,6 @@ | |||
45 | 175 | """ | 175 | """ |
46 | 176 | raise NotImplementedError(self._add) | 176 | raise NotImplementedError(self._add) |
47 | 177 | 177 | ||
48 | 178 | @needs_tree_write_lock | ||
49 | 179 | def apply_inventory_delta(self, changes): | 178 | def apply_inventory_delta(self, changes): |
50 | 180 | """Apply changes to the inventory as an atomic operation. | 179 | """Apply changes to the inventory as an atomic operation. |
51 | 181 | 180 | ||
52 | @@ -184,10 +183,7 @@ | |||
53 | 184 | :return None: | 183 | :return None: |
54 | 185 | :seealso Inventory.apply_delta: For details on the changes parameter. | 184 | :seealso Inventory.apply_delta: For details on the changes parameter. |
55 | 186 | """ | 185 | """ |
60 | 187 | self.flush() | 186 | raise NotImplementedError(self.apply_inventory_delta) |
57 | 188 | inv = self.inventory | ||
58 | 189 | inv.apply_delta(changes) | ||
59 | 190 | self._write_inventory(inv) | ||
61 | 191 | 187 | ||
62 | 192 | @needs_write_lock | 188 | @needs_write_lock |
63 | 193 | def commit(self, message=None, revprops=None, *args, | 189 | def commit(self, message=None, revprops=None, *args, |
64 | @@ -345,12 +341,6 @@ | |||
65 | 345 | :return: None | 341 | :return: None |
66 | 346 | """ | 342 | """ |
67 | 347 | 343 | ||
68 | 348 | def _fix_case_of_inventory_path(self, path): | ||
69 | 349 | """If our tree isn't case sensitive, return the canonical path""" | ||
70 | 350 | if not self.case_sensitive: | ||
71 | 351 | path = self.get_canonical_inventory_path(path) | ||
72 | 352 | return path | ||
73 | 353 | |||
74 | 354 | @needs_write_lock | 344 | @needs_write_lock |
75 | 355 | def put_file_bytes_non_atomic(self, file_id, bytes): | 345 | def put_file_bytes_non_atomic(self, file_id, bytes): |
76 | 356 | """Update the content of a file in the tree. | 346 | """Update the content of a file in the tree. |
77 | @@ -380,6 +370,75 @@ | |||
78 | 380 | """ | 370 | """ |
79 | 381 | raise NotImplementedError(self.set_parent_trees) | 371 | raise NotImplementedError(self.set_parent_trees) |
80 | 382 | 372 | ||
81 | 373 | def smart_add(self, file_list, recurse=True, action=None, save=True): | ||
82 | 374 | """Version file_list, optionally recursing into directories. | ||
83 | 375 | |||
84 | 376 | This is designed more towards DWIM for humans than API clarity. | ||
85 | 377 | For the specific behaviour see the help for cmd_add(). | ||
86 | 378 | |||
87 | 379 | :param file_list: List of zero or more paths. *NB: these are | ||
88 | 380 | interpreted relative to the process cwd, not relative to the | ||
89 | 381 | tree.* (Add and most other tree methods use tree-relative | ||
90 | 382 | paths.) | ||
91 | 383 | :param action: A reporter to be called with the inventory, parent_ie, | ||
92 | 384 | path and kind of the path being added. It may return a file_id if | ||
93 | 385 | a specific one should be used. | ||
94 | 386 | :param save: Save the inventory after completing the adds. If False | ||
95 | 387 | this provides dry-run functionality by doing the add and not saving | ||
96 | 388 | the inventory. | ||
97 | 389 | :return: A tuple - files_added, ignored_files. files_added is the count | ||
98 | 390 | of added files, and ignored_files is a dict mapping files that were | ||
99 | 391 | ignored to the rule that caused them to be ignored. | ||
100 | 392 | """ | ||
101 | 393 | raise NotImplementedError(self.smart_add) | ||
102 | 394 | |||
103 | 395 | def update_basis_by_delta(self, new_revid, delta): | ||
104 | 396 | """Update the parents of this tree after a commit. | ||
105 | 397 | |||
106 | 398 | This gives the tree one parent, with revision id new_revid. The | ||
107 | 399 | inventory delta is applied to the current basis tree to generate the | ||
108 | 400 | inventory for the parent new_revid, and all other parent trees are | ||
109 | 401 | discarded. | ||
110 | 402 | |||
111 | 403 | All the changes in the delta should be changes synchronising the basis | ||
112 | 404 | tree with some or all of the working tree, with a change to a directory | ||
113 | 405 | requiring that its contents have been recursively included. That is, | ||
114 | 406 | this is not a general purpose tree modification routine, but a helper | ||
115 | 407 | for commit which is not required to handle situations that do not arise | ||
116 | 408 | outside of commit. | ||
117 | 409 | |||
118 | 410 | See the inventory developers documentation for the theory behind | ||
119 | 411 | inventory deltas. | ||
120 | 412 | |||
121 | 413 | :param new_revid: The new revision id for the trees parent. | ||
122 | 414 | :param delta: An inventory delta (see apply_inventory_delta) describing | ||
123 | 415 | the changes from the current left most parent revision to new_revid. | ||
124 | 416 | """ | ||
125 | 417 | raise NotImplementedError(self.update_basis_by_delta) | ||
126 | 418 | |||
127 | 419 | |||
128 | 420 | class MutableInventoryTree(MutableTree,tree.InventoryTree): | ||
129 | 421 | |||
130 | 422 | @needs_tree_write_lock | ||
131 | 423 | def apply_inventory_delta(self, changes): | ||
132 | 424 | """Apply changes to the inventory as an atomic operation. | ||
133 | 425 | |||
134 | 426 | :param changes: An inventory delta to apply to the working tree's | ||
135 | 427 | inventory. | ||
136 | 428 | :return None: | ||
137 | 429 | :seealso Inventory.apply_delta: For details on the changes parameter. | ||
138 | 430 | """ | ||
139 | 431 | self.flush() | ||
140 | 432 | inv = self.inventory | ||
141 | 433 | inv.apply_delta(changes) | ||
142 | 434 | self._write_inventory(inv) | ||
143 | 435 | |||
144 | 436 | def _fix_case_of_inventory_path(self, path): | ||
145 | 437 | """If our tree isn't case sensitive, return the canonical path""" | ||
146 | 438 | if not self.case_sensitive: | ||
147 | 439 | path = self.get_canonical_inventory_path(path) | ||
148 | 440 | return path | ||
149 | 441 | |||
150 | 383 | @needs_tree_write_lock | 442 | @needs_tree_write_lock |
151 | 384 | def smart_add(self, file_list, recurse=True, action=None, save=True): | 443 | def smart_add(self, file_list, recurse=True, action=None, save=True): |
152 | 385 | """Version file_list, optionally recursing into directories. | 444 | """Version file_list, optionally recursing into directories. |
153 | @@ -642,6 +701,8 @@ | |||
154 | 642 | self.set_parent_trees([(new_revid, rev_tree)]) | 701 | self.set_parent_trees([(new_revid, rev_tree)]) |
155 | 643 | 702 | ||
156 | 644 | 703 | ||
157 | 704 | |||
158 | 705 | |||
159 | 645 | class MutableTreeHooks(hooks.Hooks): | 706 | class MutableTreeHooks(hooks.Hooks): |
160 | 646 | """A dictionary mapping a hook name to a list of callables for mutabletree | 707 | """A dictionary mapping a hook name to a list of callables for mutabletree |
161 | 647 | hooks. | 708 | hooks. |
162 | 648 | 709 | ||
163 | === modified file 'bzrlib/tests/per_repository/test_iter_reverse_revision_history.py' | |||
164 | --- bzrlib/tests/per_repository/test_iter_reverse_revision_history.py 2009-06-10 03:56:49 +0000 | |||
165 | +++ bzrlib/tests/per_repository/test_iter_reverse_revision_history.py 2011-04-11 10:06:39 +0000 | |||
166 | @@ -18,7 +18,6 @@ | |||
167 | 18 | 18 | ||
168 | 19 | from bzrlib import ( | 19 | from bzrlib import ( |
169 | 20 | errors, | 20 | errors, |
170 | 21 | osutils, | ||
171 | 22 | tests, | 21 | tests, |
172 | 23 | ) | 22 | ) |
173 | 24 | from bzrlib.tests.per_repository import TestCaseWithRepository | 23 | from bzrlib.tests.per_repository import TestCaseWithRepository |
174 | 25 | 24 | ||
175 | === modified file 'bzrlib/tests/per_tree/test_inv.py' | |||
176 | --- bzrlib/tests/per_tree/test_inv.py 2010-12-02 09:23:10 +0000 | |||
177 | +++ bzrlib/tests/per_tree/test_inv.py 2011-04-11 10:06:39 +0000 | |||
178 | @@ -17,18 +17,14 @@ | |||
179 | 17 | """Tests for interface conformance of inventories of trees.""" | 17 | """Tests for interface conformance of inventories of trees.""" |
180 | 18 | 18 | ||
181 | 19 | 19 | ||
182 | 20 | from cStringIO import StringIO | ||
183 | 21 | import os | ||
184 | 22 | |||
185 | 23 | from bzrlib import ( | 20 | from bzrlib import ( |
186 | 24 | tests, | 21 | tests, |
187 | 25 | ) | 22 | ) |
188 | 26 | from bzrlib.tests import ( | 23 | from bzrlib.tests import ( |
189 | 27 | features, | ||
190 | 28 | per_tree, | 24 | per_tree, |
191 | 29 | ) | 25 | ) |
192 | 30 | from bzrlib.mutabletree import MutableTree | 26 | from bzrlib.mutabletree import MutableTree |
194 | 31 | from bzrlib.tests import SymlinkFeature, TestSkipped | 27 | from bzrlib.tests import TestSkipped |
195 | 32 | from bzrlib.transform import _PreviewTree | 28 | from bzrlib.transform import _PreviewTree |
196 | 33 | from bzrlib.uncommit import uncommit | 29 | from bzrlib.uncommit import uncommit |
197 | 34 | 30 | ||
198 | 35 | 31 | ||
199 | === modified file 'bzrlib/tests/test_smart_add.py' | |||
200 | --- bzrlib/tests/test_smart_add.py 2011-04-11 10:06:39 +0000 | |||
201 | +++ bzrlib/tests/test_smart_add.py 2010-02-10 17:52:08 +0000 | |||
202 | @@ -152,7 +152,7 @@ | |||
203 | 152 | self.run_action("adding path\n") | 152 | self.run_action("adding path\n") |
204 | 153 | 153 | ||
205 | 154 | def run_action(self, output): | 154 | def run_action(self, output): |
207 | 155 | from bzrlib.workingtree import _FastPath | 155 | from bzrlib.mutabletree import _FastPath |
208 | 156 | inv = inventory.Inventory() | 156 | inv = inventory.Inventory() |
209 | 157 | stdout = StringIO() | 157 | stdout = StringIO() |
210 | 158 | action = add.AddAction(to_file=stdout, should_print=bool(output)) | 158 | action = add.AddAction(to_file=stdout, should_print=bool(output)) |
211 | 159 | 159 | ||
212 | === modified file 'bzrlib/workingtree.py' | |||
213 | --- bzrlib/workingtree.py 2011-04-09 15:08:16 +0000 | |||
214 | +++ bzrlib/workingtree.py 2011-04-11 10:06:39 +0000 | |||
215 | @@ -166,7 +166,7 @@ | |||
216 | 166 | return '' | 166 | return '' |
217 | 167 | 167 | ||
218 | 168 | 168 | ||
220 | 169 | class WorkingTree(bzrlib.mutabletree.MutableTree, | 169 | class WorkingTree(bzrlib.mutabletree.MutableInventoryTree, |
221 | 170 | controldir.ControlComponent): | 170 | controldir.ControlComponent): |
222 | 171 | """Working copy tree. | 171 | """Working copy tree. |
223 | 172 | 172 |
sent to pqm by email