Rev 5630: Fix bug #465517, 'bzr push' to a target with a repo but no branch in http://bazaar.launchpad.net/~jameinel/bzr/2.3-push-copy-repo-465517
John Arbash Meinel
john at arbash-meinel.com
Mon Mar 21 14:35:39 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/2.3-push-copy-repo-465517
------------------------------------------------------------
revno: 5630
revision-id: john at arbash-meinel.com-20110321143533-085v1wvpp026c8fj
parent: pqm at pqm.ubuntu.com-20110321050337-u4uytp6ia37ffach
fixes bug(s): https://launchpad.net/bugs/465517
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.3-push-copy-repo-465517
timestamp: Mon 2011-03-21 15:35:33 +0100
message:
Fix bug #465517, 'bzr push' to a target with a repo but no branch
should not copy the entire repository into the target.
We thought we were passing an explicit 'revision_id' parameter, but it turns out
that is the user revision_id, which is usually None.
-------------- next part --------------
=== modified file 'bzrlib/controldir.py'
--- a/bzrlib/controldir.py 2011-01-26 19:34:58 +0000
+++ b/bzrlib/controldir.py 2011-03-21 14:35:33 +0000
@@ -503,6 +503,10 @@
if br_to is None:
# We have a repository but no branch, copy the revisions, and then
# create a branch.
+ if revision_id is None:
+ # No revision supplied by the user, default to the branch
+ # revision
+ revision_id = source.last_revision()
repository_to.fetch(source.repository, revision_id=revision_id)
br_to = source.clone(self, revision_id=revision_id)
if source.get_push_location() is None or remember:
=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py 2011-01-10 22:20:12 +0000
+++ b/bzrlib/tests/blackbox/test_push.py 2011-03-21 14:35:33 +0000
@@ -204,6 +204,22 @@
% tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
self.failUnlessExists('to-two')
+ def test_push_repository_no_branch_doesnt_fetch_all_revs(self):
+ # See https://bugs.launchpad.net/bzr/+bug/465517
+ target_repo = self.make_repository('target')
+ source = self.make_branch_builder('source')
+ source.start_series()
+ source.build_snapshot('A', None, [
+ ('add', ('', 'root-id', 'directory', None))])
+ source.build_snapshot('B', ['A'], [])
+ source.build_snapshot('C', ['A'], [])
+ source.finish_series()
+ self.run_bzr('push target -d source')
+ self.addCleanup(target_repo.lock_read().unlock)
+ # We should have pushed 'C', but not 'B', since it isn't in the
+ # ancestry
+ self.assertEqual([('A',), ('C',)], sorted(target_repo.revisions.keys()))
+
def test_push_smart_non_stacked_streaming_acceptance(self):
self.setup_smart_server_with_call_log()
t = self.make_branch_and_tree('from')
=== modified file 'bzrlib/tests/per_branch/test_push.py'
--- a/bzrlib/tests/per_branch/test_push.py 2011-03-17 06:45:35 +0000
+++ b/bzrlib/tests/per_branch/test_push.py 2011-03-21 14:35:33 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2010 Canonical Ltd
+# Copyright (C) 2007-2011 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -187,6 +187,41 @@
self.assertEqual(tree.branch.last_revision(),
to_branch.last_revision())
+ def test_push_repository_no_branch_doesnt_fetch_all_revs(self):
+ # See https://bugs.launchpad.net/bzr/+bug/465517
+ t = self.get_transport('target')
+ t.ensure_base()
+ bzrdir = self.bzrdir_format.initialize_on_transport(t)
+ try:
+ bzrdir.open_branch()
+ except errors.NotBranchError:
+ pass
+ else:
+ raise tests.TestNotApplicable('older formats can\'t have a repo'
+ ' without a branch')
+ try:
+ source = self.make_branch_builder('source',
+ format=self.bzrdir_format)
+ except errors.UninitializableFormat:
+ raise tests.TestNotApplicable('cannot initialize this format')
+ source.start_series()
+ source.build_snapshot('A', None, [
+ ('add', ('', 'root-id', 'directory', None))])
+ source.build_snapshot('B', ['A'], [])
+ source.build_snapshot('C', ['A'], [])
+ source.finish_series()
+ b = source.get_branch()
+ # Note: We can't read lock the source branch. Some formats take a write
+ # lock to 'set_push_location', which breaks
+ self.addCleanup(b.lock_write().unlock)
+ repo = bzrdir.create_repository()
+ # This means 'push the source branch into this dir'
+ bzrdir.push_branch(b)
+ self.addCleanup(repo.lock_read().unlock)
+ # We should have pushed 'C', but not 'B', since it isn't in the
+ # ancestry
+ self.assertEqual([('A',), ('C',)], sorted(repo.revisions.keys()))
+
def test_push_overwrite_of_non_tip_with_stop_revision(self):
"""Combining the stop_revision and overwrite options works.
=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt 2011-03-18 01:46:22 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt 2011-03-21 14:35:33 +0000
@@ -32,6 +32,11 @@
.. Fixes for situations where bzr would previously crash or give incorrect
or undesirable results.
+* ``bzr push`` into a repository (that doesn't have a branch), will no
+ longer copy all revisions in the repository. Only the ones in the
+ ancestry of the source branch, like it does in all other cases.
+ (John Arbash Meinel, #465517)
+
* Fix "Unable to obtain lock" error when pushing to a bound branch if tags
had changed. Bazaar was attempting to open and lock the master branch
twice in this case. (Andrew Bennetts, #733350)
More information about the bazaar-commits
mailing list