Use change number instead of triplet.
The change number is unique. The triplet is not guaranteed to be
unique. This can cause us to throw 404s when we have non-unique
triplets.
Change-Id: I9f83b456eb47452dce88b27c62c8a38a89c7fa26
diff --git a/src/main/java/com/googlesource/gerrit/plugins/automerger/AutomergeChangeAction.java b/src/main/java/com/googlesource/gerrit/plugins/automerger/AutomergeChangeAction.java
index 0990ec5..d27638e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/automerger/AutomergeChangeAction.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/automerger/AutomergeChangeAction.java
@@ -71,7 +71,7 @@
MultipleDownstreamMergeInput mdsMergeInput = new MultipleDownstreamMergeInput();
mdsMergeInput.dsBranchMap = branchMap;
- mdsMergeInput.sourceId = change.getKey().get();
+ mdsMergeInput.sourceId = change.getId().get();
mdsMergeInput.project = change.getProject().get();
mdsMergeInput.topic = change.getTopic();
mdsMergeInput.subject = change.getSubject();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreator.java b/src/main/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreator.java
index a2ce9fe..fcfb82f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreator.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreator.java
@@ -424,7 +424,7 @@
MultipleDownstreamMergeInput mdsMergeInput = new MultipleDownstreamMergeInput();
mdsMergeInput.dsBranchMap = dsBranchMap;
- mdsMergeInput.sourceId = change.id;
+ mdsMergeInput.sourceId = change._number;
mdsMergeInput.project = change.project;
mdsMergeInput.topic = change.topic;
mdsMergeInput.subject = change.subject;
@@ -524,7 +524,7 @@
gApi.changes().id(changeNumber).abandon(abandonInput);
}
- private String setTopic(String sourceId, String topic) throws RestApiException {
+ private String setTopic(int sourceId, String topic) throws RestApiException {
if (topic == null || topic.isEmpty()) {
topic = "am-" + UUID.randomUUID().toString();
log.debug("Setting original change {} topic to {}", sourceId, topic);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/automerger/MultipleDownstreamMergeInput.java b/src/main/java/com/googlesource/gerrit/plugins/automerger/MultipleDownstreamMergeInput.java
index 99903d1..f836307 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/automerger/MultipleDownstreamMergeInput.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/automerger/MultipleDownstreamMergeInput.java
@@ -21,7 +21,7 @@
*/
public class MultipleDownstreamMergeInput {
public Map<String, Boolean> dsBranchMap;
- public String sourceId;
+ public int sourceId;
public String project;
public String topic;
public String subject;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/automerger/SingleDownstreamMergeInput.java b/src/main/java/com/googlesource/gerrit/plugins/automerger/SingleDownstreamMergeInput.java
index 8f923b9..51fde18 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/automerger/SingleDownstreamMergeInput.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/automerger/SingleDownstreamMergeInput.java
@@ -17,7 +17,7 @@
/** Class to hold input for a merge for a single source change and destination branch. */
public class SingleDownstreamMergeInput {
public String currentRevision;
- public String sourceId;
+ public int sourceId;
public String project;
public String topic;
public String subject;