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
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 errors,
6 mutabletree,
7 revision as _mod_revision,
8- revisiontree,
9- tree,
10 )
11 from bzrlib.decorators import needs_read_lock
12 from bzrlib.osutils import sha_file
13@@ -35,7 +33,7 @@
14 from bzrlib.transport.memory import MemoryTransport
15
16
17-class MemoryTree(mutabletree.MutableTree, tree.InventoryTree):
18+class MemoryTree(mutabletree.MutableInventoryTree):
19 """A MemoryTree is a specialisation of MutableTree.
20
21 It maintains nearly no state outside of read_lock and write_lock
22
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 return tree_write_locked
28
29
30-class MutableTree(tree.InventoryTree):
31+class MutableTree(tree.Tree):
32 """A MutableTree is a specialisation of Tree which is able to be mutated.
33
34 Generally speaking these mutations are only possible within a lock_write
35@@ -160,7 +160,7 @@
36 if sub_tree_id == self.get_root_id():
37 raise errors.BadReferenceTarget(self, sub_tree,
38 'Trees have the same root id.')
39- if sub_tree_id in self.inventory:
40+ if sub_tree_id in self:
41 raise errors.BadReferenceTarget(self, sub_tree,
42 'Root id already present in tree')
43 self._add([sub_tree_path], [sub_tree_id], ['tree-reference'])
44@@ -175,7 +175,6 @@
45 """
46 raise NotImplementedError(self._add)
47
48- @needs_tree_write_lock
49 def apply_inventory_delta(self, changes):
50 """Apply changes to the inventory as an atomic operation.
51
52@@ -184,10 +183,7 @@
53 :return None:
54 :seealso Inventory.apply_delta: For details on the changes parameter.
55 """
56- self.flush()
57- inv = self.inventory
58- inv.apply_delta(changes)
59- self._write_inventory(inv)
60+ raise NotImplementedError(self.apply_inventory_delta)
61
62 @needs_write_lock
63 def commit(self, message=None, revprops=None, *args,
64@@ -345,12 +341,6 @@
65 :return: None
66 """
67
68- def _fix_case_of_inventory_path(self, path):
69- """If our tree isn't case sensitive, return the canonical path"""
70- if not self.case_sensitive:
71- path = self.get_canonical_inventory_path(path)
72- return path
73-
74 @needs_write_lock
75 def put_file_bytes_non_atomic(self, file_id, bytes):
76 """Update the content of a file in the tree.
77@@ -380,6 +370,75 @@
78 """
79 raise NotImplementedError(self.set_parent_trees)
80
81+ def smart_add(self, file_list, recurse=True, action=None, save=True):
82+ """Version file_list, optionally recursing into directories.
83+
84+ This is designed more towards DWIM for humans than API clarity.
85+ For the specific behaviour see the help for cmd_add().
86+
87+ :param file_list: List of zero or more paths. *NB: these are
88+ interpreted relative to the process cwd, not relative to the
89+ tree.* (Add and most other tree methods use tree-relative
90+ paths.)
91+ :param action: A reporter to be called with the inventory, parent_ie,
92+ path and kind of the path being added. It may return a file_id if
93+ a specific one should be used.
94+ :param save: Save the inventory after completing the adds. If False
95+ this provides dry-run functionality by doing the add and not saving
96+ the inventory.
97+ :return: A tuple - files_added, ignored_files. files_added is the count
98+ of added files, and ignored_files is a dict mapping files that were
99+ ignored to the rule that caused them to be ignored.
100+ """
101+ raise NotImplementedError(self.smart_add)
102+
103+ def update_basis_by_delta(self, new_revid, delta):
104+ """Update the parents of this tree after a commit.
105+
106+ This gives the tree one parent, with revision id new_revid. The
107+ inventory delta is applied to the current basis tree to generate the
108+ inventory for the parent new_revid, and all other parent trees are
109+ discarded.
110+
111+ All the changes in the delta should be changes synchronising the basis
112+ tree with some or all of the working tree, with a change to a directory
113+ requiring that its contents have been recursively included. That is,
114+ this is not a general purpose tree modification routine, but a helper
115+ for commit which is not required to handle situations that do not arise
116+ outside of commit.
117+
118+ See the inventory developers documentation for the theory behind
119+ inventory deltas.
120+
121+ :param new_revid: The new revision id for the trees parent.
122+ :param delta: An inventory delta (see apply_inventory_delta) describing
123+ the changes from the current left most parent revision to new_revid.
124+ """
125+ raise NotImplementedError(self.update_basis_by_delta)
126+
127+
128+class MutableInventoryTree(MutableTree,tree.InventoryTree):
129+
130+ @needs_tree_write_lock
131+ def apply_inventory_delta(self, changes):
132+ """Apply changes to the inventory as an atomic operation.
133+
134+ :param changes: An inventory delta to apply to the working tree's
135+ inventory.
136+ :return None:
137+ :seealso Inventory.apply_delta: For details on the changes parameter.
138+ """
139+ self.flush()
140+ inv = self.inventory
141+ inv.apply_delta(changes)
142+ self._write_inventory(inv)
143+
144+ def _fix_case_of_inventory_path(self, path):
145+ """If our tree isn't case sensitive, return the canonical path"""
146+ if not self.case_sensitive:
147+ path = self.get_canonical_inventory_path(path)
148+ return path
149+
150 @needs_tree_write_lock
151 def smart_add(self, file_list, recurse=True, action=None, save=True):
152 """Version file_list, optionally recursing into directories.
153@@ -642,6 +701,8 @@
154 self.set_parent_trees([(new_revid, rev_tree)])
155
156
157+
158+
159 class MutableTreeHooks(hooks.Hooks):
160 """A dictionary mapping a hook name to a list of callables for mutabletree
161 hooks.
162
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
168 from bzrlib import (
169 errors,
170- osutils,
171 tests,
172 )
173 from bzrlib.tests.per_repository import TestCaseWithRepository
174
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 """Tests for interface conformance of inventories of trees."""
180
181
182-from cStringIO import StringIO
183-import os
184-
185 from bzrlib import (
186 tests,
187 )
188 from bzrlib.tests import (
189- features,
190 per_tree,
191 )
192 from bzrlib.mutabletree import MutableTree
193-from bzrlib.tests import SymlinkFeature, TestSkipped
194+from bzrlib.tests import TestSkipped
195 from bzrlib.transform import _PreviewTree
196 from bzrlib.uncommit import uncommit
197
198
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 self.run_action("adding path\n")
204
205 def run_action(self, output):
206- from bzrlib.workingtree import _FastPath
207+ from bzrlib.mutabletree import _FastPath
208 inv = inventory.Inventory()
209 stdout = StringIO()
210 action = add.AddAction(to_file=stdout, should_print=bool(output))
211
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 return ''
217
218
219-class WorkingTree(bzrlib.mutabletree.MutableTree,
220+class WorkingTree(bzrlib.mutabletree.MutableInventoryTree,
221 controldir.ControlComponent):
222 """Working copy tree.
223