bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
1 |
# Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
|
2 |
# -*- coding: utf-8 -*-
|
|
3 |
#
|
|
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.
|
|
8 |
#
|
|
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.
|
|
13 |
#
|
|
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
|
|
17 |
||
18 |
"""Tests for pushing revisions from Bazaar into Git."""
|
|
19 |
||
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
20 |
from ....controldir import ( |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
21 |
format_registry, |
22 |
)
|
|
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
23 |
from ....repository import ( |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
24 |
InterRepository, |
25 |
)
|
|
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
26 |
from ....tests import ( |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
27 |
TestCaseWithTransport, |
28 |
)
|
|
29 |
||
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
30 |
from ..mapping import ( |
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
31 |
BzrGitMappingExperimental, |
32 |
BzrGitMappingv1, |
|
33 |
)
|
|
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
34 |
from ..errors import NoPushSupport |
35 |
from ..push import ( |
|
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
36 |
InterToGitRepository, |
37 |
)
|
|
38 |
||
39 |
||
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
40 |
class InterToGitRepositoryTests(TestCaseWithTransport): |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
41 |
|
42 |
def setUp(self): |
|
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
43 |
super(InterToGitRepositoryTests, self).setUp() |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
44 |
self.git_repo = self.make_repository("git", |
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
45 |
format=format_registry.make_controldir("git")) |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
46 |
self.bzr_repo = self.make_repository("bzr", shared=True) |
47 |
||
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
48 |
def _get_interrepo(self, mapping=None): |
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
49 |
self.bzr_repo.lock_read() |
50 |
self.addCleanup(self.bzr_repo.unlock) |
|
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
51 |
interrepo = InterRepository.get(self.bzr_repo, self.git_repo) |
52 |
if mapping is not None: |
|
53 |
interrepo.mapping = mapping |
|
54 |
return interrepo |
|
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
55 |
|
56 |
def test_instance(self): |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
57 |
self.assertIsInstance(self._get_interrepo(), InterToGitRepository) |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
58 |
|
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
59 |
def test_pointless_fetch_refs_old_mapping(self): |
60 |
interrepo = self._get_interrepo(mapping=BzrGitMappingv1()) |
|
61 |
self.assertRaises(NoPushSupport, interrepo.fetch_refs, lambda x: {}, lossy=False) |
|
62 |
||
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
63 |
def test_pointless_fetch_refs(self): |
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
64 |
interrepo = self._get_interrepo(mapping=BzrGitMappingExperimental()) |
65 |
revidmap, old_refs, new_refs = interrepo.fetch_refs(lambda x: {}, lossy=False) |
|
|
0.200.1559
by Jelmer Vernooij
Fix compatibility with bzr 2.5. |
66 |
self.assertEquals(old_refs, {}) |
|
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
67 |
self.assertEquals(new_refs, {}) |
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
68 |
|
|
0.200.1422
by Jelmer Vernooij
Remove unused dfetch method. |
69 |
def test_pointless_lossy_fetch_refs(self): |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
70 |
revidmap, old_refs, new_refs = self._get_interrepo().fetch_refs(lambda x: {}, lossy=True) |
|
0.200.1559
by Jelmer Vernooij
Fix compatibility with bzr 2.5. |
71 |
self.assertEquals(old_refs, {}) |
|
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
72 |
self.assertEquals(new_refs, {}) |
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
73 |
self.assertEquals(revidmap, {}) |
74 |
||
75 |
def test_pointless_missing_revisions(self): |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
76 |
interrepo = self._get_interrepo() |
77 |
interrepo.source_store.lock_read() |
|
78 |
self.addCleanup(interrepo.source_store.unlock) |
|
79 |
self.assertEquals([], list(interrepo.missing_revisions([]))) |
|
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
80 |
|
81 |
def test_missing_revisions_unknown_stop_rev(self): |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
82 |
interrepo = self._get_interrepo() |
83 |
interrepo.source_store.lock_read() |
|
84 |
self.addCleanup(interrepo.source_store.unlock) |
|
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
85 |
self.assertEquals([], |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
86 |
list(interrepo.missing_revisions([(None, "unknown")]))) |
87 |
||
88 |
def test_odd_rename(self): |
|
89 |
# Add initial revision to bzr branch.
|
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
90 |
branch = self.bzr_repo.controldir.create_branch() |
91 |
tree = branch.controldir.create_workingtree() |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
92 |
self.build_tree(["bzr/bar/", "bzr/bar/foobar"]) |
93 |
tree.add(["bar", "bar/foobar"]) |
|
94 |
tree.commit("initial") |
|
95 |
||
96 |
# Add new directory and perform move in bzr branch.
|
|
97 |
self.build_tree(["bzr/baz/"]) |
|
98 |
tree.add(["baz"]) |
|
99 |
tree.rename_one("bar", "baz/IrcDotNet") |
|
100 |
last_revid = tree.commit("rename") |
|
101 |
||
102 |
# Push bzr branch to git branch.
|
|
103 |
def decide(x): |
|
104 |
return { "refs/heads/master": (None, last_revid) } |
|
105 |
interrepo = self._get_interrepo() |
|
106 |
revidmap, old_refs, new_refs = interrepo.fetch_refs(decide, lossy=True) |
|
107 |
gitid = revidmap[last_revid][0] |
|
108 |
store = self.git_repo._git.object_store |
|
109 |
commit = store[gitid] |
|
110 |
tree = store[commit.tree] |
|
111 |
tree.check() |
|
|
0.282.2
by William Grant
Always dirty both parents, fixing weird directory rename cases. |
112 |
self.assertTrue(tree["baz"][1] in store) |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
113 |
baz = store[tree["baz"][1]] |
114 |
baz.check() |
|
115 |
ircdotnet = store[baz["IrcDotNet"][1]] |
|
116 |
ircdotnet.check() |
|
117 |
foobar = store[ircdotnet["foobar"][1]] |
|
118 |
foobar.check() |