134
135
wc_dir = sbox.wc_dir
137
file_path = os.path.join(sbox.wc_dir, fname)
139
# lock fname as wc_author
137
# lock 'A/mu' as wc_author
140
138
svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',
141
'-m', 'some lock comment', file_path)
139
'-m', 'some lock comment',
143
142
# make a change and commit it, holding lock
144
svntest.main.file_append(file_path, "Tweak!\n")
143
sbox.simple_append('A/mu', 'Tweak!\n')
145
144
svntest.main.run_svn(None, 'commit', '-m', '', '--no-unlock',
148
147
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
149
expected_status.tweak(fname, wc_rev=2)
150
expected_status.tweak(fname, writelocked='K')
148
expected_status.tweak('A/mu', wc_rev=2, writelocked='K')
152
150
# Make sure the file is still locked
153
151
svntest.actions.run_and_verify_status(wc_dir, expected_status)
155
154
def commit_file_unlock(sbox):
156
155
"commit a file and release lock"
159
158
wc_dir = sbox.wc_dir
162
file_path = os.path.join(sbox.wc_dir, fname)
164
# lock fname as wc_author
160
# lock A/mu and iota as wc_author
165
161
svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',
166
'-m', 'some lock comment', file_path)
162
'-m', 'some lock comment',
168
166
# make a change and commit it, allowing lock to be released
169
svntest.main.file_append(file_path, "Tweak!\n")
170
svntest.main.run_svn(None, 'commit', '-m', '',
167
sbox.simple_append('A/mu', 'Tweak!\n')
173
170
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
174
expected_status.tweak(fname, wc_rev=2)
171
expected_status.tweak('A/mu', wc_rev=2)
172
expected_status.tweak('iota', wc_rev=2)
176
174
# Make sure the file is unlocked
177
175
svntest.actions.run_and_verify_status(wc_dir, expected_status)
184
182
wc_dir = sbox.wc_dir
187
file_path = os.path.join(sbox.wc_dir, fname)
189
# lock fname as wc_author
184
# lock A/mu as wc_author
190
185
svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',
191
'-m', 'some lock comment', file_path)
186
'-m', 'some lock comment',
193
189
# make a property change and commit it, allowing lock to be released
194
svntest.main.run_svn(None, 'propset', 'blue', 'azul', file_path)
195
svntest.main.run_svn(None, 'commit',
190
sbox.simple_propset('blue', 'azul', 'A/mu')
191
sbox.simple_commit('A/mu')
198
193
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
199
expected_status.tweak(fname, wc_rev=2)
194
expected_status.tweak('A/mu', wc_rev=2)
201
196
# Make sure the file is unlocked
202
197
svntest.actions.run_and_verify_status(wc_dir, expected_status)
418
402
"update handles svn:needs-lock correctly"
423
iota_path = os.path.join(wc_dir, 'iota')
424
svntest.main.run_svn(None,
425
'propset', 'svn:needs-lock', 'foo', iota_path)
426
svntest.main.run_svn(None,
427
'commit', '-m', 'log msg', iota_path)
428
svntest.main.run_svn(None,
406
sbox.simple_propset('svn:needs-lock', 'foo', 'iota')
407
sbox.simple_commit('iota')
431
410
# Lock, modify, commit, unlock, to create r3.
432
411
svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',
434
svntest.main.file_append(iota_path, "This line added in r2.\n")
435
svntest.main.run_svn(None, 'commit',
436
'-m', '', iota_path) # auto-unlocks
412
'-m', '', sbox.ospath('iota'))
413
sbox.simple_append('iota', 'This line added in r2.\n')
414
sbox.simple_commit('iota') # auto-unlocks
438
416
# Backdate to r2.
439
svntest.main.run_svn(None,
440
'update', '-r2', iota_path)
417
sbox.simple_update(revision=2)
442
419
# Try updating forward to r3 again. This is where the bug happened.
443
svntest.main.run_svn(None,
444
'update', '-r3', iota_path)
420
sbox.simple_update(revision=3)
447
423
#----------------------------------------------------------------------
552
526
wc_dir = sbox.wc_dir
554
parent_dir = os.path.join(wc_dir, 'A', 'D', 'G')
555
pi_path = os.path.join(wc_dir, 'A', 'D', 'G', 'pi')
556
rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')
557
tau_path = os.path.join(wc_dir, 'A', 'D', 'G', 'tau')
528
pi_path = sbox.ospath('A/D/G/pi')
529
rho_path = sbox.ospath('A/D/G/rho')
530
tau_path = sbox.ospath('A/D/G/tau')
559
532
svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',
560
533
'-m', '', pi_path, rho_path, tau_path)
562
svntest.actions.run_and_verify_svn(None, None, [], 'delete', parent_dir)
535
sbox.simple_rm('A/D/G') # the parent directory
564
536
svntest.actions.run_and_verify_svn(None, None, [], 'commit',
566
'-m', '', parent_dir)
538
'-m', '', sbox.ospath('A/D/G'))
568
540
#----------------------------------------------------------------------
569
541
# III.c : Lock a file and check the output of 'svn stat' from the same
582
554
file_path = os.path.join(sbox.wc_dir, fname)
584
svntest.main.file_append(file_path, "This is a spreadsheet\n")
585
svntest.main.run_svn(None, 'commit',
556
sbox.simple_append('iota', "This is a spreadsheet\n")
557
sbox.simple_commit('iota')
588
svntest.main.run_svn(None, 'lock',
559
svntest.main.run_svn(None, 'lock', '-m', '', sbox.ospath('iota'))
591
561
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
592
expected_status.tweak(fname, wc_rev=2)
593
expected_status.tweak(fname, writelocked='K')
562
expected_status.tweak('iota', wc_rev=2, writelocked='K')
595
564
svntest.actions.run_and_verify_status(wc_dir, expected_status)
597
566
# Verify status again after modifying the file
598
svntest.main.file_append(file_path, "check stat output after mod")
567
sbox.simple_append('iota', 'check stat output after mod')
600
expected_status.tweak(fname, status='M ')
569
expected_status.tweak('iota', status='M ')
602
571
svntest.actions.run_and_verify_status(wc_dir, expected_status)
604
573
# Verify status of lock from another working copy
605
574
svntest.main.run_svn(None, 'update', wc_b)
606
575
expected_status = svntest.actions.get_virginal_state(wc_b, 2)
607
expected_status.tweak(fname, writelocked='O')
576
expected_status.tweak('iota', writelocked='O')
609
578
svntest.actions.run_and_verify_status(wc_b, expected_status)
1750
1711
".*scheme.*'opaquelocktoken'", 0,
1751
1712
'lock', '-m', '', file_path)
1715
def lock_multi_wc(sbox):
1716
"obtain locks in multiple working copies in one go"
1720
sbox2 = sbox.clone_dependent(copy_wc=True)
1722
wc_name = os.path.basename(sbox.wc_dir)
1723
wc2_name = os.path.basename(sbox2.wc_dir)
1725
expected_output = svntest.verify.UnorderedOutput([
1726
'\'%s\' locked by user \'jrandom\'.\n' % os.path.join(wc_name, 'iota'),
1727
'\'%s\' locked by user \'jrandom\'.\n' % os.path.join(wc2_name, 'A', 'mu'),
1730
svntest.actions.run_and_verify_svn(None, expected_output, [],
1731
'lock', sbox.ospath('iota'),
1732
sbox2.ospath('A/mu'))
1734
expected_output = svntest.verify.UnorderedOutput([
1735
'\'%s\' unlocked.\n' % os.path.join(wc_name, 'iota'),
1736
'\'%s\' unlocked.\n' % os.path.join(wc2_name, 'A', 'mu'),
1738
svntest.actions.run_and_verify_svn(None, expected_output, [],
1739
'unlock', sbox.ospath('iota'),
1740
sbox2.ospath('A/mu'))
1743
def locks_stick_over_switch(sbox):
1744
"locks are kept alive over switching"
1747
wc_dir = sbox.wc_dir
1748
repo_url = sbox.repo_url
1750
svntest.actions.run_and_verify_svn(None, None, [],
1751
'cp', sbox.ospath('A'), repo_url + '/AA',
1754
expected_output = svntest.verify.UnorderedOutput([
1755
'\'iota\' locked by user \'jrandom\'.\n',
1756
'\'%s\' locked by user \'jrandom\'.\n' % os.path.join('A', 'D', 'H', 'chi'),
1757
'\'%s\' locked by user \'jrandom\'.\n' % os.path.join('A', 'mu'),
1759
svntest.actions.run_and_verify_svn(None, expected_output, [],
1760
'lock', sbox.ospath('A/D/H/chi'),
1761
sbox.ospath('A/mu'),
1762
sbox.ospath('iota'))
1764
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
1765
expected_status.tweak('A/D/H/chi', 'A/mu', 'iota', writelocked='K')
1767
# Make sure the file is still locked
1768
svntest.actions.run_and_verify_status(wc_dir, expected_status)
1770
expected_output = svntest.wc.State(wc_dir, {
1773
expected_status.tweak(wc_rev=2)
1774
expected_status.tweak('', wc_rev=1)
1775
expected_status.tweak('iota', writelocked='K', wc_rev=1)
1777
switched_status = expected_status.copy()
1778
switched_status.tweak(writelocked=None)
1779
switched_status.tweak('iota', writelocked='K')
1780
switched_status.tweak('A', switched='S')
1782
svntest.actions.run_and_verify_switch(wc_dir, sbox.ospath('A'),
1784
expected_output, None, switched_status)
1786
# And now switch back to verify that the locks reappear
1787
expected_output = svntest.wc.State(wc_dir, {
1789
svntest.actions.run_and_verify_switch(wc_dir, sbox.ospath('A'),
1791
expected_output, None, expected_status)
1794
def lock_unlock_deleted(sbox):
1795
"lock/unlock a deleted file"
1798
wc_dir = sbox.wc_dir
1799
svntest.actions.run_and_verify_svn(None, None, [],
1800
'rm', sbox.ospath('A/mu'))
1802
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
1803
expected_status.tweak('A/mu', status='D ')
1804
svntest.actions.run_and_verify_status(wc_dir, expected_status)
1806
expected_output = '\'mu\' locked by user \'jrandom\'.'
1807
svntest.actions.run_and_verify_svn(None, expected_output, [],
1808
'lock', sbox.ospath('A/mu'))
1809
expected_status.tweak('A/mu', writelocked='K')
1810
svntest.actions.run_and_verify_status(wc_dir, expected_status)
1812
expected_output = '\'mu\' unlocked.'
1813
svntest.actions.run_and_verify_svn(None, expected_output, [],
1814
'unlock', sbox.ospath('A/mu'))
1815
expected_status.tweak('A/mu', writelocked=None)
1816
svntest.actions.run_and_verify_status(wc_dir, expected_status)
1819
def commit_stolen_lock(sbox):
1820
"commit with a stolen lock"
1823
wc_dir = sbox.wc_dir
1825
sbox.simple_append('A/mu', 'zig-zag')
1826
sbox.simple_lock('A/mu')
1828
expected_output = '\'mu\' locked by user \'jrandom\'.'
1829
svntest.actions.run_and_verify_svn(None, expected_output, [],
1831
sbox.repo_url + '/A/mu')
1833
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
1834
expected_status.tweak('A/mu', status='M ', writelocked='T')
1835
err_re = "(.*E160037: Cannot verify lock on path '/A/mu')|" + \
1836
"(.*E160038: '/.*/A/mu': no lock token available)"
1837
svntest.actions.run_and_verify_commit(wc_dir,
1843
# When removing directories, the locks of contained files were not
1844
# correctly removed from the working copy database, thus they later
1845
# magically reappeared when new files or directories with the same
1846
# pathes were added.
1848
def drop_locks_on_parent_deletion(sbox):
1849
"drop locks when the parent is deleted"
1852
wc_dir = sbox.wc_dir
1854
# lock some files, and remove them.
1855
sbox.simple_lock('A/B/lambda')
1856
sbox.simple_lock('A/B/E/alpha')
1857
sbox.simple_lock('A/B/E/beta')
1858
sbox.simple_rm('A/B')
1860
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
1861
expected_status.remove_subtree('A/B')
1863
svntest.actions.run_and_verify_commit(wc_dir,
1869
# now re-add entities to the deleted pathes.
1870
sbox.simple_mkdir('A/B')
1871
sbox.simple_add_text('new file replacing old file', 'A/B/lambda')
1872
sbox.simple_add_text('file replacing former dir', 'A/B/F')
1873
# The bug also resurrected locks on directories when their path
1874
# matched a former file.
1875
sbox.simple_mkdir('A/B/E', 'A/B/E/alpha')
1877
expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
1878
expected_status.tweak('A/B',
1884
expected_status.remove('A/B/E/beta')
1886
svntest.actions.run_and_verify_commit(wc_dir,
1754
1893
########################################################################
1755
1894
# Run the tests