📄 commit_tests.py
字号:
# At this point, we're ready to modify omega and iota, and commit # from the top. We should *not* get a conflict! svntest.main.file_append(iota_path, "finalmoo") svntest.main.file_append(omega_path, "finalmoo") expected_output = svntest.wc.State(wc_dir, { 'iota' : Item(verb='Sending'), 'A/D/H/omega' : Item(verb='Sending'), }) expected_status = svntest.actions.get_virginal_state(wc_dir, 6) expected_status.tweak(wc_rev=1) expected_status.tweak('iota', 'A/D/H/omega', wc_rev=6) expected_status.tweak('A/D/H', 'A/D/H/psi', wc_rev=2) expected_status.tweak('A/D/H/chi', wc_rev=4) svntest.actions.run_and_verify_commit (wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir)#----------------------------------------------------------------------def commit_uri_unsafe(sbox): "commit files and dirs with URI-unsafe characters" sbox.build() wc_dir = sbox.wc_dir # Note: on Windows, files can't have angle brackets in them, so we # don't tests that case. if svntest.main.windows or sys.platform == 'cygwin': angle_name = '_angle_' nasty_name = '#![]{}()__%' else: angle_name = '<angle>' nasty_name = '#![]{}()<>%' # Make some convenient paths. hash_dir = os.path.join(wc_dir, '#hash#') nasty_dir = os.path.join(wc_dir, nasty_name) space_path = os.path.join(wc_dir, 'A', 'D', 'space path') bang_path = os.path.join(wc_dir, 'A', 'D', 'H', 'bang!') bracket_path = os.path.join(wc_dir, 'A', 'D', 'H', 'bra[ket') brace_path = os.path.join(wc_dir, 'A', 'D', 'H', 'bra{e') angle_path = os.path.join(wc_dir, 'A', 'D', 'H', angle_name) paren_path = os.path.join(wc_dir, 'A', 'D', 'pare)(theses') percent_path = os.path.join(wc_dir, '#hash#', 'percen%') nasty_path = os.path.join(wc_dir, 'A', nasty_name) os.mkdir(hash_dir) os.mkdir(nasty_dir) svntest.main.file_append(space_path, "This path has a space in it.") svntest.main.file_append(bang_path, "This path has a bang in it.") svntest.main.file_append(bracket_path, "This path has a bracket in it.") svntest.main.file_append(brace_path, "This path has a brace in it.") svntest.main.file_append(angle_path, "This path has angle brackets in it.") svntest.main.file_append(paren_path, "This path has parentheses in it.") svntest.main.file_append(percent_path, "This path has a percent in it.") svntest.main.file_append(nasty_path, "This path has all sorts of ick in it.") add_list = [hash_dir, nasty_dir, # not xml-safe space_path, bang_path, bracket_path, brace_path, angle_path, # not xml-safe paren_path, percent_path, nasty_path, # not xml-safe ] for item in add_list: svntest.main.run_svn(None, 'add', '--non-recursive', item) expected_output = svntest.wc.State(wc_dir, { '#hash#' : Item(verb='Adding'), nasty_name : Item(verb='Adding'), 'A/D/space path' : Item(verb='Adding'), 'A/D/H/bang!' : Item(verb='Adding'), 'A/D/H/bra[ket' : Item(verb='Adding'), 'A/D/H/bra{e' : Item(verb='Adding'), 'A/D/H/' + angle_name : Item(verb='Adding'), 'A/D/pare)(theses' : Item(verb='Adding'), '#hash#/percen%' : Item(verb='Adding'), 'A/' + nasty_name : Item(verb='Adding'), }) expected_status = svntest.actions.get_virginal_state(wc_dir, 2) # Items in the status list are all at rev 1 expected_status.tweak(wc_rev=1) # Items in our add list will be at rev 2 for item in expected_output.desc.keys(): expected_status.add({ item : Item(wc_rev=2, status=' ') }) svntest.actions.run_and_verify_commit (wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir)#----------------------------------------------------------------------def commit_deleted_edited(sbox): "commit deleted yet edited files" sbox.build() wc_dir = sbox.wc_dir # Make some convenient paths. iota_path = os.path.join(wc_dir, 'iota') mu_path = os.path.join(wc_dir, 'A', 'mu') # Edit the files. svntest.main.file_append(iota_path, "This file has been edited.") svntest.main.file_append(mu_path, "This file has been edited.") # Schedule the files for removal. svntest.main.run_svn(None, 'remove', '--force', iota_path) svntest.main.run_svn(None, 'remove', '--force', mu_path) # Make our output list expected_output = svntest.wc.State(wc_dir, { 'iota' : Item(verb='Deleting'), 'A/mu' : Item(verb='Deleting'), }) # Items in the status list are all at rev 1, except the two things # we changed...but then, they don't exist at all. expected_status = svntest.actions.get_virginal_state(wc_dir, 2) expected_status.remove('iota', 'A/mu') expected_status.tweak(wc_rev=1) svntest.actions.run_and_verify_commit (wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) #----------------------------------------------------------------------def commit_in_dir_scheduled_for_addition(sbox): "commit a file inside dir scheduled for addition" sbox.build() wc_dir = sbox.wc_dir A_path = os.path.join(wc_dir, 'A') Z_path = os.path.join(wc_dir, 'Z') mu_path = os.path.join(wc_dir, 'Z', 'mu') svntest.main.run_svn(None, 'move', A_path, Z_path) # Commit a copied thing inside an added-with-history directory, # expecting a specific error to occur! svntest.actions.run_and_verify_commit (wc_dir, None, None, "unversioned", None, None, None, None, mu_path) Q_path = os.path.join(wc_dir, 'Q') bloo_path = os.path.join(Q_path, 'bloo') os.mkdir(Q_path) svntest.main.file_append(bloo_path, "New contents.") svntest.main.run_svn(None, 'add', Q_path) # Commit a regular added thing inside an added directory, # expecting a specific error to occur! svntest.actions.run_and_verify_commit (wc_dir, None, None, "not under version control", None, None, None, None, bloo_path) #----------------------------------------------------------------------# Does this make sense now that deleted files are always removed from the wc?def commit_rmd_and_deleted_file(sbox): "commit deleted (and missing) file" sbox.build() wc_dir = sbox.wc_dir mu_path = os.path.join(wc_dir, 'A', 'mu') # 'svn remove' mu svntest.main.run_svn(None, 'rm', mu_path) # Commit, hoping to see no errors svntest.actions.run_and_verify_svn("Output on stderr where none expected", SVNAnyOutput, [], 'commit', '-m', 'logmsg', mu_path)#----------------------------------------------------------------------# Issue #644 which failed over ra_dav.def commit_add_file_twice(sbox): "issue 644 attempt to add a file twice" sbox.build() wc_dir = sbox.wc_dir # Create a file gloo_path = os.path.join(wc_dir, 'A', 'D', 'H', 'gloo') svntest.main.file_append(gloo_path, "hello") svntest.main.run_svn(None, 'add', gloo_path) # Create expected output tree. expected_output = svntest.wc.State(wc_dir, { 'A/D/H/gloo' : Item(verb='Adding'), }) # Created expected status tree. expected_status = svntest.actions.get_virginal_state(wc_dir, 1) expected_status.add({ 'A/D/H/gloo' : Item(status='A ', wc_rev=0), }) expected_status.tweak('A/D/H/gloo', wc_rev=2, status=' ') # Commit should succeed svntest.actions.run_and_verify_commit (wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir) # Update to state before commit svntest.main.run_svn(None, 'up', '-r', '1', wc_dir) # Create the file again gloo_path = os.path.join(wc_dir, 'A', 'D', 'H', 'gloo') svntest.main.file_append(gloo_path, "hello") svntest.main.run_svn(None, 'add', gloo_path) # Commit and *expect* a failure: svntest.actions.run_and_verify_commit (wc_dir, None, None, "already exists", None, None, None, None, wc_dir)#----------------------------------------------------------------------# There was a problem that committing from a directory that had a# longer name than the working copy directory caused the commit notify# messages to display truncated/random filenames.def commit_from_long_dir(sbox): "commit from a dir with a longer name than the wc" sbox.build() wc_dir = sbox.wc_dir was_dir = os.getcwd() abs_wc_dir = os.path.join(was_dir, wc_dir) # something to commit svntest.main.file_append(os.path.join(wc_dir, 'iota'), "modified iota") # Create expected output tree. expected_output = svntest.wc.State('', { 'iota' : Item(verb='Sending'), }) # Any length name was enough to provoke the original bug, but # keeping it's length less than that of the filename 'iota' avoided # random behaviour, but still caused the test to fail extra_name = 'xx' try: os.chdir(wc_dir) os.mkdir(extra_name) os.chdir(extra_name) svntest.actions.run_and_verify_commit (abs_wc_dir, expected_output, None, None, None, None, None, None, abs_wc_dir) finally: os.chdir(was_dir) #----------------------------------------------------------------------def commit_with_lock(sbox): "try to commit when directory is locked" sbox.build() # modify gamma and lock its directory wc_dir = sbox.wc_dir D_path = os.path.join(wc_dir, 'A', 'D') gamma_path = os.path.join(D_path, 'gamma') svntest.main.file_append(gamma_path, "modified gamma") svntest.actions.lock_admin_dir(D_path) # this commit should fail svntest.actions.run_and_verify_commit(wc_dir, None, None, 'svn: Working copy \'.*\' locked', None, None, None, None, wc_dir) # unlock directory svntest.actions.run_and_verify_svn("Output on stderr where none expected", [], [], 'cleanup', D_path) # this commit should succeed expected_output = svntest.wc.State(wc_dir, { 'A/D/gamma' : Item(verb='Sending'), }) expected_status = svntest.actions.get_virginal_state(wc_dir, 1) expected_status.tweak('A/D/gamma', wc_rev=2) svntest.actions.run_and_verify_commit(wc_dir, expected_output, expected_status, None, None, None, None, None, wc_dir)#----------------------------------------------------------------------# Explicitly commit the current directory. This did at one point fail# in post-commit processing due to a path canonicalization problem.def commit_current_dir(sbox):
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -