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

📄 commit_tests.py

📁 linux subdivision ying gai ke yi le ba
💻 PY
📖 第 1 页 / 共 5 页
字号:
                                           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",
                                     [], None,
                                     '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(repos_rev=2) # post-commit status
  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):
  "commit the current directory"

  sbox.build()

  wc_dir = sbox.wc_dir
  svntest.main.run_svn(None, 'propset', 'pname', 'pval', wc_dir)

  was_cwd = os.getcwd()
  try:
    os.chdir(wc_dir)

    expected_output = svntest.wc.State('.', {
      '.' : Item(verb='Sending'),
      })
    svntest.actions.run_and_verify_commit('.',
                                          expected_output,
                                          None,
                                          None,
                                          None, None,
                                          None, None,
                                          '.')
  finally:
    os.chdir(was_cwd)

  # I can't get the status check to work as part of run_and_verify_commit.
  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
  expected_status.tweak(repos_rev=2)
  expected_status.tweak('', wc_rev=2, status='  ')
  svntest.actions.run_and_verify_status(wc_dir, expected_status)

#----------------------------------------------------------------------

# Check that the pending txn gets removed from the repository after
# a failed commit.

def failed_commit(sbox):
  "commit with conflicts and check txn in repo"

  sbox.build()
  wc_dir = sbox.wc_dir

  # Make the other working copy
  other_wc_dir = sbox.add_wc_path('other')
  svntest.actions.duplicate_dir(wc_dir, other_wc_dir)

  # Make different changes in the two working copies
  iota_path = os.path.join (wc_dir, "iota")
  svntest.main.file_append (iota_path, "More stuff in iota")

  other_iota_path = os.path.join (other_wc_dir, "iota")
  svntest.main.file_append (other_iota_path, "More different stuff in iota")

  # Commit both working copies. The second commit should fail.
  svntest.actions.run_and_verify_svn("Output on stderr where none expected",
                                     SVNAnyOutput, None,
                                     'commit', '-m', 'log', wc_dir)

  svntest.actions.run_and_verify_svn("Output on stderr expected",
                                     None, SVNAnyOutput,
                                     'commit', '-m', 'log', other_wc_dir)

  # Now list the txns in the repo. The list should be empty.
  output, errput = svntest.main.run_svnadmin('lstxns', sbox.repo_dir)
  svntest.actions.compare_and_display_lines(
    "Error running 'svnadmin lstxns'.",
    'STDERR', [], errput)
  svntest.actions.compare_and_display_lines(
    "Output of 'svnadmin lstxns' is unexpected.",
    'STDOUT', [], output)

#----------------------------------------------------------------------

# Commit from multiple working copies is not yet supported.  At
# present an error is generated and none of the working copies change.
# Related to issue 959, this test here doesn't use svn:external but the
# behaviour needs to be considered.

def commit_multiple_wc(sbox):
  "attempted commit from multiple wc fails"

  sbox.build()
  wc_dir = sbox.wc_dir

  # Checkout a second working copy
  wc2_dir = os.path.join(wc_dir, 'A', 'wc2')
  url = svntest.main.current_repo_url
  svntest.actions.run_and_verify_svn ("Output on stderr where none expected",
                                      SVNAnyOutput, [],
                                      'checkout',
                                      '--username',
                                      svntest.main.wc_author,
                                      '--password',
                                      svntest.main.wc_passwd,
                                      url, wc2_dir)

  # Modify both working copies
  mu_path = os.path.join(wc_dir, 'A', 'mu')
  svntest.main.file_append(mu_path, 'appended mu text')
  lambda2_path = os.path.join(wc2_dir, 'A', 'B', 'lambda')
  svntest.main.file_append(lambda2_path, 'appended lambda2 text')

  # Verify modified status
  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
  expected_status.tweak('A/mu', status='M ')
  svntest.actions.run_and_verify_status(wc_dir, expected_status)
  expected_status2 = svntest.actions.get_virginal_state(wc2_dir, 1)
  expected_status2.tweak('A/B/lambda', status='M ')
  svntest.actions.run_and_verify_status(wc2_dir, expected_status2)

  # Commit should fail, even though one target is a "child" of the other.
  svntest.actions.run_and_verify_svn("Unexpectedly not locked",
                                     None, SVNAnyOutput,
                                     'commit', '-m', 'log',
                                     wc_dir, wc2_dir)

  # Verify status unchanged
  svntest.actions.run_and_verify_status(wc_dir, expected_status)
  svntest.actions.run_and_verify_status(wc2_dir, expected_status2)


