Merge lp:~mbp/bzr/715000-stacking into lp:bzr/2.2

Proposed by Martin Pool on 2011-02-09
Status: Merged
Approved by: Martin Pool on 2011-02-09
Approved revision: 5127
Merged at revision: 5125
Proposed branch: lp:~mbp/bzr/715000-stacking
Merge into: lp:bzr/2.2
Diff against target: 132 lines (+66/-3)
6 files modified
NEWS (+4/-0)
bzrlib/groupcompress.py (+2/-2)
bzrlib/knit.py (+1/-1)
bzrlib/tests/per_repository_reference/__init__.py (+1/-0)
bzrlib/tests/per_repository_reference/test_graph.py (+45/-0)
bzrlib/versionedfile.py (+13/-0)
To merge this branch: bzr merge lp:~mbp/bzr/715000-stacking
Reviewer Review Type Date Requested Status
bzr-core 2011-02-09 Pending
Review via email: mp+49015@code.launchpad.net

Commit message

handle doubly-stacked repositories in get_known_graph_ancestry (bug 715000)

Description of the change

Per discussion in https://code.launchpad.net/~mbp/bzr/715000-stacking/+merge/48886 I think this is safe to merge to lp:bzr/2.2.

To post a comment you must log in.
Martin Pool (mbp) 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 2011-02-04 14:04:18 +0000
3+++ NEWS 2011-02-09 04:22:11 +0000
4@@ -20,6 +20,10 @@
5 Bug Fixes
6 *********
7
8+* Correctly handle ``bzr log`` and `get_known_graph_ancestry` on a
9+ doubly-stacked branch.
10+ (James Westby, Martin Pool, #715000)
11+
12 Improvements
13 ************
14
15
16=== modified file 'bzrlib/groupcompress.py'
17--- bzrlib/groupcompress.py 2010-05-20 02:57:52 +0000
18+++ bzrlib/groupcompress.py 2011-02-09 04:22:11 +0000
19@@ -1,4 +1,4 @@
20-# Copyright (C) 2008, 2009, 2010 Canonical Ltd
21+# Copyright (C) 2008-2011 Canonical Ltd
22 #
23 # This program is free software; you can redistribute it and/or modify
24 # it under the terms of the GNU General Public License as published by
25@@ -1293,7 +1293,7 @@
26 # KnitVersionedFiles.get_known_graph_ancestry, but they don't share
27 # ancestry.
28 parent_map, missing_keys = self._index.find_ancestry(keys)
29- for fallback in self._fallback_vfs:
30+ for fallback in self._transitive_fallbacks():
31 if not missing_keys:
32 break
33 (f_parent_map, f_missing_keys) = fallback._index.find_ancestry(
34
35=== modified file 'bzrlib/knit.py'
36--- bzrlib/knit.py 2010-06-04 03:09:35 +0000
37+++ bzrlib/knit.py 2011-02-09 04:22:11 +0000
38@@ -1195,7 +1195,7 @@
39 def get_known_graph_ancestry(self, keys):
40 """Get a KnownGraph instance with the ancestry of keys."""
41 parent_map, missing_keys = self._index.find_ancestry(keys)
42- for fallback in self._fallback_vfs:
43+ for fallback in self._transitive_fallbacks():
44 if not missing_keys:
45 break
46 (f_parent_map, f_missing_keys) = fallback._index.find_ancestry(
47
48=== modified file 'bzrlib/tests/per_repository_reference/__init__.py'
49--- bzrlib/tests/per_repository_reference/__init__.py 2010-05-20 02:57:52 +0000
50+++ bzrlib/tests/per_repository_reference/__init__.py 2011-02-09 04:22:11 +0000
51@@ -117,6 +117,7 @@
52 'bzrlib.tests.per_repository_reference.test_fetch',
53 'bzrlib.tests.per_repository_reference.test_get_record_stream',
54 'bzrlib.tests.per_repository_reference.test_get_rev_id_for_revno',
55+ 'bzrlib.tests.per_repository_reference.test_graph',
56 'bzrlib.tests.per_repository_reference.test_initialize',
57 'bzrlib.tests.per_repository_reference.test_unlock',
58 ]
59
60=== added file 'bzrlib/tests/per_repository_reference/test_graph.py'
61--- bzrlib/tests/per_repository_reference/test_graph.py 1970-01-01 00:00:00 +0000
62+++ bzrlib/tests/per_repository_reference/test_graph.py 2011-02-09 04:22:11 +0000
63@@ -0,0 +1,45 @@
64+# Copyright (C) 2011 Canonical Ltd
65+#
66+# This program is free software; you can redistribute it and/or modify
67+# it under the terms of the GNU General Public License as published by
68+# the Free Software Foundation; either version 2 of the License, or
69+# (at your option) any later version.
70+#
71+# This program is distributed in the hope that it will be useful,
72+# but WITHOUT ANY WARRANTY; without even the implied warranty of
73+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74+# GNU General Public License for more details.
75+#
76+# You should have received a copy of the GNU General Public License
77+# along with this program; if not, write to the Free Software
78+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
79+
80+
81+"""Tests for graph operations on stacked repositories."""
82+
83+
84+from bzrlib.tests.per_repository import TestCaseWithRepository
85+
86+
87+class TestGraph(TestCaseWithRepository):
88+
89+ def test_get_known_graph_ancestry_stacked(self):
90+ """get_known_graph_ancestry works correctly on stacking.
91+
92+ See <https://bugs.launchpad.net/bugs/715000>.
93+ """
94+ branch_a, branch_b, branch_c, revid_1 = self.make_double_stacked_branches()
95+ for br in [branch_c]:
96+ self.assertEquals(
97+ [revid_1],
98+ br.repository.get_known_graph_ancestry([revid_1]).topo_sort())
99+
100+ def make_double_stacked_branches(self):
101+ wt_a = self.make_branch_and_tree('a')
102+ branch_a = wt_a.branch
103+ branch_b = self.make_branch('b')
104+ branch_b.set_stacked_on_url('../a')
105+ branch_c = self.make_branch('c')
106+ branch_c.set_stacked_on_url('../b')
107+ revid_1 = wt_a.commit('first commit')
108+ return branch_a, branch_b, branch_c, revid_1
109
110=== modified file 'bzrlib/versionedfile.py'
111--- bzrlib/versionedfile.py 2010-05-14 12:55:13 +0000
112+++ bzrlib/versionedfile.py 2011-02-09 04:22:11 +0000
113@@ -1090,6 +1090,19 @@
114 def _extract_blocks(self, version_id, source, target):
115 return None
116
117+ def _transitive_fallbacks(self):
118+ """Return the whole stack of fallback versionedfiles.
119+
120+ This VersionedFiles may have a list of fallbacks, but it doesn't
121+ necessarily know about the whole stack going down, and it can't know
122+ at open time because they may change after the objects are opened.
123+ """
124+ all_fallbacks = []
125+ for a_vfs in self._fallback_vfs:
126+ all_fallbacks.append(a_vfs)
127+ all_fallbacks.extend(a_vfs._transitive_fallbacks())
128+ return all_fallbacks
129+
130
131 class ThunkedVersionedFiles(VersionedFiles):
132 """Storage for many versioned files thunked onto a 'VersionedFile' class.

Subscribers

People subscribed via source and target branches