Beispiel #1
0
def verify_update(actual_output, wc_dir_name,
                  output_tree, disk_tree, status_tree,
                  singleton_handler_a, a_baton,
                  singleton_handler_b, b_baton,
                  check_props):
  """Verify update of WC_DIR_NAME.
  
  The subcommand output (found in ACTUAL_OUTPUT) will be verified
  against OUTPUT_TREE, and the working copy itself will be verified
  against DISK_TREE.  If optional STATUS_OUTPUT_TREE is given, then
  'svn status' output will be compared.  (This is a good way to check
  that revision numbers were bumped.)  SINGLETON_HANDLER_A and
  SINGLETON_HANDLER_B will be passed to tree.compare_trees - see that
  function's doc string for more details.  If CHECK_PROPS is set, then
  disk comparison will examine props.  Returns if successful, raises
  on failure."""

  # Verify actual output against expected output.
  tree.compare_trees (actual_output, output_tree)

  # Create a tree by scanning the working copy
  mytree = tree.build_tree_from_wc (wc_dir_name, check_props)

  # Verify expected disk against actual disk.
  tree.compare_trees (mytree, disk_tree,
                      singleton_handler_a, a_baton,
                      singleton_handler_b, b_baton)

  # Verify via 'status' command too, if possible.
  if status_tree:
    run_and_verify_status(wc_dir_name, status_tree)
Beispiel #2
0
def verify_update(actual_output, wc_dir_name, output_tree, disk_tree,
                  status_tree, singleton_handler_a, a_baton,
                  singleton_handler_b, b_baton, check_props):
    """Verify update of WC_DIR_NAME.

  The subcommand output (found in ACTUAL_OUTPUT) will be verified
  against OUTPUT_TREE, and the working copy itself will be verified
  against DISK_TREE.  If optional STATUS_OUTPUT_TREE is given, then
  'svn status' output will be compared.  (This is a good way to check
  that revision numbers were bumped.)  SINGLETON_HANDLER_A and
  SINGLETON_HANDLER_B will be passed to tree.compare_trees - see that
  function's doc string for more details.  If CHECK_PROPS is set, then
  disk comparison will examine props.  Returns if successful, raises
  on failure."""

    # Verify actual output against expected output.
    tree.compare_trees(actual_output, output_tree)

    # Create a tree by scanning the working copy
    mytree = tree.build_tree_from_wc(wc_dir_name, check_props)

    # Verify expected disk against actual disk.
    tree.compare_trees(mytree, disk_tree, singleton_handler_a, a_baton,
                       singleton_handler_b, b_baton)

    # Verify via 'status' command too, if possible.
    if status_tree:
        run_and_verify_status(wc_dir_name, status_tree)
def run_and_verify_update(wc_dir_name,
                          output_tree, disk_tree, status_tree,
                          singleton_handler_a = None,
                          a_baton = None,
                          singleton_handler_b = None,
                          b_baton = None,
                          check_props = 0,
                          *args):
  """Update WC_DIR_NAME into a new directory WC_DIR_NAME.  *ARGS are
  any extra optional args to the update subcommand.

  The subcommand output will be verified against OUTPUT_TREE, and the
  working copy itself will be verified against DISK_TREE.  If optional
  STATUS_OUTPUT_TREE is given, then 'svn status' output will be
  compared.  (This is a good way to check that revision numbers were
  bumped.)  SINGLETON_HANDLER_A and SINGLETON_HANDLER_B will be passed to
  tree.compare_trees - see that function's doc string for more details.
  If CHECK_PROPS is set, then disk comparison will examine props.
  Return 0 if successful."""

  # Update and make a tree of the output.
  output, errput = main.run_svn (None, 'up', wc_dir_name, *args)
  mytree = tree.build_tree_from_checkout (output)

  # Verify actual output against expected output.
  if tree.compare_trees (mytree, output_tree):
    return 1

  # Create a tree by scanning the working copy
  mytree = tree.build_tree_from_wc (wc_dir_name, check_props)

  # Verify expected disk against actual disk.
  if tree.compare_trees (mytree, disk_tree,
                         singleton_handler_a, a_baton,
                         singleton_handler_b, b_baton):
    return 1

  # Verify via 'status' command too, if possible.
  if status_tree:
    if run_and_verify_status(wc_dir_name, status_tree):
      return 1
  
  return 0
