/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
3221.10.2 by Robert Collins
More external reference tests.
1
# Copyright (C) 2008 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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3221.10.2 by Robert Collins
More external reference tests.
16
17
"""Tests for add_revision on a repository with external references."""
18
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
19
from breezy import errors
7143.21.1 by Jelmer Vernooij
Add WriteGroup contextmanager.
20
from breezy.repository import WriteGroup
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
21
from breezy.tests.per_repository_reference import (
3221.10.2 by Robert Collins
More external reference tests.
22
    TestCaseWithExternalReferenceRepository,
23
    )
24
25
26
class TestAddRevision(TestCaseWithExternalReferenceRepository):
27
28
    def test_add_revision_goes_to_repo(self):
29
        # adding a revision only writes to the repository add_revision is
30
        # called on.
31
        tree = self.make_branch_and_tree('sample')
32
        revid = tree.commit('one')
33
        inv = tree.branch.repository.get_inventory(revid)
4245.1.1 by Ian Clatworthy
minor test clean-ups & _reconcile_pack API
34
        tree.lock_read()
35
        self.addCleanup(tree.unlock)
3221.10.2 by Robert Collins
More external reference tests.
36
        rev = tree.branch.repository.get_revision(revid)
37
        base = self.make_repository('base')
6182.1.5 by Jelmer Vernooij
Fix more tests.
38
        repo = self.make_referring('referring', base)
7143.21.1 by Jelmer Vernooij
Add WriteGroup contextmanager.
39
        with repo.lock_write(), WriteGroup(repo):
40
            rev = tree.branch.repository.get_revision(revid)
41
            repo.texts.add_lines((inv.root.file_id, revid), [], [])
42
            repo.add_revision(revid, rev, inv=inv)
3221.10.2 by Robert Collins
More external reference tests.
43
        rev2 = repo.get_revision(revid)
44
        self.assertEqual(rev, rev2)
45
        self.assertRaises(errors.NoSuchRevision, base.get_revision, revid)