Merge lp:~lifeless/bzr/loomsupport into lp:bzr

Proposed by Robert Collins
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 5301
Proposed branch: lp:~lifeless/bzr/loomsupport
Merge into: lp:bzr
Diff against target: 174 lines (+31/-21)
7 files modified
NEWS (+6/-2)
bzrlib/branch.py (+16/-8)
bzrlib/tests/per_interbranch/__init__.py (+3/-5)
bzrlib/tests/per_interbranch/test_copy_content_into.py (+2/-2)
bzrlib/tests/per_interbranch/test_get.py (+2/-2)
bzrlib/tests/per_interbranch/test_push.py (+1/-1)
bzrlib/tests/per_interbranch/test_update_revisions.py (+1/-1)
To merge this branch: bzr merge lp:~lifeless/bzr/loomsupport
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Review via email: mp+27684@code.launchpad.net

Commit message

Make InterBranch._get_branch_formats_to_test return a list of format pairs to aid testing in bzr-loom.

Description of the change

Help looms get tested well, permit multiple permutations per InterBranch
implementation.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

Nice !
I'll add Jelmer as a reviewer to make sure he see this, foreign branches may benefit from it too (or not, I haven't checked if they can already parametrize this way).

review: Approve
Revision history for this message
Robert Collins (lifeless) wrote :

InterBranch was added for foreign format plugins, so I expect yes,
he'll be affected :)

Revision history for this message
Robert Collins (lifeless) wrote :

sent to pqm by email

Revision history for this message
Vincent Ladeuil (vila) wrote :

The order is wrong for the NEWS entry, other than that, land.

