Merge lp:~lifeless/bzr/stacking-policy into lp:~bzr/bzr/trunk-old

Proposed by Robert Collins
Status: Merged
Approved by: Ian Clatworthy
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~lifeless/bzr/stacking-policy
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 154 lines (has conflicts)
Text conflict in NEWS
To merge this branch: bzr merge lp:~lifeless/bzr/stacking-policy
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+7782@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Do not stack on the same branch/repository anymore. This was never
supported and would generally result in infinite recursion. Fixes bug
376243
.

The approach taken is to raise an error when activating stacking
locations, which will also prevent the infinite recursion reported in
the bug for existing branches. [At the cost of stopping them opening -
but it will be much faster to error].

-Rob

Revision history for this message
John A Meinel (jameinel) wrote :

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

Robert Collins wrote:
> Robert Collins has proposed merging lp:~lifeless/bzr/stacking-policy into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
>
> Do not stack on the same branch/repository anymore. This was never
> supported and would generally result in infinite recursion. Fixes bug
> 376243.
>
> The approach taken is to raise an error when activating stacking
> locations, which will also prevent the infinite recursion reported in
> the bug for existing branches. [At the cost of stopping them opening -
> but it will be much faster to error].
>
> -Rob
>

  vote approve

What if we just didn't try to set the fallback and gave a warning,
rather than raising an error?

Regardless, it is better than triggering an endless loop. Though I
wonder if we really want a new exception. I suppose perhaps a server
would want to handle the error separately?

John
=:->

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

