1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
1
# Copyright (C) 2006-2009, 2011 Canonical Ltd
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
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
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 (
32
TestCaseWithTransport,
41
def check_old_format_lock_error(repository_format):
42
"""Potentially ignore LockError on old formats.
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.
47
On new formats, LockError would be invalid, but for old formats
48
this was not supported on Win32.
50
if sys.platform != 'win32':
53
description = repository_format.get_format_description()
54
if description in ("Repository format 4",
55
"Weave repository format 5",
56
"Weave repository format 6"):
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'
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__)
75
41
class TestInterRepository(TestCaseWithInterRepository):
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()
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'],
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)
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())