1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
 
1
# Copyright (C) 2005, 2006, 2008, 2009 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
 
 
172
171
        out, err = self.run_bzr(['branch', 'source', 'target', '--hardlink'])
 
173
172
        source_stat = os.stat('source/file1')
 
174
173
        target_stat = os.stat('target/file1')
 
175
 
        self.assertEqual(source_stat, target_stat)
 
 
174
        same_file = (source_stat == target_stat)
 
 
178
            # https://bugs.edge.launchpad.net/bzr/+bug/408193
 
 
179
            self.assertContainsRe(err, "hardlinking working copy files is "
 
 
180
                "not currently supported")
 
 
181
            raise KnownFailure("--hardlink doesn't work in formats "
 
 
182
                "that support content filtering (#408193)")
 
177
184
    def test_branch_standalone(self):
 
178
185
        shared_repo = self.make_repository('repo', shared=True)
 
 
210
217
        self.assertEqual('', out)
 
211
218
        self.assertEqual('bzr: ERROR: Already a branch: "b".\n', err)
 
213
 
    def test_branch_bind(self):
 
214
 
        self.example_branch('a')
 
215
 
        out, err = self.run_bzr('branch a b --bind')
 
216
 
        self.assertEndsWith(err, "New branch bound to a\n")
 
217
 
        b = branch.Branch.open('b')
 
218
 
        self.assertEndsWith(b.get_bound_location(), '/a/')
 
220
 
    def test_branch_with_post_branch_init_hook(self):
 
222
 
        branch.Branch.hooks.install_named_hook('post_branch_init',
 
224
 
        self.assertLength(0, calls)
 
225
 
        self.example_branch('a')
 
226
 
        self.assertLength(1, calls)
 
227
 
        self.run_bzr('branch a b')
 
228
 
        self.assertLength(2, calls)
 
230
 
    def test_checkout_with_post_branch_init_hook(self):
 
232
 
        branch.Branch.hooks.install_named_hook('post_branch_init',
 
234
 
        self.assertLength(0, calls)
 
235
 
        self.example_branch('a')
 
236
 
        self.assertLength(1, calls)
 
237
 
        self.run_bzr('checkout a b')
 
238
 
        self.assertLength(2, calls)
 
240
 
    def test_lightweight_checkout_with_post_branch_init_hook(self):
 
242
 
        branch.Branch.hooks.install_named_hook('post_branch_init',
 
244
 
        self.assertLength(0, calls)
 
245
 
        self.example_branch('a')
 
246
 
        self.assertLength(1, calls)
 
247
 
        self.run_bzr('checkout --lightweight a b')
 
248
 
        self.assertLength(2, calls)
 
251
221
class TestBranchStacked(ExternalBase):
 
252
222
    """Tests for branch --stacked"""
 
 
340
310
    def test_branch_stacked_from_smart_server(self):
 
341
311
        # We can branch stacking on a smart server
 
342
 
        self.transport_server = test_server.SmartTCPServer_for_testing
 
 
312
        from bzrlib.smart.server import SmartTCPServer_for_testing
 
 
313
        self.transport_server = SmartTCPServer_for_testing
 
343
314
        trunk = self.make_branch('mainline', format='1.9')
 
344
315
        out, err = self.run_bzr(
 
345
316
            ['branch', '--stacked', self.get_url('mainline'), 'shallow'])
 
 
355
326
            '  Packs 5 (adds stacking support, requires bzr 1.6)\n'
 
356
327
            'Source branch format does not support stacking, using format:\n'
 
357
328
            '  Branch format 7\n'
 
358
 
            'Doing on-the-fly conversion from RepositoryFormatKnitPack1() to RepositoryFormatKnitPack5().\n'
 
359
 
            'This may take some time. Upgrade the repositories to the same format for better performance.\n'
 
360
329
            'Created new stacked branch referring to %s.\n' % (trunk.base,),
 
 
370
339
            '  Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)\n'
 
371
340
            'Source branch format does not support stacking, using format:\n'
 
372
341
            '  Branch format 7\n'
 
373
 
            'Doing on-the-fly conversion from RepositoryFormatKnitPack4() to RepositoryFormatKnitPack5RichRoot().\n'
 
374
 
            'This may take some time. Upgrade the repositories to the same format for better performance.\n'
 
375
342
            'Created new stacked branch referring to %s.\n' % (trunk.base,),