43
43
from bzrlib.branch import Branch
44
44
from bzrlib.clone import copy_branch
45
45
from bzrlib.errors import BzrCommandError
46
from bzrlib.osutils import has_symlinks
46
from bzrlib.osutils import has_symlinks, pathjoin
47
47
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
48
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
48
49
from bzrlib.tests.blackbox import ExternalBase
50
51
class TestCommands(ExternalBase):
215
216
os.rmdir('revertdir')
216
217
self.runbzr('revert')
218
os.symlink('/unlikely/to/exist', 'symlink')
219
self.runbzr('add symlink')
220
self.runbzr('commit -m f')
222
self.runbzr('revert')
223
self.failUnlessExists('symlink')
225
os.symlink('a-different-path', 'symlink')
226
self.runbzr('revert')
227
self.assertEqual('/unlikely/to/exist',
228
os.readlink('symlink'))
220
os.symlink('/unlikely/to/exist', 'symlink')
221
self.runbzr('add symlink')
222
self.runbzr('commit -m f')
224
self.runbzr('revert')
225
self.failUnlessExists('symlink')
227
os.symlink('a-different-path', 'symlink')
228
self.runbzr('revert')
229
self.assertEqual('/unlikely/to/exist',
230
os.readlink('symlink'))
232
self.log("skipping revert symlink tests")
230
234
file('hello', 'wt').write('xyz')
231
235
self.runbzr('commit -m xyz hello')
674
678
self.assertEquals(['If you wish to add some of these files, please'\
675
679
' add them by name.',
677
'added dir'+os.sep+'sub.txt',
679
683
'ignored 1 file(s) matching "CVS"'],
728
732
self.build_tree(['inertiatic/', 'inertiatic/esp'])
729
733
self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
730
734
self.run_bzr('add', '--no-recurse', 'inertiatic')
731
self.assertEquals(self.capture('unknowns'), 'inertiatic'+os.sep+'esp\n')
735
self.assertEquals(self.capture('unknowns'), 'inertiatic/esp\n')
732
736
self.run_bzr('add', 'inertiatic/esp')
733
737
self.assertEquals(self.capture('unknowns'), '')
1009
1013
self.assertEquals(capture('root').rstrip(),
1010
os.path.join(self.test_dir, 'branch1'))
1014
pathjoin(self.test_dir, 'branch1'))
1012
1016
progress("status of new file")
1083
1087
runbzr("rename sub1 sub2")
1084
1088
runbzr("move hello.txt sub2")
1085
1089
self.assertEqual(capture("relpath sub2/hello.txt"),
1086
os.path.join("sub2", "hello.txt\n"))
1090
pathjoin("sub2", "hello.txt\n"))
1088
1092
self.assert_(exists("sub2"))
1089
1093
self.assert_(exists("sub2/hello.txt"))
1106
1110
chdir('sub1/sub2')
1107
1111
self.assertEquals(capture('root')[:-1],
1108
os.path.join(self.test_dir, 'branch1'))
1112
pathjoin(self.test_dir, 'branch1'))
1109
1113
runbzr('move ../hello.txt .')
1110
1114
self.assert_(exists('./hello.txt'))
1111
1115
self.assertEquals(capture('relpath hello.txt'),
1112
os.path.join('sub1', 'sub2', 'hello.txt') + '\n')
1113
self.assertEquals(capture('relpath ../../sub1/sub2/hello.txt'), os.path.join('sub1', 'sub2', 'hello.txt\n'))
1116
pathjoin('sub1', 'sub2', 'hello.txt') + '\n')
1117
self.assertEquals(capture('relpath ../../sub1/sub2/hello.txt'), pathjoin('sub1', 'sub2', 'hello.txt\n'))
1114
1118
runbzr(['commit', '-m', 'move to parent directory'])
1116
self.assertEquals(capture('relpath sub2/hello.txt'), os.path.join('sub1', 'sub2', 'hello.txt\n'))
1120
self.assertEquals(capture('relpath sub2/hello.txt'), pathjoin('sub1', 'sub2', 'hello.txt\n'))
1118
1122
runbzr('move sub2/hello.txt .')
1119
1123
self.assert_(exists('hello.txt'))
1291
1295
branch.working_tree().commit('add file', rev_id='A')
1292
1296
url = self.get_remote_url('branch/')
1293
1297
self.run_bzr('check', url)
1300
class HTTPTests(TestCaseWithWebserver, RemoteTests):
1301
"""Test various commands against a HTTP server."""
1304
class SFTPTestsAbsolute(TestCaseWithSFTPServer, RemoteTests):
1305
"""Test various commands against a SFTP server using abs paths."""
1308
class SFTPTestsAbsoluteSibling(TestCaseWithSFTPServer, RemoteTests):
1309
"""Test various commands against a SFTP server using abs paths."""
1312
super(SFTPTestsAbsoluteSibling, self).setUp()
1313
self._override_home = '/dev/noone/runs/tests/here'
1316
class SFTPTestsRelative(TestCaseWithSFTPServer, RemoteTests):
1317
"""Test various commands against a SFTP server using homedir rel paths."""
1320
super(SFTPTestsRelative, self).setUp()
1321
self._get_remote_is_absolute = False