Beispiel #4
0
def run_and_verify_export(URL,
                          export_dir_name,
                          output_tree,
                          disk_tree,
                          singleton_handler_a=None,
                          a_baton=None,
                          singleton_handler_b=None,
                          b_baton=None,
                          *args):
    """Export the URL into a new directory WC_DIR_NAME.

  The subcommand output will be verified against OUTPUT_TREE,
  and the exported copy itself will be verified against DISK_TREE.
  SINGLETON_HANDLER_A and SINGLETON_HANDLER_B will be passed to
  tree.compare_trees - see that function's doc string for more details.
  Returns if successful and raise on failure."""

    if isinstance(output_tree, wc.State):
        output_tree = output_tree.old_tree()
    if isinstance(disk_tree, wc.State):
        disk_tree = disk_tree.old_tree()

    # Export and make a tree of the output, using l:foo/p:bar
    ### todo: svn should not be prompting for auth info when using
    ### repositories with no auth/auth requirements
    output, errput = main.run_svn(None, 'export', '--username', main.wc_author,
                                  '--password', main.wc_passwd, URL,
                                  export_dir_name, *args)
    mytree = tree.build_tree_from_checkout(output)

    # Verify actual output against expected output.
    tree.compare_trees(mytree, output_tree)

    # Create a tree by scanning the working copy.  Don't ignore
    # the .svn directories so that we generate an error if they
    # happen to show up.
    mytree = tree.build_tree_from_wc(export_dir_name, ignore_svn=0)

    # Verify expected disk against actual disk.
    tree.compare_trees(mytree, disk_tree, singleton_handler_a, a_baton,
                       singleton_handler_b, b_baton)
Beispiel #5
0
def run_and_verify_export(URL, export_dir_name, output_tree, disk_tree,
                          singleton_handler_a = None,
                          a_baton = None,
                          singleton_handler_b = None,
                          b_baton = None,
                          *args):
  """Export the URL into a new directory WC_DIR_NAME.

  The subcommand output will be verified against OUTPUT_TREE,
  and the exported copy itself will be verified against DISK_TREE.
  SINGLETON_HANDLER_A and SINGLETON_HANDLER_B will be passed to
  tree.compare_trees - see that function's doc string for more details.
  Returns if successful and raise on failure."""

  if isinstance(output_tree, wc.State):
    output_tree = output_tree.old_tree()
  if isinstance(disk_tree, wc.State):
    disk_tree = disk_tree.old_tree()

  # Export and make a tree of the output, using l:foo/p:bar
  ### todo: svn should not be prompting for auth info when using
  ### repositories with no auth/auth requirements
  output, errput = main.run_svn (None, 'export',
                                 '--username', main.wc_author,
                                 '--password', main.wc_passwd,
                                 URL, export_dir_name, *args)
  mytree = tree.build_tree_from_checkout (output)

  # Verify actual output against expected output.
  tree.compare_trees (mytree, output_tree)

  # Create a tree by scanning the working copy.  Don't ignore
  # the .svn directories so that we generate an error if they
  # happen to show up.
  mytree = tree.build_tree_from_wc (export_dir_name, ignore_svn=0)

  # Verify expected disk against actual disk.
  tree.compare_trees (mytree, disk_tree,
                      singleton_handler_a, a_baton,
                      singleton_handler_b, b_baton)
