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.1007
by Jelmer Vernooij
Support non-ascii characters in tag names. |
2 |
# vim: encoding=utf-8
|
0.200.872
by Jelmer Vernooij
Move refs code to separate module. |
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.872
by Jelmer Vernooij
Move refs code to separate module. |
17 |
|
18 |
||
19 |
"""Tests for ref handling."""
|
|
20 |
||
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
21 |
from ... import tests |
0.200.872
by Jelmer Vernooij
Move refs code to separate module. |
22 |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
23 |
from ..object_store import BazaarObjectStore |
24 |
from ..refs import ( |
|
25 |
BazaarRefsContainer, |
|
26 |
ref_to_branch_name, |
|
27 |
branch_name_to_ref, |
|
28 |
)
|
|
0.200.872
by Jelmer Vernooij
Move refs code to separate module. |
29 |
|
30 |
||
31 |
class BranchNameRefConversionTests(tests.TestCase): |
|
32 |
||
33 |
def test_head(self): |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
34 |
self.assertEqual("", ref_to_branch_name(b"HEAD")) |
35 |
self.assertEqual(b"HEAD", branch_name_to_ref("")) |
|
0.200.872
by Jelmer Vernooij
Move refs code to separate module. |
36 |
|
37 |
def test_tag(self): |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
38 |
self.assertRaises(ValueError, ref_to_branch_name, b"refs/tags/FOO") |
0.200.872
by Jelmer Vernooij
Move refs code to separate module. |
39 |
|
40 |
def test_branch(self): |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
41 |
self.assertEqual("frost", ref_to_branch_name(b"refs/heads/frost")) |
42 |
self.assertEqual(b"refs/heads/frost", branch_name_to_ref("frost")) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
43 |
|
44 |
||
45 |
class BazaarRefsContainerTests(tests.TestCaseWithTransport): |
|
46 |
||
47 |
def test_empty(self): |
|
48 |
tree = self.make_branch_and_tree('.') |
|
49 |
store = BazaarObjectStore(tree.branch.repository) |
|
50 |
refs = BazaarRefsContainer(tree.controldir, store) |
|
51 |
self.assertEqual(refs.as_dict(), {}) |
|
52 |
||
53 |
def test_some_commit(self): |
|
54 |
tree = self.make_branch_and_tree('.') |
|
55 |
revid = tree.commit('somechange') |
|
56 |
store = BazaarObjectStore(tree.branch.repository) |
|
57 |
refs = BazaarRefsContainer(tree.controldir, store) |
|
58 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
59 |
refs.as_dict(), |
60 |
{b'HEAD': store._lookup_revision_sha1(revid)}) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
61 |
|
62 |
def test_some_tag(self): |
|
63 |
tree = self.make_branch_and_tree('.') |
|
64 |
revid = tree.commit('somechange') |
|
65 |
tree.branch.tags.set_tag('sometag', revid) |
|
66 |
store = BazaarObjectStore(tree.branch.repository) |
|
67 |
refs = BazaarRefsContainer(tree.controldir, store) |
|
68 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
69 |
refs.as_dict(), |
70 |
{b'HEAD': store._lookup_revision_sha1(revid), |
|
71 |
b'refs/tags/sometag': store._lookup_revision_sha1(revid), |
|
72 |
})
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
73 |
|
74 |
def test_some_branch(self): |
|
75 |
tree = self.make_branch_and_tree('.') |
|
76 |
revid = tree.commit('somechange') |
|
77 |
otherbranch = tree.controldir.create_branch(name='otherbranch') |
|
78 |
otherbranch.generate_revision_history(revid) |
|
79 |
store = BazaarObjectStore(tree.branch.repository) |
|
80 |
refs = BazaarRefsContainer(tree.controldir, store) |
|
81 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
82 |
refs.as_dict(), |
83 |
{b'HEAD': store._lookup_revision_sha1(revid), |
|
84 |
b'refs/heads/otherbranch': store._lookup_revision_sha1(revid), |
|
85 |
})
|