bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6652.1.1
by Jelmer Vernooij
Bundle the link-tree command. |
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) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
40 |
self.build_tree_contents([('parent/foo', b'bar')]) |
41 |
self.parent_tree.add('foo', b'foo-id') |
|
|
6652.1.1
by Jelmer Vernooij
Bundle the link-tree command. |
42 |
self.parent_tree.commit('added foo') |
|
6652.1.3
by Jelmer Vernooij
Fix test. |
43 |
child_controldir = self.parent_tree.controldir.sprout('child') |
44 |
self.child_tree = child_controldir.open_workingtree() |
|
|
6652.1.1
by Jelmer Vernooij
Bundle the link-tree command. |
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() |