📄 svnsync_tests.py
字号:
#!/usr/bin/env python## svnsync_tests.py: Tests SVNSync's repository mirroring capabilities.## Subversion is a tool for revision control. # See http://subversion.tigris.org for more information.# # ====================================================================# Copyright (c) 2005, 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 string, sys, re, os.path# Our testing moduleimport svntestfrom authz_tests import write_restrictive_svnserve_conf, \ skip_test_when_no_authz_available# (abbreviation)Skip = svntest.testcase.SkipXFail = svntest.testcase.XFailItem = svntest.wc.StateItem####################################################################### Helper routinesdef build_repos(sbox): """Avoid the use sbox.build() because we're working with a repos other than the Greek tree.""" # Cleanup after the last run by removing any left-over repository. svntest.main.safe_rmtree(sbox.repo_dir) # Create an empty repository. svntest.main.create_repos(sbox.repo_dir) svntest.main.set_repos_paths(sbox.repo_dir)def run_sync(url, expected_error=None): "Synchronize the mirror repository with the master" output, errput = svntest.main.run_svnsync( "synchronize", url, "--username", svntest.main.wc_author, "--password", svntest.main.wc_passwd) if errput: if expected_error is None: raise svntest.actions.SVNUnexpectedStderr(errput) else: svntest.actions.match_or_fail(None, "STDERR", expected_error, errput) elif expected_error is not None: raise svntest.actions.SVNExpectedStderr() if not output and not expected_error: # should be: ['Committed revision 1.\n', 'Committed revision 2.\n'] raise svntest.actions.SVNUnexpectedStdout("Missing stdout")def run_init(dst_url, src_url): "Initialize the mirror repository from the master" output, errput = svntest.main.run_svnsync( "initialize", dst_url, src_url, "--username", svntest.main.wc_author, "--password", svntest.main.wc_passwd) if output != ['Copied properties for revision 0.\n']: raise svntest.actions.SVNUnexpectedStdout(output) if errput: raise svntest.actions.SVNUnexpectedStderr(errput)def run_test(sbox, dump_file_name): "Load a dump file, sync repositories, and compare contents." # Create the empty master repository. build_repos(sbox) # This directory contains all the dump files svnsync_tests_dir = os.path.join(os.path.dirname(sys.argv[0]), 'svnsync_tests_data') # Load the specified dump file into the master repository. master_dumpfile_contents = file(os.path.join(svnsync_tests_dir, dump_file_name)).readlines() svntest.actions.run_and_verify_load(sbox.repo_dir, master_dumpfile_contents) # Create the empty destination repository. dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) # Setup the mirror repository. Feed it the UUID of the source repository. output, errput = svntest.main.run_svnlook("uuid", sbox.repo_dir) mirror_cfg = ["SVN-fs-dump-format-version: 2\n", "UUID: " + output[0], ] svntest.actions.run_and_verify_load(dest_sbox.repo_dir, mirror_cfg) # Create the revprop-change hook for this test svntest.actions.enable_revprop_changes(svntest.main.current_repo_dir) run_init(dest_sbox.repo_url, sbox.repo_url) run_sync(dest_sbox.repo_url) # Remove some SVNSync-specific housekeeping properties from the # mirror repository in preparation for the comparison dump. for prop_name in ("svn:sync-from-url", "svn:sync-from-uuid", "svn:sync-last-merged-rev"): svntest.actions.run_and_verify_svn( None, None, [], "propdel", "--username", svntest.main.wc_author, "--password", svntest.main.wc_passwd, "--revprop", "-r", "0", prop_name, dest_sbox.repo_url) # Create a dump file from the mirror repository. dest_dump = svntest.actions.run_and_verify_dump(dest_sbox.repo_dir) # Compare the original dump file (used to create the master # repository) with the dump produced by the mirror repository. svntest.actions.compare_and_display_lines( "Dump files", "DUMP", master_dumpfile_contents, dest_dump)####################################################################### Tests#----------------------------------------------------------------------def copy_and_modify(sbox): "copy and modify" run_test(sbox, "copy-and-modify.dump")#----------------------------------------------------------------------def copy_from_previous_version_and_modify(sbox): "copy from previous version and modify" run_test(sbox, "copy-from-previous-version-and-modify.dump")#----------------------------------------------------------------------def copy_from_previous_version(sbox): "copy from previous version" run_test(sbox, "copy-from-previous-version.dump")#----------------------------------------------------------------------def modified_in_place(sbox): "modified in place" run_test(sbox, "modified-in-place.dump")#----------------------------------------------------------------------def tag_empty_trunk(sbox): "tag empty trunk" run_test(sbox, "tag-empty-trunk.dump")#----------------------------------------------------------------------def tag_trunk_with_dir(sbox): "tag trunk containing a sub-directory" run_test(sbox, "tag-trunk-with-dir.dump")#----------------------------------------------------------------------def tag_trunk_with_file(sbox): "tag trunk containing a file" run_test(sbox, "tag-trunk-with-file.dump")#----------------------------------------------------------------------def tag_trunk_with_file2(sbox): "tag trunk containing a file (#2)" run_test(sbox, "tag-trunk-with-file2.dump")#----------------------------------------------------------------------def tag_with_modified_file(sbox): "tag with a modified file" run_test(sbox, "tag-with-modified-file.dump")#----------------------------------------------------------------------def dir_prop_change(sbox): "directory property changes" run_test(sbox, "dir_prop_change.dump")#----------------------------------------------------------------------def file_dir_file(sbox): "files and dirs mixed together" run_test(sbox, "file-dir-file.dump")#----------------------------------------------------------------------def copy_parent_modify_prop(sbox): "copy parent and modify prop" run_test(sbox, "copy-parent-modify-prop.dump")#----------------------------------------------------------------------def detect_meddling(sbox): "detect non-svnsync commits in destination" sbox.build("svnsync-meddling") dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) # Make our own destination checkout (have to do it ourself because # it is not greek). svntest.main.safe_rmtree(dest_sbox.wc_dir) svntest.actions.run_and_verify_svn(None, None, [], 'co', dest_sbox.repo_url, dest_sbox.wc_dir) svntest.actions.enable_revprop_changes(svntest.main.current_repo_dir) run_init(dest_sbox.repo_url, sbox.repo_url) run_sync(dest_sbox.repo_url) svntest.actions.run_and_verify_svn(None, None, [], 'up', '--username', svntest.main.wc_author, '--password',
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -