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
1=== modified file 'bzrlib/controldir.py'
2--- bzrlib/controldir.py 2011-01-26 19:34:58 +0000
3+++ bzrlib/controldir.py 2011-03-21 14:47:24 +0000
4@@ -503,6 +503,10 @@
5 if br_to is None:
6 # We have a repository but no branch, copy the revisions, and then
7 # create a branch.
8+ if revision_id is None:
9+ # No revision supplied by the user, default to the branch
10+ # revision
11+ revision_id = source.last_revision()
12 repository_to.fetch(source.repository, revision_id=revision_id)
13 br_to = source.clone(self, revision_id=revision_id)
14 if source.get_push_location() is None or remember:
15
16=== modified file 'bzrlib/tests/blackbox/test_push.py'
17--- bzrlib/tests/blackbox/test_push.py 2011-01-10 22:20:12 +0000
18+++ bzrlib/tests/blackbox/test_push.py 2011-03-21 14:47:24 +0000
19@@ -204,6 +204,22 @@
20 % tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
21 self.failUnlessExists('to-two')
22
23+ def test_push_repository_no_branch_doesnt_fetch_all_revs(self):
24+ # See https://bugs.launchpad.net/bzr/+bug/465517
25+ target_repo = self.make_repository('target')
26+ source = self.make_branch_builder('source')
27+ source.start_series()
28+ source.build_snapshot('A', None, [
29+ ('add', ('', 'root-id', 'directory', None))])
30+ source.build_snapshot('B', ['A'], [])
31+ source.build_snapshot('C', ['A'], [])
32+ source.finish_series()
33+ self.run_bzr('push target -d source')
34+ self.addCleanup(target_repo.lock_read().unlock)
35+ # We should have pushed 'C', but not 'B', since it isn't in the
36+ # ancestry
37+ self.assertEqual([('A',), ('C',)], sorted(target_repo.revisions.keys()))
38+
39 def test_push_smart_non_stacked_streaming_acceptance(self):
40 self.setup_smart_server_with_call_log()
41 t = self.make_branch_and_tree('from')
42
43=== modified file 'bzrlib/tests/per_branch/test_push.py'
44--- bzrlib/tests/per_branch/test_push.py 2011-03-17 06:45:35 +0000
45+++ bzrlib/tests/per_branch/test_push.py 2011-03-21 14:47:24 +0000
46@@ -1,4 +1,4 @@
47-# Copyright (C) 2007-2010 Canonical Ltd
48+# Copyright (C) 2007-2011 Canonical Ltd
49 #
50 # This program is free software; you can redistribute it and/or modify
51 # it under the terms of the GNU General Public License as published by
52@@ -187,6 +187,41 @@
53 self.assertEqual(tree.branch.last_revision(),
54 to_branch.last_revision())
55
56+ def test_push_repository_no_branch_doesnt_fetch_all_revs(self):
57+ # See https://bugs.launchpad.net/bzr/+bug/465517
58+ t = self.get_transport('target')
59+ t.ensure_base()
60+ bzrdir = self.bzrdir_format.initialize_on_transport(t)
61+ try:
62+ bzrdir.open_branch()
63+ except errors.NotBranchError:
64+ pass
65+ else:
66+ raise tests.TestNotApplicable('older formats can\'t have a repo'
67+ ' without a branch')
68+ try:
69+ source = self.make_branch_builder('source',
70+ format=self.bzrdir_format)
71+ except errors.UninitializableFormat:
72+ raise tests.TestNotApplicable('cannot initialize this format')
73+ source.start_series()
74+ source.build_snapshot('A', None, [
75+ ('add', ('', 'root-id', 'directory', None))])
76+ source.build_snapshot('B', ['A'], [])
77+ source.build_snapshot('C', ['A'], [])
78+ source.finish_series()
79+ b = source.get_branch()
80+ # Note: We can't read lock the source branch. Some formats take a write
81+ # lock to 'set_push_location', which breaks
82+ self.addCleanup(b.lock_write().unlock)
83+ repo = bzrdir.create_repository()
84+ # This means 'push the source branch into this dir'
85+ bzrdir.push_branch(b)
86+ self.addCleanup(repo.lock_read().unlock)
87+ # We should have pushed 'C', but not 'B', since it isn't in the
88+ # ancestry
89+ self.assertEqual([('A',), ('C',)], sorted(repo.revisions.keys()))
90+
91 def test_push_overwrite_of_non_tip_with_stop_revision(self):
92 """Combining the stop_revision and overwrite options works.
93
94
95=== modified file 'doc/en/release-notes/bzr-2.3.txt'
96--- doc/en/release-notes/bzr-2.3.txt 2011-03-18 01:46:22 +0000
97+++ doc/en/release-notes/bzr-2.3.txt 2011-03-21 14:47:24 +0000
98@@ -32,6 +32,11 @@
99 .. Fixes for situations where bzr would previously crash or give incorrect
100 or undesirable results.
101
102+* ``bzr push`` into a repository (that doesn't have a branch), will no
103+ longer copy all revisions in the repository. Only the ones in the
104+ ancestry of the source branch, like it does in all other cases.
105+ (John Arbash Meinel, #465517)
106+
107 * Fix "Unable to obtain lock" error when pushing to a bound branch if tags
108 had changed. Bazaar was attempting to open and lock the master branch
109 twice in this case. (Andrew Bennetts, #733350)

Subscribers

People subscribed via source and target branches