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

📄 diff_tests.py

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 PY
📖 第 1 页 / 共 5 页
字号:
                     props={'svn:mime-type' : 'application/octet-stream'}),    })  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)  expected_status.add({    'A/theta' : Item(status='  ', wc_rev=2),    })  svntest.actions.run_and_verify_update(wc_dir,                                        expected_output,                                        expected_disk,                                        expected_status,                                        None, None, None, None, None,                                        1)  # verify props, too.  # Make a local mod to the binary file.  svntest.main.file_append(theta_path, "some extra junk")  # First diff use-case: plain old 'svn diff wc' will display any  # local changes in the working copy.  (diffing working  # vs. text-base)  re_nodisplay = re.compile('^Cannot display:')  stdout, stderr = svntest.main.run_svn(None, 'diff', wc_dir)  for line in stdout:    if (re_nodisplay.match(line)):      break  else:    raise svntest.Failure  # Second diff use-case: 'svn diff -r1 wc' compares the wc against a  # the first revision in the repository.  stdout, stderr = svntest.main.run_svn(None, 'diff', '-r', '1', wc_dir)  for line in stdout:    if (re_nodisplay.match(line)):      break  else:    raise svntest.Failure  # Now commit the local mod, creating rev 3.  expected_output = svntest.wc.State(wc_dir, {    'A/theta' : Item(verb='Sending'),    })  expected_status = svntest.actions.get_virginal_state(wc_dir, 3)  expected_status.tweak(wc_rev=2)  expected_status.add({    'A/theta' : Item(status='  ', wc_rev=3),    })  svntest.actions.run_and_verify_commit(wc_dir, expected_output,                                        expected_status, None,                                        None, None, None, None, wc_dir)  # Third diff use-case: 'svn diff -r2:3 wc' will compare two  # repository trees.  stdout, stderr = svntest.main.run_svn(None, 'diff', '-r', '2:3', wc_dir)  for line in stdout:    if (re_nodisplay.match(line)):      break  else:    raise svntest.Failuredef diff_nonextant_urls(sbox):  "svn diff errors against a non-existent URL"  sbox.build(create_wc = False)  non_extant_url = sbox.repo_url + '/A/does_not_exist'  extant_url = sbox.repo_url + '/A/mu'  diff_output, err_output = svntest.main.run_svn(1, 'diff',                                                 '--old', non_extant_url,                                                 '--new', extant_url)  for line in err_output:    if re.search('was not found in the repository at revision', line):      break  else:    raise svntest.Failure  diff_output, err_output = svntest.main.run_svn(1, 'diff',                                                 '--old', extant_url,                                                 '--new', non_extant_url)  for line in err_output:    if re.search('was not found in the repository at revision', line):      break  else:    raise svntest.Failuredef diff_head_of_moved_file(sbox):  "diff against the head of a moved file"  sbox.build()  mu_path = os.path.join(sbox.wc_dir, 'A', 'mu')  new_mu_path = mu_path + '.new'  svntest.main.run_svn(None, 'mv', mu_path, new_mu_path)  # Modify the file to ensure that the diff is non-empty.  svntest.main.file_append(new_mu_path, "\nActually, it's a new mu.")  svntest.actions.run_and_verify_svn(None, SVNAnyOutput, [],                                     'diff', '-r', 'HEAD', new_mu_path)#----------------------------------------------------------------------# Regression test for issue #977: make 'svn diff -r BASE:N' compare a# repository tree against the wc's text-bases, rather than the wc's# working files.  This is a long test, which checks many variations.def diff_base_to_repos(sbox):  "diff text-bases against repository"  sbox.build()  wc_dir = sbox.wc_dir  iota_path = os.path.join(sbox.wc_dir, 'iota')  newfile_path = os.path.join(sbox.wc_dir, 'A', 'D', 'newfile')  mu_path = os.path.join(sbox.wc_dir, 'A', 'mu')  # Make changes to iota, commit r2, update to HEAD (r2).  svntest.main.file_append(iota_path, "some rev2 iota text.\n")  expected_output = svntest.wc.State(wc_dir, {    'iota' : Item(verb='Sending'),    })    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_commit(wc_dir, expected_output,                                        expected_status, None,                                        None, None, None, None, wc_dir)  expected_output = svntest.wc.State(wc_dir, {})  expected_disk = svntest.main.greek_state.copy()  expected_disk.tweak ('iota',                       contents=\                       "This is the file 'iota'.\nsome rev2 iota text.\n")  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)  svntest.actions.run_and_verify_update(wc_dir, expected_output,                                        expected_disk, expected_status)    # Now make another local mod to iota.  svntest.main.file_append(iota_path, "an iota local mod.\n")  # If we run 'svn diff -r 1', we should see diffs that include *both*  # the rev2 changes and local mods.  That's because the working files  # are being compared to the repository.  diff_output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                        'diff',                                                        '-r', '1', wc_dir)  # Makes diff output look the same on all platforms.  def strip_eols(lines):    return [x.replace("\r", "").replace("\n", "") for x in lines]  expected_output_lines = [    "Index: svn-test-work/working_copies/diff_tests-14/iota\n",    "===================================================================\n",    "--- svn-test-work/working_copies/diff_tests-14/iota\t(revision 1)\n",    "+++ svn-test-work/working_copies/diff_tests-14/iota\t(working copy)\n",    "@@ -1 +1,3 @@\n",    " This is the file 'iota'.\n",    "+some rev2 iota text.\n",    "+an iota local mod.\n"]  if strip_eols(diff_output) != strip_eols(expected_output_lines):    raise svntest.Failure  # If we run 'svn diff -r BASE:1', we should see diffs that only show  # the rev2 changes and NOT the local mods.  That's because the  # text-bases are being compared to the repository.  diff_output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                        'diff', '-r', 'BASE:1',                                                        wc_dir)  expected_output_lines = [    "Index: svn-test-work/working_copies/diff_tests-14/iota\n",    "===================================================================\n",    "--- svn-test-work/working_copies/diff_tests-14/iota\t(working copy)\n",    "+++ svn-test-work/working_copies/diff_tests-14/iota\t(revision 1)\n",    "@@ -1,2 +1 @@\n",    " This is the file 'iota'.\n",    "-some rev2 iota text.\n"]  if strip_eols(diff_output) != strip_eols(expected_output_lines):    raise svntest.Failure  # But that's not all folks... no, no, we're just getting started  # here!  There are so many other tests to do.  # For example, we just ran 'svn diff -rBASE:1'.  The output should  # look exactly the same as 'svn diff -r2:1'.  (If you remove the  # header commentary)    diff_output2, err = svntest.actions.run_and_verify_svn(None, None, [],                                                         'diff', '-r', '2:1',                                                         wc_dir)  diff_output[2:4] = []  diff_output2[2:4] = []  if (diff_output2 != diff_output):    raise svntest.Failure  # and similarly, does 'svn diff -r1:2' == 'svn diff -r1:BASE' ?  diff_output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                        'diff',                                                        '-r', '1:2', wc_dir)    diff_output2, err = svntest.actions.run_and_verify_svn(None, None, [],                                                         'diff',                                                         '-r', '1:BASE',                                                         wc_dir)  diff_output[2:4] = []  diff_output2[2:4] = []  if (diff_output2 != diff_output):    raise svntest.Failure  # Now we schedule an addition and a deletion.  svntest.main.file_append(newfile_path, "Contents of newfile\n")  svntest.main.run_svn(None, 'add', newfile_path)  svntest.main.run_svn(None, 'rm', mu_path)  expected_output = svntest.actions.get_virginal_state(wc_dir, 2)  expected_output.add({    'A/D/newfile' : Item(status='A ', wc_rev=0),    })  expected_output.tweak('A/mu', status='D ')  expected_output.tweak('iota', status='M ')  svntest.actions.run_and_verify_status (wc_dir, expected_output)  # once again, verify that -r1:2 and -r1:BASE look the same, as do  # -r2:1 and -rBASE:1.  None of these diffs should mention the  # scheduled addition or deletion.  diff_output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                        'diff', '-r',                                                        '1:2', wc_dir)  diff_output2, err = svntest.actions.run_and_verify_svn(None, None, [],                                                         'diff', '-r',                                                         '1:BASE', wc_dir)  diff_output3, err = svntest.actions.run_and_verify_svn(None, None, [],                                                         'diff', '-r',                                                         '2:1', wc_dir)  diff_output4, err = svntest.actions.run_and_verify_svn(None, None, [],                                                         'diff', '-r',                                                         'BASE:1', wc_dir)  diff_output[2:4] = []  diff_output2[2:4] = []  diff_output3[2:4] = []  diff_output4[2:4] = []  if (diff_output != diff_output2):    raise svntest.Failure  if (diff_output3 != diff_output4):    raise svntest.Failure  # Great!  So far, so good.  Now we commit our three changes (a local  # mod, an addition, a deletion) and update to HEAD (r3).  expected_output = svntest.wc.State(wc_dir, {    'iota' : Item(verb='Sending'),    'A/mu' : Item(verb='Deleting'),    'A/D/newfile' : Item(verb='Adding')    })  expected_status = svntest.actions.get_virginal_state(wc_dir, 3)  expected_status.tweak(wc_rev=2)  expected_status.tweak('iota', wc_rev=3)  expected_status.remove('A/mu')  expected_status.add({    'A/D/newfile' : Item(status='  ', wc_rev=3),    })  svntest.actions.run_and_verify_commit(wc_dir, expected_output,                                        expected_status, None,                                        None, None, None, None, wc_dir)  expected_output = svntest.wc.State(wc_dir, {})  expected_disk = svntest.main.greek_state.copy()  expected_disk.tweak('iota',                      contents="This is the file 'iota'.\n" + \                      "some rev2 iota text.\nan iota local mod.\n")  expected_disk.add({'A/D/newfile' : Item("Contents of newfile\n")})  expected_disk.remove ('A/mu')  expected_status = svntest.actions.get_virginal_state(wc_dir, 3)  expected_status.remove('A/mu')  expected_status.add({    'A/D/newfile' : Item(status='  ', wc_rev=3),    })  svntest.actions.run_and_verify_update(wc_dir, expected_output,                                        expected_disk, expected_status)    # Now 'svn diff -r3:2' should == 'svn diff -rBASE:2', showing the  # removal of changes to iota, the adding of mu, and deletion of newfile.  diff_output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                        'diff', '-r',                                                        '3:2', wc_dir)  diff_output2, err = svntest.actions.run_and_verify_svn(None, None, [],                                                         'diff', '-r',                                                         'BASE:2', wc_dir)  # to do the comparison, remove all output lines starting with +++ or ---  re_infoline = re.compile('^(\+\+\+|---).*$')  list1 = []  list2 = []  for line in diff_output:    if not re_infoline.match(line):      list1.append(line)  for line in diff_output2:    if not re_infoline.match(line):      list2.append(line)  if list1 != list2:    raise svntest.Failure  #----------------------------------------------------------------------# This is a simple regression test for issue #891, whereby ra_dav's# REPORT request would fail, because the object no longer exists in HEAD.def diff_deleted_in_head(sbox):  "repos-repos diff on item deleted from HEAD"  sbox.build()  wc_dir = sbox.wc_dir  A_path = os.path.join(sbox.wc_dir, 'A')  mu_path = os.path.join(sbox.wc_dir, 'A', 'mu')  # Make a change to mu, commit r2, update.  svntest.main.file_append(mu_path, "some rev2 mu text.\n")  expected_output = svntest.wc.State(wc_dir, {    'A/mu' : Item(verb='Sending'),    })  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)  expected_status.tweak(wc_rev=1)  expected_status.tweak('A/mu', wc_rev=2)  svntest.actions.run_and_verify_commit(wc_dir, expected_output,                                        expected_status, None,                                        None, None, None, None, wc_dir)  expected_output = svntest.wc.State(wc_dir, {})  expected_disk = svntest.main.greek_state.copy()  expected_disk.tweak ('A/mu',                       contents="This is the file 'mu'.\nsome rev2 mu text.\n")  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)  svntest.actions.run_and_verify_update(wc_dir, expected_output,                                        expected_disk, expected_status)  # Now delete the whole directory 'A', and commit as r3.

⌨️ 快捷键说明

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