예제 #1
0
파일: main.py 프로젝트: pirapu/raj
def compare_unordered_output(expected, actual):
  """Compare lists of output lines for equality disregarding the
     order of the lines"""
  if len(actual) != len(expected):
    raise Failure("Length of expected output not equal to actual length")
  for aline in actual:
    try:
      i = expected.index(aline)
      expected.pop(i)
    except ValueError:
      raise Failure("Expected output does not match actual output")
예제 #2
0
파일: actions.py 프로젝트: pirapu/raj
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)
예제 #3
0
파일: main.py 프로젝트: pirapu/raj
 def build(self, name = None, create_wc = True):
   if name != None:
     self._set_name(name)
   if actions.make_repo_and_wc(self, create_wc):
     raise Failure("Could not build repository and sandbox '%s'" % self.name)
예제 #4
0
 def build(self):
     if actions.make_repo_and_wc(self):
         raise Failure("Could not build repository and sandbox '%s'" %
                       self.name)
예제 #5
0
파일: main.py 프로젝트: yinjinzhong/mycode
 def build(self, name=None, create_wc=True, read_only=False):
     self._set_name(name, read_only)
     if actions.make_repo_and_wc(self, create_wc, read_only):
         raise Failure("Could not build repository and sandbox '%s'" %
                       self.name)
예제 #6
0
파일: main.py 프로젝트: yinjinzhong/mycode
def _check_command_line_parsed():
    """Raise an exception if the command line has not yet been parsed."""
    if not command_line_parsed:
        raise Failure(
            "Condition cannot be tested until command line is parsed")