def commit_nonrecursive(sbox):
  "commit named targets with -N (issues #1195, #1239)"
  
  sbox.build()
  wc_dir = sbox.wc_dir

  #####################################################
  ### Issue #1195:
  ###
  ### 1. Create these directories and files:
  ###
  ###    file1
  ###    dir1
  ###    dir1/file2
  ###    dir1/file3
  ###    dir1/dir2
  ###    dir1/dir2/file4
  ###   
  ### 2. run 'svn add -N <all of the above>'
  ###
  ### 3. run 'svn ci -N <all of the above>'
  ###
  ### (The bug was that only 4 entities would get committed, when it
  ### should be 6: dir2/ and file4 were left out.)

  # These paths are relative to the top of the test's working copy.
  file1_path = 'file1'
  dir1_path  = 'dir1'
  file2_path = os.path.join('dir1', 'file2')
  file3_path = os.path.join('dir1', 'file3')
  dir2_path  = os.path.join('dir1', 'dir2')
  file4_path = os.path.join('dir1', 'dir2', 'file4')

  # Create the new files and directories.
  svntest.main.file_append(os.path.join(wc_dir, file1_path), 'this is file1')
  os.mkdir(os.path.join(wc_dir, dir1_path))
  svntest.main.file_append(os.path.join(wc_dir, file2_path), 'this is file2')
  svntest.main.file_append(os.path.join(wc_dir, file3_path), 'this is file3')
  os.mkdir(os.path.join(wc_dir, dir2_path))
  svntest.main.file_append(os.path.join(wc_dir, file4_path), 'this is file4')

  # Add them to version control.
  svntest.actions.run_and_verify_svn("", SVNAnyOutput, None,
                                     'add', '-N',
                                     os.path.join(wc_dir, file1_path),
                                     os.path.join(wc_dir, dir1_path),
                                     os.path.join(wc_dir, file2_path),
                                     os.path.join(wc_dir, file3_path),
                                     os.path.join(wc_dir, dir2_path),
                                     os.path.join(wc_dir, file4_path))

  # Commit.  We should see all 6 items (2 dirs, 4 files) get sent.
  expected_output = svntest.wc.State(
    wc_dir,
    { file1_path                    : Item(verb='Adding'),
      dir1_path                     : Item(verb='Adding'),
      file2_path                    : Item(verb='Adding'),
      file3_path                    : Item(verb='Adding'),
      dir2_path                     : Item(verb='Adding'),
      file4_path                    : Item(verb='Adding'),
      }
    )

  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
  expected_status.tweak(repos_rev=2) # post-commit revision
  expected_status.add({
    file1_path   : Item(status='  ', repos_rev=2, wc_rev=2),
    dir1_path    : Item(status='  ', repos_rev=2, wc_rev=2),
    file2_path   : Item(status='  ', repos_rev=2, wc_rev=2),
    file3_path   : Item(status='  ', repos_rev=2, wc_rev=2),
    dir2_path    : Item(status='  ', repos_rev=2, wc_rev=2),
    file4_path   : Item(status='  ', repos_rev=2, wc_rev=2),
    })

  svntest.actions.run_and_verify_commit(wc_dir,
                                        expected_output,
                                        expected_status,
                                        None,
                                        None, None,
                                        None, None,
                                        '-N',
                                        os.path.join(wc_dir, file1_path),
                                        os.path.join(wc_dir, dir1_path),
                                        os.path.join(wc_dir, file2_path),
                                        os.path.join(wc_dir, file3_path),
                                        os.path.join(wc_dir, dir2_path),
                                        os.path.join(wc_dir, file4_path))

  #####################################################
  ### Issue #1239:
  ###
  ### 1. Create these directories and files:
  ###
  ###    dirA
  ###    dirA/fileA
  ###    dirA/fileB
  ###    dirA/dirB
  ###    dirA/dirB/fileC
  ###    dirA/dirB/nocommit
  ###   
  ### 2. run 'svn add -N <all of the above>'
  ###
  ### 3. run 'svn ci -N <all but nocommit>'
  ###
  ### The bug was that it would attempt to commit the file `nocommit',
  ### when it shouldn't, and then get an error anyway:
  ###
  ###    Adding         wc/dirA
  ###    Adding         wc/dirA/fileA
  ###    Adding         wc/dirA/fileB
  ###    Adding         wc/dirA/dirB
  ###    Adding         wc/dirA/dirB/nocommit
  ###    Adding         wc/dirA/dirB/fileC
  ###    Transmitting file data ....svn: A problem occurred; see later errors
  ###    for details
  ###    svn: Commit succeeded, but other errors follow:
  ###    svn: Problem running log
  ###    svn: Error bumping revisions post-commit (details follow):
  ###    svn: in directory
  ###    'F:/Programmation/Projets/subversion/svnant/test/wc/dirA'
  ###    svn: start_handler: error processing command 'committed' in
  ###    'F:/Programmation/Projets/subversion/svnant/test/wc/dirA'
  ###    svn: Working copy not locked
  ###    svn: directory not locked
  ###    (F:/Programmation/Projets/subversion/svnant/test/wc)  
  ### 

  # Now add these directories and files, except the last:
  dirA_path  = 'dirA'
  fileA_path = os.path.join('dirA', 'fileA')
  fileB_path = os.path.join('dirA', 'fileB')
  dirB_path  = os.path.join('dirA', 'dirB')
  fileC_path = os.path.join(dirB_path, 'fileC')
  nocommit_path = os.path.join(dirB_path, 'nocommit')

  # Create the new files and directories.
  os.mkdir(os.path.join(wc_dir, dirA_path))
  svntest.main.file_append(os.path.join(wc_dir, fileA_path), 'fileA')
  svntest.main.file_append(os.path.join(wc_dir, fileB_path), 'fileB')
  os.mkdir(os.path.join(wc_dir, dirB_path))
  svntest.main.file_append(os.path.join(wc_dir, fileC_path), 'fileC')
  svntest.main.file_append(os.path.join(wc_dir, nocommit_path), 'nocommit')

  # Add them to version control.
  svntest.actions.run_and_verify_svn("", SVNAnyOutput, None,
                                     'add', '-N',
                                     os.path.join(wc_dir, dirA_path),
                                     os.path.join(wc_dir, fileA_path),
                                     os.path.join(wc_dir, fileB_path),
                                     os.path.join(wc_dir, dirB_path),
                                     os.path.join(wc_dir, fileC_path),
                                     os.path.join(wc_dir, nocommit_path))

  expected_output = svntest.wc.State(
    wc_dir,
    { dirA_path  : Item(verb='Adding'),
      fileA_path : Item(verb='Adding'),
    

⌨️ 快捷键说明

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