1
# Copyright (C) 2009 Canonical Ltd
3
# 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 by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Tests for branch.create_clone behaviour."""
19
from bzrlib.tests.branch_implementations.test_branch import TestCaseWithBranch
22
class TestCreateClone(TestCaseWithBranch):
24
def test_create_clone_on_transport_no_revision_id(self):
25
tree = self.make_branch_and_tree('source')
26
tree.commit('a commit')
28
target_transport = self.get_transport('target')
29
result = tree.branch.create_clone_on_transport(target_transport)
30
self.assertEqual(source.last_revision(), result.last_revision())
32
def test_create_clone_on_transport_revision_id(self):
33
tree = self.make_branch_and_tree('source')
34
old_revid = tree.commit('a commit')
35
source_tip = tree.commit('a second commit')
37
target_transport = self.get_transport('target')
38
result = tree.branch.create_clone_on_transport(target_transport,
39
revision_id=old_revid)
40
self.assertEqual(old_revid, result.last_revision())
42
self.addCleanup(result.unlock)
43
self.assertFalse(result.repository.has_revision(source_tip))
45
def test_create_clone_on_transport_stacked(self):
46
tree = self.make_branch_and_tree('source')
47
tree.commit('a commit')
48
trunk = tree.branch.create_clone_on_transport(
49
self.get_transport('trunk'))
50
revid = tree.commit('a second commit')
52
target_transport = self.get_transport('target')
53
result = tree.branch.create_clone_on_transport(target_transport,
54
stacked_on=trunk.base)
55
self.assertEqual(revid, result.last_revision())
56
self.assertEqual(trunk.base, result.get_stacked_on_url())