diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-04-22 17:44:00 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-05-27 16:41:11 +0000 |
commit | ab66f12e2ae6882b4679904caa364576fbb38986 (patch) | |
tree | 486e2242d3fc5b8ce7a0e714b5fead40dcfb6ced | |
parent | 96c094f73f8c85e8fd6a4944d5bc7dfea09d1b53 (diff) |
Port plugin core functionality to Gerrit v3.1.4 API
Change-Id: I1c8aa86dbc86ff6fd91075b239e888a704179b5b
Reviewed-by: Jukka Jokiniva <jukka.jokiniva@qt.io>
18 files changed, 193 insertions, 189 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtAbandon.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtAbandon.java index 81ae794..f570599 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtAbandon.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtAbandon.java @@ -8,9 +8,10 @@ import com.google.common.flogger.FluentLogger; import com.google.gerrit.extensions.api.changes.AbandonInput; import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.restapi.ResourceConflictException; +import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.webui.UiAction; -import com.google.gerrit.reviewdb.client.Change; +import com.google.gerrit.entities.Change; import com.google.gerrit.server.ChangeMessagesUtil; import com.google.gerrit.server.ChangeUtil; import com.google.gerrit.server.PatchSetUtil; @@ -52,7 +53,7 @@ public class QtAbandon extends RetryingRestModifyView<ChangeResource, AbandonInp } @Override - protected ChangeInfo applyImpl( + protected Response<ChangeInfo> applyImpl( BatchUpdate.Factory updateFactory, ChangeResource rsrc, AbandonInput input) throws RestApiException, UpdateException, PermissionBackendException, IOException { Change change = rsrc.getChange(); @@ -85,7 +86,7 @@ public class QtAbandon extends RetryingRestModifyView<ChangeResource, AbandonInp logger.atInfo().log("qtcodereview: abandoned %s", change); change = op.getChange(); - return json.noOptions().format(change); + return Response.ok(json.noOptions().format(change)); } @Override diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtBuildFailedSender.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtBuildFailedSender.java index 2d8236f..feecae9 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtBuildFailedSender.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtBuildFailedSender.java @@ -5,8 +5,8 @@ package com.googlesource.gerrit.plugins.qtcodereview; import com.google.gerrit.exceptions.EmailException; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.entities.Change; +import com.google.gerrit.entities.Project; import com.google.gerrit.server.account.ProjectWatches.NotifyType; import com.google.gerrit.server.mail.send.EmailArguments; import com.google.gerrit.server.mail.send.ReplyToChangeSender; diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeMessageModifier.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeMessageModifier.java index 8e030ab..ba2484c 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeMessageModifier.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeMessageModifier.java @@ -4,7 +4,7 @@ package com.googlesource.gerrit.plugins.qtcodereview; -import com.google.gerrit.reviewdb.client.Branch; +import com.google.gerrit.entities.BranchNameKey; import com.google.gerrit.server.git.ChangeMessageModifier; import com.google.inject.Singleton; import org.eclipse.jgit.revwalk.RevCommit; @@ -15,7 +15,7 @@ public class QtChangeMessageModifier implements ChangeMessageModifier { // Remove extra commit message footers @Override public String onSubmit( - String commitMessage, RevCommit original, RevCommit mergeTip, Branch.NameKey destination) { + String commitMessage, RevCommit original, RevCommit mergeTip, BranchNameKey destination) { StringBuilder stringBuilder = new StringBuilder(""); String[] lines = commitMessage.split("\n"); diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeStagedEvent.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeStagedEvent.java index eca3e7b..0f2ed35 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeStagedEvent.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeStagedEvent.java @@ -5,7 +5,7 @@ package com.googlesource.gerrit.plugins.qtcodereview; import com.google.common.base.Supplier; -import com.google.gerrit.reviewdb.client.Change; +import com.google.gerrit.entities.Change; import com.google.gerrit.server.data.AccountAttribute; import com.google.gerrit.server.events.PatchSetEvent; diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeUnStagedEvent.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeUnStagedEvent.java index 3502e5a..4f04968 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeUnStagedEvent.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeUnStagedEvent.java @@ -5,7 +5,7 @@ package com.googlesource.gerrit.plugins.qtcodereview; import com.google.common.base.Supplier; -import com.google.gerrit.reviewdb.client.Change; +import com.google.gerrit.entities.Change; import com.google.gerrit.server.data.AccountAttribute; import com.google.gerrit.server.events.PatchSetEvent; diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeUpdateOp.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeUpdateOp.java index 54a2103..1ffc899 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeUpdateOp.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtChangeUpdateOp.java @@ -10,11 +10,11 @@ import com.google.common.collect.Iterables; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; import com.google.gerrit.extensions.restapi.ResourceConflictException; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.reviewdb.client.ChangeMessage; -import com.google.gerrit.reviewdb.client.LabelId; -import com.google.gerrit.reviewdb.client.PatchSet; -import com.google.gerrit.reviewdb.client.PatchSetApproval; +import com.google.gerrit.entities.Change; +import com.google.gerrit.entities.ChangeMessage; +import com.google.gerrit.entities.LabelId; +import com.google.gerrit.entities.PatchSet; +import com.google.gerrit.entities.PatchSetApproval; import com.google.gerrit.server.ApprovalsUtil; import com.google.gerrit.server.ChangeMessagesUtil; import com.google.gerrit.server.change.LabelNormalizer; @@ -139,15 +139,15 @@ public class QtChangeUpdateOp implements BatchUpdateOp { for (PatchSetApproval psa : approvalsUtil.byPatchSet( ctx.getNotes(), psId, ctx.getRevWalk(), ctx.getRepoView().getConfig())) { - byKey.put(psa.getKey(), psa); + byKey.put(psa.key(), psa); } submitter = - ApprovalsUtil.newApproval(psId, ctx.getUser(), LabelId.legacySubmit(), 1, ctx.getWhen()); - byKey.put(submitter.getKey(), submitter); + ApprovalsUtil.newApproval(psId, ctx.getUser(), LabelId.legacySubmit(), 1, ctx.getWhen()).build(); + byKey.put(submitter.key(), submitter); LabelNormalizer.Result normalized = labelNormalizer.normalize(ctx.getNotes(), byKey.values()); - update.putApproval(submitter.getLabel(), submitter.getValue()); + update.putApproval(submitter.label(), submitter.value()); saveApprovals(normalized, update, false); return normalized; } @@ -155,41 +155,41 @@ public class QtChangeUpdateOp implements BatchUpdateOp { private void saveApprovals( LabelNormalizer.Result normalized, ChangeUpdate update, boolean includeUnchanged) { for (PatchSetApproval psa : normalized.updated()) { - update.putApprovalFor(psa.getAccountId(), psa.getLabel(), psa.getValue()); + update.putApprovalFor(psa.accountId(), psa.label(), psa.value()); } for (PatchSetApproval psa : normalized.deleted()) { - update.removeApprovalFor(psa.getAccountId(), psa.getLabel()); + update.removeApprovalFor(psa.accountId(), psa.label()); } for (PatchSetApproval psa : normalized.unchanged()) { if (includeUnchanged || psa.isLegacySubmit()) { logger.atFine().log("Adding submit label %s", psa); - update.putApprovalFor(psa.getAccountId(), psa.getLabel(), psa.getValue()); + update.putApprovalFor(psa.accountId(), psa.label(), psa.value()); } } } private Function<PatchSetApproval, PatchSetApproval> convertPatchSet(final PatchSet.Id psId) { return psa -> { - if (psa.getPatchSetId().equals(psId)) { + if (psa.patchSetId().equals(psId)) { return psa; } - return new PatchSetApproval(psId, psa); + return psa.copyWithPatchSet(psId); }; } - private Iterable<PatchSetApproval> convertPatchSet( - Iterable<PatchSetApproval> approvals, PatchSet.Id psId) { - return Iterables.transform(approvals, convertPatchSet(psId)); - } - - private Iterable<PatchSetApproval> zero(Iterable<PatchSetApproval> approvals) { - return Iterables.transform( - approvals, - a -> { - PatchSetApproval copy = new PatchSetApproval(a.getPatchSetId(), a); - copy.setValue((short) 0); - return copy; - }); - } +// private Iterable<PatchSetApproval> convertPatchSet( +// Iterable<PatchSetApproval> approvals, PatchSet.Id psId) { +// return Iterables.transform(approvals, convertPatchSet(psId)); +// } +// +// private Iterable<PatchSetApproval> zero(Iterable<PatchSetApproval> approvals) { +// return Iterables.transform( +// approvals, +// a -> { +// PatchSetApproval copy = new PatchSetApproval(a.getPatchSetId(), a); +// copy.setValue((short) 0); +// return copy; +// }); +// } } diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCherryPickPatch.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCherryPickPatch.java index 5c821c3..f43de65 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCherryPickPatch.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCherryPickPatch.java @@ -5,8 +5,8 @@ package com.googlesource.gerrit.plugins.qtcodereview; import com.google.common.flogger.FluentLogger; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.entities.Change; +import com.google.gerrit.entities.Project; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.git.CodeReviewCommit; import com.google.gerrit.server.git.CodeReviewCommit.CodeReviewRevWalk; @@ -100,7 +100,7 @@ public class QtCherryPickPatch { PersonIdent committerIdent = new PersonIdent(commitToCherryPick.getCommitterIdent(), new Date()); - commitToCherryPick.setPatchsetId(changeData.currentPatchSet().getId()); + commitToCherryPick.setPatchsetId(changeData.currentPatchSet().id()); commitToCherryPick.setNotes(changeData.notes()); CodeReviewCommit cherryPickCommit; diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandAdminChangeStatus.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandAdminChangeStatus.java index 83af904..8f195e9 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandAdminChangeStatus.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandAdminChangeStatus.java @@ -8,8 +8,8 @@ import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.restapi.RestApiException; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.entities.Change; +import com.google.gerrit.entities.Project; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.update.BatchUpdate; diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandBuildApprove.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandBuildApprove.java index 7d7bd40..0efbfe3 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandBuildApprove.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandBuildApprove.java @@ -8,10 +8,10 @@ import com.google.common.flogger.FluentLogger; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.RestApiException; -import com.google.gerrit.reviewdb.client.Branch; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.reviewdb.client.PatchSet; -import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.entities.BranchNameKey; +import com.google.gerrit.entities.Change; +import com.google.gerrit.entities.PatchSet; +import com.google.gerrit.entities.Project; import com.google.gerrit.server.ChangeMessagesUtil; import com.google.gerrit.server.ChangeUtil; import com.google.gerrit.server.change.PatchSetInserter; @@ -130,10 +130,10 @@ class QtCommandBuildApprove extends SshCommand { private static final String STDIN_MESSAGE = "-"; private Project.NameKey projectKey; - private Branch.NameKey buildBranchKey; - private Branch.NameKey destBranchKey; - private Branch.NameKey stagingBranchKey; - private Branch.NameKey destBranchShortKey; + private BranchNameKey buildBranchKey; + private BranchNameKey destBranchKey; + private BranchNameKey stagingBranchKey; + private BranchNameKey destBranchShortKey; private List<Entry<ChangeData, RevCommit>> affectedChanges = null; @@ -158,21 +158,21 @@ class QtCommandBuildApprove extends SshCommand { permissionBackend .user(user) .project(projectKey) - .ref(destBranchKey.get()) + .ref(destBranchKey.branch()) .check(RefPermission.UPDATE); permissionBackend .user(user) .project(projectKey) - .ref(stagingBranchKey.get()) + .ref(stagingBranchKey.branch()) .check(RefPermission.UPDATE); permissionBackend .user(user) .project(projectKey) - .ref(buildBranchKey.get()) + .ref(buildBranchKey.branch()) .check(RefPermission.READ); - if (git.resolve(destBranchKey.get()) == null) throw die("branch not found"); - if (git.resolve(buildBranchKey.get()) == null) throw die("build not found"); + if (git.resolve(destBranchKey.branch()) == null) throw die("branch not found"); + if (git.resolve(buildBranchKey.branch()) == null) throw die("build not found"); // Initialize and populate open changes list. affectedChanges = qtUtil.listChangesNotMerged(git, buildBranchKey, destBranchKey); @@ -223,7 +223,7 @@ class QtCommandBuildApprove extends SshCommand { RestApiException, ConfigInvalidException { if (message == null) message = String.format("Change merged into branch %s", destBranchKey); - ObjectId oldId = git.resolve(destBranchKey.get()); + ObjectId oldId = git.resolve(destBranchKey.branch()); Result result = QtUtil.mergeBranches(user.asIdentifiedUser(), git, buildBranchKey, destBranchKey); @@ -241,11 +241,11 @@ class QtCommandBuildApprove extends SshCommand { logger.atInfo().log( "qtcodereview: staging-approve build %s merged into branch %s", buildBranch, destBranchKey); - ObjectId newId = git.resolve(destBranchKey.get()); + ObjectId newId = git.resolve(destBranchKey.branch()); // send ref updated event only if there are changes to build if (!newId.equals(oldId)) { referenceUpdated.fire( - projectKey, destBranchKey.get(), oldId, newId, user.asIdentifiedUser().state()); + projectKey, destBranchKey.branch(), oldId, newId, user.asIdentifiedUser().state()); } } @@ -291,9 +291,9 @@ class QtCommandBuildApprove extends SshCommand { Change change = cd.change(); if (change.getStatus() == oldStatus) { if (newStatus == Change.Status.MERGED) { - ObjectId obj = git.resolve(cd.currentPatchSet().getRevision().get()); + ObjectId obj = git.resolve(cd.currentPatchSet().commitId().name()); CodeReviewCommit currCommit = new CodeReviewCommit(obj); - currCommit.setPatchsetId(cd.currentPatchSet().getId()); + currCommit.setPatchsetId(cd.currentPatchSet().id()); CodeReviewCommit newCommit = new CodeReviewCommit(item.getValue()); Change.Id changeId = insertPatchSet(u, git, cd.notes(), newCommit); if (!changeId.equals(cd.getId())) { @@ -346,7 +346,7 @@ class QtCommandBuildApprove extends SshCommand { PatchSet ps = changeData.currentPatchSet(); changeMerged.fire( - changeData.change(), ps, user.asIdentifiedUser().state(), ps.getRevision().get(), ts); + changeData.change(), ps, user.asIdentifiedUser().state(), ps.commitId().name(), ts); // logger.atInfo().log("qtcodereview: staging-approve sending merge event failed for %s", // changeData.change()); diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandListStaging.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandListStaging.java index a31379c..009b469 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandListStaging.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandListStaging.java @@ -6,9 +6,9 @@ package com.googlesource.gerrit.plugins.qtcodereview; import com.google.common.flogger.FluentLogger; import com.google.gerrit.extensions.restapi.AuthException; -import com.google.gerrit.reviewdb.client.Branch; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.entities.BranchNameKey; +import com.google.gerrit.entities.Change; +import com.google.gerrit.entities.Project; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; @@ -69,9 +69,9 @@ class QtCommandListStaging extends SshCommand { final PrintWriter stdout = toPrintWriter(out); - Project.NameKey projectKey = new Project.NameKey(project); - Branch.NameKey aBranchKey = new Branch.NameKey(projectKey, branch); - Branch.NameKey destBranchShortKey = + Project.NameKey projectKey = Project.nameKey(project); + BranchNameKey aBranchKey = BranchNameKey.create(projectKey, branch); + BranchNameKey destBranchShortKey = QtUtil.getNameKeyShort(project, QtUtil.R_HEADS, destination); try { @@ -80,15 +80,15 @@ class QtCommandListStaging extends SshCommand { permissionBackend .user(user) .project(projectKey) - .ref(aBranchKey.get()) + .ref(aBranchKey.branch()) .check(RefPermission.READ); permissionBackend .user(user) .project(projectKey) - .ref(destBranchShortKey.get()) + .ref(destBranchShortKey.branch()) .check(RefPermission.READ); - if (git.resolve(aBranchKey.get()) == null) { + if (git.resolve(aBranchKey.branch()) == null) { throw die("branch ref not found"); } diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandNewBuild.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandNewBuild.java index 41e2b94..0569099 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandNewBuild.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandNewBuild.java @@ -7,9 +7,9 @@ package com.googlesource.gerrit.plugins.qtcodereview; import com.google.common.flogger.FluentLogger; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.RestApiException; -import com.google.gerrit.reviewdb.client.Branch; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.entities.BranchNameKey; +import com.google.gerrit.entities.Change; +import com.google.gerrit.entities.Project; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; @@ -79,26 +79,26 @@ class QtCommandNewBuild extends SshCommand { "qtcodereview: staging-new-build -p %s -s %s -i %s", project, stagingBranch, build); try { - Project.NameKey projectKey = new Project.NameKey(project); + Project.NameKey projectKey = Project.nameKey(project); git = gitManager.openRepository(projectKey); - Branch.NameKey buildBranchKey = QtUtil.getNameKeyLong(project, QtUtil.R_BUILDS, build); - Branch.NameKey stagingBranchKey = + BranchNameKey buildBranchKey = QtUtil.getNameKeyLong(project, QtUtil.R_BUILDS, build); + BranchNameKey stagingBranchKey = QtUtil.getNameKeyLong(project, QtUtil.R_STAGING, stagingBranch); - Branch.NameKey destBranchShortKey = + BranchNameKey destBranchShortKey = QtUtil.getNameKeyShort(project, QtUtil.R_STAGING, stagingBranch); - Branch.NameKey destinationKey = QtUtil.getNameKeyLong(project, QtUtil.R_HEADS, stagingBranch); + BranchNameKey destinationKey = QtUtil.getNameKeyLong(project, QtUtil.R_HEADS, stagingBranch); // Check required permissions permissionBackend .user(user) .project(projectKey) - .ref(destinationKey.get()) + .ref(destinationKey.branch()) .check(RefPermission.UPDATE); permissionBackend .user(user) .project(projectKey) - .ref(buildBranchKey.get()) + .ref(buildBranchKey.branch()) .check(RefPermission.CREATE); if (QtUtil.branchExists(git, buildBranchKey) == true) { diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandRebuildStaging.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandRebuildStaging.java index 2929433..198f7a5 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandRebuildStaging.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandRebuildStaging.java @@ -6,8 +6,8 @@ package com.googlesource.gerrit.plugins.qtcodereview; import com.google.common.flogger.FluentLogger; import com.google.gerrit.extensions.restapi.AuthException; -import com.google.gerrit.reviewdb.client.Branch; -import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.entities.BranchNameKey; +import com.google.gerrit.entities.Project; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; @@ -54,20 +54,20 @@ class QtCommandRebuildStaging extends SshCommand { protected void run() throws UnloggedFailure { logger.atInfo().log("qtcodereview: staging-rebuild -p %s -b %s", project, branch); - Branch.NameKey stagingBranchKey = QtUtil.getNameKeyLong(project, QtUtil.R_STAGING, branch); - Branch.NameKey destBranchShortKey = QtUtil.getNameKeyShort(project, QtUtil.R_HEADS, branch); + BranchNameKey stagingBranchKey = QtUtil.getNameKeyLong(project, QtUtil.R_STAGING, branch); + BranchNameKey destBranchShortKey = QtUtil.getNameKeyShort(project, QtUtil.R_HEADS, branch); try { - Project.NameKey projectKey = new Project.NameKey(project); + Project.NameKey projectKey = Project.nameKey(project); git = gitManager.openRepository(projectKey); permissionBackend .user(user) .project(projectKey) - .ref(destBranchShortKey.get()) + .ref(destBranchShortKey.branch()) .check(RefPermission.UPDATE); - if (git.resolve(stagingBranchKey.get()) == null) throw die("branch staging ref not found"); + if (git.resolve(stagingBranchKey.branch()) == null) throw die("branch staging ref not found"); qtUtil.rebuildStagingBranch( git, user.asIdentifiedUser(), projectKey, stagingBranchKey, destBranchShortKey); diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandStage.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandStage.java index 15f9fcf..eb97c81 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandStage.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandStage.java @@ -7,7 +7,7 @@ package com.googlesource.gerrit.plugins.qtcodereview; import com.google.common.flogger.FluentLogger; import com.google.gerrit.extensions.api.changes.SubmitInput; import com.google.gerrit.extensions.restapi.IdString; -import com.google.gerrit.reviewdb.client.PatchSet; +import com.google.gerrit.entities.PatchSet; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.change.RevisionResource; import com.google.gerrit.server.restapi.change.ChangesCollection; @@ -53,9 +53,9 @@ class QtCommandStage extends SshCommand { for (PatchSet patchSet : patchSets) { try { - logger.atInfo().log("qtcodereview: ssh command stage %s", patchSet.getId()); - ChangeResource c = changes.parse(patchSet.getId().getParentKey()); - IdString id = IdString.fromDecoded(patchSet.getRevision().get()); + logger.atInfo().log("qtcodereview: ssh command stage %s", patchSet.id()); + ChangeResource c = changes.parse(patchSet.id().changeId()); + IdString id = IdString.fromDecoded(patchSet.commitId().name()); RevisionResource r = revisions.parse(c, id); qtStage.apply(r, new SubmitInput()); } catch (Exception e) { diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtDefer.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtDefer.java index d8c51d4..00547c9 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtDefer.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtDefer.java @@ -24,8 +24,9 @@ import com.google.gerrit.extensions.api.changes.AbandonInput; import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.RestApiException; +import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.webui.UiAction; -import com.google.gerrit.reviewdb.client.Change; +import com.google.gerrit.entities.Change; import com.google.gerrit.server.ChangeMessagesUtil; import com.google.gerrit.server.ChangeUtil; import com.google.gerrit.server.PatchSetUtil; @@ -65,7 +66,7 @@ class QtDefer extends RetryingRestModifyView<ChangeResource, AbandonInput, Chang } @Override - protected ChangeInfo applyImpl( + protected Response<ChangeInfo> applyImpl( BatchUpdate.Factory updateFactory, ChangeResource rsrc, AbandonInput input) throws RestApiException, UpdateException, PermissionBackendException, IOException { Change change = rsrc.getChange(); @@ -99,7 +100,7 @@ class QtDefer extends RetryingRestModifyView<ChangeResource, AbandonInput, Chang change = op.getChange(); logger.atInfo().log("qtcodereview: deferred %s", change); - return json.noOptions().format(change); + return Response.ok(json.noOptions().format(change)); } @Override diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtReOpen.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtReOpen.java index 2767a0b..476310d 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtReOpen.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtReOpen.java @@ -8,9 +8,10 @@ import com.google.common.flogger.FluentLogger; import com.google.gerrit.extensions.api.changes.RestoreInput; import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.restapi.ResourceConflictException; +import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.webui.UiAction; -import com.google.gerrit.reviewdb.client.Change; +import com.google.gerrit.entities.Change; import com.google.gerrit.server.ChangeUtil; import com.google.gerrit.server.PatchSetUtil; import com.google.gerrit.server.change.ChangeJson; @@ -53,7 +54,7 @@ class QtReOpen extends RetryingRestModifyView<ChangeResource, RestoreInput, Chan } @Override - protected ChangeInfo applyImpl( + protected Response<ChangeInfo> applyImpl( BatchUpdate.Factory updateFactory, ChangeResource rsrc, RestoreInput input) throws RestApiException, UpdateException, PermissionBackendException, IOException { Change change = rsrc.getChange(); @@ -87,7 +88,7 @@ class QtReOpen extends RetryingRestModifyView<ChangeResource, RestoreInput, Chan change = op.getChange(); logger.atInfo().log("qtcodereview: reopened %s", change); - return json.noOptions().format(change); + return Response.ok(json.noOptions().format(change)); } @Override diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtStage.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtStage.java index cb7084d..733bbd0 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtStage.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtStage.java @@ -14,13 +14,13 @@ import com.google.gerrit.extensions.api.changes.SubmitInput; import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestModifyView; +import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.webui.UiAction; -import com.google.gerrit.reviewdb.client.Branch; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.reviewdb.client.PatchSet; -import com.google.gerrit.reviewdb.client.Project; -import com.google.gerrit.reviewdb.client.RevId; -import com.google.gerrit.reviewdb.client.Change.Status; +import com.google.gerrit.entities.PatchSet; +import com.google.gerrit.entities.BranchNameKey; +import com.google.gerrit.entities.Change; +import com.google.gerrit.entities.Change.Status; +import com.google.gerrit.entities.Project; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.ProjectUtil; import com.google.gerrit.server.account.AccountResolver; @@ -86,8 +86,8 @@ public class QtStage private Change change; private Project.NameKey projectKey; - private Branch.NameKey destBranchKey; - private Branch.NameKey stagingBranchKey; + private BranchNameKey destBranchKey; + private BranchNameKey stagingBranchKey; @Inject QtStage( @@ -119,7 +119,7 @@ public class QtStage } @Override - public Output apply(RevisionResource rsrc, SubmitInput input) + public Response<Output> apply(RevisionResource rsrc, SubmitInput input) throws RestApiException, RepositoryNotFoundException, IOException, PermissionBackendException, UpdateException, ConfigInvalidException { @@ -135,7 +135,7 @@ public class QtStage projectCache.checkedGet(rsrc.getProject()).checkStatePermitsWrite(); - return new Output(changeToStaging(rsrc, submitter, input)); + return Response.ok(new Output(changeToStaging(rsrc, submitter, input))); } private Change changeToStaging(RevisionResource rsrc, IdentifiedUser submitter, SubmitInput input) @@ -150,15 +150,15 @@ public class QtStage } else if (!ProjectUtil.branchExists(repoManager, change.getDest())) { logger.atSevere().log( "qtcodereview: stage: change %s destination branch \"%s\" not found", - change, change.getDest().get()); + change, change.getDest().branch()); throw new ResourceConflictException( - String.format("Destination branch \"%s\" not found.", change.getDest().get())); - } else if (!rsrc.getPatchSet().getId().equals(change.currentPatchSetId())) { + String.format("Destination branch \"%s\" not found.", change.getDest().branch())); + } else if (!rsrc.getPatchSet().id().equals(change.currentPatchSetId())) { logger.atSevere().log( "qtcodereview: stage: change %s revision %s is not current revision", - change, rsrc.getPatchSet().getRevision().get()); + change, rsrc.getPatchSet().commitId()); throw new ResourceConflictException( - String.format("Revision %s is not current.", rsrc.getPatchSet().getRevision().get())); + String.format("Revision %s is not current.", rsrc.getPatchSet().commitId())); } Repository git = null; @@ -172,15 +172,15 @@ public class QtStage if (!ProjectUtil.branchExists(repoManager, stagingBranchKey)) { Result result = QtUtil.createStagingBranch(git, destBranchKey); if (result == null) - throw new NoSuchRefException("Cannot create staging ref: " + stagingBranchKey.get()); + throw new NoSuchRefException("Cannot create staging ref: " + stagingBranchKey.branch()); } - destId = git.resolve(stagingBranchKey.get()); + destId = git.resolve(stagingBranchKey.branch()); if (destId == null) - throw new NoSuchRefException("Invalid Revision: " + stagingBranchKey.get()); + throw new NoSuchRefException("Invalid Revision: " + stagingBranchKey.branch()); - sourceId = git.resolve(rsrc.getPatchSet().getRevision().get()); + sourceId = git.resolve(rsrc.getPatchSet().commitId().name()); if (sourceId == null) - throw new NoSuchRefException("Invalid Revision: " + rsrc.getPatchSet().getRevision().get()); + throw new NoSuchRefException("Invalid Revision: " + rsrc.getPatchSet().commitId()); checkParents(git, rsrc); @@ -199,9 +199,9 @@ public class QtStage null, // inputMessage QtUtil.TAG_CI // tag ); - Result result = qtUtil.updateRef(git, stagingBranchKey.get(), commit.toObjectId(), false); + Result result = qtUtil.updateRef(git, stagingBranchKey.branch(), commit.toObjectId(), false); referenceUpdated.fire( - projectKey, stagingBranchKey.get(), destId, commit.toObjectId(), submitter.state()); + projectKey, stagingBranchKey.branch(), destId, commit.toObjectId(), submitter.state()); } catch (IntegrationException e) { logger.atInfo().log("qtcodereview: stage merge error %s", e); @@ -238,7 +238,7 @@ public class QtStage private void checkParents(Repository repository, RevisionResource resource) throws ResourceConflictException { try (final RevWalk rw = new RevWalk(repository)) { final PatchSet ps = resource.getPatchSet(); - final RevCommit rc = rw.parseCommit(ObjectId.fromString(ps.getRevision().get())); + final RevCommit rc = rw.parseCommit(ObjectId.fromString(ps.commitId().name())); if (rc.getParentCount() < 2) { return; } @@ -294,12 +294,12 @@ public class QtStage // throw new OrmRuntimeException("Could not determine mergeability", e); // } - RevId revId = resource.getPatchSet().getRevision(); + ObjectId revId = resource.getPatchSet().commitId(); Map<String, String> params = ImmutableMap.of( - "patchSet", String.valueOf(resource.getPatchSet().getPatchSetId()), - "branch", change.getDest().getShortName(), - "commit", ObjectId.fromString(revId.get()).abbreviate(7).name()); + "patchSet", String.valueOf(resource.getPatchSet().number()), + "branch", change.getDest().shortName(), + "commit", revId.abbreviate(7).name()); return new UiAction.Description() .setLabel(label) .setTitle(Strings.emptyToNull(titlePattern.replace(params))) diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtUnStage.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtUnStage.java index 92d2292..7fe8ca6 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtUnStage.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtUnStage.java @@ -8,13 +8,14 @@ import com.google.common.flogger.FluentLogger; import com.google.gerrit.extensions.api.changes.SubmitInput; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ResourceConflictException; +import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.webui.UiAction; -import com.google.gerrit.reviewdb.client.Branch; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.reviewdb.client.PatchSet; -import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.entities.BranchNameKey; +import com.google.gerrit.entities.Change; +import com.google.gerrit.entities.PatchSet; +import com.google.gerrit.entities.Project; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.ProjectUtil; import com.google.gerrit.server.account.AccountResolver; @@ -57,8 +58,8 @@ class QtUnStage private Change change; private Project.NameKey projectKey; - private Branch.NameKey destBranchKey; - private Branch.NameKey stagingBranchKey; + private BranchNameKey destBranchKey; + private BranchNameKey stagingBranchKey; @Inject QtUnStage( @@ -79,7 +80,7 @@ class QtUnStage } @Override - public Output apply(RevisionResource rsrc, SubmitInput input) + public Response<Output> apply(RevisionResource rsrc, SubmitInput input) throws RestApiException, IOException, UpdateException, PermissionBackendException, ConfigInvalidException { @@ -96,7 +97,7 @@ class QtUnStage projectCache.checkedGet(rsrc.getProject()).checkStatePermitsWrite(); - return new Output(removeChangeFromStaging(rsrc, submitter)); + return Response.ok(new Output(removeChangeFromStaging(rsrc, submitter))); } private Change removeChangeFromStaging(RevisionResource rsrc, IdentifiedUser submitter) @@ -115,25 +116,25 @@ class QtUnStage } else if (!ProjectUtil.branchExists(repoManager, change.getDest())) { logger.atSevere().log( "qtcodereview: unstage: change %s destination branch \"%s\" not found", - change, change.getDest().get()); + change, change.getDest().branch()); throw new ResourceConflictException( - String.format("destination branch \"%s\" not found.", change.getDest().get())); - } else if (!rsrc.getPatchSet().getId().equals(change.currentPatchSetId())) { + String.format("destination branch \"%s\" not found.", change.getDest().branch())); + } else if (!rsrc.getPatchSet().id().equals(change.currentPatchSetId())) { logger.atSevere().log( "qtcodereview: unstage: change %s revision %s is not current revision", - change, rsrc.getPatchSet().getRevision().get()); + change, rsrc.getPatchSet().commitId()); throw new ResourceConflictException( String.format( - "revision %s is not current revision", rsrc.getPatchSet().getRevision().get())); + "revision %s is not current revision", rsrc.getPatchSet().commitId())); } - final Branch.NameKey destBranchShortKey = - QtUtil.getNameKeyShort(projectKey.get(), QtUtil.R_STAGING, stagingBranchKey.get()); + final BranchNameKey destBranchShortKey = + QtUtil.getNameKeyShort(projectKey.get(), QtUtil.R_STAGING, stagingBranchKey.branch()); try { git = repoManager.openRepository(projectKey); - ObjectId srcId = git.resolve(patchSet.getRevision().get()); + ObjectId srcId = git.resolve(patchSet.commitId().name()); if (srcId == null) { logger.atSevere().log( "qtcodereview: unstage merge: change %s has invalid revision %s", change, patchSet); diff --git a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtUtil.java b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtUtil.java index 5926dc9..70c89fe 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtUtil.java +++ b/src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtUtil.java @@ -23,10 +23,10 @@ import com.google.gerrit.common.FooterConstants; import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.restapi.RestApiException; -import com.google.gerrit.reviewdb.client.Branch; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.reviewdb.client.PatchSet; -import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.entities.BranchNameKey; +import com.google.gerrit.entities.Change; +import com.google.gerrit.entities.PatchSet; +import com.google.gerrit.entities.Project; import com.google.gerrit.server.ChangeMessagesUtil; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.data.ChangeAttribute; @@ -136,7 +136,7 @@ public class QtUtil { if (project.endsWith(Constants.DOT_GIT_EXT)) { projectName = project.substring(0, project.length() - Constants.DOT_GIT_EXT.length()); } - return new Project.NameKey(projectName); + return Project.nameKey(projectName); } /** @@ -147,13 +147,13 @@ public class QtUtil { * @param branch Branch name with or without prefix. * @return Branch name key with prefix. */ - public static Branch.NameKey getNameKeyLong( + public static BranchNameKey getNameKeyLong( final String project, final String prefix, final String branch) { final Project.NameKey projectKey = getProjectKey(project); if (branch.startsWith(prefix)) { - return new Branch.NameKey(projectKey, branch); + return BranchNameKey.create(projectKey, branch); } else { - return new Branch.NameKey(projectKey, prefix + branch); + return BranchNameKey.create(projectKey, prefix + branch); } } @@ -165,19 +165,19 @@ public class QtUtil { * @param branch Branch name with or without prefix. * @return Branch name key without prefix. */ - public static Branch.NameKey getNameKeyShort( + public static BranchNameKey getNameKeyShort( final String project, final String prefix, final String branch) { final Project.NameKey projectKey = getProjectKey(project); if (branch.startsWith(prefix)) { - return new Branch.NameKey(projectKey, branch.substring(prefix.length())); + return BranchNameKey.create(projectKey, branch.substring(prefix.length())); } else { - return new Branch.NameKey(projectKey, branch); + return BranchNameKey.create(projectKey, branch); } } - public static boolean branchExists(Repository git, final Branch.NameKey branch) + public static boolean branchExists(Repository git, final BranchNameKey branch) throws IOException { - return git.getRefDatabase().getRef(branch.get()) != null; + return git.getRefDatabase().getRef(branch.branch()) != null; } /** @@ -186,33 +186,33 @@ public class QtUtil { * @param branch Branch under refs/heads. E.g. refs/heads/master. Can be short name. * @return Matching staging branch. E.g. refs/staging/master */ - public static Branch.NameKey getStagingBranch(final Branch.NameKey branch) { + public static BranchNameKey getStagingBranch(final BranchNameKey branch) { return getBranchWithNewPrefix(branch, R_HEADS, R_STAGING); } - private static Branch.NameKey getBranchWithNewPrefix( - final Branch.NameKey branch, final String oldPrefix, final String newPrefix) { - final String ref = branch.get(); + private static BranchNameKey getBranchWithNewPrefix( + final BranchNameKey branch, final String oldPrefix, final String newPrefix) { + final String ref = branch.branch(); if (ref.startsWith(oldPrefix)) { // Create new ref replacing the old prefix with new. - return new Branch.NameKey( - branch.getParentKey(), newPrefix + ref.substring(oldPrefix.length())); + return BranchNameKey.create( + branch.project(), newPrefix + ref.substring(oldPrefix.length())); } // Treat the ref as short name. - return new Branch.NameKey(branch.getParentKey(), newPrefix + ref); + return BranchNameKey.create(branch.project(), newPrefix + ref); } - public static Result createStagingBranch(Repository git, final Branch.NameKey sourceBranch) { + public static Result createStagingBranch(Repository git, final BranchNameKey sourceBranch) { try { final String sourceBranchName; - if (sourceBranch.get().startsWith(R_HEADS)) { - sourceBranchName = sourceBranch.get(); + if (sourceBranch.branch().startsWith(R_HEADS)) { + sourceBranchName = sourceBranch.branch(); } else { - sourceBranchName = R_HEADS + sourceBranch.get(); + sourceBranchName = R_HEADS + sourceBranch.branch(); } - final String stagingBranch = R_STAGING + sourceBranch.getShortName(); + final String stagingBranch = R_STAGING + sourceBranch.shortName(); return updateRef(git, stagingBranch, sourceBranchName, true); } catch (NoSuchRefException | IOException e) { @@ -234,21 +234,21 @@ public class QtUtil { Repository git, IdentifiedUser user, final Project.NameKey projectKey, - final Branch.NameKey stagingBranch, - final Branch.NameKey newBranch) + final BranchNameKey stagingBranch, + final BranchNameKey newBranch) throws IOException, NoSuchRefException { final String stagingBranchName; - if (stagingBranch.get().startsWith(R_STAGING)) { - stagingBranchName = stagingBranch.get(); + if (stagingBranch.branch().startsWith(R_STAGING)) { + stagingBranchName = stagingBranch.branch(); } else { - stagingBranchName = R_STAGING + stagingBranch.get(); + stagingBranchName = R_STAGING + stagingBranch.branch(); } final String buildBranchName; - if (newBranch.get().startsWith(R_BUILDS)) { - buildBranchName = newBranch.get(); + if (newBranch.branch().startsWith(R_BUILDS)) { + buildBranchName = newBranch.branch(); } else { - buildBranchName = R_BUILDS + newBranch.get(); + buildBranchName = R_BUILDS + newBranch.branch(); } Ref sourceRef = git.getRefDatabase().getRef(stagingBranchName); @@ -342,7 +342,7 @@ public class QtUtil { Change change = item.change(); logger.atInfo().log("qtcodereview: rebuilding add %s", change); PatchSet p = item.currentPatchSet(); - ObjectId srcId = git.resolve(p.getRevision().get()); + ObjectId srcId = git.resolve(p.commitId().name()); newId = qtCherryPickPatch .cherryPickPatch( @@ -427,8 +427,8 @@ public class QtUtil { Repository git, IdentifiedUser user, final Project.NameKey projectKey, - final Branch.NameKey stagingBranchKey, - final Branch.NameKey destBranchShortKey) + final BranchNameKey stagingBranchKey, + final BranchNameKey destBranchShortKey) throws MergeConflictException { InternalChangeQuery query = null; List<ChangeData> changes_integrating = null; @@ -441,9 +441,9 @@ public class QtUtil { String stagingBranchName = null; try { - stagingBranchName = stagingBranchKey.get(); + stagingBranchName = stagingBranchKey.branch(); oldStageRef = git.resolve(stagingBranchName); - branchRef = git.resolve(destBranchShortKey.get()); + branchRef = git.resolve(destBranchShortKey.branch()); query = queryProvider.get(); changes_integrating = query.byBranchStatus(destBranchShortKey, Change.Status.INTEGRATING); @@ -529,16 +529,16 @@ public class QtUtil { * @throws IOException Thrown by Repository or RevWalk if repository is not accessible. */ public List<Map.Entry<ChangeData, RevCommit>> listChangesNotMerged( - Repository git, final Branch.NameKey branch, final Branch.NameKey destination) + Repository git, final BranchNameKey branch, final BranchNameKey destination) throws IOException, BranchNotFoundException { Map<Change.Id, Map.Entry<ChangeData, RevCommit>> map = new HashMap<>(); RevWalk revWalk = new RevWalk(git); try { - Ref ref = git.getRefDatabase().getRef(branch.get()); + Ref ref = git.getRefDatabase().getRef(branch.branch()); if (ref == null) throw new BranchNotFoundException("No such branch: " + branch); - Ref refDest = git.getRefDatabase().getRef(destination.get()); + Ref refDest = git.getRefDatabase().getRef(destination.branch()); if (refDest == null) throw new BranchNotFoundException("No such branch: " + destination); RevCommit firstCommit = revWalk.parseCommit(ref.getObjectId()); revWalk.markStart(firstCommit); @@ -552,7 +552,7 @@ public class QtUtil { List<ChangeData> changes = null; if (changeId != null) { - Change.Key key = new Change.Key(changeId); + Change.Key key = Change.key(changeId); changes = queryProvider.get().byBranchKey(destination, key); } @@ -618,24 +618,24 @@ public class QtUtil { public static RefUpdate.Result mergeBranches( IdentifiedUser user, Repository git, - final Branch.NameKey branch, - final Branch.NameKey destination) + final BranchNameKey branch, + final BranchNameKey destination) throws NoSuchRefException, IOException, MergeConflictException { - ObjectId srcId = git.resolve(branch.get()); + ObjectId srcId = git.resolve(branch.branch()); if (srcId == null) throw new NoSuchRefException("Invalid Revision: " + branch); return mergeObjectToBranch(user, git, srcId, destination); } private static RefUpdate.Result mergeObjectToBranch( - IdentifiedUser user, Repository git, ObjectId srcId, final Branch.NameKey destination) + IdentifiedUser user, Repository git, ObjectId srcId, final BranchNameKey destination) throws NoSuchRefException, IOException, MergeConflictException { - Ref destRef = git.getRefDatabase().getRef(destination.get()); + Ref destRef = git.getRefDatabase().getRef(destination.branch()); if (destRef == null) throw new NoSuchRefException("No such branch: " + destination); - ObjectId destId = git.resolve(destination.get()); + ObjectId destId = git.resolve(destination.branch()); if (destId == null) throw new NoSuchRefException("Invalid Revision: " + destination); RevWalk revWalk = new RevWalk(git); @@ -651,7 +651,7 @@ public class QtUtil { objInserter.flush(); logger.atInfo().log("qtcodereview: merge commit for %s added to %s", srcId, destination); - RefUpdate refUpdate = git.updateRef(destination.get()); + RefUpdate refUpdate = git.updateRef(destination.branch()); refUpdate.setNewObjectId(mergeCommit); return refUpdate.update(); } catch (Exception e) { |