<commit_before>/*
 * Copyright (c) 2011 Google, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.devtools.moe.client.directives;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.devtools.moe.client.MoeProblem;
import com.google.devtools.moe.client.MoeUserProblem;
import com.google.devtools.moe.client.Ui;
import com.google.devtools.moe.client.codebase.Codebase;
import com.google.devtools.moe.client.codebase.CodebaseCreationError;
import com.google.devtools.moe.client.database.RepositoryEquivalence;
import com.google.devtools.moe.client.database.RepositoryEquivalenceMatcher.Result;
import com.google.devtools.moe.client.migrations.Migration;
import com.google.devtools.moe.client.migrations.MigrationConfig;
import com.google.devtools.moe.client.migrations.Migrator;
import com.google.devtools.moe.client.parser.Expression;
import com.google.devtools.moe.client.parser.RepositoryExpression;
import com.google.devtools.moe.client.project.ProjectConfig;
import com.google.devtools.moe.client.project.ProjectContext;
import com.google.devtools.moe.client.project.RepositoryConfig;
import com.google.devtools.moe.client.project.ScrubberConfig;
import com.google.devtools.moe.client.repositories.Repositories;
import com.google.devtools.moe.client.repositories.RepositoryType;
import com.google.devtools.moe.client.repositories.Revision;
import com.google.devtools.moe.client.repositories.RevisionHistory;
import com.google.devtools.moe.client.repositories.RevisionMetadata;
import com.google.devtools.moe.client.translation.editors.Editor;
import com.google.devtools.moe.client.translation.pipeline.TranslationPath;
import com.google.devtools.moe.client.translation.pipeline.TranslationPipeline;
import com.google.devtools.moe.client.writer.DraftRevision;
import com.google.devtools.moe.client.writer.Writer;
import com.google.devtools.moe.client.writer.WritingError;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import java.io.File;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import org.kohsuke.args4j.Option;

/**
 * Perform a one-directional merge from a branch (and specified branch point) onto the head
 * of the target repository.
 *
 * <p>This is effectively works like the {@link MagicDirective} except that it only passes in one
 * direction, and does no bookkeeping.
 */
public class MigrateBranchDirective extends Directive {
  @Option(name = "--db", required = false, usage = "Location of MOE database")
  private final String dbLocation = "";

  // TODO(cgruber) determine this from implicit signals.
  @Option(name = "--from_repository", required = true, usage = "The label of the source repository")
  private final String registeredFromRepository = "";

  @Option(name = "--branch", required = true, usage = "the symbolic name of the imported branch")
  private final String branchLabel = "";

  @Option(
    name = "--override_repository_url",
    required = false,
    usage = "the repository url to use in the case that the branch is in a fork of the repository"
  )
  private final String overrideUrl = "";

  private final ProjectConfig config;
  private final ProjectContext context;
  private final Repositories repositories;
  private final Ui ui;
  private final Migrator migrator;

  File resultDirectory;

  @Inject
  MigrateBranchDirective(
      ProjectConfig config,
      ProjectContext context,
      Repositories repositories,
      Ui ui,
      Migrator migrator) {
    this.config = config;
    this.context = context;
    this.repositories = repositories;
    this.ui = ui;
    this.migrator = migrator;
  }

  @Override
  protected int performDirectiveBehavior() {
    return performBranchMigration(registeredFromRepository, branchLabel, overrideUrl);
  }<commit_msg>Remove final from @Option fields in MigrateBranchDirective. They cannot be set from the CLI otherwise.<commit_after>/*
 * Copyright (c) 2011 Google, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.devtools.moe.client.directives;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.devtools.moe.client.MoeProblem;
import com.google.devtools.moe.client.MoeUserProblem;
import com.google.devtools.moe.client.Ui;
import com.google.devtools.moe.client.codebase.Codebase;
import com.google.devtools.moe.client.codebase.CodebaseCreationError;
import com.google.devtools.moe.client.database.RepositoryEquivalence;
import com.google.devtools.moe.client.database.RepositoryEquivalenceMatcher.Result;
import com.google.devtools.moe.client.migrations.Migration;
import com.google.devtools.moe.client.migrations.MigrationConfig;
import com.google.devtools.moe.client.migrations.Migrator;
import com.google.devtools.moe.client.parser.Expression;
import com.google.devtools.moe.client.parser.RepositoryExpression;
import com.google.devtools.moe.client.project.ProjectConfig;
import com.google.devtools.moe.client.project.ProjectContext;
import com.google.devtools.moe.client.project.RepositoryConfig;
import com.google.devtools.moe.client.project.ScrubberConfig;
import com.google.devtools.moe.client.repositories.Repositories;
import com.google.devtools.moe.client.repositories.RepositoryType;
import com.google.devtools.moe.client.repositories.Revision;
import com.google.devtools.moe.client.repositories.RevisionHistory;
import com.google.devtools.moe.client.repositories.RevisionMetadata;
import com.google.devtools.moe.client.translation.editors.Editor;
import com.google.devtools.moe.client.translation.pipeline.TranslationPath;
import com.google.devtools.moe.client.translation.pipeline.TranslationPipeline;
import com.google.devtools.moe.client.writer.DraftRevision;
import com.google.devtools.moe.client.writer.Writer;
import com.google.devtools.moe.client.writer.WritingError;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
import java.io.File;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import org.kohsuke.args4j.Option;

/**
 * Perform a one-directional merge from a branch (and specified branch point) onto the head
 * of the target repository.
 *
 * <p>This is effectively works like the {@link MagicDirective} except that it only passes in one
 * direction, and does no bookkeeping.
 */
public class MigrateBranchDirective extends Directive {
  @Option(name = "--db", required = false, usage = "Location of MOE database")
  private String dbLocation = "";

  // TODO(cgruber) determine this from implicit signals.
  @Option(name = "--from_repository", required = true, usage = "The label of the source repository")
  private String registeredFromRepository = "";

  @Option(name = "--branch", required = true, usage = "the symbolic name of the imported branch")
  private String branchLabel = "";

  @Option(
    name = "--override_repository_url",
    required = false,
    usage = "the repository url to use in the case that the branch is in a fork of the repository"
  )
  private String overrideUrl = "";

  private final ProjectConfig config;
  private final ProjectContext context;
  private final Repositories repositories;
  private final Ui ui;
  private final Migrator migrator;

  File resultDirectory;

  @Inject
  MigrateBranchDirective(
      ProjectConfig config,
      ProjectContext context,
      Repositories repositories,
      Ui ui,
      Migrator migrator) {
    this.config = config;
    this.context = context;
    this.repositories = repositories;
    this.ui = ui;
    this.migrator = migrator;
  }

  @Override
  protected int performDirectiveBehavior() {
    return performBranchMigration(registeredFromRepository, branchLabel, overrideUrl);
  }
{'fraction_non_alphanumeric': 0.0962671905697446, 'fraction_numerical': 0.0018612346189639127, 'mean_word_length': 4.915596330275229, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6820945', 'n_tokens_mistral': 2845, 'n_tokens_neox': 2786, 'n_words': 721}