/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.82.1 by Ian Clatworthy
nicer and round-trippable mapping of git ref names to bzr branch names
1
# Copyright (C) 2009 Canonical Ltd
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
"""Test the BranchMapper methods."""
18
19
from bzrlib import tests
20
21
from bzrlib.plugins.fastimport import (
22
    branch_mapper,
23
    )
24
25
26
class TestBranchMapper(tests.TestCase):
27
28
    def test_git_to_bzr(self):
29
        m = branch_mapper.BranchMapper()
0.112.3 by Max Bowsher
Make BranchMapper just map one name per call.
30
        for git, bzr in {
0.82.1 by Ian Clatworthy
nicer and round-trippable mapping of git ref names to bzr branch names
31
            'refs/heads/master':                'trunk',
32
            'refs/heads/foo':                   'foo',
33
            'refs/tags/master':                 'trunk.tag',
34
            'refs/tags/foo':                    'foo.tag',
35
            'refs/remotes/origin/master':       'trunk.remote',
36
            'refs/remotes/origin/foo':          'foo.remote',
0.112.3 by Max Bowsher
Make BranchMapper just map one name per call.
37
            }.items():
38
            self.assertEqual(m.git_to_bzr(git), bzr)
0.82.1 by Ian Clatworthy
nicer and round-trippable mapping of git ref names to bzr branch names
39
0.64.256 by Ian Clatworthy
handle git ref names with slashes in them
40
    def test_git_to_bzr_with_slashes(self):
41
        m = branch_mapper.BranchMapper()
0.112.3 by Max Bowsher
Make BranchMapper just map one name per call.
42
        for git, bzr in {
0.64.256 by Ian Clatworthy
handle git ref names with slashes in them
43
            'refs/heads/master/slave':              'master/slave',
44
            'refs/heads/foo/bar':                   'foo/bar',
45
            'refs/tags/master/slave':               'master/slave.tag',
46
            'refs/tags/foo/bar':                    'foo/bar.tag',
47
            'refs/remotes/origin/master/slave':     'master/slave.remote',
48
            'refs/remotes/origin/foo/bar':          'foo/bar.remote',
0.112.3 by Max Bowsher
Make BranchMapper just map one name per call.
49
            }.items():
50
            self.assertEqual(m.git_to_bzr(git), bzr)
0.64.256 by Ian Clatworthy
handle git ref names with slashes in them
51
0.82.1 by Ian Clatworthy
nicer and round-trippable mapping of git ref names to bzr branch names
52
    def test_git_to_bzr_for_trunk(self):
53
        # As 'master' in git is mapped to trunk in bzr, we need to handle
54
        # 'trunk' in git in a sensible way.
55
        m = branch_mapper.BranchMapper()
0.112.3 by Max Bowsher
Make BranchMapper just map one name per call.
56
        for git, bzr in {
0.82.1 by Ian Clatworthy
nicer and round-trippable mapping of git ref names to bzr branch names
57
            'refs/heads/trunk':             'git-trunk',
58
            'refs/tags/trunk':              'git-trunk.tag',
59
            'refs/remotes/origin/trunk':    'git-trunk.remote',
60
            'refs/heads/git-trunk':         'git-git-trunk',
61
            'refs/tags/git-trunk':          'git-git-trunk.tag',
62
            'refs/remotes/origin/git-trunk':'git-git-trunk.remote',
0.112.3 by Max Bowsher
Make BranchMapper just map one name per call.
63
            }.items():
64
            self.assertEqual(m.git_to_bzr(git), bzr)