bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.358.2
by Jelmer Vernooij
Refresh copyright headers, add my email. |
1 |
# Copyright (C) 2010-2018 Jelmer Vernooij <jelmer@jelmer.uk>
|
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
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
|
|
|
0.358.1
by Jelmer Vernooij
Fix FSF address. |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
17 |
|
18 |
"""Tests for pushing revisions from Bazaar into Git."""
|
|
19 |
||
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
20 |
from ...controldir import ( |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
21 |
format_registry, |
22 |
)
|
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
23 |
from ...repository import ( |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
24 |
InterRepository, |
25 |
)
|
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
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.401.2
by Jelmer Vernooij
Move all InterRepository implementations into interrepo. |
34 |
from ..interrepo import ( |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
35 |
InterToGitRepository, |
36 |
)
|
|
37 |
||
38 |
||
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
39 |
class InterToGitRepositoryTests(TestCaseWithTransport): |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
40 |
|
41 |
def setUp(self): |
|
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
42 |
super(InterToGitRepositoryTests, self).setUp() |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
43 |
self.git_repo = self.make_repository("git", |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
44 |
format=format_registry.make_controldir("git")) |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
45 |
self.bzr_repo = self.make_repository("bzr", shared=True) |
46 |
||
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
47 |
def _get_interrepo(self, mapping=None): |
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
48 |
self.bzr_repo.lock_read() |
49 |
self.addCleanup(self.bzr_repo.unlock) |
|
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
50 |
interrepo = InterRepository.get(self.bzr_repo, self.git_repo) |
51 |
if mapping is not None: |
|
52 |
interrepo.mapping = mapping |
|
53 |
return interrepo |
|
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
54 |
|
55 |
def test_instance(self): |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
56 |
self.assertIsInstance(self._get_interrepo(), InterToGitRepository) |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
57 |
|
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
58 |
def test_pointless_fetch_refs_old_mapping(self): |
59 |
interrepo = self._get_interrepo(mapping=BzrGitMappingv1()) |
|
|
0.320.2
by Jelmer Vernooij
Only complain about roundtripping if revisions being pushed didn't originally come from git. |
60 |
interrepo.fetch_refs(lambda x: {}, lossy=False) |
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
61 |
|
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
62 |
def test_pointless_fetch_refs(self): |
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
63 |
interrepo = self._get_interrepo(mapping=BzrGitMappingExperimental()) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
64 |
revidmap, old_refs, new_refs = interrepo.fetch_refs( |
65 |
lambda x: {}, lossy=False) |
|
66 |
self.assertEqual(old_refs, {b'HEAD': ( |
|
67 |
b'ref: refs/heads/master', None)}) |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
68 |
self.assertEqual(new_refs, {}) |
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
69 |
|
|
0.200.1422
by Jelmer Vernooij
Remove unused dfetch method. |
70 |
def test_pointless_lossy_fetch_refs(self): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
71 |
revidmap, old_refs, new_refs = self._get_interrepo( |
72 |
).fetch_refs(lambda x: {}, lossy=True) |
|
73 |
self.assertEqual(old_refs, {b'HEAD': ( |
|
74 |
b'ref: refs/heads/master', None)}) |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
75 |
self.assertEqual(new_refs, {}) |
76 |
self.assertEqual(revidmap, {}) |
|
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
77 |
|
78 |
def test_pointless_missing_revisions(self): |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
79 |
interrepo = self._get_interrepo() |
80 |
interrepo.source_store.lock_read() |
|
81 |
self.addCleanup(interrepo.source_store.unlock) |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
82 |
self.assertEqual([], list(interrepo.missing_revisions([]))) |
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
83 |
|
84 |
def test_missing_revisions_unknown_stop_rev(self): |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
85 |
interrepo = self._get_interrepo() |
86 |
interrepo.source_store.lock_read() |
|
87 |
self.addCleanup(interrepo.source_store.unlock) |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
88 |
self.assertEqual([], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
89 |
list(interrepo.missing_revisions([(None, b"unknown")]))) |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
90 |
|
91 |
def test_odd_rename(self): |
|
92 |
# Add initial revision to bzr branch.
|
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
93 |
branch = self.bzr_repo.controldir.create_branch() |
94 |
tree = branch.controldir.create_workingtree() |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
95 |
self.build_tree(["bzr/bar/", "bzr/bar/foobar"]) |
96 |
tree.add(["bar", "bar/foobar"]) |
|
97 |
tree.commit("initial") |
|
98 |
||
99 |
# Add new directory and perform move in bzr branch.
|
|
100 |
self.build_tree(["bzr/baz/"]) |
|
101 |
tree.add(["baz"]) |
|
102 |
tree.rename_one("bar", "baz/IrcDotNet") |
|
103 |
last_revid = tree.commit("rename") |
|
104 |
||
105 |
# Push bzr branch to git branch.
|
|
106 |
def decide(x): |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
107 |
return {b"refs/heads/master": (None, last_revid)} |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
108 |
interrepo = self._get_interrepo() |
109 |
revidmap, old_refs, new_refs = interrepo.fetch_refs(decide, lossy=True) |
|
110 |
gitid = revidmap[last_revid][0] |
|
111 |
store = self.git_repo._git.object_store |
|
112 |
commit = store[gitid] |
|
113 |
tree = store[commit.tree] |
|
114 |
tree.check() |
|
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
115 |
self.assertIn(b"baz", tree, repr(tree.items())) |
116 |
self.assertIn(tree[b"baz"][1], store) |
|
117 |
baz = store[tree[b"baz"][1]] |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
118 |
baz.check() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
119 |
ircdotnet = store[baz[b"IrcDotNet"][1]] |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
120 |
ircdotnet.check() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
121 |
foobar = store[ircdotnet[b"foobar"][1]] |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
122 |
foobar.check() |