~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_interrepository/test_interrepository.py

  • Committer: John Arbash Meinel
  • Date: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2006-2009, 2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
19
19
import sys
20
20
 
21
21
import bzrlib
22
 
import bzrlib.bzrdir as bzrdir
23
 
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock
24
22
import bzrlib.errors as errors
25
23
import bzrlib.gpg
26
24
from bzrlib.inventory import Inventory
27
 
import bzrlib.repofmt.weaverepo as weaverepo
28
 
import bzrlib.repository as repository
29
 
from bzrlib.revision import NULL_REVISION, Revision
 
25
from bzrlib.revision import NULL_REVISION
30
26
from bzrlib.tests import (
31
 
    TestCase,
32
 
    TestCaseWithTransport,
33
27
    TestNotApplicable,
34
28
    TestSkipped,
35
29
    )
38
32
    )
39
33
 
40
34
 
41
 
def check_old_format_lock_error(repository_format):
42
 
    """Potentially ignore LockError on old formats.
43
 
 
44
 
    On win32, with the old OS locks, we get a failure of double-lock when
45
 
    we open a object in 2 objects and try to lock both.
46
 
 
47
 
    On new formats, LockError would be invalid, but for old formats
48
 
    this was not supported on Win32.
49
 
    """
50
 
    if sys.platform != 'win32':
51
 
        raise
52
 
 
53
 
    description = repository_format.get_format_description()
54
 
    if description in ("Repository format 4",
55
 
                       "Weave repository format 5",
56
 
                       "Weave repository format 6"):
57
 
        # jam 20060701
58
 
        # win32 OS locks are not re-entrant. So one process cannot
59
 
        # open the same repository twice and lock them both.
60
 
        raise TestSkipped('%s on win32 cannot open the same'
61
 
                          ' repository twice in different objects'
62
 
                          % description)
63
 
    raise
64
 
 
65
 
 
66
35
def check_repo_format_for_funky_id_on_win32(repo):
67
 
    if (isinstance(repo, (weaverepo.AllInOneRepository,
68
 
                          weaverepo.WeaveMetaDirRepository))
69
 
        and sys.platform == 'win32'):
70
 
            raise TestSkipped("funky chars does not permitted"
71
 
                              " on this platform in repository"
72
 
                              " %s" % repo.__class__.__name__)
 
36
    if not repo._format.supports_funky_characters and sys.platform == 'win32':
 
37
        raise TestSkipped("funky chars not allowed on this platform in repository"
 
38
                          " %s" % repo.__class__.__name__)
73
39
 
74
40
 
75
41
class TestInterRepository(TestCaseWithInterRepository):
110
76
        # and sign 'rev2'
111
77
        tree_a.branch.repository.lock_write()
112
78
        tree_a.branch.repository.start_write_group()
113
 
        tree_a.branch.repository.sign_revision('rev2', bzrlib.gpg.LoopbackGPGStrategy(None))
 
79
        tree_a.branch.repository.sign_revision('rev2',
 
80
            bzrlib.gpg.LoopbackGPGStrategy(None))
114
81
        tree_a.branch.repository.commit_write_group()
115
82
        tree_a.branch.repository.unlock()
116
83
 
139
106
        self.assertFalse(repo_b.has_revision('pizza'))
140
107
        # Asking specifically for an absent revision errors.
141
108
        self.assertRaises(errors.NoSuchRevision,
142
 
            repo_b.search_missing_revision_ids, repo_a, revision_id='pizza',
 
109
            repo_b.search_missing_revision_ids, repo_a, revision_ids=['pizza'],
143
110
            find_ghosts=True)
144
111
        self.assertRaises(errors.NoSuchRevision,
 
112
            repo_b.search_missing_revision_ids, repo_a, revision_ids=['pizza'],
 
113
            find_ghosts=False)
 
114
        self.callDeprecated(
 
115
            ['search_missing_revision_ids(revision_id=...) was deprecated in '
 
116
             '2.4.  Use revision_ids=[...] instead.'],
 
117
            self.assertRaises, errors.NoSuchRevision,
145
118
            repo_b.search_missing_revision_ids, repo_a, revision_id='pizza',
146
119
            find_ghosts=False)
147
120
 
151
124
        # make a repository to compare against that is empty
152
125
        repo_b = self.make_to_repository('empty')
153
126
        repo_a = self.bzrdir.open_repository()
154
 
        result = repo_b.search_missing_revision_ids(repo_a, revision_id='rev1')
 
127
        result = repo_b.search_missing_revision_ids(
 
128
            repo_a, revision_ids=['rev1'])
155
129
        self.assertEqual(set(['rev1']), result.get_keys())
156
130
        self.assertEqual(('search', set(['rev1']), set([NULL_REVISION]), 1),
157
131
            result.get_recipe())