/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_shared_repository.py

  • Committer: Martin
  • Date: 2010-05-25 17:27:52 UTC
  • mfrom: (5254 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5257.
  • Revision ID: gzlist@googlemail.com-20100525172752-amm089xcikv968sw
Merge bzr.dev to unite with similar changes already made

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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
18
18
 
19
19
import os
20
20
 
21
 
from bzrlib.bzrdir import BzrDir
 
21
from bzrlib import osutils
 
22
from bzrlib.bzrdir import BzrDir, BzrDirMetaFormat1
22
23
import bzrlib.errors as errors
23
24
from bzrlib.tests import TestCaseInTempDir
24
25
 
119
120
        # being too low. If rpc_count increases, more network roundtrips have
120
121
        # become necessary for this use case. Please do not adjust this number
121
122
        # upwards without agreement from bzr's network support maintainers.
122
 
        self.assertLength(16, self.hpss_calls)
 
123
        self.assertLength(15, self.hpss_calls)
 
124
 
 
125
    def test_notification_on_branch_from_repository(self):
 
126
        out, err = self.run_bzr("init-repository -q a")
 
127
        self.assertEqual(out, "")
 
128
        self.assertEqual(err, "")
 
129
        dir = BzrDir.open('a')
 
130
        dir.open_repository() # there is a repository there
 
131
        e = self.assertRaises(errors.NotBranchError, dir.open_branch)
 
132
        self.assertContainsRe(str(e), "location is a repository")
 
133
 
 
134
    def test_notification_on_branch_from_nonrepository(self):
 
135
        fmt = BzrDirMetaFormat1()
 
136
        t = self.get_transport()
 
137
        t.mkdir('a')
 
138
        dir = fmt.initialize_on_transport(t.clone('a'))
 
139
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
 
140
        e = self.assertRaises(errors.NotBranchError, dir.open_branch)
 
141
        self.assertNotContainsRe(str(e), "location is a repository")
 
142
 
 
143
    def test_init_repo_with_post_repo_init_hook(self):
 
144
        calls = []
 
145
        BzrDir.hooks.install_named_hook('post_repo_init', calls.append, None)
 
146
        self.assertLength(0, calls)
 
147
        self.run_bzr("init-repository a")
 
148
        self.assertLength(1, calls)
 
149
 
 
150
    def test_init_repo_without_username(self):
 
151
        """Ensure init-repo works if username is not set.
 
152
        """
 
153
        # bzr makes user specified whoami mandatory for operations
 
154
        # like commit as whoami is recorded. init-repo however is not so final
 
155
        # and uses whoami only in a lock file. Without whoami the login name
 
156
        # is used. This test is to ensure that init-repo passes even when whoami
 
157
        # is not available.
 
158
        osutils.set_or_unset_env('EMAIL', None)
 
159
        osutils.set_or_unset_env('BZR_EMAIL', None)
 
160
        out, err = self.run_bzr(['init-repo', 'foo'])
 
161
        self.assertEqual(err, '')
 
162
        self.assertTrue(os.path.exists('foo'))