Package com.google.devtools.moe.client

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


    try {
      SvnRepository.runSvnCommand(
          ImmutableList.of(
              "co", "-r", revision.revId, config.getUrl(), rootDirectory.getAbsolutePath()), "");
    } catch (CommandRunner.CommandException e) {
      throw new MoeProblem("Could not check out from svn: " + e.stderr);
    }
  }
View Full Code Here


        "--template={node} {branch}\n");
    String heads;
    try {
      heads = HgRepository.runHgCommand(args, tipClone.getLocalTempDir().getAbsolutePath());
    } catch (CommandException e) {
      throw new MoeProblem(
          String.format("Failed hg run: %s %d %s %s",
                        args.toString(),
                        e.returnStatus,
                        e.stdout,
                        e.stderr));
View Full Code Here

      boolean srcExecutable = fs.isExecutable(src);
      boolean destExecutable = fs.isExecutable(dest);

      if (!srcExists && !destExists) {
        throw new MoeProblem(
            String.format("Neither src nor dests exists. Unreachable code:%n%s%n%s%n%s",
                          relativeFilename, src, dest));
      }

      if (!srcExists) {
        SvnRepository.runSvnCommand(
            ImmutableList.of("rm", relativeFilename), rootDirectory.getAbsolutePath());
        // TODO(dbentley): handle newly-empty directories
        return;
      }

      try {
        fs.makeDirsForFile(dest);
        fs.copyFile(src, dest);
      } catch (IOException e) {
        throw new MoeProblem(e.getMessage());
      }

      if (!destExists) {
        SvnRepository.runSvnCommand(
            ImmutableList.of("add", "--parents", relativeFilename),
            rootDirectory.getAbsolutePath());
      }

      String mimeType = guessMimeType(relativeFilename);
      if (mimeType != null) {
        try {
          SvnRepository.runSvnCommand(
              ImmutableList.of("propset", "svn:mime-type", mimeType, relativeFilename),
              rootDirectory.getAbsolutePath());
        } catch (CommandRunner.CommandException e) {
          // If the mime type setting fails, it's not really a big deal.
          // Just log it and keep going.
          AppContext.RUN.ui.info(
              String.format("Error setting mime-type for %s", relativeFilename));
        }
      }

      if (destExecutable != srcExecutable) {
        if (srcExecutable) {
          SvnRepository.runSvnCommand(
              ImmutableList.of("propset", "svn:executable", "*", relativeFilename),
              rootDirectory.getAbsolutePath());
        } else {
          SvnRepository.runSvnCommand(
              ImmutableList.of("propdel", "svn:executable", relativeFilename),
              rootDirectory.getAbsolutePath());
        }
      }
    } catch (CommandRunner.CommandException e) {
      throw new MoeProblem("problem occurred while running svn: " + e.stderr);
    }
  }
View Full Code Here

    try {
      SvnRepository.runSvnCommand(ImmutableList.of(
          "export", config.getUrl(), "-r", rev.revId, exportPath.getAbsolutePath()), "");
    } catch (CommandRunner.CommandException e) {
      throw new MoeProblem("could not export from svn" + e.getMessage());
    }

    // Filter codebase by ignore_file_res.
    final Predicate<CharSequence> nonIgnoredFilePred =
        Utils.nonMatchingPredicateFromRes(config.getIgnoreFileRes());
View Full Code Here

  protected boolean hasPendingChanges() {
    try {
      String statusStdout = revClone.runHgCommand("status");
      return !Strings.isNullOrEmpty(statusStdout);
    } catch (CommandException e) {
      throw new MoeProblem("Error in hg status: " + e);
    }
  }
View Full Code Here

          .translateTo(toProjectSpace)
          .withReferenceToCodebase(referenceToCodebase)
          .createCodebase(context);

    } catch (InvalidProject e) {
      throw new MoeProblem(e.getMessage());
    } catch (CodebaseCreationError e) {
      throw new MoeProblem(e.getMessage());
    }

    MetadataScrubberConfig sc = migration.config.getMetadataScrubberConfig();
    RevisionMetadata metadata = (sc == null)
        ? DetermineMetadataLogic.determine(context, migration.fromRevisions, mostRecentFromRev)
View Full Code Here

    if (patchFilePath == null || patchFilePath.equals("")) {
      return input;
    } else {
      File patchFile = new File(patchFilePath);
      if (!AppContext.RUN.fileSystem.isReadable(patchFile)) {
        throw new MoeProblem(String.format(
            "cannot read file %s", patchFilePath));
      }
      try {
       Utils.copyDirectory(input.getPath(), tempDir);
      } catch (IOException e) {
        throw new MoeProblem(e.getMessage());
      } catch (CommandRunner.CommandException e) {
        throw new MoeProblem(e.getMessage());
      }
      try {
        AppContext.RUN.cmd.runCommand(
            "patch",
            ImmutableList.of(
                "-p0",
                "--input=" + patchFilePath),
            tempDir.getAbsolutePath());
      } catch (CommandRunner.CommandException e) {
        throw new MoeProblem(e.getMessage());
      }
      return new Codebase(tempDir, input.getProjectSpace(), input.getExpression());
    }
  }
View Full Code Here

    String log;
    try {
      log = SvnRepository.runSvnCommand(args, "");
    } catch (CommandException e) {
      throw new MoeProblem(
          String.format("Failed svn run: %s %d %s %s", args.toString(), e.returnStatus,
              e.stdout, e.stderr));
    }

    List<Revision> revisions = parseRevisions(log, name);
View Full Code Here

        String revId = nl.item(i).getAttributes().getNamedItem("revision").getNodeValue();
        resultBuilder.add(new Revision(revId, repositoryName));
      }
      return resultBuilder.build();
    } catch (Exception e) {
      throw new MoeProblem("Could not parse xml log: " + log + e.getMessage());
    }
  }
View Full Code Here

   * @param revision  the revision to get metadata for
   */
  @Override
  public RevisionMetadata getMetadata(Revision revision) throws MoeProblem {
    if (!name.equals(revision.repositoryName)) {
      throw new MoeProblem(
          String.format("Could not get metadata: Revision %s is in repository %s instead of %s",
                        revision.revId, revision.repositoryName, name));
    }
    // svn log command for output in xml format for 2 log entries, for revision and its parent
    ImmutableList<String> args = ImmutableList.of("log", "--xml", "-l", "2", "-r",
        revision.revId + ":1", url);
    String log;
    try {
      log = SvnRepository.runSvnCommand(args, "");
    } catch (CommandException e) {
      throw new MoeProblem(
          String.format("Failed svn run: %s %d %s %s", args.toString(), e.returnStatus,
              e.stdout, e.stderr));
    }
    List<RevisionMetadata> metadata = parseMetadata(log);
    return metadata.get(0);
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.