Merge lp:~jameinel/bzr/2.3-push-copy-repo-465517 into lp:bzr/2.3

Proposed by John A Meinel
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 5631
Proposed branch: lp:~jameinel/bzr/2.3-push-copy-repo-465517
Merge into: lp:bzr/2.3
Diff against target: 109 lines (+61/-1)
4 files modified
bzrlib/controldir.py (+4/-0)
bzrlib/tests/blackbox/test_push.py (+16/-0)
bzrlib/tests/per_branch/test_push.py (+36/-1)
doc/en/release-notes/bzr-2.3.txt (+5/-0)
To merge this branch: bzr merge lp:~jameinel/bzr/2.3-push-copy-repo-465517
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+54218@code.launchpad.net

Commit message

Fix bug #465517, 'bzr push' to a repo w/ no branch should only push the branch ancestry, not all revs in the repo.

Description of the change

This fixes a long-standing bug. If you interrupt a push to a new branch on Launchpad, it can leave a Repository with no Branch. If you then start the push over again, you end up pushing the whole local repository, instead of just the tip revision. (Most noticeable in my repo that mixes plugins with bzr source.)

It doesn't solve the remaining bug, that the final branch isn't stacked like it should be. But I'm not subscribed as "In Progress" to that bug :).

I'm targeting 2.3 because it was easy enough. I thought about backporting, but at 2.3 we switched from having the code in "bzrdir.py" to "controldir.py", and that was a sufficient threshold that I didn't bother going further back.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

W00t.

"But I'm not subscribed as "In Progress" to that bug :)" doesn't parse. Do you mean you're working on that bit as well?

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

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

On 3/21/2011 4:29 PM, Jelmer Vernooij wrote:
> W00t.
>
> "But I'm not subscribed as "In Progress" to that bug :)" doesn't parse. Do you mean you're working on that bit as well?

I'm clearing out my "todo" queue, that bug isn't in my todo queue.

John
=:->

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

iEYEARECAAYFAk2HdKYACgkQJdeBCYSNAAMalQCbBJ9F5/Hsi3hB8XkAzaLLAiJK
zSMAoKJ4o8vLdbe5vGasA1yyoqDbvXap
=Ep5U
-----END PGP SIGNATURE-----

