Merge lp:~spiv/bzr/inter1and2helper-636930-2.2 into lp:bzr/2.2

Proposed by Andrew Bennetts
Status: Merged
Approved by: Andrew Bennetts
Approved revision: no longer in the source branch.
Merged at revision: 5087
Proposed branch: lp:~spiv/bzr/inter1and2helper-636930-2.2
Merge into: lp:bzr/2.2
Diff against target: 133 lines (+30/-10)
4 files modified
NEWS (+6/-0)
bzrlib/fetch.py (+5/-4)
bzrlib/tests/per_interrepository/__init__.py (+14/-3)
bzrlib/tests/test_selftest.py (+5/-3)
To merge this branch: bzr merge lp:~spiv/bzr/inter1and2helper-636930-2.2
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+35358@code.launchpad.net

Commit message

Fix fetching more than 100 revisions from non-rich-root to rich-root repositories.

Description of the change

This fixes a regression in 2.2 caused by very shallow bug. I've also added another per_interrepo scenario so that this case gets some test coverage so it won't break again. The new scenario isn't the most elegant thing ever, but actually the cost in terms of code complexity and in terms of test running time is pretty low, so I think it's worth it.

The really elegant fix is to get rid of InterDifferingSerializer in favour of using streaming fetch all the time ;)

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

nice, thanks.

you might want to check if the other reports gz mentioned in that bug are in fact dupes.

review: Approve
Revision history for this message
Andrew Bennetts (spiv) wrote :

sent to pqm by email

Revision history for this message
Andrew Bennetts (spiv) 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-09-13 02:32:44 +0000
3+++ NEWS 2010-09-14 07:16:05 +0000
4@@ -46,6 +46,12 @@
5 later which can mangle bytestrings printed to the console.
6 (Martin [gz], #631350)
7
8+* Upgrading or fetching from a non-rich-root repository to a rich-root
9+ repository (e.g. from pack-0.92 to 2a) no longer fails with
10+ ``'Inter1and2Helper' object has no attribute 'source_repo'``. This was
11+ a regression from Bazaar 2.1. (Andrew Bennetts, #636930)
12+
13+
14 Improvements
15 ************
16
17
18=== modified file 'bzrlib/fetch.py'
19--- bzrlib/fetch.py 2010-05-13 10:08:32 +0000
20+++ bzrlib/fetch.py 2010-09-14 07:16:05 +0000
21@@ -182,6 +182,9 @@
22 This is for use by fetchers and converters.
23 """
24
25+ # This is a class variable so that the test suite can override it.
26+ known_graph_threshold = 100
27+
28 def __init__(self, source):
29 """Constructor.
30
31@@ -243,10 +246,8 @@
32 # yet, and are unlikely to in non-rich-root environments anyway.
33 root_id_order.sort(key=operator.itemgetter(0))
34 # Create a record stream containing the roots to create.
35- if len(revs) > 100:
36- # XXX: not covered by tests, should have a flag to always run
37- # this. -- mbp 20100129
38- graph = self.source_repo.get_known_graph_ancestry(revs)
39+ if len(revs) > self.known_graph_threshold:
40+ graph = self.source.get_known_graph_ancestry(revs)
41 new_roots_stream = _new_root_data_stream(
42 root_id_order, rev_id_to_root_id, parent_map, self.source, graph)
43 return [('texts', new_roots_stream)]
44
45=== modified file 'bzrlib/tests/per_interrepository/__init__.py'
46--- bzrlib/tests/per_interrepository/__init__.py 2010-06-20 11:18:38 +0000
47+++ bzrlib/tests/per_interrepository/__init__.py 2010-09-14 07:16:05 +0000
48@@ -49,7 +49,7 @@
49 (label, repository_format, repository_format_to).
50 """
51 result = []
52- for label, repository_format, repository_format_to in formats:
53+ for label, repository_format, repository_format_to, extra_setup in formats:
54 id = '%s,%s,%s' % (label, repository_format.__class__.__name__,
55 repository_format_to.__class__.__name__)
56 scenario = (id,
57@@ -57,6 +57,7 @@
58 "transport_readonly_server": transport_readonly_server,
59 "repository_format": repository_format,
60 "repository_format_to": repository_format_to,
61+ "extra_setup": extra_setup,
62 })
63 result.append(scenario)
64 return result
65@@ -71,8 +72,8 @@
66 weaverepo,
67 )
68 result = []
69- def add_combo(label, from_format, to_format):
70- result.append((label, from_format, to_format))
71+ def add_combo(label, from_format, to_format, extra_setup=None):
72+ result.append((label, from_format, to_format, extra_setup))
73 # test the default InterRepository between format 6 and the current
74 # default format.
75 # XXX: robertc 20060220 reinstate this when there are two supported
76@@ -89,6 +90,9 @@
77 # XXX: although we attach InterRepository class names to these scenarios,
78 # there's nothing asserting that these labels correspond to what is
79 # actually used.
80+ def force_known_graph(testcase):
81+ from bzrlib.fetch import Inter1and2Helper
82+ testcase.overrideAttr(Inter1and2Helper, 'known_graph_threshold', -1)
83 add_combo('InterRepository',
84 weaverepo.RepositoryFormat5(),
85 knitrepo.RepositoryFormatKnit3())
86@@ -113,6 +117,11 @@
87 add_combo('InterDifferingSerializer',
88 pack_repo.RepositoryFormatKnitPack1(),
89 pack_repo.RepositoryFormatKnitPack6RichRoot())
90+ add_combo('InterDifferingSerializer+get_known_graph_ancestry',
91+ pack_repo.RepositoryFormatKnitPack1(),
92+ pack_repo.RepositoryFormatKnitPack6RichRoot(),
93+ force_known_graph,
94+ )
95 add_combo('InterDifferingSerializer',
96 pack_repo.RepositoryFormatKnitPack6RichRoot(),
97 groupcompress_repo.RepositoryFormat2a())
98@@ -132,6 +141,8 @@
99
100 def setUp(self):
101 super(TestCaseWithInterRepository, self).setUp()
102+ if self.extra_setup:
103+ self.extra_setup(self)
104
105 def make_branch(self, relpath, format=None):
106 repo = self.make_repository(relpath, format=format)
107
108=== modified file 'bzrlib/tests/test_selftest.py'
109--- bzrlib/tests/test_selftest.py 2010-06-20 11:18:38 +0000
110+++ bzrlib/tests/test_selftest.py 2010-09-14 07:16:05 +0000
111@@ -312,19 +312,21 @@
112 from bzrlib.tests.per_interrepository import make_scenarios
113 server1 = "a"
114 server2 = "b"
115- formats = [("C0", "C1", "C2"), ("D0", "D1", "D2")]
116+ formats = [("C0", "C1", "C2", "C3"), ("D0", "D1", "D2", "D3")]
117 scenarios = make_scenarios(server1, server2, formats)
118 self.assertEqual([
119 ('C0,str,str',
120 {'repository_format': 'C1',
121 'repository_format_to': 'C2',
122 'transport_readonly_server': 'b',
123- 'transport_server': 'a'}),
124+ 'transport_server': 'a',
125+ 'extra_setup': 'C3'}),
126 ('D0,str,str',
127 {'repository_format': 'D1',
128 'repository_format_to': 'D2',
129 'transport_readonly_server': 'b',
130- 'transport_server': 'a'})],
131+ 'transport_server': 'a',
132+ 'extra_setup': 'D3'})],
133 scenarios)
134
135

Subscribers

People subscribed via source and target branches