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

📄 copy_tests.py

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 PY
📖 第 1 页 / 共 5 页
字号:
#!/usr/bin/env python##  copy_tests.py:  testing the many uses of 'svn cp' and 'svn mv'##  Subversion is a tool for revision control. #  See http://subversion.tigris.org for more information.#    # ====================================================================# Copyright (c) 2000-2006 CollabNet.  All rights reserved.## This software is licensed as described in the file COPYING, which# you should have received as part of this distribution.  The terms# are also available at http://subversion.tigris.org/license-1.html.# If newer versions of this license are posted there, you may use a# newer version instead, at your option.######################################################################## General modulesimport stat, string, sys, os, shutil, re# Our testing moduleimport svntestfrom svntest import SVNAnyOutput# (abbreviation)Skip = svntest.testcase.SkipXFail = svntest.testcase.XFailItem = svntest.wc.StateItem####################################################################### Utilities#def get_repos_rev(sbox):  wc_dir = sbox.wc_dir;  out, err = svntest.actions.run_and_verify_svn("Getting Repository Revision",                                                None, [], "up", wc_dir)  mo=re.match("(?:At|Updated to) revision (\\d+)\\.", out[-1])  if mo:    return int(mo.group(1))  else:    raise svntest.Failure##----------------------------------------------------------------------# Helper for wc_copy_replacement and repos_to_wc_copy_replacementdef copy_replace(sbox, wc_copy):  """Tests for 'R'eplace functionanity for files.Depending on the value of wc_copy either a working copy (when true)or a url (when false) copy source is used."""  sbox.build()  wc_dir = sbox.wc_dir  # File scheduled for deletion  rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')  svntest.actions.run_and_verify_svn(None, None, [], 'rm', rho_path)  # Status before attempting copies  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  expected_status.tweak('A/D/G/rho', status='D ')  svntest.actions.run_and_verify_status(wc_dir, expected_status)  # The copy shouldn't fail  if wc_copy:    pi_src = os.path.join(wc_dir, 'A', 'D', 'G', 'pi')  else:    pi_src = svntest.main.current_repo_url + '/A/D/G/pi'  svntest.actions.run_and_verify_svn("", None, [],                                     'cp', pi_src, rho_path)  # Now commit  expected_status.tweak('A/D/G/rho', status='R ', copied='+', wc_rev='-')  svntest.actions.run_and_verify_status(wc_dir, expected_status)  expected_status.tweak(repos_rev='2')  expected_status.tweak('A/D/G/rho', status='  ', copied=None,                        repos_rev='2', wc_rev='2')  expected_output = svntest.wc.State(wc_dir, {    'A/D/G/rho': Item(verb='Replacing'),    })  svntest.actions.run_and_verify_commit(wc_dir,                                        expected_output,                                        expected_status,                                        None, None, None, None, None,                                        wc_dir)# Helper for wc_copy_replace_with_props and# repos_to_wc_copy_replace_with_propsdef copy_replace_with_props(sbox, wc_copy):  """Tests for 'R'eplace functionanity for files with props.Depending on the value of wc_copy either a working copy (when true)or a url (when false) copy source is used."""  sbox.build()  wc_dir = sbox.wc_dir  # Use a temp file to set properties with wildcards in their values  # otherwise Win32/VS2005 will expand them  prop_path = os.path.join(wc_dir, 'proptmp')  svntest.main.file_append (prop_path, '*')  # Set props on file which is copy-source later on  pi_path = os.path.join(wc_dir, 'A', 'D', 'G', 'pi')  rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')  svntest.actions.run_and_verify_svn("", None, [],                                     'ps', 'phony-prop', '-F',                                     prop_path, pi_path)  os.remove(prop_path)  svntest.actions.run_and_verify_svn("", None, [],                                     'ps', 'svn:eol-style', 'LF', rho_path)  # Verify props having been set  expected_disk = svntest.main.greek_state.copy()  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  expected_disk.tweak('A/D/G/pi',                      props={ 'phony-prop': '*' })  expected_disk.tweak('A/D/G/rho',                      props={ 'svn:eol-style': 'LF' })  actual_disk = svntest.tree.build_tree_from_wc(wc_dir, 1)  svntest.tree.compare_trees(actual_disk, expected_disk.old_tree())  # Commit props  expected_output = svntest.wc.State(wc_dir, {    'A/D/G/pi':  Item(verb='Sending'),    'A/D/G/rho': Item(verb='Sending'),    })  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)  expected_status.tweak(repos_rev='2')  expected_status.tweak('A/D/G/pi',  wc_rev='2')  expected_status.tweak('A/D/G/rho', wc_rev='2')  svntest.actions.run_and_verify_commit(wc_dir,                                        expected_output,                                        expected_status,                                        None, None, None, None, None,                                        wc_dir)  # Bring wc into sync  svntest.actions.run_and_verify_svn("", None, [], 'up', wc_dir)  # File scheduled for deletion  svntest.actions.run_and_verify_svn(None, None, [], 'rm', rho_path)  # Status before attempting copies  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)  expected_status.tweak('A/D/G/rho', status='D ')  svntest.actions.run_and_verify_status(wc_dir, expected_status)  # The copy shouldn't fail  if wc_copy:    pi_src = os.path.join(wc_dir, 'A', 'D', 'G', 'pi')  else:    pi_src = svntest.main.current_repo_url + '/A/D/G/pi'  svntest.actions.run_and_verify_svn("", None, [],                                     'cp', pi_src, rho_path)  # Verify both content and props have been copied  expected_disk.tweak('A/D/G/rho',                      contents="This is the file 'pi'.\n",                      props={ 'phony-prop': '*' })  actual_disk = svntest.tree.build_tree_from_wc(wc_dir, 1)  svntest.tree.compare_trees(actual_disk, expected_disk.old_tree())  # Now commit and verify  expected_status.tweak('A/D/G/rho', status='R ', copied='+', wc_rev='-')  svntest.actions.run_and_verify_status(wc_dir, expected_status)  expected_status.tweak(repos_rev='3')  expected_status.tweak('A/D/G/rho', status='  ', copied=None,                        repos_rev='3', wc_rev='3')  expected_output = svntest.wc.State(wc_dir, {    'A/D/G/rho': Item(verb='Replacing'),    })  svntest.actions.run_and_verify_commit(wc_dir,                                        expected_output,                                        expected_status,                                        None, None, None, None, None,                                        wc_dir)####################################################################### Tests##   Each test must return on success or raise on failure.# (Taken from notes/copy-planz.txt:)##  We have four use cases for 'svn cp' now.##     A. svn cp wc_path1 wc_path2##        This duplicates a path in the working copy, and schedules it#        for addition with history.##     B. svn cp URL [-r rev]  wc_path##        This "checks out" URL (in REV) into the working copy at#        wc_path, integrates it, and schedules it for addition with#        history.##     C. svn cp wc_path URL##        This immediately commits wc_path to URL on the server;  the#        commit will be an addition with history.  The commit will not#        change the working copy at all.##     D. svn cp URL1 [-r rev] URL2##        This causes a server-side copy to happen immediately;  no#        working copy is required.# TESTS THAT NEED TO BE WRITTEN##  Use Cases A & C##   -- single files, with/without local mods, as both 'cp' and 'mv'.#        (need to verify commit worked by updating a 2nd working copy#        to see the local mods)##   -- dir copy, has mixed revisions##   -- dir copy, has local mods (an edit, an add, a delete, and a replace)##   -- dir copy, has mixed revisions AND local mods##   -- dir copy, has mixed revisions AND another previously-made copy!#      (perhaps done as two nested 'mv' commands!)##  Use Case D##   By the time the copy setup algorithm is complete, the copy#   operation will have four parts: SRC-DIR, SRC-BASENAME, DST-DIR,#   DST-BASENAME.  In all cases, SRC-DIR/SRC-BASENAME and DST_DIR must#   already exist before the operation, but DST_DIR/DST_BASENAME must#   NOT exist.##   Besides testing things that don't meet the above criteria, we want to#   also test valid cases:##   - where SRC-DIR/SRC-BASENAME is a file or a dir.#   - where SRC-DIR (or SRC-DIR/SRC-BASENAME) is a parent/grandparent#     directory of DST-DIR#   - where SRC-DIR (or SRC-DIR/SRC-BASENAME) is a child/grandchild#     directory of DST-DIR#   - where SRC-DIR (or SRC-DIR/SRC-BASENAME) is not in the lineage#     of DST-DIR at all#----------------------------------------------------------------------def basic_copy_and_move_files(sbox):  "basic copy and move commands -- on files only"  sbox.build()  wc_dir = sbox.wc_dir  mu_path = os.path.join(wc_dir, 'A', 'mu')  iota_path = os.path.join(wc_dir, 'iota')  rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')  D_path = os.path.join(wc_dir, 'A', 'D')  C_path = os.path.join(wc_dir, 'A', 'C')  alpha_path = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha')  H_path = os.path.join(wc_dir, 'A', 'D', 'H')  F_path = os.path.join(wc_dir, 'A', 'B', 'F')  new_mu_path = os.path.join(H_path, 'mu')  new_iota_path = os.path.join(F_path, 'iota')  rho_copy_path = os.path.join(D_path, 'rho')  alpha2_path = os.path.join(C_path, 'alpha2')  # Make local mods to mu and rho  svntest.main.file_append (mu_path, 'appended mu text')  svntest.main.file_append (rho_path, 'new appended text for rho')  # Copy rho to D -- local mods  svntest.actions.run_and_verify_svn(None, None, [], 'cp', rho_path, D_path)  # Copy alpha to C -- no local mods, and rename it to 'alpha2' also  svntest.actions.run_and_verify_svn(None, None, [], 'cp',                                     alpha_path, alpha2_path)  # Move mu to H -- local mods  svntest.actions.run_and_verify_svn(None, None, [], 'mv', '--force',                                     mu_path, H_path)  # Move iota to F -- no local mods  svntest.actions.run_and_verify_svn(None, None, [], 'mv', iota_path, F_path)  # Created expected output tree for 'svn ci':  # We should see four adds, two deletes, and one change in total.  expected_output = svntest.wc.State(wc_dir, {    'A/D/G/rho' : Item(verb='Sending'),    'A/D/rho' : Item(verb='Adding'),    'A/C/alpha2' : Item(verb='Adding'),    'A/D/H/mu' : Item(verb='Adding'),    'A/B/F/iota' : Item(verb='Adding'),    'A/mu' : Item(verb='Deleting'),    'iota' : Item(verb='Deleting'),    })  # Create expected status tree; all local revisions should be at 1,  # but several files should be at revision 2.  Also, two files should  # be missing.    expected_status = svntest.actions.get_virginal_state(wc_dir, 2)  expected_status.tweak(wc_rev=1)  expected_status.tweak('A/D/G/rho', 'A/mu', wc_rev=2)  expected_status.add({    'A/D/rho' : Item(status='  ', wc_rev=2),    'A/C/alpha2' : Item(status='  ', wc_rev=2),    'A/D/H/mu' : Item(status='  ', wc_rev=2),    'A/B/F/iota' : Item(status='  ', wc_rev=2),    })  expected_status.remove('A/mu', 'iota')  svntest.actions.run_and_verify_commit (wc_dir,                                         expected_output,                                         expected_status,                                         None,                                         None, None,                                         None, None,                                         wc_dir)  # Issue 1091, alpha2 would now have the wrong checksum and so a  # subsequent commit would fail  svntest.main.file_append (alpha2_path, 'appended alpha2 text')  expected_output = svntest.wc.State(wc_dir, {    'A/C/alpha2' : Item(verb='Sending'),    })  expected_status.tweak('A/C/alpha2', wc_rev=3)  svntest.actions.run_and_verify_commit (wc_dir,

⌨️ 快捷键说明

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