Beispiel #1
0
def run_sync(url, source_url=None, expected_error=None,
             source_prop_encoding=None):
  "Synchronize the mirror repository with the master"
  if source_url is not None:
    args = ["synchronize", url, source_url,
      "--username", svntest.main.wc_author,
      "--password", svntest.main.wc_passwd]
  else: # Allow testing of old source-URL-less syntax
    args = ["synchronize", url,
      "--username", svntest.main.wc_author,
      "--password", svntest.main.wc_passwd]
  if source_prop_encoding:
    args.append("--source-prop-encoding")
    args.append(source_prop_encoding)

  exit_code, output, errput = svntest.main.run_svnsync(*args)
  for index, line in enumerate(errput[:]):
    if re.search("warning: W200007", line):
      del errput[index]
  if errput:
    if expected_error is None:
      raise SVNUnexpectedStderr(errput)
    else:
      expected_error = svntest.verify.RegexOutput(expected_error,
                                                  match_all=False)
      svntest.verify.compare_and_display_lines(None, "STDERR",
                                               expected_error, errput)
  elif expected_error is not None:
    raise SVNExpectedStderr
  if not output and not expected_error:
    # should be: ['Committed revision 1.\n', 'Committed revision 2.\n']
    raise SVNUnexpectedStdout("Missing stdout")
Beispiel #2
0
def info_synchronized(sbox):
    "test info cmd on a synchronized repo"

    sbox.build("svnsync-info-syncd", False)

    # Get the UUID of the source repository.
    exit_code, output, errput = svntest.main.run_svnlook("uuid", sbox.repo_dir)
    src_uuid = output[0].strip()

    dest_sbox = sbox.clone_dependent()
    build_repos(dest_sbox)

    svntest.actions.enable_revprop_changes(dest_sbox.repo_dir)
    run_init(dest_sbox.repo_url, sbox.repo_url)
    run_sync(dest_sbox.repo_url)

    exit_code, output, errput = svntest.main.run_svnsync(
        "info", dest_sbox.repo_url, "--username", svntest.main.wc_author,
        "--password", svntest.main.wc_passwd)
    if errput:
        raise SVNUnexpectedStderr(errput)

    expected_out = [
        'Source URL: %s\n' % sbox.repo_url,
        'Source Repository UUID: %s\n' % src_uuid,
        'Last Merged Revision: 1\n',
    ]

    svntest.verify.compare_and_display_lines(None, 'INFO', expected_out,
                                             output)
Beispiel #3
0
def run_copy_revprops(url,
                      source_url,
                      expected_error=None,
                      source_prop_encoding=None):
    "Copy revprops to the mirror repository from the master"
    args = [
        "copy-revprops", url, source_url, "--username", svntest.main.wc_author,
        "--password", svntest.main.wc_passwd
    ]
    if source_prop_encoding:
        args.append("--source-prop-encoding")
        args.append(source_prop_encoding)

    exit_code, output, errput = svntest.main.run_svnsync(*args)
    for index, line in enumerate(errput[:]):
        if re.search("warning: W200007", line):
            del errput[index]
    if errput:
        if expected_error is None:
            raise SVNUnexpectedStderr(errput)
        else:
            expected_error = svntest.verify.RegexOutput(expected_error,
                                                        match_all=False)
            svntest.verify.compare_and_display_lines(None, "STDERR",
                                                     expected_error, errput)
    elif expected_error is not None:
        raise SVNExpectedStderr
    if not output and not expected_error:
        # should be: ['Copied properties for revision 1.\n',
        #             'Copied properties for revision 2.\n']
        raise SVNUnexpectedStdout("Missing stdout")
Beispiel #4
0
def delete_revprops(sbox):
    "copy-revprops with removals"
    svnsync_tests_dir = os.path.join(os.path.dirname(sys.argv[0]),
                                     'svnsync_tests_data')
    initial_contents = open(
        os.path.join(svnsync_tests_dir, "delete-revprops.dump"),
        'rb').readlines()
    expected_contents = open(
        os.path.join(svnsync_tests_dir, "delete-revprops.expected.dump"),
        'rb').readlines()

    # Create the initial repos and mirror, and sync 'em.
    dest_sbox = setup_and_sync(sbox, initial_contents)

    # Now remove a revprop from r1 of the source, and run 'svnsync
    # copy-revprops' to re-sync 'em.
    svntest.actions.enable_revprop_changes(sbox.repo_dir)
    exit_code, out, err = svntest.main.run_svn(None, 'pdel', '-r', '1',
                                               '--revprop', 'issue-id',
                                               sbox.repo_url)
    if err:
        raise SVNUnexpectedStderr(err)
    run_copy_revprops(dest_sbox.repo_url, sbox.repo_url)

    # Does the result look as we expected?
    verify_mirror(dest_sbox, expected_contents)
Beispiel #5
0
def run_init(dst_url, src_url):
    "Initialize the mirror repository from the master"
    exit_code, output, errput = svntest.main.run_svnsync(
        "initialize", dst_url, src_url, "--username", svntest.main.wc_author,
        "--password", svntest.main.wc_passwd)
    if errput:
        raise SVNUnexpectedStderr(errput)
    if output != ['Copied properties for revision 0.\n']:
        raise SVNUnexpectedStdout(output)
Beispiel #6
0
def set_uuid(sbox):
    "test 'svnadmin setuuid'"

    sbox.build(create_wc=False)

    # Squirrel away the original repository UUID.
    exit_code, output, errput = svntest.main.run_svnlook('uuid', sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)
    orig_uuid = output[0].rstrip()

    # Try setting a new, bogus UUID.
    svntest.actions.run_and_verify_svnadmin(None, None, '^.*Malformed UUID.*$',
                                            'setuuid', sbox.repo_dir, 'abcdef')

    # Try generating a brand new UUID.
    svntest.actions.run_and_verify_svnadmin(None, [], None, 'setuuid',
                                            sbox.repo_dir)
    exit_code, output, errput = svntest.main.run_svnlook('uuid', sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)
    new_uuid = output[0].rstrip()
    if new_uuid == orig_uuid:
        print("Error: new UUID matches the original one")
        raise svntest.Failure

    # Now, try setting the UUID back to the original value.
    svntest.actions.run_and_verify_svnadmin(None, [], None, 'setuuid',
                                            sbox.repo_dir, orig_uuid)
    exit_code, output, errput = svntest.main.run_svnlook('uuid', sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)
    new_uuid = output[0].rstrip()
    if new_uuid != orig_uuid:
        print("Error: new UUID doesn't match the original one")
        raise svntest.Failure
Beispiel #7
0
def run_init(dst_url, src_url, source_prop_encoding=None):
  "Initialize the mirror repository from the master"
  args = ["initialize", dst_url, src_url,
    "--username", svntest.main.wc_author,
    "--password", svntest.main.wc_passwd]
  if source_prop_encoding:
    args.append("--source-prop-encoding")
    args.append(source_prop_encoding)

  exit_code, output, errput = svntest.main.run_svnsync(*args)
  for index, line in enumerate(errput[:]):
    if re.search("warning: W200007", line):
      del errput[index]
  if errput:
    raise SVNUnexpectedStderr(errput)
  if output != ['Copied properties for revision 0.\n']:
    raise SVNUnexpectedStdout(output)
Beispiel #8
0
def run_sync(url, expected_error=None):
    "Synchronize the mirror repository with the master"
    exit_code, 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 SVNUnexpectedStderr(errput)
        else:
            expected_error = svntest.verify.RegexOutput(expected_error,
                                                        match_all=False)
            svntest.verify.compare_and_display_lines(None, "STDERR",
                                                     expected_error, errput)
    elif expected_error is not None:
        raise SVNExpectedStderr
    if not output and not expected_error:
        # should be: ['Committed revision 1.\n', 'Committed revision 2.\n']
        raise SVNUnexpectedStdout("Missing stdout")
Beispiel #9
0
def run_copy_revprops(url, expected_error=None):
    "Copy revprops to the mirror repository from the master"
    exit_code, output, errput = svntest.main.run_svnsync(
        "copy-revprops", url, "--username", svntest.main.wc_author,
        "--password", svntest.main.wc_passwd)
    if errput:
        if expected_error is None:
            raise SVNUnexpectedStderr(errput)
        else:
            expected_error = svntest.verify.RegexOutput(expected_error,
                                                        match_all=False)
            svntest.verify.compare_and_display_lines(None, "STDERR",
                                                     expected_error, errput)
    elif expected_error is not None:
        raise SVNExpectedStderr
    if not output and not expected_error:
        # should be: ['Copied properties for revision 1.\n',
        #             'Copied properties for revision 2.\n']
        raise SVNUnexpectedStdout("Missing stdout")
Beispiel #10
0
def run_info(url, expected_error=None):
    "Print synchronization information of the repository"
    exit_code, output, errput = svntest.main.run_svnsync(
        "info", url, "--username", svntest.main.wc_author, "--password",
        svntest.main.wc_passwd)
    if errput:
        if expected_error is None:
            raise SVNUnexpectedStderr(errput)
        else:
            expected_error = svntest.verify.RegexOutput(expected_error,
                                                        match_all=False)
            svntest.verify.compare_and_display_lines(None, "STDERR",
                                                     expected_error, errput)
    elif expected_error is not None:
        raise SVNExpectedStderr
    if not output and not expected_error:
        # should be: ['From URL: http://....\n',
        #             'From UUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n',
        #             'Last Merged Revision: XXX\n']
        raise SVNUnexpectedStdout("Missing stdout")
