~bzr-pqm/bzr/bzr.dev

4593.2.1 by Martin Pool
bundle_info blackbox test passes on rich-root formats
1
# Copyright (C) 2007, 2009 Canonical Ltd
1551.18.5 by Aaron Bentley
Add test cases for bzr bundle-info
2
#
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.
7
#
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.
12
#
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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1551.18.5 by Aaron Bentley
Add test cases for bzr bundle-info
16
17
18
from bzrlib import (
19
    merge_directive,
20
    tests,
21
    )
22
23
24
class TestBundleInfo(tests.TestCaseWithTransport):
25
26
    def test_bundle_info(self):
27
        source = self.make_branch_and_tree('source')
28
        self.build_tree(['source/foo'])
29
        source.add('foo')
30
        source.commit('added file', rev_id='rev1')
31
        bundle = open('bundle', 'wb')
32
        try:
33
            source.branch.repository.create_bundle('rev1', 'null:', bundle,
34
                                                   '4')
35
        finally:
36
            bundle.close()
37
        info = self.run_bzr('bundle-info bundle')[0]
4593.2.1 by Martin Pool
bundle_info blackbox test passes on rich-root formats
38
        # there might be either one file, or two, depending on whether the
39
        # tree root counts...
40
        self.assertContainsRe(info, 'file: [12] .0 multiparent.')
1551.18.5 by Aaron Bentley
Add test cases for bzr bundle-info
41
        self.assertContainsRe(info, 'nicks: source')
42
        self.assertNotContainsRe(info, 'foo')
3221.1.6 by Martin Pool
Better error message from bundle-info
43
        self.run_bzr_error(['--verbose requires a merge directive'],
1551.18.5 by Aaron Bentley
Add test cases for bzr bundle-info
44
                           'bundle-info -v bundle')
45
        target = self.make_branch('target')
46
        md = merge_directive.MergeDirective2.from_objects(
47
            source.branch.repository, 'rev1', 0, 0, 'target',
48
            base_revision_id='null:')
49
        directive = open('directive', 'wb')
50
        try:
51
            directive.writelines(md.to_lines())
52
        finally:
53
            directive.close()
54
        info = self.run_bzr('bundle-info -v directive')[0]
55
        self.assertContainsRe(info, 'foo')