Merge lp:~abentley/bzr/commit-preview into lp:~bzr/bzr/trunk-old

Proposed by Aaron Bentley on 2009-05-21
Status: Merged
Approved by: Ian Clatworthy on 2009-05-28
Approved revision: 4363
Merged at revision: not available
Proposed branch: lp:~abentley/bzr/commit-preview
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 139 lines
To merge this branch: bzr merge lp:~abentley/bzr/commit-preview
Reviewer Review Type Date Requested Status
Ian Clatworthy 2009-05-21 Approve on 2009-05-26
Review via email: mp+6727@code.launchpad.net
To post a comment you must log in.
Aaron Bentley (abentley) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

This patch is a followup on my changes to allow PreviewTree to be
committed. It turns out that get_file_with_stat should be declared on
the Tree interface. This patch moves the code from MutableTree to Tree,
and updates the tests accordingly.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkoVRrkACgkQ0F+nu1YWqI3NswCePVKEnKq6danx6Nf8JSizvuZL
MJgAn2FBFMkyS2MHICAMaIvq8Hfn+wtu
=nQw3
-----END PGP SIGNATURE-----

review: Approve
lp:~abentley/bzr/commit-preview updated on 2009-05-28
4362. By Aaron Bentley on 2009-05-28

Merge bzr.dev into commit-preview.

4363. By Aaron Bentley on 2009-05-28

Remove reference to workingtree_implementations.test_get_file_with_stat

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/mutabletree.py'
2--- bzrlib/mutabletree.py 2009-04-09 20:23:07 +0000
3+++ bzrlib/mutabletree.py 2009-05-28 12:36:32 +0000
4@@ -232,20 +232,6 @@
5 """Helper function for add - sets the entries of kinds."""
6 raise NotImplementedError(self._gather_kinds)
7
8- def get_file_with_stat(self, file_id, path=None):
9- """Get a file handle and stat object for file_id.
10-
11- The default implementation returns (self.get_file, None) for backwards
12- compatibility.
13-
14- :param file_id: The file id to read.
15- :param path: The path of the file, if it is known.
16- :return: A tuple (file_handle, stat_value_or_None). If the tree has
17- no stat facility, or need for a stat cache feedback during commit,
18- it may return None for the second element of the tuple.
19- """
20- return (self.get_file(file_id, path), None)
21-
22 @needs_read_lock
23 def last_revision(self):
24 """Return the revision id of the last commit performed in this tree.
25
26=== modified file 'bzrlib/tests/tree_implementations/__init__.py'
27--- bzrlib/tests/tree_implementations/__init__.py 2009-04-11 16:06:53 +0000
28+++ bzrlib/tests/tree_implementations/__init__.py 2009-05-28 12:36:33 +0000
29@@ -365,6 +365,7 @@
30 submod_tests = loader.loadTestsFromModuleNames([
31 'bzrlib.tests.tree_implementations.test_annotate_iter',
32 'bzrlib.tests.tree_implementations.test_get_file_mtime',
33+ 'bzrlib.tests.tree_implementations.test_get_file_with_stat',
34 'bzrlib.tests.tree_implementations.test_get_root_id',
35 'bzrlib.tests.tree_implementations.test_get_symlink_target',
36 'bzrlib.tests.tree_implementations.test_inv',
37
38=== renamed file 'bzrlib/tests/workingtree_implementations/test_get_file_with_stat.py' => 'bzrlib/tests/tree_implementations/test_get_file_with_stat.py'
39--- bzrlib/tests/workingtree_implementations/test_get_file_with_stat.py 2009-03-23 14:59:43 +0000
40+++ bzrlib/tests/tree_implementations/test_get_file_with_stat.py 2009-05-28 12:36:33 +0000
41@@ -18,15 +18,16 @@
42
43 import os
44
45-from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
46-
47-
48-class TestGetFileWithStat(TestCaseWithWorkingTree):
49+from bzrlib.tests.tree_implementations import TestCaseWithTree
50+
51+
52+class TestGetFileWithStat(TestCaseWithTree):
53
54 def test_get_file_with_stat_id_only(self):
55- tree = self.make_branch_and_tree('.')
56+ work_tree = self.make_branch_and_tree('.')
57 self.build_tree(['foo'])
58- tree.add(['foo'], ['foo-id'])
59+ work_tree.add(['foo'], ['foo-id'])
60+ tree = self._convert_tree(work_tree)
61 tree.lock_read()
62 self.addCleanup(tree.unlock)
63 file_obj, statvalue = tree.get_file_with_stat('foo-id')
64@@ -36,9 +37,10 @@
65 self.assertEqual(["contents of foo\n"], file_obj.readlines())
66
67 def test_get_file_with_stat_id_and_path(self):
68- tree = self.make_branch_and_tree('.')
69+ work_tree = self.make_branch_and_tree('.')
70 self.build_tree(['foo'])
71- tree.add(['foo'], ['foo-id'])
72+ work_tree.add(['foo'], ['foo-id'])
73+ tree = self._convert_tree(work_tree)
74 tree.lock_read()
75 self.addCleanup(tree.unlock)
76 file_obj, statvalue = tree.get_file_with_stat('foo-id', 'foo')
77
78=== modified file 'bzrlib/tests/workingtree_implementations/__init__.py'
79--- bzrlib/tests/workingtree_implementations/__init__.py 2009-04-11 16:06:53 +0000
80+++ bzrlib/tests/workingtree_implementations/__init__.py 2009-05-28 12:36:33 +0000
81@@ -72,7 +72,6 @@
82 'bzrlib.tests.workingtree_implementations.test_eol_conversion',
83 'bzrlib.tests.workingtree_implementations.test_executable',
84 'bzrlib.tests.workingtree_implementations.test_flush',
85- 'bzrlib.tests.workingtree_implementations.test_get_file_with_stat',
86 'bzrlib.tests.workingtree_implementations.test_get_file_mtime',
87 'bzrlib.tests.workingtree_implementations.test_get_parent_ids',
88 'bzrlib.tests.workingtree_implementations.test_inv',
89
90=== modified file 'bzrlib/transform.py'
91--- bzrlib/transform.py 2009-05-28 07:46:53 +0000
92+++ bzrlib/transform.py 2009-05-28 12:36:32 +0000
93@@ -1915,7 +1915,7 @@
94 name = self._transform._limbo_name(trans_id)
95 return open(name, 'rb')
96
97- def get_file_with_stat(self, file_id, path):
98+ def get_file_with_stat(self, file_id, path=None):
99 return self.get_file(file_id, path), None
100
101 def annotate_iter(self, file_id,
102
103=== modified file 'bzrlib/tree.py'
104--- bzrlib/tree.py 2009-05-23 04:55:52 +0000
105+++ bzrlib/tree.py 2009-05-28 12:36:32 +0000
106@@ -263,6 +263,20 @@
107 """
108 raise NotImplementedError(self.get_file)
109
110+ def get_file_with_stat(self, file_id, path=None):
111+ """Get a file handle and stat object for file_id.
112+
113+ The default implementation returns (self.get_file, None) for backwards
114+ compatibility.
115+
116+ :param file_id: The file id to read.
117+ :param path: The path of the file, if it is known.
118+ :return: A tuple (file_handle, stat_value_or_None). If the tree has
119+ no stat facility, or need for a stat cache feedback during commit,
120+ it may return None for the second element of the tuple.
121+ """
122+ return (self.get_file(file_id, path), None)
123+
124 def get_file_text(self, file_id, path=None):
125 """Return the byte content of a file.
126
127
128=== modified file 'bzrlib/workingtree.py'
129--- bzrlib/workingtree.py 2009-05-13 17:16:28 +0000
130+++ bzrlib/workingtree.py 2009-05-28 12:36:33 +0000
131@@ -446,7 +446,7 @@
132
133 def get_file_with_stat(self, file_id, path=None, filtered=True,
134 _fstat=os.fstat):
135- """See MutableTree.get_file_with_stat."""
136+ """See Tree.get_file_with_stat."""
137 if path is None:
138 path = self.id2path(file_id)
139 file_obj = self.get_file_byname(path, filtered=False)