Package com.google.devtools.moe.client.migrations

Examples of com.google.devtools.moe.client.migrations.MigrationConfig


   */
  public static int bookkeep(List<String> migrationNames, Db db, String dbLocation,
                             ProjectContext context) {
    Ui.Task t = AppContext.RUN.ui.pushTask("perform_checks", "Updating database");
    for (String s : migrationNames) {
      MigrationConfig m = context.migrationConfigs.get(s);
      if (m == null) {
        AppContext.RUN.ui.error(String.format("No migration '%s' in MOE config", s));
        return 1;
      }

      Ui.Task bookkeepOneMigrationTask = AppContext.RUN.ui.pushTask(
          "bookkeping_one_migration",
          String.format("Doing bookkeeping between '%s' and '%s' for migration '%s'",
                        m.getFromRepository(), m.getToRepository(), m.getName()));

      TranslatorConfig migrationTranslator =
          getTranslatorConfig(m.getFromRepository(), m.getToRepository(), context);

      // TODO(user): ? Switch the order of these two checks, so that we don't have to look back
      // through the history for irrelevant equivalences if there's one at head.
      Ui.Task checkMigrationsTask = AppContext.RUN.ui.pushTask(
          "check_migrations",
          String.format(
              "Checking completed migrations for new equivalence between '%s' and '%s'",
              m.getFromRepository(), m.getToRepository()));
      updateCompletedMigrations(
          m.getFromRepository(), m.getToRepository(), db, context,
          migrationTranslator.isInverse());
      AppContext.RUN.ui.popTask(checkMigrationsTask, "");

      // Skip head-equivalence checking for inverse translation -- assume it will be performed via
      // the forward-translated migration.
      if (!migrationTranslator.isInverse()) {
        Ui.Task checkHeadsTask = AppContext.RUN.ui.pushTask(
            "check_heads",
            String.format(
                "Checking head equivalence between '%s' and '%s'",
                m.getFromRepository(), m.getToRepository()));
        updateHeadEquivalence(m.getFromRepository(), m.getToRepository(), db, context);
        AppContext.RUN.ui.popTask(checkHeadsTask, "");
      }

      AppContext.RUN.ui.popTask(bookkeepOneMigrationTask, "");
    }
View Full Code Here


    for (String migrationName : migrationNames) {
      Ui.Task migrationTask = AppContext.RUN.ui.pushTask(
          "perform_migration",
          String.format("Performing migration '%s'", migrationName));

      MigrationConfig migrationConfig = context.migrationConfigs.get(migrationName);
      if (migrationConfig == null) {
        AppContext.RUN.ui.error("No migration found with name " + migrationName);
        continue;
      }

      List<Migration> migrations =
          DetermineMigrationsLogic.determineMigrations(context, migrationConfig, db);

      if (migrations.isEmpty()) {
        AppContext.RUN.ui.info("No pending revisions to migrate for " + migrationName);
        continue;
      }

      Equivalence lastEq = migrations.get(0).sinceEquivalence;
      // toRe represents toRepo at the revision of last equivalence with fromRepo.
      RepositoryExpression toRe = new RepositoryExpression(migrationConfig.getToRepository());
      if (lastEq != null) {
        toRe = toRe.atRevision(
            lastEq.getRevisionForRepository(migrationConfig.getToRepository()).revId);
      }

      Writer toWriter;
      try {
        toWriter = toRe.createWriter(context);
      } catch (WritingError e) {
        throw new MoeProblem("Couldn't create local repo " + toRe + ": " + e);
      }

      DraftRevision dr = null;
      Revision lastMigratedRevision = null;
      if (lastEq != null) {
        lastMigratedRevision = lastEq.getRevisionForRepository(migrationConfig.getFromRepository());
      }

      for (Migration m : migrations) {
        // For each migration, the reference to-codebase for inverse translation is the Writer,
        // since it contains the latest changes (i.e. previous migrations) to the to-repository.
        Expression referenceToCodebase = new RepositoryExpression(migrationConfig.getToRepository())
              .withOption("localroot", toWriter.getRoot().getAbsolutePath());

        Ui.Task oneMigrationTask = AppContext.RUN.ui.pushTask(
            "perform_individual_migration",
            String.format("Performing individual migration '%s'", m.toString()));
        dr = OneMigrationLogic.migrate(m, context, toWriter, referenceToCodebase);
        lastMigratedRevision = m.fromRevisions.get(m.fromRevisions.size() - 1);
        AppContext.RUN.ui.popTask(oneMigrationTask, "");
      }

      // TODO(user): Add properly formatted one-DraftRevison-per-Migration message for svn.
      migrationsMadeBuilder.add(String.format(
          "%s in repository %s", dr.getLocation(), migrationConfig.getToRepository()));
      toWriter.printPushMessage();
      AppContext.RUN.ui.popTaskAndPersist(migrationTask, toWriter.getRoot());
    }

    List<String> migrationsMade = migrationsMadeBuilder.build();
View Full Code Here

        AppContext.RUN.ui.error(e, "Error creating DB");
        return 1;
      }
    }

    MigrationConfig config = context.migrationConfigs.get(options.migrationName);
    if (config == null) {
      AppContext.RUN.ui.error("No migration found with name " + options.migrationName);
      return 1;
    }
View Full Code Here

TOP

Related Classes of com.google.devtools.moe.client.migrations.MigrationConfig

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.