summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <dpursehouse@collab.net>2016-08-18 10:29:14 +0900
committerDavid Pursehouse <dpursehouse@collab.net>2016-08-18 10:41:24 +0900
commit9865f4735dee61e505698577aa56923abe00e480 (patch)
tree3267df35f9ed09fd679b945bcc63b53820f01fac
parentb9c11b4d4ed37f566e6e2daa11d96e1ca3d23c02 (diff)
parent51d6be2b49b8136d594309743edf26a74948bd23 (diff)
Merge branch 'stable-2.12'
* stable-2.12: Destination: Consider ref visibility when scheduling replication On master the isVisibilty method was renamed to shouldReplicate and has additional logic to check for replication of hidden projects. Rename the newly added isVisibility method to shouldReplicate to be consistent. Move the hidden projects logic to a utility method and use it in both shouldReplicate methods. Change-Id: I7b713636164fd78425561a98a1f50182c9501f4a
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
index 3e615d5..06cbe33 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
@@ -199,15 +199,39 @@ public class Destination {
return cnt;
}
- private boolean shouldReplicate(final Project.NameKey project,
+ private boolean shouldReplicate(ProjectControl projectControl) {
+ return projectControl.isReadable() && (!projectControl.isHidden()
+ || config.replicateHiddenProjects());
+ }
+
+ private boolean shouldReplicate(final Project.NameKey project, final String ref,
ReplicationState... states) {
try {
return threadScoper.scope(new Callable<Boolean>() {
@Override
public Boolean call() throws NoSuchProjectException {
ProjectControl projectControl = controlFor(project);
- return projectControl.isReadable() && (!projectControl.isHidden()
- || config.replicateHiddenProjects());
+ return shouldReplicate(projectControl)
+ && (PushOne.ALL_REFS.equals(ref)
+ || projectControl.controlForRef(ref).isVisible());
+ }
+ }).call();
+ } catch (NoSuchProjectException err) {
+ stateLog.error(String.format("source project %s not available", project),
+ err, states);
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ return false;
+ }
+
+ private boolean shouldReplicate(final Project.NameKey project,
+ ReplicationState... states) {
+ try {
+ return threadScoper.scope(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws NoSuchProjectException {
+ return shouldReplicate(controlFor(project));
}
}).call();
} catch (NoSuchProjectException err) {
@@ -223,7 +247,7 @@ public class Destination {
void schedule(Project.NameKey project, String ref, URIish uri,
ReplicationState state) {
repLog.info("scheduling replication {}:{} => {}", project, ref, uri);
- if (!shouldReplicate(project, state)) {
+ if (!shouldReplicate(project, ref, state)) {
return;
}