Merge "Populate CodeReviewCommit before passing to MergeValidators" into stable-2.9
diff --git a/Documentation/dev-plugins.txt b/Documentation/dev-plugins.txt
index d89f79e..39cd1fc 100644
--- a/Documentation/dev-plugins.txt
+++ b/Documentation/dev-plugins.txt
@@ -853,7 +853,7 @@
 == Plugin Owned Capabilities
 
 Plugins may provide their own capabilities and restrict usage of SSH
-commands to the users who are granted those capabilities.
+commands or `UiAction` to the users who are granted those capabilities.
 
 Plugins define the capabilities by overriding the `CapabilityDefinition`
 abstract class:
@@ -868,7 +868,7 @@
 }
 ----
 
-If no Guice modules are declared in the manifest, UI actions may
+If no Guice modules are declared in the manifest, capability may
 use auto-registration by providing an `@Export` annotation:
 
 [source,java]
diff --git a/Documentation/rest-api-changes.txt b/Documentation/rest-api-changes.txt
index c1bb66d..fe5d17d 100644
--- a/Documentation/rest-api-changes.txt
+++ b/Documentation/rest-api-changes.txt
@@ -1070,6 +1070,25 @@
   }
 ----
 
+[[index-change]]
+=== Index Change
+--
+'POST /changes/link:#change-id[\{change-id\}]/index'
+--
+
+Adds or updates the change in the secondary index.
+
+.Request
+----
+  POST /changes/myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940/index HTTP/1.0
+----
+
+.Response
+----
+  HTTP/1.1 204 No Content
+----
+
+
 [[reviewer-endpoints]]
 == Reviewer Endpoints
 
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/Restore.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/Restore.java
index b3641e5..99c262c 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/change/Restore.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/Restore.java
@@ -29,7 +29,6 @@
 import com.google.gerrit.server.ChangeUtil;
 import com.google.gerrit.server.IdentifiedUser;
 import com.google.gerrit.server.change.ChangeJson.ChangeInfo;
-import com.google.gerrit.server.index.ChangeIndexer;
 import com.google.gerrit.server.mail.ReplyToChangeSender;
 import com.google.gerrit.server.mail.RestoredSender;
 import com.google.gerrit.server.project.ChangeControl;
@@ -52,19 +51,19 @@
   private final RestoredSender.Factory restoredSenderFactory;
   private final Provider<ReviewDb> dbProvider;
   private final ChangeJson json;
-  private final ChangeIndexer indexer;
+  private final MergeabilityChecker mergeabilityChecker;
 
   @Inject
   Restore(ChangeHooks hooks,
       RestoredSender.Factory restoredSenderFactory,
       Provider<ReviewDb> dbProvider,
       ChangeJson json,
-      ChangeIndexer indexer) {
+      MergeabilityChecker mergeabilityChecker) {
     this.hooks = hooks;
     this.restoredSenderFactory = restoredSenderFactory;
     this.dbProvider = dbProvider;
     this.json = json;
-    this.indexer = indexer;
+    this.mergeabilityChecker = mergeabilityChecker;
   }
 
   @Override
@@ -108,8 +107,11 @@
       db.rollback();
     }
 
-    CheckedFuture<?, IOException> indexFuture =
-        indexer.indexAsync(change.getId());
+    CheckedFuture<?, IOException> f = mergeabilityChecker.newCheck()
+        .addChange(change)
+        .reindex()
+        .runAsync();
+
     try {
       ReplyToChangeSender cm = restoredSenderFactory.create(change);
       cm.setFrom(caller.getAccountId());
@@ -124,7 +126,7 @@
         Strings.emptyToNull(input.message),
         dbProvider.get());
     ChangeInfo result = json.format(change);
-    indexFuture.checkedGet();
+    f.checkedGet();
     return result;
   }