def run_and_verify_checkout(URL, wc_dir_name, output_tree, disk_tree,
                            singleton_handler_a = None,
                            a_baton = None,
                            singleton_handler_b = None,
                            b_baton = None):
  """Checkout the the URL into a new directory WC_DIR_NAME.

  The subcommand output will be verified against OUTPUT_TREE,
  and the working copy itself will be verified against DISK_TREE.
  SINGLETON_HANDLER_A and SINGLETON_HANDLER_B will be passed to
  tree.compare_trees - see that function's doc string for more details.
  Return 0 if successful."""

  # Remove dir if it's already there.
  main.remove_wc(wc_dir_name)

  # Checkout and make a tree of the output, using l:foo/p:bar
  ### todo: svn should not be prompting for auth info when using
  ### repositories with no auth/auth requirements
  output, errput = main.run_svn (None, 'co',
                                 '--username', main.wc_author,
                                 '--password', main.wc_passwd,
                                 URL, '-d', wc_dir_name)
  mytree = tree.build_tree_from_checkout (output)

  # Verify actual output against expected output.
  if tree.compare_trees (mytree, output_tree):
    return 1

  # Create a tree by scanning the working copy
  mytree = tree.build_tree_from_wc (wc_dir_name)

  # Verify expected disk against actual disk.
  if tree.compare_trees (mytree, disk_tree,
                                 singleton_handler_a, a_baton,
                                 singleton_handler_b, b_baton):
    return 1

  return 0
Beispiel #7
0
def run_and_verify_merge2(dir,
                          rev1,
                          rev2,
                          url1,
                          url2,
                          output_tree,
                          disk_tree,
                          status_tree,
                          skip_tree,
                          error_re_string=None,
                          singleton_handler_a=None,
                          a_baton=None,
                          singleton_handler_b=None,
                          b_baton=None,
                          check_props=0,
                          dry_run=1,
                          *args):
    """Run 'svn merge URL1@REV1 URL2@REV2 DIR' if URL2 is not None
  (for a three-way merge between URLs and WC).

  If URL2 is None, run 'svn merge -rREV1:REV2 URL1 DIR'.

  If ERROR_RE_STRING, the merge must exit with error, and the error
  message must match regular expression ERROR_RE_STRING.

  Else if ERROR_RE_STRING is None, then:

  The subcommand output will be verified against OUTPUT_TREE, and the
  working copy itself will be verified against DISK_TREE.  If optional
  STATUS_TREE is given, then 'svn status' output will be compared.
  The 'skipped' merge output will be compared to SKIP_TREE.
  SINGLETON_HANDLER_A and SINGLETON_HANDLER_B will be passed to
  tree.compare_trees - see that function's doc string for more
  details.

  If CHECK_PROPS is set, then disk comparison will examine props.

  If DRY_RUN is set then a --dry-run merge will be carried out first and
  the output compared with that of the full merge.

  Returns if successful, raises on failure."""

    if isinstance(output_tree, wc.State):
        output_tree = output_tree.old_tree()
    if isinstance(disk_tree, wc.State):
        disk_tree = disk_tree.old_tree()
    if isinstance(status_tree, wc.State):
        status_tree = status_tree.old_tree()
    if isinstance(skip_tree, wc.State):
        skip_tree = skip_tree.old_tree()

    if url2:
        merge_command = ("merge", url1 + "@" + str(rev1),
                         url2 + "@" + str(rev2), dir)
    else:
        merge_command = ("merge", "-r", str(rev1) + ":" + str(rev2), url1, dir)

    if dry_run:
        pre_disk = tree.build_tree_from_wc(dir)
        dry_run_command = merge_command + ('--dry-run', )
        dry_run_command = dry_run_command + args
        out_dry, err_dry = main.run_svn(error_re_string, *dry_run_command)
        post_disk = tree.build_tree_from_wc(dir)
        try:
            tree.compare_trees(post_disk, pre_disk)
        except tree.SVNTreeError:
            print "============================================================="
            print "Dry-run merge altered working copy"
            print "============================================================="
            raise

    # Update and make a tree of the output.
    merge_command = merge_command + args
    out, err = main.run_svn(error_re_string, *merge_command)

    if (error_re_string):
        rm = re.compile(error_re_string)
        for line in err:
            match = rm.search(line)
            if match:
                return
        raise main.SVNUnmatchedError
    elif err:
        ### we should raise a less generic error here. which?
        raise Failure(err)

    if dry_run and out != out_dry:
        print "============================================================="
        print "Merge outputs differ"
        print "The dry-run merge output:"
        map(sys.stdout.write, out_dry)
        print "The full merge output:"
        map(sys.stdout.write, out)
        print "============================================================="
        raise main.SVNUnmatchedError

    def missing_skip(a, b):
        print "============================================================="
        print "Merge failed to skip: " + a.path
        print "============================================================="
        raise Failure

    def extra_skip(a, b):
        print "============================================================="
        print "Merge unexpectedly skipped: " + a.path
        print "============================================================="
        raise Failure

    myskiptree = tree.build_tree_from_skipped(out)
    tree.compare_trees(myskiptree, skip_tree, extra_skip, None, missing_skip,
                       None)

    mytree = tree.build_tree_from_checkout(out)
    verify_update(mytree, dir, output_tree, disk_tree, status_tree,
                  singleton_handler_a, a_baton, singleton_handler_b, b_baton,
                  check_props)