def copy_from_unreadable_dir(sbox):
    "verify that copies from unreadable dirs work"

    sbox.build()

    B_url = sbox.repo_url + '/A/B'
    P_url = sbox.repo_url + '/A/P'

    # Set a property on the directory we're going to copy, and a file in it, to
    # confirm that they're transmitted when we later sync the copied directory
    svntest.actions.run_and_verify_svn(None, [], 'pset', 'foo', 'bar',
                                       sbox.wc_dir + '/A/B/lambda')

    svntest.actions.run_and_verify_svn(None, [], 'pset', 'baz', 'zot',
                                       sbox.wc_dir + '/A/B')

    svntest.actions.run_and_verify_svn(None, [], 'ci', sbox.wc_dir + '/A/B',
                                       '-m', 'log_msg')

    # Now copy that directory so we'll see it in our synced copy
    svntest.actions.run_and_verify_svn(None, [], 'cp', B_url, P_url, '-m',
                                       'Copy B to P')

    write_restrictive_svnserve_conf(sbox.repo_dir)

    dest_sbox = sbox.clone_dependent()
    dest_sbox.build(create_wc=False, empty=True)

    svntest.actions.enable_revprop_changes(dest_sbox.repo_dir)

    src_authz = sbox.authz_name()
    dst_authz = dest_sbox.authz_name()
    write_authz_file(sbox,
                     None,
                     prefixed_rules={
                         src_authz + ':/': '* = r',
                         src_authz + ':/A/B': '* =',
                         dst_authz + ':/': '* = rw',
                     })

    run_init(dest_sbox.repo_url, sbox.repo_url)

    run_sync(dest_sbox.repo_url)

    expected_out = [
        'Changed paths:\n',
        '   A /A/P\n',
        '   A /A/P/E\n',
        '   A /A/P/E/alpha\n',
        '   A /A/P/E/beta\n',
        '   A /A/P/F\n',
        '   A /A/P/lambda\n',
        '\n',
        '\n',  # log message is stripped
    ]

    exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '3', '-v',
                                               dest_sbox.repo_url)

    if err:
        raise SVNUnexpectedStderr(err)

    svntest.verify.compare_and_display_lines(None, 'LOG', expected_out,
                                             out[2:11])

    svntest.actions.run_and_verify_svn(['bar\n'], [], 'pget', 'foo',
                                       dest_sbox.repo_url + '/A/P/lambda')

    svntest.actions.run_and_verify_svn(['zot\n'], [], 'pget', 'baz',
                                       dest_sbox.repo_url + '/A/P')
def copy_with_mod_from_unreadable_dir_and_copy(sbox):
    "verify copies with mods from unreadable dirs +copy"

    sbox.build()

    # Make a copy of the B directory.
    svntest.actions.run_and_verify_svn(None, [], 'cp', sbox.wc_dir + '/A/B',
                                       sbox.wc_dir + '/A/P')

    # Copy a (readable) file into the copied directory.
    svntest.actions.run_and_verify_svn(None, [], 'cp',
                                       sbox.wc_dir + '/A/D/gamma',
                                       sbox.wc_dir + '/A/P/E')

    # Commit the copy-with-modification.
    svntest.actions.run_and_verify_svn(None, [], 'ci', sbox.wc_dir, '-m',
                                       'log_msg')

    # Lock down the source repository.
    write_restrictive_svnserve_conf(sbox.repo_dir)

    dest_sbox = sbox.clone_dependent()
    dest_sbox.build(create_wc=False, empty=True)

    svntest.actions.enable_revprop_changes(dest_sbox.repo_dir)

    src_authz = sbox.authz_name()
    dst_authz = dest_sbox.authz_name()
    write_authz_file(sbox,
                     None,
                     prefixed_rules={
                         src_authz + ':/': '* = r',
                         src_authz + ':/A/B': '* =',
                         dst_authz + ':/': '* = rw',
                     })

    run_init(dest_sbox.repo_url, sbox.repo_url)

    run_sync(dest_sbox.repo_url)

    expected_out = [
        'Changed paths:\n',
        '   A /A/P\n',
        '   A /A/P/E\n',
        '   A /A/P/E/alpha\n',
        '   A /A/P/E/beta\n',
        '   A /A/P/E/gamma (from /A/D/gamma:1)\n',
        '   A /A/P/F\n',
        '   A /A/P/lambda\n',
        '\n',
        '\n',  # log message is stripped
    ]

    exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '2', '-v',
                                               dest_sbox.repo_url)

    if err:
        raise SVNUnexpectedStderr(err)

    svntest.verify.compare_and_display_lines(None, 'LOG', expected_out,
                                             out[2:12])
def copy_with_mod_from_unreadable_dir(sbox):
    "verify copies with mods from unreadable dirs"

    sbox.build()

    # Make a copy of the B directory.
    svntest.actions.run_and_verify_svn(None, [], 'cp', sbox.wc_dir + '/A/B',
                                       sbox.wc_dir + '/A/P')

    # Set a property inside the copied directory.
    svntest.actions.run_and_verify_svn(None, [], 'pset', 'foo', 'bar',
                                       sbox.wc_dir + '/A/P/lambda')

    # Add a new directory and file inside the copied directory.
    svntest.actions.run_and_verify_svn(None, [], 'mkdir',
                                       sbox.wc_dir + '/A/P/NEW-DIR')

    svntest.main.file_append(sbox.wc_dir + '/A/P/E/new-file', "bla bla")
    svntest.main.run_svn(None, 'add', sbox.wc_dir + '/A/P/E/new-file')

    # Delete a file inside the copied directory.
    svntest.actions.run_and_verify_svn(None, [], 'rm',
                                       sbox.wc_dir + '/A/P/E/beta')

    # Commit the copy-with-modification.
    svntest.actions.run_and_verify_svn(None, [], 'ci', sbox.wc_dir, '-m',
                                       'log_msg')

    # Lock down the source repository.
    write_restrictive_svnserve_conf(sbox.repo_dir)

    dest_sbox = sbox.clone_dependent()
    dest_sbox.build(create_wc=False, empty=True)

    svntest.actions.enable_revprop_changes(dest_sbox.repo_dir)

    src_authz = sbox.authz_name()
    dst_authz = dest_sbox.authz_name()
    write_authz_file(sbox,
                     None,
                     prefixed_rules={
                         src_authz + ':/': '* = r',
                         src_authz + ':/A/B': '* =',
                         dst_authz + ':/': '* = rw',
                     })

    run_init(dest_sbox.repo_url, sbox.repo_url)

    run_sync(dest_sbox.repo_url)

    expected_out = [
        'Changed paths:\n',
        '   A /A/P\n',
        '   A /A/P/E\n',
        '   A /A/P/E/alpha\n',
        '   A /A/P/E/new-file\n',
        '   A /A/P/F\n',
        '   A /A/P/NEW-DIR\n',
        '   A /A/P/lambda\n',
        '\n',
        '\n',  # log message is stripped
    ]

    exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '2', '-v',
                                               dest_sbox.repo_url)

    if err:
        raise SVNUnexpectedStderr(err)

    svntest.verify.compare_and_display_lines(None, 'LOG', expected_out,
                                             out[2:12])

    svntest.actions.run_and_verify_svn(['bar\n'], [], 'pget', 'foo',
                                       dest_sbox.repo_url + '/A/P/lambda')
Beispiel #14
0
def copy_with_mod_from_unreadable_dir_and_copy(sbox):
    "verify copies with mods from unreadable dirs +copy"

    sbox.build("svnsync-copy-with-mod-from-unreadable-dir-and-copy")

    # Make a copy of the B directory.
    svntest.actions.run_and_verify_svn(None, None, [], 'cp',
                                       sbox.wc_dir + '/A/B',
                                       sbox.wc_dir + '/A/P')

    # Copy a (readable) file into the copied directory.
    svntest.actions.run_and_verify_svn(None, None, [], 'cp',
                                       sbox.wc_dir + '/A/D/gamma',
                                       sbox.wc_dir + '/A/P/E')

    # Commit the copy-with-modification.
    svntest.actions.run_and_verify_svn(None, None, [], 'ci', sbox.wc_dir, '-m',
                                       'log_msg')

    # Lock down the source repository.
    write_restrictive_svnserve_conf(sbox.repo_dir)

    dest_sbox = sbox.clone_dependent()
    build_repos(dest_sbox)

    svntest.actions.enable_revprop_changes(dest_sbox.repo_dir)

    args = tuple(s.authz_name() for s in [sbox, sbox, dest_sbox])
    open(sbox.authz_file, 'w').write("[%s:/]\n"
                                     "* = r\n"
                                     "\n"
                                     "[%s:/A/B]\n"
                                     "* = \n"
                                     "\n"
                                     "[%s:/]\n"
                                     "* = rw" % args)

    run_init(dest_sbox.repo_url, sbox.repo_url)

    run_sync(dest_sbox.repo_url)

    expected_out = [
        'Changed paths:\n',
        '   A /A/P\n',
        '   A /A/P/E\n',
        '   A /A/P/E/alpha\n',
        '   A /A/P/E/beta\n',
        '   A /A/P/E/gamma (from /A/D/gamma:1)\n',
        '   A /A/P/F\n',
        '   A /A/P/lambda\n',
        '\n',
        '\n',  # log message is stripped
    ]

    exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '2', '-v',
                                               dest_sbox.repo_url)

    if err:
        raise SVNUnexpectedStderr(err)

    svntest.verify.compare_and_display_lines(None, 'LOG', expected_out,
                                             out[2:12])
Beispiel #15
0
def copy_with_mod_from_unreadable_dir(sbox):
    "verify copies with mods from unreadable dirs"

    sbox.build("svnsync-copy-with-mod-from-unreadable-dir")

    # Make a copy of the B directory.
    svntest.actions.run_and_verify_svn(None, None, [], 'cp',
                                       sbox.wc_dir + '/A/B',
                                       sbox.wc_dir + '/A/P')

    # Set a property inside the copied directory.
    svntest.actions.run_and_verify_svn(None, None, [], 'pset', 'foo', 'bar',
                                       sbox.wc_dir + '/A/P/lambda')

    # Add a new directory and file inside the copied directory.
    svntest.actions.run_and_verify_svn(None, None, [], 'mkdir',
                                       sbox.wc_dir + '/A/P/NEW-DIR')

    svntest.main.file_append(sbox.wc_dir + '/A/P/E/new-file', "bla bla")
    svntest.main.run_svn(None, 'add', sbox.wc_dir + '/A/P/E/new-file')

    # Delete a file inside the copied directory.
    svntest.actions.run_and_verify_svn(None, None, [], 'rm',
                                       sbox.wc_dir + '/A/P/E/beta')

    # Commit the copy-with-modification.
    svntest.actions.run_and_verify_svn(None, None, [], 'ci', sbox.wc_dir, '-m',
                                       'log_msg')

    # Lock down the source repository.
    write_restrictive_svnserve_conf(sbox.repo_dir)

    dest_sbox = sbox.clone_dependent()
    build_repos(dest_sbox)

    svntest.actions.enable_revprop_changes(dest_sbox.repo_dir)

    args = tuple(s.authz_name() for s in [sbox, sbox, dest_sbox])
    open(sbox.authz_file, 'w').write("[%s:/]\n"
                                     "* = r\n"
                                     "\n"
                                     "[%s:/A/B]\n"
                                     "* = \n"
                                     "\n"
                                     "[%s:/]\n"
                                     "* = rw" % args)

    run_init(dest_sbox.repo_url, sbox.repo_url)

    run_sync(dest_sbox.repo_url)

    expected_out = [
        'Changed paths:\n',
        '   A /A/P\n',
        '   A /A/P/E\n',
        '   A /A/P/E/alpha\n',
        '   A /A/P/E/new-file\n',
        '   A /A/P/F\n',
        '   A /A/P/NEW-DIR\n',
        '   A /A/P/lambda\n',
        '\n',
        '\n',  # log message is stripped
    ]

    exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '2', '-v',
                                               dest_sbox.repo_url)

    if err:
        raise SVNUnexpectedStderr(err)

    svntest.verify.compare_and_display_lines(None, 'LOG', expected_out,
                                             out[2:12])

    svntest.actions.run_and_verify_svn(None, ['bar\n'], [], 'pget', 'foo',
                                       dest_sbox.repo_url + '/A/P/lambda')
Beispiel #16
0
def copy_with_mod_from_unreadable_dir_and_copy(sbox):
    "verify copies with mods from unreadable dirs +copy"

    sbox.build("svnsync-copy-with-mod-from-unreadable-dir-and-copy")

    # Make a copy of the B directory.
    svntest.actions.run_and_verify_svn(None, None, [], 'cp',
                                       sbox.wc_dir + '/A/B',
                                       sbox.wc_dir + '/A/P')

    # Copy a (readable) file into the copied directory.
    svntest.actions.run_and_verify_svn(None, None, [], 'cp',
                                       sbox.wc_dir + '/A/D/gamma',
                                       sbox.wc_dir + '/A/P/E')

    # Commit the copy-with-modification.
    svntest.actions.run_and_verify_svn(None, None, [], 'ci', sbox.wc_dir, '-m',
                                       'log_msg')

    # Lock down the source repository.
    write_restrictive_svnserve_conf(sbox.repo_dir)

    dest_sbox = sbox.clone_dependent()
    build_repos(dest_sbox)

    svntest.actions.enable_revprop_changes(dest_sbox.repo_dir)

    fp = open(sbox.authz_file, 'w')

    # For mod_dav_svn's parent path setup we need per-repos permissions in
    # the authz file...
    if sbox.repo_url.startswith('http'):
        fp.write(
            "[svnsync-copy-with-mod-from-unreadable-dir-and-copy:/]\n" +
            "* = r\n" + "\n" +
            "[svnsync-copy-with-mod-from-unreadable-dir-and-copy:/A/B]\n" +
            "* = \n" + "\n" +
            "[svnsync-copy-with-mod-from-unreadable-dir-and-copy-1:/]\n" +
            "* = rw")

    # Otherwise we can just go with the permissions needed for the source
    # repository.
    else:
        fp.write("[/]\n" + "* = r\n" + "\n" + "[/A/B]\n" + "* =\n")
    fp.close()

    run_init(dest_sbox.repo_url, sbox.repo_url)

    run_sync(dest_sbox.repo_url)

    expected_out = [
        'Changed paths:\n',
        '   A /A/P\n',
        '   A /A/P/E\n',
        '   A /A/P/E/alpha\n',
        '   A /A/P/E/beta\n',
        '   A /A/P/E/gamma (from /A/D/gamma:1)\n',
        '   A /A/P/F\n',
        '   A /A/P/lambda\n',
        '\n',
        '\n',  # log message is stripped
    ]

    exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '2', '-v',
                                               dest_sbox.repo_url)

    if err:
        raise SVNUnexpectedStderr(err)

    svntest.verify.compare_and_display_lines(None, 'LOG', expected_out,
                                             out[2:12])
Beispiel #17
0
def copy_from_unreadable_dir(sbox):
    "verify that copies from unreadable dirs work"

    sbox.build("svnsync-copy-from-unreadable-dir")

    B_url = sbox.repo_url + '/A/B'
    P_url = sbox.repo_url + '/A/P'

    # Set a property on the directory we're going to copy, and a file in it, to
    # confirm that they're transmitted when we later sync the copied directory
    svntest.actions.run_and_verify_svn(None, None, [], 'pset', 'foo', 'bar',
                                       sbox.wc_dir + '/A/B/lambda')

    svntest.actions.run_and_verify_svn(None, None, [], 'pset', 'baz', 'zot',
                                       sbox.wc_dir + '/A/B')

    svntest.actions.run_and_verify_svn(None, None, [], 'ci',
                                       sbox.wc_dir + '/A/B', '-m', 'log_msg')

    # Now copy that directory so we'll see it in our synced copy
    svntest.actions.run_and_verify_svn(None, None, [], 'cp', B_url, P_url,
                                       '-m', 'Copy B to P')

    write_restrictive_svnserve_conf(sbox.repo_dir)

    dest_sbox = sbox.clone_dependent()
    build_repos(dest_sbox)

    svntest.actions.enable_revprop_changes(dest_sbox.repo_dir)

    fp = open(sbox.authz_file, 'w')

    # For mod_dav_svn's parent path setup we need per-repos permissions in
    # the authz file...
    if sbox.repo_url.startswith('http'):
        fp.write("[svnsync-copy-from-unreadable-dir:/]\n" + "* = r\n" + "\n" +
                 "[svnsync-copy-from-unreadable-dir:/A/B]\n" + "* = \n" +
                 "\n" + "[svnsync-copy-from-unreadable-dir-1:/]\n" + "* = rw")

    # Otherwise we can just go with the permissions needed for the source
    # repository.
    else:
        fp.write("[/]\n" + "* = r\n" + "\n" + "[/A/B]\n" + "* =\n")
    fp.close()

    run_init(dest_sbox.repo_url, sbox.repo_url)

    run_sync(dest_sbox.repo_url)

    expected_out = [
        'Changed paths:\n',
        '   A /A/P\n',
        '   A /A/P/E\n',
        '   A /A/P/E/alpha\n',
        '   A /A/P/E/beta\n',
        '   A /A/P/F\n',
        '   A /A/P/lambda\n',
        '\n',
        '\n',  # log message is stripped
    ]

    exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '3', '-v',
                                               dest_sbox.repo_url)

    if err:
        raise SVNUnexpectedStderr(err)

    svntest.verify.compare_and_display_lines(None, 'LOG', expected_out,
                                             out[2:11])

    svntest.actions.run_and_verify_svn(None, ['bar\n'], [], 'pget', 'foo',
                                       dest_sbox.repo_url + '/A/P/lambda')

    svntest.actions.run_and_verify_svn(None, ['zot\n'], [], 'pget', 'baz',
                                       dest_sbox.repo_url + '/A/P')
Beispiel #18
0
def copy_with_mod_from_unreadable_dir(sbox):
    "verify copies with mods from unreadable dirs"

    sbox.build("svnsync-copy-with-mod-from-unreadable-dir")

    # Make a copy of the B directory.
    svntest.actions.run_and_verify_svn(None, None, [], 'cp',
                                       sbox.wc_dir + '/A/B',
                                       sbox.wc_dir + '/A/P')

    # Set a property inside the copied directory.
    svntest.actions.run_and_verify_svn(None, None, [], 'pset', 'foo', 'bar',
                                       sbox.wc_dir + '/A/P/lambda')

    # Add a new directory and file inside the copied directory.
    svntest.actions.run_and_verify_svn(None, None, [], 'mkdir',
                                       sbox.wc_dir + '/A/P/NEW-DIR')

    svntest.main.file_append(sbox.wc_dir + '/A/P/E/new-file', "bla bla")
    svntest.main.run_svn(None, 'add', sbox.wc_dir + '/A/P/E/new-file')

    # Delete a file inside the copied directory.
    svntest.actions.run_and_verify_svn(None, None, [], 'rm',
                                       sbox.wc_dir + '/A/P/E/beta')

    # Commit the copy-with-modification.
    svntest.actions.run_and_verify_svn(None, None, [], 'ci', sbox.wc_dir, '-m',
                                       'log_msg')

    # Lock down the source repository.
    write_restrictive_svnserve_conf(sbox.repo_dir)

    dest_sbox = sbox.clone_dependent()
    build_repos(dest_sbox)

    svntest.actions.enable_revprop_changes(dest_sbox.repo_dir)

    fp = open(sbox.authz_file, 'w')

    # For mod_dav_svn's parent path setup we need per-repos permissions in
    # the authz file...
    if sbox.repo_url.startswith('http'):
        fp.write("[svnsync-copy-with-mod-from-unreadable-dir:/]\n" +
                 "* = r\n" + "\n" +
                 "[svnsync-copy-with-mod-from-unreadable-dir:/A/B]\n" +
                 "* = \n" + "\n" +
                 "[svnsync-copy-with-mod-from-unreadable-dir-1:/]\n" +
                 "* = rw")

    # Otherwise we can just go with the permissions needed for the source
    # repository.
    else:
        fp.write("[/]\n" + "* = r\n" + "\n" + "[/A/B]\n" + "* =\n")
    fp.close()

    run_init(dest_sbox.repo_url, sbox.repo_url)

    run_sync(dest_sbox.repo_url)

    expected_out = [
        'Changed paths:\n',
        '   A /A/P\n',
        '   A /A/P/E\n',
        '   A /A/P/E/alpha\n',
        '   A /A/P/E/new-file\n',
        '   A /A/P/F\n',
        '   A /A/P/NEW-DIR\n',
        '   A /A/P/lambda\n',
        '\n',
        '\n',  # log message is stripped
    ]

    out, err = svntest.main.run_svn(None, 'log', '-r', '2', '-v',
                                    dest_sbox.repo_url)

    if err:
        raise SVNUnexpectedStderr(err)

    svntest.verify.compare_and_display_lines(None, 'LOG', expected_out,
                                             out[2:12])

    svntest.actions.run_and_verify_svn(None, ['bar\n'], [], 'pget', 'foo',
                                       dest_sbox.repo_url + '/A/P/lambda')
Beispiel #19
0
def copy_from_unreadable_dir(sbox):
    "verify that copies from unreadable dirs work"

    sbox.build("svnsync-copy-from-unreadable-dir")

    B_url = sbox.repo_url + '/A/B'
    P_url = sbox.repo_url + '/A/P'

    # Set a property on the directory we're going to copy, and a file in it, to
    # confirm that they're transmitted when we later sync the copied directory
    svntest.actions.run_and_verify_svn(None, None, [], 'pset', 'foo', 'bar',
                                       sbox.wc_dir + '/A/B/lambda')

    svntest.actions.run_and_verify_svn(None, None, [], 'pset', 'baz', 'zot',
                                       sbox.wc_dir + '/A/B')

    svntest.actions.run_and_verify_svn(None, None, [], 'ci',
                                       sbox.wc_dir + '/A/B', '-m', 'log_msg')

    # Now copy that directory so we'll see it in our synced copy
    svntest.actions.run_and_verify_svn(None, None, [], 'cp', B_url, P_url,
                                       '-m', 'Copy B to P')

    write_restrictive_svnserve_conf(sbox.repo_dir)

    dest_sbox = sbox.clone_dependent()
    build_repos(dest_sbox)

    svntest.actions.enable_revprop_changes(dest_sbox.repo_dir)

    args = tuple(s.authz_name() for s in [sbox, sbox, dest_sbox])
    open(sbox.authz_file, 'w').write("[%s:/]\n"
                                     "* = r\n"
                                     "\n"
                                     "[%s:/A/B]\n"
                                     "* = \n"
                                     "\n"
                                     "[%s:/]\n"
                                     "* = rw" % args)

    run_init(dest_sbox.repo_url, sbox.repo_url)

    run_sync(dest_sbox.repo_url)

    expected_out = [
        'Changed paths:\n',
        '   A /A/P\n',
        '   A /A/P/E\n',
        '   A /A/P/E/alpha\n',
        '   A /A/P/E/beta\n',
        '   A /A/P/F\n',
        '   A /A/P/lambda\n',
        '\n',
        '\n',  # log message is stripped
    ]

    exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '3', '-v',
                                               dest_sbox.repo_url)

    if err:
        raise SVNUnexpectedStderr(err)

    svntest.verify.compare_and_display_lines(None, 'LOG', expected_out,
                                             out[2:11])

    svntest.actions.run_and_verify_svn(None, ['bar\n'], [], 'pget', 'foo',
                                       dest_sbox.repo_url + '/A/P/lambda')

    svntest.actions.run_and_verify_svn(None, ['zot\n'], [], 'pget', 'baz',
                                       dest_sbox.repo_url + '/A/P')
Beispiel #20
0
def recover_fsfs(sbox):
    "recover a repository (FSFS only)"
    sbox.build()
    current_path = os.path.join(sbox.repo_dir, 'db', 'current')

    # Commit up to r3, so we can test various recovery scenarios.
    svntest.main.file_append(os.path.join(sbox.wc_dir, 'iota'), 'newer line\n')
    svntest.main.run_svn(None, 'ci', sbox.wc_dir, '--quiet', '-m', 'log msg')

    svntest.main.file_append(os.path.join(sbox.wc_dir, 'iota'),
                             'newest line\n')
    svntest.main.run_svn(None, 'ci', sbox.wc_dir, '--quiet', '-m', 'log msg')

    # Remember the contents of the db/current file.
    expected_current_contents = svntest.main.file_read(current_path)

    # Move aside the current file for r3.
    os.rename(os.path.join(sbox.repo_dir, 'db', 'current'),
              os.path.join(sbox.repo_dir, 'db', 'was_current'))

    # Run 'svnadmin recover' and check that the current file is recreated.
    exit_code, output, errput = svntest.main.run_svnadmin(
        "recover", sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)

    actual_current_contents = svntest.main.file_read(current_path)
    svntest.verify.compare_and_display_lines(
        "Contents of db/current is unexpected.", 'db/current',
        expected_current_contents, actual_current_contents)

    # Now try writing db/current to be one rev lower than it should be.
    svntest.main.file_write(current_path, '2\n')

    # Run 'svnadmin recover' and check that the current file is fixed.
    exit_code, output, errput = svntest.main.run_svnadmin(
        "recover", sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)

    actual_current_contents = svntest.main.file_read(current_path)
    svntest.verify.compare_and_display_lines(
        "Contents of db/current is unexpected.", 'db/current',
        expected_current_contents, actual_current_contents)

    # Now try writing db/current to be *two* revs lower than it should be.
    svntest.main.file_write(current_path, '1\n')

    # Run 'svnadmin recover' and check that the current file is fixed.
    exit_code, output, errput = svntest.main.run_svnadmin(
        "recover", sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)

    actual_current_contents = svntest.main.file_read(current_path)
    svntest.verify.compare_and_display_lines(
        "Contents of db/current is unexpected.", 'db/current',
        expected_current_contents, actual_current_contents)

    # Now try writing db/current to be fish revs lower than it should be.
    #
    # Note: I'm not actually sure it's wise to recover from this, but
    # detecting it would require rewriting fs_fs.c:get_youngest() to
    # check the actual contents of its buffer, since atol() will happily
    # convert "fish" to 0.
    svntest.main.file_write(current_path, 'fish\n')

    # Run 'svnadmin recover' and check that the current file is fixed.
    exit_code, output, errput = svntest.main.run_svnadmin(
        "recover", sbox.repo_dir)
    if errput:
        raise SVNUnexpectedStderr(errput)

    actual_current_contents = svntest.main.file_read(current_path)
    svntest.verify.compare_and_display_lines(
        "Contents of db/current is unexpected.", 'db/current',
        expected_current_contents, actual_current_contents)