~greatmay12/+junk/test1

« back to all changes in this revision

Viewing changes to build/lib.linux-x86_64-2.6/bzrlib/tests/per_repository_reference/test_add_signature_text.py

  • Committer: thitipong at ndrsolution
  • Date: 2011-11-14 06:31:02 UTC
  • Revision ID: thitipong@ndrsolution.com-20111114063102-9obte3yfi2azku7d
ndr redirect version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
"""Tests for add_signature_text on a repository with external references."""
 
18
 
 
19
from bzrlib import errors
 
20
from bzrlib.tests.per_repository_reference import (
 
21
    TestCaseWithExternalReferenceRepository,
 
22
    )
 
23
 
 
24
 
 
25
class TestAddSignatureText(TestCaseWithExternalReferenceRepository):
 
26
 
 
27
    def test_add_signature_text_goes_to_repo(self):
 
28
        # adding a signature only writes to the repository add_signature_text
 
29
        # is called on.
 
30
        tree = self.make_branch_and_tree('sample')
 
31
        revid = tree.commit('one')
 
32
        inv = tree.branch.repository.get_inventory(revid)
 
33
        tree.lock_read()
 
34
        self.addCleanup(tree.unlock)
 
35
        base = self.make_repository('base')
 
36
        repo = self.make_referring('referring', 'base')
 
37
        repo.lock_write()
 
38
        try:
 
39
            repo.start_write_group()
 
40
            try:
 
41
                rev = tree.branch.repository.get_revision(revid)
 
42
                repo.texts.add_lines((inv.root.file_id, revid), [], [])
 
43
                repo.add_revision(revid, rev, inv=inv)
 
44
                repo.add_signature_text(revid, "text")
 
45
                repo.commit_write_group()
 
46
            except:
 
47
                repo.abort_write_group()
 
48
                raise
 
49
        finally:
 
50
            repo.unlock()
 
51
        repo.get_signature_text(revid)
 
52
        self.assertRaises(errors.NoSuchRevision, base.get_signature_text,
 
53
            revid)