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 |
||
|
0.358.3
by Jelmer Vernooij
Enable absolute import. |
20 |
from __future__ import absolute_import |
21 |
||
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
22 |
from ...controldir import ( |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
23 |
format_registry, |
24 |
)
|
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
25 |
from ...repository import ( |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
26 |
InterRepository, |
27 |
)
|
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
28 |
from ...tests import ( |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
29 |
TestCaseWithTransport, |
30 |
)
|
|
31 |
||
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
32 |
from ..mapping import ( |
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
33 |
BzrGitMappingExperimental, |
34 |
BzrGitMappingv1, |
|
35 |
)
|
|
|
0.401.2
by Jelmer Vernooij
Move all InterRepository implementations into interrepo. |
36 |
from ..interrepo import ( |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
37 |
InterToGitRepository, |
38 |
)
|
|
39 |
||
40 |
||
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
41 |
class InterToGitRepositoryTests(TestCaseWithTransport): |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
42 |
|
43 |
def setUp(self): |
|
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
44 |
super(InterToGitRepositoryTests, self).setUp() |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
45 |
self.git_repo = self.make_repository("git", |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
46 |
format=format_registry.make_controldir("git")) |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
47 |
self.bzr_repo = self.make_repository("bzr", shared=True) |
48 |
||
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
49 |
def _get_interrepo(self, mapping=None): |
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
50 |
self.bzr_repo.lock_read() |
51 |
self.addCleanup(self.bzr_repo.unlock) |
|
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
52 |
interrepo = InterRepository.get(self.bzr_repo, self.git_repo) |
53 |
if mapping is not None: |
|
54 |
interrepo.mapping = mapping |
|
55 |
return interrepo |
|
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
56 |
|
57 |
def test_instance(self): |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
58 |
self.assertIsInstance(self._get_interrepo(), InterToGitRepository) |
|
0.200.967
by Jelmer Vernooij
Add initial test for push. |
59 |
|
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
60 |
def test_pointless_fetch_refs_old_mapping(self): |
61 |
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. |
62 |
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. |
63 |
|
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
64 |
def test_pointless_fetch_refs(self): |
|
0.200.1509
by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings. |
65 |
interrepo = self._get_interrepo(mapping=BzrGitMappingExperimental()) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
66 |
revidmap, old_refs, new_refs = interrepo.fetch_refs( |
67 |
lambda x: {}, lossy=False) |
|
68 |
self.assertEqual(old_refs, {b'HEAD': ( |
|
69 |
b'ref: refs/heads/master', None)}) |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
70 |
self.assertEqual(new_refs, {}) |
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
71 |
|
|
0.200.1422
by Jelmer Vernooij
Remove unused dfetch method. |
72 |
def test_pointless_lossy_fetch_refs(self): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
73 |
revidmap, old_refs, new_refs = self._get_interrepo( |
74 |
).fetch_refs(lambda x: {}, lossy=True) |
|
75 |
self.assertEqual(old_refs, {b'HEAD': ( |
|
76 |
b'ref: refs/heads/master', None)}) |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
77 |
self.assertEqual(new_refs, {}) |
78 |
self.assertEqual(revidmap, {}) |
|
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
79 |
|
80 |
def test_pointless_missing_revisions(self): |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
81 |
interrepo = self._get_interrepo() |
82 |
interrepo.source_store.lock_read() |
|
83 |
self.addCleanup(interrepo.source_store.unlock) |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
84 |
self.assertEqual([], list(interrepo.missing_revisions([]))) |
|
0.200.968
by Jelmer Vernooij
Add more tests, simplify push code. |
85 |
|
86 |
def test_missing_revisions_unknown_stop_rev(self): |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
87 |
interrepo = self._get_interrepo() |
88 |
interrepo.source_store.lock_read() |
|
89 |
self.addCleanup(interrepo.source_store.unlock) |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
90 |
self.assertEqual([], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
91 |
list(interrepo.missing_revisions([(None, b"unknown")]))) |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
92 |
|
93 |
def test_odd_rename(self): |
|
94 |
# Add initial revision to bzr branch.
|
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
95 |
branch = self.bzr_repo.controldir.create_branch() |
96 |
tree = branch.controldir.create_workingtree() |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
97 |
self.build_tree(["bzr/bar/", "bzr/bar/foobar"]) |
98 |
tree.add(["bar", "bar/foobar"]) |
|
99 |
tree.commit("initial") |
|
100 |
||
101 |
# Add new directory and perform move in bzr branch.
|
|
102 |
self.build_tree(["bzr/baz/"]) |
|
103 |
tree.add(["baz"]) |
|
104 |
tree.rename_one("bar", "baz/IrcDotNet") |
|
105 |
last_revid = tree.commit("rename") |
|
106 |
||
107 |
# Push bzr branch to git branch.
|
|
108 |
def decide(x): |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
109 |
return {b"refs/heads/master": (None, last_revid)} |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
110 |
interrepo = self._get_interrepo() |
111 |
revidmap, old_refs, new_refs = interrepo.fetch_refs(decide, lossy=True) |
|
112 |
gitid = revidmap[last_revid][0] |
|
113 |
store = self.git_repo._git.object_store |
|
114 |
commit = store[gitid] |
|
115 |
tree = store[commit.tree] |
|
116 |
tree.check() |
|
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
117 |
self.assertIn(b"baz", tree, repr(tree.items())) |
118 |
self.assertIn(tree[b"baz"][1], store) |
|
119 |
baz = store[tree[b"baz"][1]] |
|
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
120 |
baz.check() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
121 |
ircdotnet = store[baz[b"IrcDotNet"][1]] |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
122 |
ircdotnet.check() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
123 |
foobar = store[ircdotnet[b"foobar"][1]] |
|
0.273.1
by Jelmer Vernooij
add test for bug 818318. |
124 |
foobar.check() |