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

📄 diff_tests.py

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 PY
📖 第 1 页 / 共 5 页
字号:
  good_src = ".../prefix_mydir"  good_dest = ".../prefix_other/mytag"  if ((src != good_src) or (dest != good_dest)):    print("src is '%s' instead of '%s' and dest is '%s' instead of '%s'" %          (src, good_src, dest, good_dest))    raise svntest.Failure#----------------------------------------------------------------------def diff_renamed_file(sbox):  "diff a file that has been renamed"  sbox.build()  was_cwd = os.getcwd()  os.chdir(sbox.wc_dir)  try:    pi_path = os.path.join('A', 'D', 'G', 'pi')    pi2_path = os.path.join('A', 'D', 'pi2')    open(pi_path, 'w').write("new pi")    svntest.actions.run_and_verify_svn(None, None, [],                                       'ci', '-m', 'log msg')    svntest.main.file_append(pi_path, "even more pi")    svntest.actions.run_and_verify_svn(None, None, [],                                       'ci', '-m', 'log msg')    svntest.main.run_svn(None, 'mv', pi_path, pi2_path)    # Repos->WC diff of the file    diff_output, err_output = svntest.main.run_svn(None, 'diff', '-r', '1',                                                   pi2_path)    if check_diff_output(diff_output,                         pi2_path,                         'M') :      raise svntest.Failure    svntest.main.file_append(pi2_path, "new pi")    # Repos->WC of the directory    diff_output, err_output = svntest.main.run_svn(None, 'diff', '-r', '1',                                                   os.path.join('A', 'D'))    if check_diff_output(diff_output,                         pi_path,                         'D') :      raise svntest.Failure    if check_diff_output(diff_output,                         pi2_path,                         'M') :      raise svntest.Failure    # WC->WC of the file    diff_output, err_output = svntest.main.run_svn(None, 'diff',                                                   pi2_path)    if check_diff_output(diff_output,                         pi2_path,                         'M') :      raise svntest.Failure    svntest.actions.run_and_verify_svn(None, None, [],                                       'ci', '-m', 'log msg')    # Repos->WC diff of file after the rename.    diff_output, err_output = svntest.main.run_svn(None, 'diff', '-r', '1',                                                   pi2_path)    if check_diff_output(diff_output,                         pi2_path,                         'M') :      raise svntest.Failure    # Repos->repos diff after the rename.    diff_output, err_output = svntest.main.run_svn(None, 'diff', '-r', '2:3',                                                   pi2_path)    if check_diff_output(diff_output,                         os.path.join('A', 'D', 'pi'),                         'M') :      raise svntest.Failure  finally:    os.chdir(was_cwd)#----------------------------------------------------------------------def diff_within_renamed_dir(sbox):  "diff a file within a renamed directory"  sbox.build()  was_cwd = os.getcwd()  os.chdir(sbox.wc_dir)  try:    svntest.main.run_svn(None, 'mv', os.path.join('A', 'D', 'G'),                                     os.path.join('A', 'D', 'I'))    # svntest.main.run_svn(None, 'ci', '-m', 'log_msg')    open(os.path.join('A', 'D', 'I', 'pi'), 'w').write("new pi")    # Check a repos->wc diff    diff_output, err_output = svntest.main.run_svn(None, 'diff',                                                   os.path.join('A', 'D', 'I', 'pi'))    if check_diff_output(diff_output,                         os.path.join('A', 'D', 'I', 'pi'),                         'M') :      raise svntest.Failure    svntest.actions.run_and_verify_svn(None, None, [],                                       'ci', '-m', 'log msg')    # Check repos->wc after commit    diff_output, err_output = svntest.main.run_svn(None, 'diff', '-r', '1',                                                   os.path.join('A', 'D', 'I', 'pi'))    if check_diff_output(diff_output,                         os.path.join('A', 'D', 'I', 'pi'),                         'M') :      raise svntest.Failure    # Test the diff while within the moved directory    os.chdir(os.path.join('A','D','I'))    diff_output, err_output = svntest.main.run_svn(None, 'diff', '-r', '1')    if check_diff_output(diff_output, 'pi', 'M') :      raise svntest.Failure    # Test a repos->repos diff while within the moved directory    diff_output, err_output = svntest.main.run_svn(None, 'diff', '-r', '1:2')    if check_diff_output(diff_output, 'pi', 'M') :      raise svntest.Failure  finally:    os.chdir(was_cwd)#----------------------------------------------------------------------def diff_prop_on_named_dir(sbox):  "diff a prop change on a dir named explicitly"  # Diff of a property change or addition should contain a "+" line.  # Diff of a property change or deletion should contain a "-" line.  # On a diff between repository revisions (not WC) of a dir named  # explicitly, the "-" line was missing.  (For a file, and for a dir  # recursed into, the result was correct.)  sbox.build()  wc_dir = sbox.wc_dir  current_dir = os.getcwd()  os.chdir(sbox.wc_dir)  try:    svntest.actions.run_and_verify_svn(None, None, [],                                       'propset', 'p', 'v', 'A')    svntest.actions.run_and_verify_svn(None, None, [],                                       'ci', '-m', '')    svntest.actions.run_and_verify_svn(None, None, [],                                       'propdel', 'p', 'A')    svntest.actions.run_and_verify_svn(None, None, [],                                       'ci', '-m', '')    diff_output, err_output = svntest.main.run_svn(None,                                                   'diff', '-r2:3', 'A')    # Check that the result contains a "-" line.    verify_expected_output(diff_output, "   - v")  finally:    os.chdir(current_dir)#----------------------------------------------------------------------def diff_keywords(sbox):  "ensure that diff won't show keywords"  sbox.build()  iota_path = os.path.join(sbox.wc_dir, 'iota')    svntest.actions.run_and_verify_svn(None, None, [],                                     'ps',                                     'svn:keywords',                                     'Id Rev Date',                                     iota_path)  fp = open(iota_path, 'w')  fp.write("$Date$\n")  fp.write("$Id$\n")  fp.write("$Rev$\n")  fp.write("$Date::%s$\n" % (' ' * 80))  fp.write("$Id::%s$\n"   % (' ' * 80))  fp.write("$Rev::%s$\n"  % (' ' * 80))  fp.close()    svntest.actions.run_and_verify_svn(None, None, [],                                     'ci', '-m', 'keywords', sbox.wc_dir)  svntest.main.file_append(iota_path, "bar\n")  svntest.actions.run_and_verify_svn(None, None, [],                                     'ci', '-m', 'added bar', sbox.wc_dir)  svntest.actions.run_and_verify_svn(None, None, [],                                     'up', sbox.wc_dir)  diff_output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                        'diff',                                                        '-r', 'prev:head',                                                        sbox.wc_dir)  verify_expected_output(diff_output, "+bar")  verify_excluded_output(diff_output, "$Date:")  verify_excluded_output(diff_output, "$Rev:")  verify_excluded_output(diff_output, "$Id:")    diff_output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                        'diff',                                                        '-r', 'head:prev',                                                        sbox.wc_dir)  verify_expected_output(diff_output, "-bar")  verify_excluded_output(diff_output, "$Date:")  verify_excluded_output(diff_output, "$Rev:")  verify_excluded_output(diff_output, "$Id:")  # Check fixed length keywords will show up  # when the length of keyword has changed  fp = open(iota_path, 'w')  fp.write("$Date$\n")  fp.write("$Id$\n")  fp.write("$Rev$\n")  fp.write("$Date::%s$\n" % (' ' * 79))  fp.write("$Id::%s$\n"   % (' ' * 79))  fp.write("$Rev::%s$\n"  % (' ' * 79))  fp.close()  svntest.actions.run_and_verify_svn(None, None, [],                                     'ci', '-m', 'keywords 2', sbox.wc_dir)  svntest.actions.run_and_verify_svn(None, None, [],                                     'up', sbox.wc_dir)  diff_output, err = svntest.actions.run_and_verify_svn(None, None, [],                                                        'diff',                                                        '-r', 'prev:head',                                                        sbox.wc_dir)  # these should show up  verify_expected_output(diff_output, "+$Id:: ")  verify_expected_output(diff_output, "-$Id:: ")  verify_expected_output(diff_output, "-$Rev:: ")  verify_expected_output(diff_output, "+$Rev:: ")  verify_expected_output(diff_output, "-$Date:: ")  verify_expected_output(diff_output, "+$Date:: ")  # ... and these won't  verify_excluded_output(diff_output, "$Date: ")  verify_excluded_output(diff_output, "$Rev: ")  verify_excluded_output(diff_output, "$Id: ")def diff_force(sbox):  "show diffs for binary files with --force"  sbox.build()  wc_dir = sbox.wc_dir    iota_path = os.path.join(wc_dir, 'iota')    # Append a line to iota and make it binary.  svntest.main.file_append(iota_path, "new line")  svntest.main.run_svn(None, 'propset', 'svn:mime-type',                       'application/octet-stream', iota_path)    # Created expected output tree for 'svn ci'  expected_output = svntest.wc.State(wc_dir, {    'iota' : Item(verb='Sending'),    })  # Create expected status tree  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)  expected_status.tweak(wc_rev=1)  expected_status.add({    'iota' : Item(status='  ', wc_rev=2),    })  # Commit iota, creating revision 2.  svntest.actions.run_and_verify_commit(wc_dir, expected_output,                                        expected_status, None,                                        None, None, None, None, wc_dir)  # Add another line, while keeping he file as binary.  svntest.main.file_append(iota_path, "another line")  # Commit creating rev 3.  expected_output = svntest.wc.State(wc_dir, {    'iota' : Item(verb='Sending'),    })  expected_status = svntest.actions.get_virginal_state(wc_dir, 3)  expected_status.tweak(wc_rev=1)  expected_status.add({    'iota' : Item(status='  ', wc_rev=3),    })  svntest.actions.run_and_verify_commit(wc_dir, expected_output,                                        expected_status, None,                                        None, None, None, None, wc_dir)  # Check that we get diff when the first, the second and both files are  # marked as binary.  re_nodisplay = re.compile('^Cannot display:')  stdout, stderr = svntest.main.run_svn(None, 'diff', '-r1:2', iota_path,                                        '--force')  for line in stdout:    if (re_nodisplay.match(line)):      raise svntest.Failure  stdout, stderr = svntest.main.run_svn(None, 'diff', '-r2:1', iota_path,                                        '--force')  for line in stdout:    if (re_nodisplay.match(line)):      raise svntest.Failure  stdout, stderr = svntest.main.run_svn(None, 'diff', '-r2:3', iota_path,                                        '--force')  for line in stdout:    if (re_nodisplay.match(line)):      raise svntest.Failure#----------------------------------------------------------------------# Regression test for issue #2333: Renaming a directory should produce# deletion and addition diffs for each included file.def diff_renamed_dir(sbox):  "diff a renamed directory"  sbox.build()  was_cwd = os.getcwd()  os.chdir(sbox.wc_dir)  try:    svntest.main.run_svn(None, 'mv', os.path.join('A', 'D', 'G'),                                     os.path.join('A', 'D', 'I'))    # Check a repos->wc diff    diff_output, err_output = svntest.main.run_svn(None, 'diff',                                                   os.path.join('A', 'D'))    if check_diff_output(diff_output,                         os.path.join('A', 'D', 'G', 'pi'),                         'D') :      raise svntest.Failure    if check_diff_output(diff_output,                         os.path.join('A', 'D', 'I', 'pi'),                         'A') :      raise svntest.Failure    svntest.actions.run_and_verify_svn(None, None, [],                                       'ci', '-m', 'log msg')    # Check repos->wc after commit    diff_output, err_output = svntest.main.run_svn(None, 'diff', '-r', '1',                                                   os.p

⌨️ 快捷键说明

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