Revision history for this message
Martin Pool (mbp) :
review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/controldir.py'
--- bzrlib/controldir.py 2011-01-26 19:34:58 +0000
+++ bzrlib/controldir.py 2011-03-21 14:47:24 +0000
@@ -503,6 +503,10 @@
503 if br_to is None:503 if br_to is None:
504 # We have a repository but no branch, copy the revisions, and then504 # We have a repository but no branch, copy the revisions, and then
505 # create a branch.505 # create a branch.
506 if revision_id is None:
507 # No revision supplied by the user, default to the branch
508 # revision
509 revision_id = source.last_revision()
506 repository_to.fetch(source.repository, revision_id=revision_id)510 repository_to.fetch(source.repository, revision_id=revision_id)
507 br_to = source.clone(self, revision_id=revision_id)511 br_to = source.clone(self, revision_id=revision_id)
508 if source.get_push_location() is None or remember:512 if source.get_push_location() is None or remember:
509513
=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- bzrlib/tests/blackbox/test_push.py 2011-01-10 22:20:12 +0000
+++ bzrlib/tests/blackbox/test_push.py 2011-03-21 14:47:24 +0000
@@ -204,6 +204,22 @@
204 % tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))204 % tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
205 self.failUnlessExists('to-two')205 self.failUnlessExists('to-two')
206206
207 def test_push_repository_no_branch_doesnt_fetch_all_revs(self):
208 # See https://bugs.launchpad.net/bzr/+bug/465517
209 target_repo = self.make_repository('target')
210 source = self.make_branch_builder('source')
211 source.start_series()
212 source.build_snapshot('A', None, [
213 ('add', ('', 'root-id', 'directory', None))])
214 source.build_snapshot('B', ['A'], [])
215 source.build_snapshot('C', ['A'], [])
216 source.finish_series()
217 self.run_bzr('push target -d source')
218 self.addCleanup(target_repo.lock_read().unlock)
219 # We should have pushed 'C', but not 'B', since it isn't in the
220 # ancestry
221 self.assertEqual([('A',), ('C',)], sorted(target_repo.revisions.keys()))
222
207 def test_push_smart_non_stacked_streaming_acceptance(self):223 def test_push_smart_non_stacked_streaming_acceptance(self):
208 self.setup_smart_server_with_call_log()224 self.setup_smart_server_with_call_log()
209 t = self.make_branch_and_tree('from')225 t = self.make_branch_and_tree('from')
210226
=== modified file 'bzrlib/tests/per_branch/test_push.py'
--- bzrlib/tests/per_branch/test_push.py 2011-03-17 06:45:35 +0000
+++ bzrlib/tests/per_branch/test_push.py 2011-03-21 14:47:24 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2007-2010 Canonical Ltd1# Copyright (C) 2007-2011 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -187,6 +187,41 @@
187 self.assertEqual(tree.branch.last_revision(),187 self.assertEqual(tree.branch.last_revision(),
188 to_branch.last_revision())188 to_branch.last_revision())
189189
190 def test_push_repository_no_branch_doesnt_fetch_all_revs(self):
191 # See https://bugs.launchpad.net/bzr/+bug/465517
192 t = self.get_transport('target')
193 t.ensure_base()
194 bzrdir = self.bzrdir_format.initialize_on_transport(t)
195 try:
196 bzrdir.open_branch()
197 except errors.NotBranchError:
198 pass
199 else:
200 raise tests.TestNotApplicable('older formats can\'t have a repo'
201 ' without a branch')
202 try:
203 source = self.make_branch_builder('source',
204 format=self.bzrdir_format)
205 except errors.UninitializableFormat:
206 raise tests.TestNotApplicable('cannot initialize this format')
207 source.start_series()
208 source.build_snapshot('A', None, [
209 ('add', ('', 'root-id', 'directory', None))])
210 source.build_snapshot('B', ['A'], [])
211 source.build_snapshot('C', ['A'], [])
212 source.finish_series()
213 b = source.get_branch()
214 # Note: We can't read lock the source branch. Some formats take a write
215 # lock to 'set_push_location', which breaks
216 self.addCleanup(b.lock_write().unlock)
217 repo = bzrdir.create_repository()
218 # This means 'push the source branch into this dir'
219 bzrdir.push_branch(b)
220 self.addCleanup(repo.lock_read().unlock)
221 # We should have pushed 'C', but not 'B', since it isn't in the
222 # ancestry
223 self.assertEqual([('A',), ('C',)], sorted(repo.revisions.keys()))
224
190 def test_push_overwrite_of_non_tip_with_stop_revision(self):225 def test_push_overwrite_of_non_tip_with_stop_revision(self):
191 """Combining the stop_revision and overwrite options works.226 """Combining the stop_revision and overwrite options works.
192227
193228
=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- doc/en/release-notes/bzr-2.3.txt 2011-03-18 01:46:22 +0000
+++ doc/en/release-notes/bzr-2.3.txt 2011-03-21 14:47:24 +0000
@@ -32,6 +32,11 @@
32.. Fixes for situations where bzr would previously crash or give incorrect32.. Fixes for situations where bzr would previously crash or give incorrect
33 or undesirable results.33 or undesirable results.
3434
35* ``bzr push`` into a repository (that doesn't have a branch), will no
36 longer copy all revisions in the repository. Only the ones in the
37 ancestry of the source branch, like it does in all other cases.
38 (John Arbash Meinel, #465517)
39
35* Fix "Unable to obtain lock" error when pushing to a bound branch if tags40* Fix "Unable to obtain lock" error when pushing to a bound branch if tags
36 had changed. Bazaar was attempting to open and lock the master branch41 had changed. Bazaar was attempting to open and lock the master branch
37 twice in this case. (Andrew Bennetts, #733350)42 twice in this case. (Andrew Bennetts, #733350)

Subscribers

People subscribed via source and target branches