/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/plugins/fastimport/tests/test_branch_mapper.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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, see <http://www.gnu.org/licenses/>.
 
15
 
 
16
"""Test the BranchMapper methods."""
 
17
 
 
18
from __future__ import absolute_import
 
19
 
 
20
from .... import tests
 
21
 
 
22
from .. import (
 
23
    branch_mapper,
 
24
    )
 
25
 
 
26
from . import (
 
27
    FastimportFeature,
 
28
    )
 
29
 
 
30
 
 
31
class TestBranchMapper(tests.TestCase):
 
32
 
 
33
    _test_needs_features = [FastimportFeature]
 
34
 
 
35
    def test_git_to_bzr(self):
 
36
        m = branch_mapper.BranchMapper()
 
37
        for git, bzr in {
 
38
            'refs/heads/master':                'trunk',
 
39
            'refs/heads/foo':                   'foo',
 
40
            'refs/tags/master':                 'trunk.tag',
 
41
            'refs/tags/foo':                    'foo.tag',
 
42
            'refs/remotes/origin/master':       'trunk.remote',
 
43
            'refs/remotes/origin/foo':          'foo.remote',
 
44
            }.items():
 
45
            self.assertEqual(m.git_to_bzr(git), bzr)
 
46
 
 
47
    def test_git_to_bzr_with_slashes(self):
 
48
        m = branch_mapper.BranchMapper()
 
49
        for git, bzr in {
 
50
            'refs/heads/master/slave':              'master/slave',
 
51
            'refs/heads/foo/bar':                   'foo/bar',
 
52
            'refs/tags/master/slave':               'master/slave.tag',
 
53
            'refs/tags/foo/bar':                    'foo/bar.tag',
 
54
            'refs/remotes/origin/master/slave':     'master/slave.remote',
 
55
            'refs/remotes/origin/foo/bar':          'foo/bar.remote',
 
56
            }.items():
 
57
            self.assertEqual(m.git_to_bzr(git), bzr)
 
58
 
 
59
    def test_git_to_bzr_for_trunk(self):
 
60
        # As 'master' in git is mapped to trunk in bzr, we need to handle
 
61
        # 'trunk' in git in a sensible way.
 
62
        m = branch_mapper.BranchMapper()
 
63
        for git, bzr in {
 
64
            'refs/heads/trunk':             'git-trunk',
 
65
            'refs/tags/trunk':              'git-trunk.tag',
 
66
            'refs/remotes/origin/trunk':    'git-trunk.remote',
 
67
            'refs/heads/git-trunk':         'git-git-trunk',
 
68
            'refs/tags/git-trunk':          'git-git-trunk.tag',
 
69
            'refs/remotes/origin/git-trunk':'git-git-trunk.remote',
 
70
            }.items():
 
71
            self.assertEqual(m.git_to_bzr(git), bzr)