6
from bzrlib.selftest import InTempDir, TestBase
6
from bzrlib.selftest import InTempDir, TestCase
7
7
from bzrlib.branch import ScratchBranch, Branch
8
8
from bzrlib.errors import NotBranchError, NotVersionedError
11
class Unknowns(InTempDir):
11
class TestBranch(InTempDir):
13
def test_unknowns(self):
13
14
b = Branch('.', init=True)
15
16
self.build_tree(['hello.txt',
58
class ValidateRevisionId(TestBase):
56
class TestRevisionId(TestCase):
58
def test_validate_revision_id(self):
60
59
from bzrlib.revision import validate_revision_id
61
60
validate_revision_id('mbp@sourcefrog.net-20050311061123-96a255005c7c9dbe')
63
61
self.assertRaises(ValueError,
64
62
validate_revision_id,
68
64
self.assertRaises(ValueError,
69
65
validate_revision_id,
70
66
'mbp@sourcefrog.net-20050311061123-96a255005c7c9dbe\n')
73
67
self.assertRaises(ValueError,
74
68
validate_revision_id,
75
69
' mbp@sourcefrog.net-20050311061123-96a255005c7c9dbe')
77
70
self.assertRaises(ValueError,
78
71
validate_revision_id,
79
72
'Martin Pool <mbp@sourcefrog.net>-20050311061123-96a255005c7c9dbe')
83
75
class PendingMerges(InTempDir):
84
"""Tracking pending-merged revisions."""
77
def test_pending_merges(self):
78
"""Tracking pending-merged revisions."""
86
79
b = Branch('.', init=True)
88
81
self.assertEquals(b.pending_merges(), [])
90
b.add_pending_merge('foo@azkhazan-123123-abcabc')
92
self.assertEquals(b.pending_merges(), ['foo@azkhazan-123123-abcabc'])
94
b.add_pending_merge('foo@azkhazan-123123-abcabc')
96
self.assertEquals(b.pending_merges(), ['foo@azkhazan-123123-abcabc'])
82
b.add_pending_merge('foo@azkhazan-123123-abcabc')
83
self.assertEquals(b.pending_merges(), ['foo@azkhazan-123123-abcabc'])
84
b.add_pending_merge('foo@azkhazan-123123-abcabc')
85
self.assertEquals(b.pending_merges(), ['foo@azkhazan-123123-abcabc'])
98
86
b.add_pending_merge('wibble@fofof--20050401--1928390812')
99
87
self.assertEquals(b.pending_merges(),
100
88
['foo@azkhazan-123123-abcabc',
101
89
'wibble@fofof--20050401--1928390812'])
103
90
b.commit("commit from base with two merges")
105
91
rev = b.get_revision(b.revision_history()[0])
106
92
self.assertEquals(len(rev.parents), 2)
107
93
self.assertEquals(rev.parents[0].revision_id,
108
94
'foo@azkhazan-123123-abcabc')
109
95
self.assertEquals(rev.parents[1].revision_id,
110
96
'wibble@fofof--20050401--1928390812')
112
97
# list should be cleared when we do a commit
113
98
self.assertEquals(b.pending_merges(), [])
118
class Revert(InTempDir):
119
"""Test selected-file revert"""
100
def test_revert(self):
101
"""Test selected-file revert"""
121
102
b = Branch('.', init=True)
123
104
self.build_tree(['hello.txt'])
143
124
self.check_file_contents('hello.txt', 'initial hello')
144
125
self.check_file_contents('hello.txt~', 'initial hello')
148
class RenameDirs(InTempDir):
149
"""Test renaming directories and the files within them."""
127
def test_rename_dirs(self):
128
"""Test renaming directories and the files within them."""
151
129
b = Branch('.', init=True)
152
130
self.build_tree(['dir/', 'dir/sub/', 'dir/sub/file'])
153
131
b.add(['dir', 'dir/sub', 'dir/sub/file'])
176
154
['newdir', 'newdir/newsub',
177
155
'newdir/newsub/file'])
182
class BranchPathTestCase(TestBase):
183
"""test for branch path lookups
185
Branch.relpath and bzrlib.branch._relpath do a simple but subtle
186
job: given a path (either relative to cwd or absolute), work out
187
if it is inside a branch and return the path relative to the base.
157
def test_relpath(self):
158
"""test for branch path lookups
160
Branch.relpath and bzrlib.branch._relpath do a simple but subtle
161
job: given a path (either relative to cwd or absolute), work out
162
if it is inside a branch and return the path relative to the base.
191
164
from bzrlib.branch import _relpath
192
165
import tempfile, shutil