1
# Copyright (C) 2006 by Canonical Ltd
2
# Authors: Aaron Bentley
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
from StringIO import StringIO
22
from bzrlib.bundle.read_bundle import BundleReader
23
from bzrlib.bzrdir import BzrDir
24
from bzrlib.tests import TestCaseInTempDir
27
class TestBundle(TestCaseInTempDir):
29
def test_uses_parent(self):
30
"""Parent location is used as a basis by default"""
32
parent_tree = BzrDir.create_standalone_workingtree('parent')
33
parent_tree.commit('initial commit', rev_id='revision1')
35
errmsg = self.run_bzr('bundle', retcode=3)[1]
36
self.assertContainsRe(errmsg, 'No base branch known or specified')
37
branch_tree = parent_tree.bzrdir.sprout('../branch').open_workingtree()
38
branch_tree.commit('next commit', rev_id='revision2')
39
branch_tree.commit('last commit', rev_id='revision3')
41
br = BundleReader(StringIO(self.run_bzr('bundle')[0]))
42
self.assertEqual(br.info.revisions[0].revision_id, 'revision3')
43
self.assertEqual(len(br.info.revisions), 2)
44
self.assertEqual(br.info.revisions[1].revision_id, 'revision2')