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

📄 lock_tests.py

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 PY
📖 第 1 页 / 共 5 页
字号:
  # Verify status of lock from another working copy  svntest.main.run_svn(None, 'update', wc_b)  expected_status = svntest.actions.get_virginal_state(wc_b, 2)  expected_status.tweak(fname, writelocked='O')  svntest.actions.run_and_verify_status(wc_b, expected_status)#----------------------------------------------------------------------# III.c : Steal lock on a file from another working copy with 'svn lock# --force', and check the status of lock in the repository from the # working copy in which the file was initially locked.def stolen_lock_status (sbox):  "verify status of stolen 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)  # lock a file as wc_author  fname = 'iota'  file_path = os.path.join(sbox.wc_dir, fname)  file_path_b = os.path.join(wc_b, 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)  # Forcibly lock same file (steal lock) from another working copy  svntest.main.run_svn(None, 'update', wc_b)  svntest.main.run_svn(None, 'lock',                       '--username', svntest.main.wc_author,                       '--password', svntest.main.wc_passwd,                       '-m', '', '--force', file_path_b)   # Verify status from working copy where file was initially locked  expected_status.tweak(fname, writelocked='T')  svntest.actions.run_and_verify_status(wc_dir, expected_status)#----------------------------------------------------------------------# III.c : Break lock from another working copy with 'svn unlock --force'# and verify the status of the lock in the repository with 'svn stat -u'# from the working copy in the file was initially lockeddef broken_lock_status (sbox):  "verify status of broken 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)  # lock a file as wc_author  fname = 'iota'  file_path = os.path.join(sbox.wc_dir, fname)  file_path_b = os.path.join(wc_b, 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)  # Forcibly unlock the same file (break lock) from another working copy  svntest.main.run_svn(None, 'update', wc_b)  svntest.main.run_svn(None, 'unlock',                       '--username', svntest.main.wc_author,                       '--password', svntest.main.wc_passwd,                       '--force', file_path_b)  # Verify status from working copy where file was initially locked  expected_status.tweak(fname, writelocked='B')  svntest.actions.run_and_verify_status(wc_dir, expected_status)#----------------------------------------------------------------------# Invalid input test - lock non-existent filedef lock_non_existent_file (sbox):  "verify error on locking non-existent file"  sbox.build()  fname = 'A/foo'  file_path = os.path.join(sbox.wc_dir, fname)  output, error = svntest.main.run_svn(1, 'lock',                                       '--username', svntest.main.wc_author,                                       '--password', svntest.main.wc_passwd,                                       '-m', '', file_path)  error_msg = "'foo' is not under version control"  for line in error:    if line.find(error_msg) != -1:      break  else:    print "Error:", error_msg, ": not found in:", error    raise svntest.Failure#----------------------------------------------------------------------# Check that locking an out-of-date file fails.def out_of_date(sbox):  "lock an out-of-date file and ensure failure"  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)  fname = 'iota'  file_path = os.path.join(sbox.wc_dir, fname)  file_path_b = os.path.join(wc_b, fname)  # Make a new revision of the file in the first WC.  svntest.main.file_append(file_path, "This represents a binary file\n")  svntest.main.run_svn(None, 'commit',                       '--username', svntest.main.wc_author,                       '--password', svntest.main.wc_passwd,                       '-m', '', file_path)  # --- Meanwhile, in our other working copy... ---  svntest.actions.run_and_verify_svn(None, None,                                     ".*newer version of '/iota' exists",                                      'lock',                                     '--username', svntest.main.wc_author2,                                     '--password', svntest.main.wc_passwd,                                     '-m', '', file_path_b)#----------------------------------------------------------------------# Tests reverting a svn:needs-lock filedef revert_lock(sbox):  "verify svn:needs-lock behavior with revert"  sbox.build()  wc_dir = sbox.wc_dir  iota_path = os.path.join(wc_dir, 'iota')  mode = stat.S_IWGRP | stat.S_IWOTH | stat.S_IWRITE  # set the prop in wc   svntest.actions.run_and_verify_svn(None, None, [], 'propset',                                  'svn:needs-lock', 'foo', iota_path)  # commit r2  svntest.actions.run_and_verify_svn(None, None, [], 'commit',                       '--username', svntest.main.wc_author,                       '--password', svntest.main.wc_passwd,                       '-m', '', iota_path)  # make sure that iota got set to read-only  if (os.stat (iota_path)[0] & mode):    print "Committing a file with 'svn:needs-lock'"    print "did not set the file to read-only"    raise svntest.Failure  # verify status is as we expect  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)  expected_status.tweak(wc_rev=1)  expected_status.tweak('iota', wc_rev=2)  svntest.actions.run_and_verify_status(wc_dir, expected_status)  # remove read-only-ness  svntest.actions.run_and_verify_svn(None, None, [], 'propdel',                                  'svn:needs-lock', iota_path)  # make sure that iota got read-only-ness removed  if (os.stat (iota_path)[0] & mode == 0):    print "Deleting the 'svn:needs-lock' property "    print "did not remove read-only-ness"    raise svntest.Failure    # revert the change  svntest.actions.run_and_verify_svn(None, None, [], 'revert', iota_path)  # make sure that iota got set back to read-only  if (os.stat (iota_path)[0] & mode):    print "Reverting a file with 'svn:needs-lock'"    print "did not set the file back to read-only"    raise svntest.Failure   # try propdel and revert from a different directory so  # full filenames are used  extra_name = 'xx'  # now 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', '', iota_path)    # modify it  svntest.main.file_append(iota_path, "This line added\n")  expected_status.tweak(wc_rev=1)  expected_status.tweak('iota', wc_rev=2)  expected_status.tweak('iota', status='M ', writelocked='K')  svntest.actions.run_and_verify_status(wc_dir, expected_status)    # revert it  svntest.actions.run_and_verify_svn(None, None, [], 'revert', iota_path)  # make sure it is still writable since we have the lock  if (os.stat (iota_path)[0] & mode == 0):    print "Reverting a 'svn:needs-lock' file (with lock in wc) "    print "did not leave the file writable"    raise svntest.Failure  #----------------------------------------------------------------------def examine_lock_via_url(sbox):  "examine the fields of a lock from a URL"  sbox.build()  wc_dir = sbox.wc_dir  fname = 'iota'  comment = 'This is a lock test.'  file_path = os.path.join(sbox.wc_dir, fname)  file_url = svntest.main.current_repo_url + '/' + fname  # lock a file as wc_author  svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',                                     '--username', svntest.main.wc_author2,                                     '--password', svntest.main.wc_passwd,                                     '--no-auth-cache',                                     '-m', comment, file_path)  output, err = svntest.actions.run_and_verify_svn(None, None, [], 'info',                                                   file_url)  match_line = 'Lock Owner: ' + svntest.main.wc_author2 + '\n'  if not match_line in output:    print "Error: expected output '%s' not found in output." % match_line    raise svntest.Failure#----------------------------------------------------------------------def lock_several_files(sbox):  "lock/unlock several files in one go"  sbox.build()  wc_dir = sbox.wc_dir  # Deliberately have no direct child of A as a target  iota_path = os.path.join(sbox.wc_dir, 'iota')  lambda_path = os.path.join(sbox.wc_dir, 'A', 'B', 'lambda')  alpha_path = os.path.join(sbox.wc_dir, 'A', 'B', 'E', 'alpha')  svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',                                     '--username', svntest.main.wc_author2,                                     '--password', svntest.main.wc_passwd,                                     '--no-auth-cache',                                     '-m', 'lock several',                                     iota_path, lambda_path, alpha_path)    expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  expected_status.tweak('iota', 'A/B/lambda', 'A/B/E/alpha', writelocked='K')  svntest.actions.run_and_verify_status(wc_dir, expected_status)  svntest.actions.run_and_verify_svn(None, ".*unlocked", [], 'unlock',                                     '--username', svntest.main.wc_author2,                                     '--password', svntest.main.wc_passwd,                                     '--no-auth-cache',                                     iota_path, lambda_path, alpha_path)  expected_status.tweak('iota', 'A/B/lambda', 'A/B/E/alpha', writelocked=None)  svntest.actions.run_and_verify_status(wc_dir, expected_status)#----------------------------------------------------------------------def lock_switched_files(sbox):  "lock/unlock switched files"  sbox.build()  wc_dir = sbox.wc_dir  gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')  lambda_path = os.path.join(wc_dir, 'A', 'B', 'lambda')  iota_URL = svntest.main.current_repo_url + '/iota'  alpha_URL = svntest.main.current_repo_url + '/A/B/E/alpha'  svntest.actions.run_and_verify_svn(None, None, [], 'switch',                                     iota_URL, gamma_path)  svntest.actions.run_and_verify_svn(None, None, [], 'switch',                                     alpha_URL, lambda_path)  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  expected_status.tweak('A/D/gamma', 'A/B/lambda', switched='S')  svntest.actions.run_and_verify_status(wc_dir, expected_status)  svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',                                     '--username', svntest.main.wc_author,                                     '--password', svntest.main.wc_passwd,                                     '--no-auth-cache',                                     '-m', 'lock several',                                     gamma_path, lambda_path)

⌨️ 快捷键说明

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