Merge branch 'stable-2.9'

* stable-2.9:
  Recheck change mergeability status on restore
  Add missing documentation of changes REST API index endpoint
  Update plugin owned capabilities documentation
  Populate CodeReviewCommit before passing to MergeValidators

Change-Id: Ia65a58b137f29b4c21b4c8cc44fb3b12033fc62c
This commit is contained in:
David Pursehouse 2014-06-02 23:36:53 +09:00
commit 2f25904b06
4 changed files with 39 additions and 17 deletions

View File

@ -853,7 +853,7 @@ public class MyListener implements GitReferenceUpdatedListener {
== 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 @@ public class PrintHelloCapability extends CapabilityDefinition {
}
----
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]

View File

@ -1119,6 +1119,25 @@ an link:#included-in-info[IncludedInInfo] entity is returned.
}
----
[[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

View File

@ -29,7 +29,6 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
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;
@ -54,19 +53,19 @@ public class Restore implements RestModifyView<ChangeResource, RestoreInput>,
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
@ -110,8 +109,11 @@ public class Restore implements RestModifyView<ChangeResource, RestoreInput>,
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());
@ -126,7 +128,7 @@ public class Restore implements RestModifyView<ChangeResource, RestoreInput>,
Strings.emptyToNull(input.message),
dbProvider.get());
ChangeInfo result = json.format(change);
indexFuture.checkedGet();
f.checkedGet();
return result;
}

View File

@ -520,6 +520,15 @@ public class MergeOp {
continue;
}
try {
commit.setControl(changeControlFactory.controlFor(chg,
identifiedUserFactory.create(chg.getOwner())));
} catch (NoSuchChangeException e) {
throw new MergeException("Failed to validate changes", e);
}
commit.setPatchsetId(ps.getId());
commit.originalOrder = commitOrder++;
MergeValidators mergeValidators = mergeValidatorsFactory.create();
try {
mergeValidators.validatePreMerge(repo, commit, destProject, destBranch, ps.getId());
@ -529,14 +538,6 @@ public class MergeOp {
continue;
}
try {
commit.setControl(changeControlFactory.controlFor(chg,
identifiedUserFactory.create(chg.getOwner())));
} catch (NoSuchChangeException e) {
throw new MergeException("Failed to validate changes", e);
}
commit.setPatchsetId(ps.getId());
commit.originalOrder = commitOrder++;
commits.put(changeId, commit);
if (branchTip != null) {