/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright (C) 2006-2012 Aaron Bentley
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#

"""Tests of the 'brz import' command."""

import os

from ... import (
    osutils,
    tests,
    urlutils,
    )
from .. import (
    features,
    script,
    )


LzmaFeature = features.ModuleAvailableFeature("lzma")


class TestImport(tests.TestCaseWithTransport):

    def test_import_upstream(self):
        self.run_bzr('init source')
        os.mkdir('source/src')
        with open('source/src/myfile', 'wb') as f:
            f.write(b'hello?')
        os.chdir('source')
        self.run_bzr('add')
        self.run_bzr('commit -m hello')
        self.run_bzr('export ../source-0.1.tar.gz')
        self.run_bzr('export ../source-0.1.tar.bz2')
        self.run_bzr('export ../source-0.1')
        self.run_bzr('init ../import')
        os.chdir('../import')
        self.run_bzr('import ../source-0.1.tar.gz')
        self.assertPathExists('src/myfile')
        result = self.run_bzr('import ../source-0.1.tar.gz', retcode=3)[1]
        self.assertContainsRe(result, 'Working tree has uncommitted changes')
        self.run_bzr('commit -m commit')
        self.run_bzr('import ../source-0.1.tar.gz')
        os.chdir('..')
        self.run_bzr('init import2')
        self.run_bzr('import source-0.1.tar.gz import2')
        self.assertPathExists('import2/src/myfile')
        self.run_bzr('import source-0.1.tar.gz import3')
        self.assertPathExists('import3/src/myfile')
        self.run_bzr('import source-0.1.tar.bz2 import4')
        self.assertPathExists('import4/src/myfile')
        self.run_bzr('import source-0.1 import5')
        self.assertPathExists('import5/src/myfile')

    def test_import_upstream_lzma(self):
        self.requireFeature(LzmaFeature)
        self.run_bzr('init source')
        os.mkdir('source/src')
        with open('source/src/myfile', 'wb') as f:
            f.write(b'hello?')
        os.chdir('source')
        self.run_bzr('add')
        self.run_bzr('commit -m hello')
        self.run_bzr('export ../source-0.1.tar.lzma')
        self.run_bzr('export ../source-0.1.tar.xz')
        os.chdir('..')
        self.run_bzr('import source-0.1.tar.lzma import1')
        self.assertPathExists('import1/src/myfile')
        self.run_bzr('import source-0.1.tar.xz import2')
        self.assertPathExists('import2/src/myfile')