iEYEARECAAYFAkpASTUACgkQJdeBCYSNAANmFwCgjbTyTtbGSGQ708hqef8J56EY
Ja4An0PEFBVmYYc2UFR0sWupIMS6w0aC
=KbT4
-----END PGP SIGNATURE-----

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2009-06-22 21:55:37 +0000
3+++ NEWS 2009-06-23 03:35:14 +0000
4@@ -42,6 +42,7 @@
5 ``BZR_PROGRESS_BAR`` is set to ``none``.
6 (Martin Pool, #339385)
7
8+<<<<<<< TREE
9 * Reduced memory consumption during ``bzr commit`` of large files. For
10 pre 2a formats, should be down to ~3x the size of a file, and for
11 ``--2a`` formats should be down to exactly 2x the size. Related to bug
12@@ -54,6 +55,15 @@
13 * Unshelve works correctly when multiple zero-length files are present on
14 the shelf. (Aaron Bentley, #363444)
15
16+=======
17+* Stacking will no longer accept requests to stack on the same
18+ branch/repository. Existing branches that incorrectly reference the same
19+ repository in a stacking configuration will now raise
20+ UnstackableLocationError when the branch is opened. This can be fixed by
21+ removing the stacking location inside ``.bzr/branch``.
22+ (Robert Collins, #376243)
23+
24+>>>>>>> MERGE-SOURCE
25 Internals
26 *********
27
28
29=== modified file 'bzrlib/branch.py'
30--- bzrlib/branch.py 2009-06-17 03:53:51 +0000
31+++ bzrlib/branch.py 2009-06-23 03:35:14 +0000
32@@ -105,6 +105,8 @@
33 def _activate_fallback_location(self, url):
34 """Activate the branch/repository from url as a fallback repository."""
35 repo = self._get_fallback_repository(url)
36+ if repo.has_same_location(self.repository):
37+ raise errors.UnstackableLocationError(self.base, url)
38 self.repository.add_fallback_repository(repo)
39
40 def break_lock(self):
41
42=== modified file 'bzrlib/errors.py'
43--- bzrlib/errors.py 2009-06-17 05:05:28 +0000
44+++ bzrlib/errors.py 2009-06-23 03:35:14 +0000
45@@ -636,6 +636,16 @@
46 self.url = url
47
48
49+class UnstackableLocationError(BzrError):
50+
51+ _fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'."
52+
53+ def __init__(self, branch_url, target_url):
54+ BzrError.__init__(self)
55+ self.branch_url = branch_url
56+ self.target_url = target_url
57+
58+
59 class UnstackableRepositoryFormat(BzrError):
60
61 _fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
62
63=== modified file 'bzrlib/tests/branch_implementations/test_stacking.py'
64--- bzrlib/tests/branch_implementations/test_stacking.py 2009-06-11 07:43:56 +0000
65+++ bzrlib/tests/branch_implementations/test_stacking.py 2009-06-23 03:35:14 +0000
66@@ -78,6 +78,34 @@
67 return
68 self.assertEqual('../target', branch.get_stacked_on_url())
69
70+ def test_set_stacked_on_same_branch_raises(self):
71+ # Stacking on the same branch silently raises and doesn't execute the
72+ # change. Reported in bug 376243.
73+ branch = self.make_branch('branch')
74+ try:
75+ self.assertRaises(errors.UnstackableLocationError,
76+ branch.set_stacked_on_url, '../branch')
77+ except unstackable_format_errors:
78+ # if the set failed, so must the get
79+ self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
80+ return
81+ self.assertRaises(errors.NotStacked, branch.get_stacked_on_url)
82+
83+ def test_set_stacked_on_same_branch_after_being_stacked_raises(self):
84+ # Stacking on the same branch silently raises and doesn't execute the
85+ # change.
86+ branch = self.make_branch('branch')
87+ target = self.make_branch('target')
88+ try:
89+ branch.set_stacked_on_url('../target')
90+ except unstackable_format_errors:
91+ # if the set failed, so must the get
92+ self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
93+ return
94+ self.assertRaises(errors.UnstackableLocationError,
95+ branch.set_stacked_on_url, '../branch')
96+ self.assertEqual('../target', branch.get_stacked_on_url())
97+
98 def assertRevisionInRepository(self, repo_path, revid):
99 """Check that a revision is in a repository, disregarding stacking."""
100 repo = bzrdir.BzrDir.open(repo_path).open_repository()
101
102=== modified file 'bzrlib/tests/bzrdir_implementations/test_push.py'
103--- bzrlib/tests/bzrdir_implementations/test_push.py 2009-04-03 14:24:40 +0000
104+++ bzrlib/tests/bzrdir_implementations/test_push.py 2009-06-23 03:35:14 +0000
105@@ -33,13 +33,13 @@
106 tree.commit('one', rev_id='r1')
107 return tree
108
109- def test_push_new_branch(self):
110+ def test_push_new_branch(self):
111 tree = self.create_simple_tree()
112 dir = self.make_repository('dir').bzrdir
113 result = dir.push_branch(tree.branch)
114 self.assertEquals(tree.branch, result.source_branch)
115 self.assertEquals(dir.open_branch().base, result.target_branch.base)
116- self.assertEquals(dir.open_branch().base,
117+ self.assertEquals(dir.open_branch().base,
118 tree.branch.get_push_location())
119
120 def test_push_new_empty(self):
121@@ -47,7 +47,7 @@
122 dir = self.make_repository('dir').bzrdir
123 result = dir.push_branch(tree.branch)
124 self.assertEquals(tree.branch.base, result.source_branch.base)
125- self.assertEquals(dir.open_branch().base,
126+ self.assertEquals(dir.open_branch().base,
127 result.target_branch.base)
128
129 def test_push_incremental(self):
130@@ -58,7 +58,7 @@
131 tree.add(['b'])
132 tree.commit('two', rev_id='r2')
133 result = dir.push_branch(tree.branch)
134- self.assertEquals(tree.last_revision(),
135+ self.assertEquals(tree.last_revision(),
136 result.branch_push_result.new_revid)
137 self.assertEquals(2, result.branch_push_result.new_revno)
138 self.assertEquals(tree.branch.base, result.source_branch.base)
139
140=== modified file 'bzrlib/tests/test_errors.py'
141--- bzrlib/tests/test_errors.py 2009-05-01 06:42:30 +0000
142+++ bzrlib/tests/test_errors.py 2009-06-23 03:35:14 +0000
143@@ -242,6 +242,11 @@
144 "You will need to upgrade the branch to permit branch stacking.",
145 str(error))
146
147+ def test_unstackable_location(self):
148+ error = errors.UnstackableLocationError('foo', 'bar')
149+ self.assertEqualDiff("The branch 'foo' cannot be stacked on 'bar'.",
150+ str(error))
151+
152 def test_unstackable_repository_format(self):
153 format = u'foo'
154 url = "/foo"