bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1740.3.1
by Jelmer Vernooij
Introduce and use CommitBuilder objects. |
1 |
# Copyright (C) 2006 by 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, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
"""Tests for repository commit builder."""
|
|
18 |
||
|
1910.2.6
by Aaron Bentley
Update for merge review, handle deprecations |
19 |
from bzrlib import inventory |
|
1740.3.9
by Jelmer Vernooij
Make the commit message the first argument of CommitBuilder.commit(). |
20 |
from bzrlib.errors import UnsupportedOperation |
|
1740.3.1
by Jelmer Vernooij
Introduce and use CommitBuilder objects. |
21 |
from bzrlib.repository import CommitBuilder |
22 |
from bzrlib.tests.repository_implementations.test_repository import TestCaseWithRepository |
|
23 |
||
24 |
||
25 |
class TestCommitBuilder(TestCaseWithRepository): |
|
|
1740.3.3
by Jelmer Vernooij
Move storing directories and links to commit builder. |
26 |
|
|
1740.3.10
by Jelmer Vernooij
Fix some minor issues pointed out by j-a-m. |
27 |
def test_get_commit_builder(self): |
|
1740.3.7
by Jelmer Vernooij
Move committer, log, revprops, timestamp and timezone to CommitBuilder. |
28 |
tree = self.make_branch_and_tree(".") |
29 |
builder = tree.branch.get_commit_builder([]) |
|
|
1740.3.1
by Jelmer Vernooij
Introduce and use CommitBuilder objects. |
30 |
self.assertIsInstance(builder, CommitBuilder) |
|
1740.3.3
by Jelmer Vernooij
Move storing directories and links to commit builder. |
31 |
|
|
1910.2.6
by Aaron Bentley
Update for merge review, handle deprecations |
32 |
def record_root(self, builder, tree): |
33 |
if builder.record_root_entry is True: |
|
34 |
ie = tree.inventory.root |
|
35 |
parent_tree = tree.branch.repository.revision_tree(None) |
|
36 |
parent_invs = [parent_tree.inventory] |
|
37 |
builder.record_entry_contents(ie, parent_invs, '', tree) |
|
38 |
||
|
1740.3.10
by Jelmer Vernooij
Fix some minor issues pointed out by j-a-m. |
39 |
def test_finish_inventory(self): |
|
1740.3.7
by Jelmer Vernooij
Move committer, log, revprops, timestamp and timezone to CommitBuilder. |
40 |
tree = self.make_branch_and_tree(".") |
41 |
builder = tree.branch.get_commit_builder([]) |
|
|
1910.2.6
by Aaron Bentley
Update for merge review, handle deprecations |
42 |
self.record_root(builder, tree) |
|
1740.3.8
by Jelmer Vernooij
Move make_revision() to commit builder. |
43 |
builder.finish_inventory() |
|
1740.3.3
by Jelmer Vernooij
Move storing directories and links to commit builder. |
44 |
|
|
1740.3.10
by Jelmer Vernooij
Fix some minor issues pointed out by j-a-m. |
45 |
def test_commit_message(self): |
|
1740.3.7
by Jelmer Vernooij
Move committer, log, revprops, timestamp and timezone to CommitBuilder. |
46 |
tree = self.make_branch_and_tree(".") |
|
1740.3.9
by Jelmer Vernooij
Make the commit message the first argument of CommitBuilder.commit(). |
47 |
builder = tree.branch.get_commit_builder([]) |
|
1910.2.6
by Aaron Bentley
Update for merge review, handle deprecations |
48 |
self.record_root(builder, tree) |
|
1740.3.9
by Jelmer Vernooij
Make the commit message the first argument of CommitBuilder.commit(). |
49 |
builder.finish_inventory() |
50 |
rev_id = builder.commit('foo bar blah') |
|
51 |
rev = tree.branch.repository.get_revision(rev_id) |
|
52 |
self.assertEqual('foo bar blah', rev.message) |
|
53 |
||
|
1740.3.10
by Jelmer Vernooij
Fix some minor issues pointed out by j-a-m. |
54 |
def test_commit_with_revision_id(self): |
|
1740.3.9
by Jelmer Vernooij
Make the commit message the first argument of CommitBuilder.commit(). |
55 |
tree = self.make_branch_and_tree(".") |
56 |
try: |
|
57 |
builder = tree.branch.get_commit_builder([], revision_id="foo") |
|
58 |
except UnsupportedOperation: |
|
59 |
# This format doesn't support supplied revision ids
|
|
60 |
return
|
|
|
1910.2.6
by Aaron Bentley
Update for merge review, handle deprecations |
61 |
self.record_root(builder, tree) |
|
1740.3.9
by Jelmer Vernooij
Make the commit message the first argument of CommitBuilder.commit(). |
62 |
builder.finish_inventory() |
63 |
self.assertEqual("foo", builder.commit('foo bar')) |
|
64 |
self.assertTrue(tree.branch.repository.has_revision("foo")) |
|
|
1757.1.2
by Robert Collins
Bugfix CommitBuilders recording of the inventory revision id. |
65 |
# the revision id must be set on the inventory when saving it. This does not
|
66 |
# precisely test that - a repository that wants to can add it on deserialisation,
|
|
67 |
# but thats all the current contract guarantees anyway.
|
|
68 |
self.assertEqual('foo', tree.branch.repository.get_inventory('foo').revision_id) |
|
|
1740.3.8
by Jelmer Vernooij
Move make_revision() to commit builder. |
69 |
|
|
1910.2.8
by Aaron Bentley
Fix commit_builder when root not passed to record_entry_contents |
70 |
def test_commit_without_root(self): |
71 |
"""This should cause a deprecation warning, not an assertion failure""" |
|
72 |
tree = self.make_branch_and_tree(".") |
|
73 |
self.build_tree(['foo']) |
|
74 |
tree.add('foo', 'foo-id') |
|
75 |
entry = tree.inventory['foo-id'] |
|
76 |
builder = tree.branch.get_commit_builder([]) |
|
|
1551.8.9
by Aaron Bentley
Rename assertDeprecated to callDeprecated |
77 |
self.callDeprecated(['Root entry should be supplied to' |
|
1910.2.9
by Aaron Bentley
Inroduce assertDeprecated, and use it to test old commitbuilder API |
78 |
' record_entry_contents, as of bzr 0.10.'], |
79 |
builder.record_entry_contents, entry, [], 'foo', tree) |
|
|
1910.2.8
by Aaron Bentley
Fix commit_builder when root not passed to record_entry_contents |
80 |
builder.finish_inventory() |
81 |
rev_id = builder.commit('foo bar') |
|
82 |
||
|
1740.3.10
by Jelmer Vernooij
Fix some minor issues pointed out by j-a-m. |
83 |
def test_commit(self): |
|
1740.3.8
by Jelmer Vernooij
Move make_revision() to commit builder. |
84 |
tree = self.make_branch_and_tree(".") |
|
1740.3.9
by Jelmer Vernooij
Make the commit message the first argument of CommitBuilder.commit(). |
85 |
builder = tree.branch.get_commit_builder([]) |
|
1910.2.6
by Aaron Bentley
Update for merge review, handle deprecations |
86 |
self.record_root(builder, tree) |
|
1740.3.8
by Jelmer Vernooij
Move make_revision() to commit builder. |
87 |
builder.finish_inventory() |
|
1740.3.9
by Jelmer Vernooij
Make the commit message the first argument of CommitBuilder.commit(). |
88 |
rev_id = builder.commit('foo bar') |
89 |
self.assertNotEqual(None, rev_id) |
|
90 |
self.assertTrue(tree.branch.repository.has_revision(rev_id)) |
|
|
1757.1.2
by Robert Collins
Bugfix CommitBuilders recording of the inventory revision id. |
91 |
# the revision id must be set on the inventory when saving it. This does not
|
92 |
# precisely test that - a repository that wants to can add it on deserialisation,
|
|
93 |
# but thats all the current contract guarantees anyway.
|
|
94 |
self.assertEqual(rev_id, tree.branch.repository.get_inventory(rev_id).revision_id) |