review: Approve
Revision history for this message
Robert Collins (lifeless) 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 'NEWS'
2--- NEWS 2010-06-17 02:06:20 +0000
3+++ NEWS 2010-06-17 06:52:26 +0000
4@@ -96,10 +96,14 @@
5 API Changes
6 ***********
7
8+* ``bzrlib.branch.InterBranch._get_branch_formats_to_test`` now returns
9+ an iterable of format pairs, rather than just a single pair, permitting
10+ InterBranch objects that work with multiple permutations to be
11+ comprehensively tested. (Robert Collins)
12+
13 * ``bzrlib.knit.KnitSequenceMatcher``, which has been deprecated since
14 2007, has been deleted. Use ``PatienceSequenceMatcher`` from
15- ``bzrlib.patiencediff`` instead.
16- (Andrew Bennetts)
17+ ``bzrlib.patiencediff`` instead. (Andrew Bennetts)
18
19 * ``bzrlib.transport.ssh.SSHVendor.connect_ssh`` now returns an object
20 that implements the interface of ``bzrlib.transport.ssh.SSHConnection``.
21
22=== modified file 'bzrlib/branch.py'
23--- bzrlib/branch.py 2010-06-14 21:41:32 +0000
24+++ bzrlib/branch.py 2010-06-17 06:52:26 +0000
25@@ -1023,7 +1023,6 @@
26 self._extend_partial_history(distance_from_last)
27 return self._partial_revision_history_cache[distance_from_last]
28
29- @needs_write_lock
30 def pull(self, source, overwrite=False, stop_revision=None,
31 possible_transports=None, *args, **kwargs):
32 """Mirror source into this branch.
33@@ -3185,11 +3184,17 @@
34 _optimisers = []
35 """The available optimised InterBranch types."""
36
37- @staticmethod
38- def _get_branch_formats_to_test():
39- """Return a tuple with the Branch formats to use when testing."""
40- raise NotImplementedError(InterBranch._get_branch_formats_to_test)
41+ @classmethod
42+ def _get_branch_formats_to_test(klass):
43+ """Return an iterable of format tuples for testing.
44+
45+ :return: An iterable of (from_format, to_format) to use when testing
46+ this InterBranch class. Each InterBranch class should define this
47+ method itself.
48+ """
49+ raise NotImplementedError(klass._get_branch_formats_to_test)
50
51+ @needs_write_lock
52 def pull(self, overwrite=False, stop_revision=None,
53 possible_transports=None, local=False):
54 """Mirror source into target branch.
55@@ -3200,6 +3205,7 @@
56 """
57 raise NotImplementedError(self.pull)
58
59+ @needs_write_lock
60 def update_revisions(self, stop_revision=None, overwrite=False,
61 graph=None):
62 """Pull in new perfect-fit revisions.
63@@ -3213,6 +3219,7 @@
64 """
65 raise NotImplementedError(self.update_revisions)
66
67+ @needs_write_lock
68 def push(self, overwrite=False, stop_revision=None,
69 _override_hook_source_branch=None):
70 """Mirror the source branch into the target branch.
71@@ -3230,9 +3237,9 @@
72 # GenericBranch uses the public API, so always compatible
73 return True
74
75- @staticmethod
76- def _get_branch_formats_to_test():
77- return BranchFormat._default_format, BranchFormat._default_format
78+ @classmethod
79+ def _get_branch_formats_to_test(klass):
80+ return [(BranchFormat._default_format, BranchFormat._default_format)]
81
82 @classmethod
83 def unwrap_format(klass, format):
84@@ -3300,6 +3307,7 @@
85 (this_last_revision, this_revno)])
86 self.target.set_last_revision_info(stop_revno, stop_revision)
87
88+ @needs_write_lock
89 def pull(self, overwrite=False, stop_revision=None,
90 possible_transports=None, run_hooks=True,
91 _override_hook_target=None, local=False):
92
93=== modified file 'bzrlib/tests/per_interbranch/__init__.py'
94--- bzrlib/tests/per_interbranch/__init__.py 2010-06-14 06:57:25 +0000
95+++ bzrlib/tests/per_interbranch/__init__.py 2010-06-17 06:52:26 +0000
96@@ -76,11 +76,9 @@
97 # test the default InterBranch between format 6 and the current
98 # default format.
99 for optimiser_class in InterBranch._optimisers:
100- format_from_test, format_to_test = \
101- optimiser_class._get_branch_formats_to_test()
102- if format_to_test is not None:
103- result.append((optimiser_class,
104- format_from_test, format_to_test))
105+ for format_from_test, format_to_test in \
106+ optimiser_class._get_branch_formats_to_test():
107+ result.append((optimiser_class, format_from_test, format_to_test))
108 # if there are specific combinations we want to use, we can add them
109 # here.
110 return result
111
112=== modified file 'bzrlib/tests/per_interbranch/test_copy_content_into.py'
113--- bzrlib/tests/per_interbranch/test_copy_content_into.py 2010-06-14 06:57:25 +0000
114+++ bzrlib/tests/per_interbranch/test_copy_content_into.py 2010-06-17 06:52:26 +0000
115@@ -27,14 +27,14 @@
116 class TestCopyContentInto(TestCaseWithInterBranch):
117
118 def test_contract_convenience_method(self):
119- self.tree1 = self.make_branch_and_tree('tree1')
120+ self.tree1 = self.make_from_branch_and_tree('tree1')
121 rev1 = self.tree1.commit('one')
122 branch2 = self.make_to_branch('tree2')
123 branch2.repository.fetch(self.tree1.branch.repository)
124 self.tree1.branch.copy_content_into(branch2, revision_id=rev1)
125
126 def test_inter_is_used(self):
127- self.tree1 = self.make_branch_and_tree('tree1')
128+ self.tree1 = self.make_from_branch_and_tree('tree1')
129 self.addCleanup(branch.InterBranch.unregister_optimiser,
130 StubMatchingInter)
131 branch.InterBranch.register_optimiser(StubMatchingInter)
132
133=== modified file 'bzrlib/tests/per_interbranch/test_get.py'
134--- bzrlib/tests/per_interbranch/test_get.py 2010-06-14 06:37:11 +0000
135+++ bzrlib/tests/per_interbranch/test_get.py 2010-06-17 06:52:26 +0000
136@@ -24,10 +24,10 @@
137 )
138
139
140-class TestCopyContentInto(TestCaseWithInterBranch):
141+class TestInterBranchGet(TestCaseWithInterBranch):
142
143 def test_gets_right_inter(self):
144- self.tree1 = self.make_branch_and_tree('tree1')
145+ self.tree1 = self.make_from_branch_and_tree('tree1')
146 branch2 = self.make_to_branch('tree2')
147 self.assertIs(branch.InterBranch.get(
148 self.tree1.branch, branch2).__class__,
149
150=== modified file 'bzrlib/tests/per_interbranch/test_push.py'
151--- bzrlib/tests/per_interbranch/test_push.py 2010-02-23 07:43:11 +0000
152+++ bzrlib/tests/per_interbranch/test_push.py 2010-06-17 06:52:26 +0000
153@@ -145,7 +145,7 @@
154 except (errors.IncompatibleFormat, errors.UninitializableFormat):
155 # This Branch format cannot create shared repositories
156 return
157- # This is a little bit trickier because make_branch_and_tree will not
158+ # This is a little bit trickier because make_from_branch_and_tree will not
159 # re-use a shared repository.
160 try:
161 a_branch = self.make_from_branch('repo/tree')
162
163=== modified file 'bzrlib/tests/per_interbranch/test_update_revisions.py'
164--- bzrlib/tests/per_interbranch/test_update_revisions.py 2009-05-07 05:08:46 +0000
165+++ bzrlib/tests/per_interbranch/test_update_revisions.py 2010-06-17 06:52:26 +0000
166@@ -26,7 +26,7 @@
167
168 def setUp(self):
169 super(TestUpdateRevisions, self).setUp()
170- self.tree1 = self.make_branch_and_tree('tree1')
171+ self.tree1 = self.make_from_branch_and_tree('tree1')
172 rev1 = self.tree1.commit('one')
173 branch2 = self.make_to_branch('tree2')
174 branch2.repository.fetch(self.tree1.branch.repository)