Merge lp:~jelmer/bzr/mutableinventorytree into lp:bzr

Proposed by Jelmer Vernooij
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
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 MutableInventoryTree.

Description of the change

Split inventory-specific bits out of MutableTree into MutableInventoryTree.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) :
review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

sent to pqm by email

Revision history for this message
Martin Pool (mbp) wrote :

(I'm using this to test the pqm lucid upgrade so this might have some spurious rejections.)

Revision history for this message
Martin Pool (mbp) wrote :

sent to pqm by email

Revision history for this message
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.tests.test_smart_add.TestAddActions.test__print [ multipart
Content-Type: text/plain;charset=utf8
log
0
Content-Type: text/x-traceback;charset=utf8,language=python
traceback
24A
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/testtools/runtest.py", line
144, in _run_user
    return fn(*args)
  File "/usr/lib/python2.6/dist-packages/testtools/testcase.py", line
465, in _run_test_method
    testMethod()
  File "/home/pqm/bzr-pqm-workdir/home/+trunk/bzrlib/tests/test_smart_add.py",
line 152, in test__print
    self.run_action("adding path\n")
  File "/home/pqm/bzr-pqm-workdir/home/+trunk/bzrlib/tests/test_smart_add.py",
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.tests.test_smart_add.TestAddActions.test_quiet
time: 2011-04-11 06:28:10.819279Z
error: bzrlib.tests.test_smart_add.TestAddActions.test_quiet [ multipart
Content-Type: text/plain;charset=utf8
log
0
Content-Type: text/x-traceback;charset=utf8,language=python
traceback
23C
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/testtools/runtest.py", line
144, in _run_user
    return fn(*args)
  File "/usr/lib/python2.6/dist-packages/testtools/testcase.py", line
465, in _run_test_method
    testMethod()
  File "/home/pqm/bzr-pqm-workdir/home/+trunk/bzrlib/tests/test_smart_add.py",
line 149, in test_quiet
    self.run_action("")
  File "/home/pqm/bzr-pqm-workdir/home/+trunk/bzrlib/tests/test_smart_add.py",
line 155, in run_action
    from bzrlib.workingtree import _FastPath
ImportError: cannot import name _FastPath
0
]

Revision history for this message
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.tests.test_smart_add.TestAddActions.test_quiet
> time: 2011-04-11 06:28:10.819279Z
> error: bzrlib.tests.test_smart_add.TestAddActions.test_quiet [ multipart
> Content-Type: text/plain;charset=utf8
> log
> 0
> Content-Type: text/x-traceback;charset=utf8,language=python
> traceback
> 23C
> Traceback (most recent call last):
> File "/usr/lib/python2.6/dist-packages/testtools/runtest.py", line
> 144, in _run_user
> return fn(*args)
> File "/usr/lib/python2.6/dist-packages/testtools/testcase.py", line
> 465, in _run_test_method
> testMethod()
> File "/home/pqm/bzr-pqm-workdir/home/+trunk/bzrlib/tests/test_smart_add.py",
> line 149, in test_quiet
> self.run_action("")
> File "/home/pqm/bzr-pqm-workdir/home/+trunk/bzrlib/tests/test_smart_add.py",
> 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://enigmail.mozdev.org/

iEYEARECAAYFAk2isNcACgkQJdeBCYSNAAOoHQCdEYRpqc8SzWZ2uExlCPC9waoI
L+EAoMfffQWhlfvcKqv+U8LHvjjKYkp8
=Q/Zr
-----END PGP SIGNATURE-----

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

sent to pqm by email

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

sent to pqm by email

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/memorytree.py'
--- bzrlib/memorytree.py 2011-04-11 10:06:39 +0000
+++ bzrlib/memorytree.py 2011-04-11 10:06:39 +0000
@@ -26,8 +26,6 @@
26 errors,26 errors,
27 mutabletree,27 mutabletree,
28 revision as _mod_revision,28 revision as _mod_revision,
29 revisiontree,
30 tree,
31 )29 )
32from bzrlib.decorators import needs_read_lock30from bzrlib.decorators import needs_read_lock
33from bzrlib.osutils import sha_file31from bzrlib.osutils import sha_file
@@ -35,7 +33,7 @@
35from bzrlib.transport.memory import MemoryTransport33from bzrlib.transport.memory import MemoryTransport
3634
3735
38class MemoryTree(mutabletree.MutableTree, tree.InventoryTree):36class MemoryTree(mutabletree.MutableInventoryTree):
39 """A MemoryTree is a specialisation of MutableTree.37 """A MemoryTree is a specialisation of MutableTree.
4038
41 It maintains nearly no state outside of read_lock and write_lock39 It maintains nearly no state outside of read_lock and write_lock
4240
=== modified file 'bzrlib/mutabletree.py'
--- bzrlib/mutabletree.py 2011-04-11 10:06:39 +0000
+++ bzrlib/mutabletree.py 2011-04-11 10:06:39 +0000
@@ -54,7 +54,7 @@
54 return tree_write_locked54 return tree_write_locked
5555
5656
57class MutableTree(tree.InventoryTree):57class MutableTree(tree.Tree):
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.
5959
60 Generally speaking these mutations are only possible within a lock_write60 Generally speaking these mutations are only possible within a lock_write
@@ -160,7 +160,7 @@
160 if sub_tree_id == self.get_root_id():160 if sub_tree_id == self.get_root_id():
161 raise errors.BadReferenceTarget(self, sub_tree,161 raise errors.BadReferenceTarget(self, sub_tree,
162 'Trees have the same root id.')162 'Trees have the same root id.')
163 if sub_tree_id in self.inventory:163 if sub_tree_id in self:
164 raise errors.BadReferenceTarget(self, sub_tree,164 raise errors.BadReferenceTarget(self, sub_tree,
165 'Root id already present in tree')165 'Root id already present in tree')
166 self._add([sub_tree_path], [sub_tree_id], ['tree-reference'])166 self._add([sub_tree_path], [sub_tree_id], ['tree-reference'])
@@ -175,7 +175,6 @@
175 """175 """
176 raise NotImplementedError(self._add)176 raise NotImplementedError(self._add)
177177
178 @needs_tree_write_lock
179 def apply_inventory_delta(self, changes):178 def apply_inventory_delta(self, changes):
180 """Apply changes to the inventory as an atomic operation.179 """Apply changes to the inventory as an atomic operation.
181180
@@ -184,10 +183,7 @@
184 :return None:183 :return None:
185 :seealso Inventory.apply_delta: For details on the changes parameter.184 :seealso Inventory.apply_delta: For details on the changes parameter.
186 """185 """
187 self.flush()186 raise NotImplementedError(self.apply_inventory_delta)
188 inv = self.inventory
189 inv.apply_delta(changes)
190 self._write_inventory(inv)
191187
192 @needs_write_lock188 @needs_write_lock
193 def commit(self, message=None, revprops=None, *args,189 def commit(self, message=None, revprops=None, *args,
@@ -345,12 +341,6 @@
345 :return: None341 :return: None
346 """342 """
347343
348 def _fix_case_of_inventory_path(self, path):
349 """If our tree isn't case sensitive, return the canonical path"""
350 if not self.case_sensitive:
351 path = self.get_canonical_inventory_path(path)
352 return path
353
354 @needs_write_lock344 @needs_write_lock
355 def put_file_bytes_non_atomic(self, file_id, bytes):345 def put_file_bytes_non_atomic(self, file_id, bytes):
356 """Update the content of a file in the tree.346 """Update the content of a file in the tree.
@@ -380,6 +370,75 @@
380 """370 """
381 raise NotImplementedError(self.set_parent_trees)371 raise NotImplementedError(self.set_parent_trees)
382372
373 def smart_add(self, file_list, recurse=True, action=None, save=True):
374 """Version file_list, optionally recursing into directories.
375
376 This is designed more towards DWIM for humans than API clarity.
377 For the specific behaviour see the help for cmd_add().
378
379 :param file_list: List of zero or more paths. *NB: these are
380 interpreted relative to the process cwd, not relative to the
381 tree.* (Add and most other tree methods use tree-relative
382 paths.)
383 :param action: A reporter to be called with the inventory, parent_ie,
384 path and kind of the path being added. It may return a file_id if
385 a specific one should be used.
386 :param save: Save the inventory after completing the adds. If False
387 this provides dry-run functionality by doing the add and not saving
388 the inventory.
389 :return: A tuple - files_added, ignored_files. files_added is the count
390 of added files, and ignored_files is a dict mapping files that were
391 ignored to the rule that caused them to be ignored.
392 """
393 raise NotImplementedError(self.smart_add)
394
395 def update_basis_by_delta(self, new_revid, delta):
396 """Update the parents of this tree after a commit.
397
398 This gives the tree one parent, with revision id new_revid. The
399 inventory delta is applied to the current basis tree to generate the
400 inventory for the parent new_revid, and all other parent trees are
401 discarded.
402
403 All the changes in the delta should be changes synchronising the basis
404 tree with some or all of the working tree, with a change to a directory
405 requiring that its contents have been recursively included. That is,
406 this is not a general purpose tree modification routine, but a helper
407 for commit which is not required to handle situations that do not arise
408 outside of commit.
409
410 See the inventory developers documentation for the theory behind
411 inventory deltas.
412
413 :param new_revid: The new revision id for the trees parent.
414 :param delta: An inventory delta (see apply_inventory_delta) describing
415 the changes from the current left most parent revision to new_revid.
416 """
417 raise NotImplementedError(self.update_basis_by_delta)
418
419
420class MutableInventoryTree(MutableTree,tree.InventoryTree):
421
422 @needs_tree_write_lock
423 def apply_inventory_delta(self, changes):
424 """Apply changes to the inventory as an atomic operation.
425
426 :param changes: An inventory delta to apply to the working tree's
427 inventory.
428 :return None:
429 :seealso Inventory.apply_delta: For details on the changes parameter.
430 """
431 self.flush()
432 inv = self.inventory
433 inv.apply_delta(changes)
434 self._write_inventory(inv)
435
436 def _fix_case_of_inventory_path(self, path):
437 """If our tree isn't case sensitive, return the canonical path"""
438 if not self.case_sensitive:
439 path = self.get_canonical_inventory_path(path)
440 return path
441
383 @needs_tree_write_lock442 @needs_tree_write_lock
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):
385 """Version file_list, optionally recursing into directories.444 """Version file_list, optionally recursing into directories.
@@ -642,6 +701,8 @@
642 self.set_parent_trees([(new_revid, rev_tree)])701 self.set_parent_trees([(new_revid, rev_tree)])
643702
644703
704
705
645class MutableTreeHooks(hooks.Hooks):706class MutableTreeHooks(hooks.Hooks):
646 """A dictionary mapping a hook name to a list of callables for mutabletree707 """A dictionary mapping a hook name to a list of callables for mutabletree
647 hooks.708 hooks.
648709
=== modified file 'bzrlib/tests/per_repository/test_iter_reverse_revision_history.py'
--- bzrlib/tests/per_repository/test_iter_reverse_revision_history.py 2009-06-10 03:56:49 +0000
+++ bzrlib/tests/per_repository/test_iter_reverse_revision_history.py 2011-04-11 10:06:39 +0000
@@ -18,7 +18,6 @@
1818
19from bzrlib import (19from bzrlib import (
20 errors,20 errors,
21 osutils,
22 tests,21 tests,
23 )22 )
24from bzrlib.tests.per_repository import TestCaseWithRepository23from bzrlib.tests.per_repository import TestCaseWithRepository
2524
=== modified file 'bzrlib/tests/per_tree/test_inv.py'
--- bzrlib/tests/per_tree/test_inv.py 2010-12-02 09:23:10 +0000
+++ bzrlib/tests/per_tree/test_inv.py 2011-04-11 10:06:39 +0000
@@ -17,18 +17,14 @@
17"""Tests for interface conformance of inventories of trees."""17"""Tests for interface conformance of inventories of trees."""
1818
1919
20from cStringIO import StringIO
21import os
22
23from bzrlib import (20from bzrlib import (
24 tests,21 tests,
25 )22 )
26from bzrlib.tests import (23from bzrlib.tests import (
27 features,
28 per_tree,24 per_tree,
29 )25 )
30from bzrlib.mutabletree import MutableTree26from bzrlib.mutabletree import MutableTree
31from bzrlib.tests import SymlinkFeature, TestSkipped27from bzrlib.tests import TestSkipped
32from bzrlib.transform import _PreviewTree28from bzrlib.transform import _PreviewTree
33from bzrlib.uncommit import uncommit29from bzrlib.uncommit import uncommit
3430
3531
=== modified file 'bzrlib/tests/test_smart_add.py'
--- bzrlib/tests/test_smart_add.py 2011-04-11 10:06:39 +0000
+++ bzrlib/tests/test_smart_add.py 2010-02-10 17:52:08 +0000
@@ -152,7 +152,7 @@
152 self.run_action("adding path\n")152 self.run_action("adding path\n")
153153
154 def run_action(self, output):154 def run_action(self, output):
155 from bzrlib.workingtree import _FastPath155 from bzrlib.mutabletree import _FastPath
156 inv = inventory.Inventory()156 inv = inventory.Inventory()
157 stdout = StringIO()157 stdout = StringIO()
158 action = add.AddAction(to_file=stdout, should_print=bool(output))158 action = add.AddAction(to_file=stdout, should_print=bool(output))
159159
=== modified file 'bzrlib/workingtree.py'
--- bzrlib/workingtree.py 2011-04-09 15:08:16 +0000
+++ bzrlib/workingtree.py 2011-04-11 10:06:39 +0000
@@ -166,7 +166,7 @@
166 return ''166 return ''
167167
168168
169class WorkingTree(bzrlib.mutabletree.MutableTree,169class WorkingTree(bzrlib.mutabletree.MutableInventoryTree,
170 controldir.ControlComponent):170 controldir.ControlComponent):
171 """Working copy tree.171 """Working copy tree.
172172