⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lock_tests.py

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 PY
📖 第 1 页 / 共 5 页
字号:
# B.  Verify that wc A gracefully cleans up the lock via update as# well as via commit.def handle_defunct_lock(sbox):  "verify behavior when a lock in a wc is defunct"  sbox.build()  wc_dir = sbox.wc_dir  fname = 'iota'  file_path = os.path.join(sbox.wc_dir, fname)  # set up our expected status  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  # lock the file  svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',                                     '--username', svntest.main.wc_author,                                     '--password', svntest.main.wc_passwd,                                     '-m', '', file_path)  # Make a second copy of the working copy  wc_b = sbox.add_wc_path('_b')  svntest.actions.duplicate_dir(wc_dir, wc_b)  file_path_b = os.path.join(wc_b, fname)  # --- Meanwhile, in our other working copy... ---  # Try unlocking the file in the second wc.  svntest.actions.run_and_verify_svn(None, ".*unlocked", [], 'unlock',                                     '--username', svntest.main.wc_author,                                     '--password', svntest.main.wc_passwd,                                     file_path_b)  # update the 1st wc, which should clear the lock there  svntest.main.run_svn(None, 'update', wc_dir)  # Make sure the file is unlocked  svntest.actions.run_and_verify_status(wc_dir, expected_status)#----------------------------------------------------------------------# II.B.1: Set "svn:needs-lock" property on file in wc A.  Checkout wc# B and verify that that file is set as read-only.## Tests propset, propdel, lock, and unlockdef enforce_lock(sbox):  "verify svn:needs-lock read-only behavior"  sbox.build()  wc_dir = sbox.wc_dir  iota_path = os.path.join(wc_dir, 'iota')  lambda_path = os.path.join(wc_dir, 'A', 'B', 'lambda')  mu_path = os.path.join(wc_dir, 'A', 'mu')  # svn:needs-lock value should be forced to a '*'  svntest.main.run_svn(None, 'propset', 'svn:needs-lock', 'foo', iota_path)  svntest.main.run_svn(None, 'propset', 'svn:needs-lock', '', lambda_path)  svntest.main.run_svn(None, 'propset', 'svn:needs-lock', '      ', mu_path)  # Check svn:needs-lock  check_prop('svn:needs-lock', iota_path, ['*'])  check_prop('svn:needs-lock', lambda_path, ['*'])  check_prop('svn:needs-lock', mu_path, ['*'])  svntest.main.run_svn(None, 'commit',                       '--username', svntest.main.wc_author,                       '--password', svntest.main.wc_passwd,                       '-m', '', iota_path, lambda_path, mu_path)  # Now make sure that the perms were flipped on all files  if os.name == 'posix':    mode = stat.S_IWGRP | stat.S_IWOTH | stat.S_IWRITE    if ((os.stat (iota_path)[0] & mode)        or (os.stat (lambda_path)[0] & mode)        or (os.stat (mu_path)[0] & mode)):      print "Setting 'svn:needs-lock' property on a file failed to set"      print "file mode to read-only."      raise svntest.Failure    # obtain a lock on one of these files...    svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',                                       '--username', svntest.main.wc_author,                                       '--password', svntest.main.wc_passwd,                                       '-m', '', iota_path)    # ...and verify that the write bit gets set...    if not (os.stat (iota_path)[0] & mode):      print "Locking a file with 'svn:needs-lock' failed to set write bit."      raise svntest.Failure    # ...and unlock it...    svntest.actions.run_and_verify_svn(None, ".*unlocked", [], 'unlock',                                       '--username', svntest.main.wc_author,                                       '--password', svntest.main.wc_passwd,                                       iota_path)    # ...and verify that the write bit gets unset    if (os.stat (iota_path)[0] & mode):      print "Unlocking a file with 'svn:needs-lock' failed to unset write bit."      raise svntest.Failure    # Verify that removing the property restores the file to read-write    svntest.main.run_svn(None, 'propdel', 'svn:needs-lock', iota_path)    if not (os.stat (iota_path)[0] & mode):      print "Deleting 'svn:needs-lock' failed to set write bit."      raise svntest.Failure#----------------------------------------------------------------------# Test that updating a file with the "svn:needs-lock" property works,# especially on Windows, where renaming A to B fails if B already# exists and has its read-only bit set.  See also issue #2278.def update_while_needing_lock(sbox):  "update handles svn:needs-lock correctly"  sbox.build()  wc_dir = sbox.wc_dir  iota_path = os.path.join(wc_dir, 'iota')  svntest.main.run_svn(None, 'propset', 'svn:needs-lock', 'foo', iota_path)  svntest.main.run_svn(None, 'commit', '-m', 'log msg', iota_path)  svntest.main.run_svn(None, 'up', wc_dir)  # Lock, modify, commit, unlock, to create r3.  svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',                                     '--username', svntest.main.wc_author,                                     '--password', svntest.main.wc_passwd,                                     '-m', '', iota_path)  svntest.main.file_append(iota_path, "This line added in r2.\n")  svntest.main.run_svn(None, 'commit', '-m', '', iota_path) # auto-unlocks  # Backdate to r2.  svntest.main.run_svn(None, 'update', '-r2', iota_path)  # Try updating forward to r3 again.  This is where the bug happened.  svntest.main.run_svn(None, 'update', '-r3', iota_path)#----------------------------------------------------------------------# Tests update / checkout with changing propsdef defunct_lock(sbox):  "verify svn:needs-lock behavior with defunct lock"  sbox.build()  wc_dir = sbox.wc_dir  # Make a second copy of the working copy  wc_b = sbox.add_wc_path('_b')  svntest.actions.duplicate_dir(wc_dir, wc_b)  iota_path = os.path.join(wc_dir, 'iota')  iota_path_b = os.path.join(wc_b, 'iota')  mode = stat.S_IWGRP | stat.S_IWOTH | stat.S_IWRITE# Set the prop in wc a  svntest.main.run_svn(None, 'propset', 'svn:needs-lock', 'foo', iota_path)  # commit r2  svntest.main.run_svn(None, 'commit',                       '--username', svntest.main.wc_author,                       '--password', svntest.main.wc_passwd,                       '-m', '', iota_path)  # update wc_b  svntest.main.run_svn(None, 'update', wc_b)  # lock iota in wc_b  svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',                                     '--username', svntest.main.wc_author,                                     '--password', svntest.main.wc_passwd,                                     '-m', '', iota_path_b)  # break the lock iota in wc a  svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock', '--force',                                     '--username', svntest.main.wc_author,                                     '--password', svntest.main.wc_passwd,                                     '-m', '', iota_path)  # update wc_b  svntest.main.run_svn(None, 'update', wc_b)  # make sure that iota got set to read-only  if (os.stat (iota_path_b)[0] & mode):    print "Upon removal of a defunct lock, a file with 'svn:needs-lock'"    print "was not set back to read-only"    raise svntest.Failure#----------------------------------------------------------------------# Tests dealing with a lock on a deleted path def deleted_path_lock(sbox):  "verify lock removal on a deleted path"  sbox.build()  wc_dir = sbox.wc_dir  iota_path = os.path.join(wc_dir, 'iota')  iota_url = svntest.main.current_repo_url + '/iota'  svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',                                     '--username', svntest.main.wc_author,                                     '--password', svntest.main.wc_passwd,                                     '-m', '', iota_path)  svntest.actions.run_and_verify_svn(None, None, [], 'delete', iota_path)  svntest.actions.run_and_verify_svn(None, None, [], 'commit',                                     '--username', svntest.main.wc_author,                                     '--password', svntest.main.wc_passwd,                                     '--no-unlock',                                     '-m', '', iota_path)  # Now make sure that we can delete the lock from iota via a URL  svntest.actions.run_and_verify_svn(None, ".*unlocked", [], 'unlock',                                     '--username', svntest.main.wc_author,                                     '--password', svntest.main.wc_passwd,                                     iota_url)#----------------------------------------------------------------------# Tests dealing with locking and unlockingdef lock_unlock(sbox):  "lock and unlock some files"  sbox.build()  wc_dir = sbox.wc_dir  pi_path = os.path.join(wc_dir, 'A', 'D', 'G', 'pi')  rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')  tau_path = os.path.join(wc_dir, 'A', 'D', 'G', 'tau')  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  expected_status.tweak('A/D/G/pi', 'A/D/G/rho', 'A/D/G/tau', writelocked='K')  svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',                                     '--username', svntest.main.wc_author,                                     '--password', svntest.main.wc_passwd,                                     '-m', '', pi_path, rho_path, tau_path)  svntest.actions.run_and_verify_status(wc_dir, expected_status)  expected_status.tweak('A/D/G/pi', 'A/D/G/rho', 'A/D/G/tau', writelocked=None)  svntest.actions.run_and_verify_svn(None, ".*unlocked", [], 'unlock',                                     '--username', svntest.main.wc_author,                                     '--password', svntest.main.wc_passwd,                                     pi_path, rho_path, tau_path)  svntest.actions.run_and_verify_status(wc_dir, expected_status)#----------------------------------------------------------------------# Tests dealing with directory deletion and locksdef deleted_dir_lock(sbox):  "verify removal of a directory with locks inside"  sbox.build()  wc_dir = sbox.wc_dir  parent_dir = os.path.join(wc_dir, 'A', 'D', 'G')  pi_path = os.path.join(wc_dir, 'A', 'D', 'G', 'pi')  rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')  tau_path = os.path.join(wc_dir, 'A', 'D', 'G', 'tau')  svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',                                     '--username', svntest.main.wc_author,                                     '--password', svntest.main.wc_passwd,                                     '-m', '', pi_path, rho_path, tau_path)  svntest.actions.run_and_verify_svn(None, None, [], 'delete', parent_dir)  svntest.actions.run_and_verify_svn(None, None, [], 'commit',                                     '--username', svntest.main.wc_author,                                     '--password', svntest.main.wc_passwd,                                     '--no-unlock',                                     '-m', '', parent_dir)#----------------------------------------------------------------------# III.c : Lock a file and check the output of 'svn stat' from the same# working copy and another.def lock_status(sbox):  "verify status of lock in working copy"  sbox.build()  wc_dir = sbox.wc_dir   # Make a second copy of the working copy  wc_b = sbox.add_wc_path('_b')  svntest.actions.duplicate_dir(wc_dir, wc_b)  # lock a file as wc_author  fname = 'iota'  file_path = os.path.join(sbox.wc_dir, fname)  svntest.main.file_append(file_path, "This is a spreadsheet\n")  svntest.main.run_svn(None, 'commit',                       '--username', svntest.main.wc_author,                       '--password', svntest.main.wc_passwd,                       '-m', '', file_path)  svntest.main.run_svn(None, 'lock',                        '--username', svntest.main.wc_author,                       '--password', svntest.main.wc_passwd,                       '-m', '', file_path)   expected_status = svntest.actions.get_virginal_state(wc_dir, 2)    expected_status.tweak(wc_rev=1)  expected_status.tweak(fname, wc_rev=2)  expected_status.tweak(fname, writelocked='K')  svntest.actions.run_and_verify_status(wc_dir, expected_status)  # Verify status again after modifying the file  svntest.main.file_append(file_path, "check stat output after mod")  expected_status.tweak(fname, status='M ')  svntest.actions.run_and_verify_status(wc_dir, expected_status)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -