/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 breezy/tests/blackbox/test_link_tree.py

  • Committer: Jelmer Vernooij
  • Date: 2018-04-02 00:52:27 UTC
  • mfrom: (6939 work)
  • mto: This revision was merged to the branch mainline in revision 7274.
  • Revision ID: jelmer@jelmer.uk-20180402005227-pecflp1mvdjrjqd6
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2008 Aaron Bentley
 
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
 
 
18
"""Tests for the 'brz link-tree' command."""
 
19
 
 
20
import os
 
21
 
 
22
from ... import (
 
23
    tests,
 
24
    )
 
25
 
 
26
from ..features import (
 
27
    HardlinkFeature,
 
28
    )
 
29
 
 
30
 
 
31
class TestLinkTreeCommand(tests.TestCaseWithTransport):
 
32
 
 
33
    _test_needs_features = [HardlinkFeature]
 
34
 
 
35
    def setUp(self):
 
36
        tests.TestCaseWithTransport.setUp(self)
 
37
        self.parent_tree = self.make_branch_and_tree('parent')
 
38
        self.parent_tree.lock_write()
 
39
        self.addCleanup(self.parent_tree.unlock)
 
40
        self.build_tree_contents([('parent/foo', b'bar')])
 
41
        self.parent_tree.add('foo', b'foo-id')
 
42
        self.parent_tree.commit('added foo')
 
43
        child_controldir = self.parent_tree.controldir.sprout('child')
 
44
        self.child_tree = child_controldir.open_workingtree()
 
45
 
 
46
    def hardlinked(self):
 
47
        parent_stat = os.lstat(self.parent_tree.abspath('foo'))
 
48
        child_stat = os.lstat(self.child_tree.abspath('foo'))
 
49
        return parent_stat.st_ino == child_stat.st_ino
 
50
 
 
51
    def test_link_tree(self):
 
52
        """Ensure the command works as intended"""
 
53
        os.chdir('child')
 
54
        self.parent_tree.unlock()
 
55
        self.run_bzr('link-tree ../parent')
 
56
        self.assertTrue(self.hardlinked())
 
57
        # want teh addCleanup to work properly
 
58
        self.parent_tree.lock_write()