Package com.google.devtools.moe.client.codebase

Examples of com.google.devtools.moe.client.codebase.Codebase


  }

  @Override
  public Codebase translate(
      Codebase toTranslate, Map<String, String> options, ProjectContext context) {
    Codebase translated = toTranslate;
    for (TranslatorStep s : steps) {
      Ui.Task editTask = AppContext.RUN.ui.pushTask("edit", "Translation editor: " + s.name);
      // Pass the translation options to each editor.
      translated = s.editor.edit(translated, context, options);
      AppContext.RUN.ui.popTaskAndPersist(editTask, translated.getPath());
    }
    return translated;
  }
View Full Code Here


      return 1;
    }

    List<Revision> revs = Revision.fromRepositoryExpression(fromRepoEx, context);

    Codebase c;
    try {
      c = new RepositoryExpression(fromRepoEx.getRepositoryName())
          .atRevision(revs.get(0).revId)
          .translateTo(toProjectSpace)
          .createCodebase(context);
View Full Code Here

      AppContext.RUN.cmd.runCommand("bash", ImmutableList.of("-c", this.commandString),
          tempDir.getAbsolutePath());
    } catch (CommandRunner.CommandException e) {
      throw new MoeProblem(e.getMessage());
    }
    return new Codebase(tempDir, input.getProjectSpace(), input.getExpression());
  }
View Full Code Here

    this.translateOp = translateOp;
  }

  @Override
  public Codebase createCodebase(ProjectContext context) throws CodebaseCreationError {
    Codebase codebaseToTranslate = exToTranslate.createCodebase(context);
    String toProjectSpace = translateOp.term.identifier;
    TranslatorPath path = new TranslatorPath(
        codebaseToTranslate.getProjectSpace(), toProjectSpace);
    Translator translator = context.translators.get(path);
    if (translator == null) {
      throw new CodebaseCreationError(
          String.format("Could not find translator from project space \"%s\" to \"%s\"",
                        codebaseToTranslate.getProjectSpace(), toProjectSpace));
    }

    Ui.Task translateTask = AppContext.RUN.ui.pushTask(
        "translate",
        String.format(
            "Translating %s from project space \"%s\" to \"%s\"",
            codebaseToTranslate.getPath(), codebaseToTranslate.getProjectSpace(), toProjectSpace));

    Codebase translatedCodebase =
        translator.translate(codebaseToTranslate, translateOp.term.options, context);

    // Don't mark the translated codebase for persistence if it wasn't allocated by the Translator.
    if (translatedCodebase.equals(codebaseToTranslate)) {
      AppContext.RUN.ui.popTask(translateTask, translatedCodebase.getPath() + " (unmodified)");
    } else {
      AppContext.RUN.ui.popTaskAndPersist(translateTask, translatedCodebase.getPath());
    }
    return translatedCodebase.copyWithExpression(this).copyWithProjectSpace(toProjectSpace);
  }
View Full Code Here

      return 1;
    }

    Task createCodebaseTask =
        AppContext.RUN.ui.pushTask("create_codebase", "Creating codebase " + options.codebase);
    Codebase c;
    try {
      c = Parser.parseExpression(options.codebase).createCodebase(context);
    } catch (ParseError e) {
      AppContext.RUN.ui.error(e, "Error creating codebase");
      return 1;
    } catch (CodebaseCreationError e) {
      AppContext.RUN.ui.error(e, "Error creating codebase");
      return 1;
    }
    AppContext.RUN.ui.info(
        String.format("Codebase \"%s\" created at %s", c.toString(), c.getPath()));

    try {
      maybeWriteTar(c);
    } catch (CommandException e) {
      AppContext.RUN.ui.error(e, "Error creating codebase tarfile");
      return 1;
    }

    AppContext.RUN.ui.popTaskAndPersist(createCodebaseTask, c.getPath());
    return 0;
  }
View Full Code Here

    File codebasePath = getCodebasePath(new File(source));
    String projectSpace = options.containsKey(PROJECT_SPACE_OPTION)
                          ? options.get(PROJECT_SPACE_OPTION)
                          : "public";
    RepositoryExpression expression = new RepositoryExpression(new Term("file", options));
    return new Codebase(codebasePath, projectSpace, expression);
  }
View Full Code Here

    } catch (InvalidProject e) {
      AppContext.RUN.ui.error(e, "Error creating project");
      return 1;
    }

    Codebase originalCodebase, destinationCodebase, modifiedCodebase;
    try {
      originalCodebase = Parser.parseExpression(options.originalCodebase).createCodebase(context);
      modifiedCodebase = Parser.parseExpression(options.modifiedCodebase).createCodebase(context);
      destinationCodebase =
          Parser.parseExpression(options.destinationCodebase).createCodebase(context);
    } catch (ParseError e) {
      AppContext.RUN.ui.error(e, "Error parsing");
      return 1;
    } catch (CodebaseCreationError e) {
      AppContext.RUN.ui.error(e, "Error creating codebase");
      return 1;
    }
    Codebase mergedCodebase = MergeCodebasesLogic.merge(originalCodebase, destinationCodebase,
        modifiedCodebase);

    return 0;
  }
View Full Code Here

    expect(mockRepo.archiveAtRevision("mock head changeset ID"))
        .andReturn(new File(archiveTempDir));

    control.replay();

    Codebase codebase = codebaseCreator.create(Collections.<String, String>emptyMap());

    assertEquals(new File(archiveTempDir), codebase.getPath());
    assertEquals("public", codebase.getProjectSpace());
    assertEquals("mockrepo", codebase.getExpression().toString());

    control.verify();
  }
View Full Code Here

    if (revId == null) {
      revId = "1";
    }


    return new Codebase(
        new File("/dummy/codebase/" + name + "/" + revId),
        projectSpace,
        new RepositoryExpression(new Term(name, ImmutableMap.<String, String>of())));
  }
View Full Code Here

        .andReturn(new Revision(givenRev, MOCK_REPO_NAME));
    expect(mockRepo.archiveAtRevision(givenRev)).andReturn(new File(archiveTempDir));

    control.replay();

    Codebase codebase = codebaseCreator.create(ImmutableMap.of("revision", givenRev));

    assertEquals(new File(archiveTempDir), codebase.getPath());
    assertEquals("public", codebase.getProjectSpace());
    assertEquals("mockrepo(revision=" + givenRev + ")", codebase.getExpression().toString());

    control.verify();
  }
View Full Code Here

TOP

Related Classes of com.google.devtools.moe.client.codebase.Codebase

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.