Beispiel #8
0
def run_and_verify_merge(dir, rev1, rev2, url,
                         output_tree, disk_tree, status_tree, skip_tree,
                         error_re_string = None,
                         singleton_handler_a = None,
                         a_baton = None,
                         singleton_handler_b = None,
                         b_baton = None,
                         check_props = 0,
                         dry_run = 1,
                         *args):

  """Run 'svn merge -rREV1:REV2 URL DIR'

  If ERROR_RE_STRING, the merge must exit with error, and the error
  message must match regular expression ERROR_RE_STRING.

  Else if ERROR_RE_STRING is None, then:

  The subcommand output will be verified against OUTPUT_TREE, and the
  working copy itself will be verified against DISK_TREE.  If optional
  STATUS_TREE is given, then 'svn status' output will be compared.
  The 'skipped' merge output will be compared to SKIP_TREE.
  SINGLETON_HANDLER_A and SINGLETON_HANDLER_B will be passed to
  tree.compare_trees - see that function's doc string for more
  details.
  
  If CHECK_PROPS is set, then disk comparison will examine props.

  If DRY_RUN is set then a --dry-run merge will be carried out first and
  the output compared with that of the full merge.
  
  Returns if successful, raises on failure."""

  if isinstance(output_tree, wc.State):
    output_tree = output_tree.old_tree()
  if isinstance(disk_tree, wc.State):
    disk_tree = disk_tree.old_tree()
  if isinstance(status_tree, wc.State):
    status_tree = status_tree.old_tree()
  if isinstance(skip_tree, wc.State):
    skip_tree = skip_tree.old_tree()

  merge_command = ('merge', '-r', rev1 + ':' + rev2, url, dir)

  if dry_run:
    pre_disk = tree.build_tree_from_wc(dir)
    dry_run_command = merge_command + ('--dry-run',)
    dry_run_command = dry_run_command + args
    out_dry, err_dry = main.run_svn(error_re_string, *dry_run_command)
    post_disk = tree.build_tree_from_wc(dir)
    try:
      tree.compare_trees(post_disk, pre_disk)
    except tree.SVNTreeError:
      print "============================================================="
      print "Dry-run merge altered working copy"
      print "============================================================="
      raise
      

  # Update and make a tree of the output.
  merge_command = merge_command + args
  out, err = main.run_svn (error_re_string, *merge_command)

  if (error_re_string):
    rm = re.compile(error_re_string)
    for line in err:
      match = rm.search(line)
      if match:
        return
    raise main.SVNUnmatchedError
  elif err:
    ### we should raise a less generic error here. which?
    raise Failure(err)

  if dry_run and out != out_dry:
    print "============================================================="
    print "Merge outputs differ"
    print "The dry-run merge output:"
    map(sys.stdout.write, out_dry)
    print "The full merge output:"
    map(sys.stdout.write, out)
    print "============================================================="
    raise main.SVNUnmatchedError

  def missing_skip(a, b):
    print "============================================================="
    print "Merge failed to skip: " + a.path
    print "============================================================="
    raise Failure
  def extra_skip(a, b):
    print "============================================================="
    print "Merge unexpectedly skipped: " + a.path
    print "============================================================="
    raise Failure

  myskiptree = tree.build_tree_from_skipped(out)
  tree.compare_trees(myskiptree, skip_tree,
                     extra_skip, None, missing_skip, None)

  mytree = tree.build_tree_from_checkout(out)
  verify_update (mytree, dir,
                 output_tree, disk_tree, status_tree,
                 singleton_handler_a, a_baton,
                 singleton_handler_b, b_baton,
                 check_props)