~gagern/bzr-svn/bug242321

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

"""Basis and revision tree tests."""

from bzrlib.osutils import has_symlinks
from bzrlib.workingtree import WorkingTree

import os, sys

from tree import SvnBasisTree
from tests import TestCaseWithSubversionRepository

class TestBasisTree(TestCaseWithSubversionRepository):
    def test_executable(self):
        self.make_client("d", "dc")
        self.build_tree({"dc/file": "x"})
        self.client_add("dc/file")
        self.client_set_prop("dc/file", "svn:executable", "*")
        self.client_commit("dc", "executable")
        tree = SvnBasisTree(self.open_checkout("dc"))
        self.assertTrue(tree.inventory[tree.inventory.path2id("file")].executable)

    def test_executable_changed(self):
        self.make_client("d", "dc")
        self.build_tree({"dc/file": "x"})
        self.client_add("dc/file")
        self.client_commit("dc", "executable")
        self.client_update("dc")
        self.client_set_prop("dc/file", "svn:executable", "*")
        tree = SvnBasisTree(self.open_checkout("dc"))
        self.assertFalse(tree.inventory[tree.inventory.path2id("file")].executable)

    def test_symlink(self):
        if not has_symlinks():
            return
        self.make_client("d", "dc")
        os.symlink("target", "dc/file")
        self.build_tree({"dc/file": "x"})
        self.client_add("dc/file")
        self.client_commit("dc", "symlink")
        self.client_update("dc")
        tree = SvnBasisTree(self.open_checkout("dc"))
        self.assertEqual('symlink', 
                         tree.inventory[tree.inventory.path2id("file")].kind)
        self.assertEqual("target",
                         tree.inventory[tree.inventory.path2id("file")].symlink_target)

    def test_symlink_next(self):
        if not has_symlinks():
            return
        self.make_client("d", "dc")
        os.symlink("target", "dc/file")
        self.build_tree({"dc/file": "x", "dc/bla": "p"})
        self.client_add("dc/file")
        self.client_add("dc/bla")
        self.client_commit("dc", "symlink")
        self.build_tree({"dc/bla": "pa"})
        self.client_commit("dc", "change")
        self.client_update("dc")
        tree = SvnBasisTree(self.open_checkout("dc"))
        self.assertEqual('symlink', 
                         tree.inventory[tree.inventory.path2id("file")].kind)
        self.assertEqual("target",
                         tree.inventory[tree.inventory.path2id("file")].symlink_target)

    def test_executable_link(self):
        if not has_symlinks():
            return
        self.make_client("d", "dc")
        os.symlink("target", "dc/file")
        self.build_tree({"dc/file": "x"})
        self.client_add("dc/file")
        self.client_set_prop("dc/file", "svn:executable", "*")
        self.client_commit("dc", "exe1")
        wt = self.open_checkout("dc")
        tree = SvnBasisTree(wt)
        self.assertFalse(tree.inventory[tree.inventory.path2id("file")].executable)
        self.assertFalse(wt.inventory[wt.inventory.path2id("file")].executable)