Package com.google.devtools.moe.client

Examples of com.google.devtools.moe.client.MoeProblem


    try {
      fs.makeDirsForFile(mergedFile);
      fs.copyFile(destFile, mergedFile);
      return mergedFile;
    } catch (IOException e) {
      throw new MoeProblem(e.getMessage());
    }
  }
View Full Code Here


    boolean modExists = fs.exists(modFile);

    if (!destExists && !modExists) {
      // This should never be thrown since generateMergedFile(...) is only called on filesToMerge
      // from merge() which is the union of the files in the destination and modified codebases.
      throw new MoeProblem(
          String.format("%s doesn't exist in either %s nor %s. This should not be possible.",
          filename, destinationCodebase, modifiedCodebase));

    } else if (origExists && modExists && !destExists) {
      if (areDifferent(filename, origFile, modFile)) {
        // Proceed and merge in /dev/null, which should produce a merge conflict (incoming edit on
        // delete).
        destFile = new File("/dev/null");
      } else {
        // Defer to deletion in destination codebase.
        return;
      }

    } else if (origExists && !modExists && destExists) {
      // Blindly follow deletion of the original file by not copying it into the merged codebase.
      return;

    } else if (!origExists && !(modExists && destExists)) {
      // File exists only in modified or destination codebase, so just copy it over.
      File existingFile = (modExists ? modFile : destFile);
      copyToMergedCodebase(filename, existingFile);
      return;

    } else if (!origExists && modExists && destExists) {
      // Merge both new files (conflict expected).
      origFile = new File("/dev/null");
    }

    File mergedFile = copyToMergedCodebase(filename, destFile);

    String mergeOutput;
    try {
      // Merges the changes that lead from origFile to modFile into mergedFile (which is a copy
      // of destFile). After, mergedFile will have the combined changes of modFile and destFile.
      mergeOutput = AppContext.RUN.cmd.runCommand("merge", ImmutableList.of(
          mergedFile.getAbsolutePath(), origFile.getAbsolutePath(), modFile.getAbsolutePath()),
          this.mergedCodebase.getPath().getAbsolutePath());
      // Return status was 0 and the merge was successful. Note it.
      mergedFiles.add(mergedFile.getAbsolutePath().toString());
    } catch (CommandException e) {
      // If merge fails with exit status 1, then a conflict occurred. Make a note of the filepath.
      if (e.returnStatus == 1) {
        failedToMergeFiles.add(mergedFile.getAbsolutePath().toString());
      } else {
        throw new MoeProblem(
            String.format(
                "Merge returned with unexpected status %d when trying to run \"merge -p %s %s %s\"",
                e.returnStatus,
                destFile.getAbsolutePath(),
                origFile.getAbsolutePath(),
View Full Code Here

   *
   * @throws MoeProblem  if in a different project space
   */
  public void checkProjectSpace(String projectSpace) {
    if (!this.getProjectSpace().equals(projectSpace)) {
      throw new MoeProblem(
          String.format(
              "Expected project space \"%s\", but Codebase \"%s\" is in project space \"%s\"",
              projectSpace, toString(), this.projectSpace));
    }
  }
View Full Code Here

TOP

Related Classes of com.google.devtools.moe.client.MoeProblem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.