59
59
def test_revert(self):
60
60
self.run_bzr('init')
62
with open('hello', 'wt') as f: f.write('foo')
62
with open('hello', 'wt') as f:
63
64
self.run_bzr('add hello')
64
65
self.run_bzr('commit -m setup hello')
66
with open('goodbye', 'wt') as f: f.write('baz')
67
with open('goodbye', 'wt') as f:
67
69
self.run_bzr('add goodbye')
68
70
self.run_bzr('commit -m setup goodbye')
70
with open('hello', 'wt') as f: f.write('bar')
71
with open('goodbye', 'wt') as f: f.write('qux')
72
with open('hello', 'wt') as f:
74
with open('goodbye', 'wt') as f:
72
76
self.run_bzr('revert hello')
73
77
self.check_file_contents('hello', b'foo')
74
78
self.check_file_contents('goodbye', b'qux')
97
101
self.log("skipping revert symlink tests")
99
with open('hello', 'wt') as f: f.write('xyz')
103
with open('hello', 'wt') as f:
100
105
self.run_bzr('commit -m xyz hello')
101
106
self.run_bzr('revert -r 1 hello')
102
107
self.check_file_contents('hello', b'foo')
109
114
def example_branch(test):
110
115
test.run_bzr('init')
111
with open('hello', 'wt') as f: f.write('foo')
116
with open('hello', 'wt') as f:
112
118
test.run_bzr('add hello')
113
119
test.run_bzr('commit -m setup hello')
114
with open('goodbye', 'wt') as f: f.write('baz')
120
with open('goodbye', 'wt') as f:
115
122
test.run_bzr('add goodbye')
116
123
test.run_bzr('commit -m setup goodbye')
194
202
"""Create a conflicted tree"""
197
with open('hello', 'wb') as f: f.write(b"hi world")
198
with open('answer', 'wb') as f: f.write(b"42")
205
with open('hello', 'wb') as f:
207
with open('answer', 'wb') as f:
199
209
self.run_bzr('init')
200
210
self.run_bzr('add')
201
211
self.run_bzr('commit -m base')
202
212
self.run_bzr('branch . ../other')
203
213
self.run_bzr('branch . ../this')
204
214
os.chdir('../other')
205
with open('hello', 'wb') as f: f.write(b"Hello.")
206
with open('answer', 'wb') as f: f.write(b"Is anyone there?")
215
with open('hello', 'wb') as f:
217
with open('answer', 'wb') as f:
218
f.write(b"Is anyone there?")
207
219
self.run_bzr('commit -m other')
208
220
os.chdir('../this')
209
with open('hello', 'wb') as f: f.write(b"Hello, world")
221
with open('hello', 'wb') as f:
222
f.write(b"Hello, world")
210
223
self.run_bzr('mv answer question')
211
with open('question', 'wb') as f: f.write(b"What do you get when you multiply six"
224
with open('question', 'wb') as f:
225
f.write(b"What do you get when you multiply six"
213
227
self.run_bzr('commit -m this')
215
229
def test_status(self):
248
261
self.assertTrue('hi world' not in conflict_text)
249
262
result = self.run_bzr('conflicts')[0]
250
263
self.assertEqual(result, "Text conflict in hello\nText conflict in"
252
265
result = self.run_bzr('status')[0]
253
266
self.assertTrue("conflicts:\n Text conflict in hello\n"
254
" Text conflict in question\n" in result, result)
267
" Text conflict in question\n" in result, result)
255
268
self.run_bzr('resolve hello')
256
269
result = self.run_bzr('conflicts')[0]
257
270
self.assertEqual(result, "Text conflict in question\n")
421
434
self.assertTrue("this is my new commit\n and" in log_out)
422
435
self.assertTrue("rename nested" not in log_out)
423
436
self.assertTrue('revision-id' not in log_out)
424
self.assertTrue('revision-id' in self.run_bzr('log --show-ids -m commit')[0])
438
'revision-id' in self.run_bzr('log --show-ids -m commit')[0])
426
440
log_out = self.run_bzr('log --line')[0]
427
441
# determine the widest line we want
435
449
progress("file with spaces in name")
436
450
mkdir('sub directory')
437
with open('sub directory/file with spaces ', 'wt') as f: f.write('see how this works\n')
451
with open('sub directory/file with spaces ', 'wt') as f:
452
f.write('see how this works\n')
438
453
self.run_bzr('add .')
439
454
self.run_bzr('diff', retcode=1)
440
455
self.run_bzr('commit -m add-spaces')
507
522
self.run_bzr('export -r 1 exp1.tmp')
508
523
chdir("exp1.tmp")
509
self.assertEqual(listdir_sorted("."), [ "link1" ])
524
self.assertEqual(listdir_sorted("."), ["link1"])
510
525
self.assertEqual(os.readlink("link1"), "NOWHERE1")
513
528
self.run_bzr('export -r 2 exp2.tmp')
514
529
chdir("exp2.tmp")
515
self.assertEqual(listdir_sorted("."), [ "d1", "link1" ])
530
self.assertEqual(listdir_sorted("."), ["d1", "link1"])
518
533
self.run_bzr('export -r 3 exp3.tmp')
519
534
chdir("exp3.tmp")
520
self.assertEqual(listdir_sorted("."), [ "d2", "link2" ])
521
self.assertEqual(listdir_sorted("d2"), [ "link1", "link3" ])
535
self.assertEqual(listdir_sorted("."), ["d2", "link2"])
536
self.assertEqual(listdir_sorted("d2"), ["link1", "link3"])
522
537
self.assertEqual(os.readlink("d2/link1"), "NOWHERE1")
523
538
self.assertEqual(os.readlink("link2"), "NOWHERE2")
526
541
self.run_bzr('export -r 4 exp4.tmp')
527
542
chdir("exp4.tmp")
528
self.assertEqual(listdir_sorted("."), [ "d2", "link2" ])
543
self.assertEqual(listdir_sorted("."), ["d2", "link2"])
529
544
self.assertEqual(os.readlink("d2/link1"), "TARGET 1")
530
545
self.assertEqual(os.readlink("link2"), "TARGET 2")
531
self.assertEqual(listdir_sorted("d2"), [ "link1", "link3" ])
546
self.assertEqual(listdir_sorted("d2"), ["link1", "link3"])
534
549
self.run_bzr('export -r 5 exp5.tmp')
535
550
chdir("exp5.tmp")
536
self.assertEqual(listdir_sorted("."), [ "d2", "link2" ])
551
self.assertEqual(listdir_sorted("."), ["d2", "link2"])
537
552
self.assertTrue(os.path.islink("link2"))
538
self.assertTrue(listdir_sorted("d2")== [ "link3" ])
553
self.assertTrue(listdir_sorted("d2") == ["link3"])
541
556
self.run_bzr('export -r 8 exp6.tmp')
542
557
chdir("exp6.tmp")
543
self.assertEqual(listdir_sorted("."), [ "d1", "d2", "link2"])
544
self.assertEqual(listdir_sorted("d1"), [ "link3new" ])
558
self.assertEqual(listdir_sorted("."), ["d1", "d2", "link2"])
559
self.assertEqual(listdir_sorted("d1"), ["link3new"])
545
560
self.assertEqual(listdir_sorted("d2"), [])
546
561
self.assertEqual(os.readlink("d1/link3new"), "NOWHERE3")