Update bazlets to latest stable-2.15 to use 2.15.1 API
And adapt to the API changes.
Bug: Issue 8753
Change-Id: I036c6d03e446154b74b74a94c1b1228cfb058d8f
diff --git a/WORKSPACE b/WORKSPACE
index 57d536f..6f890c6 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
load("//:bazlets.bzl", "load_bazlets")
load_bazlets(
- commit = "d9abef15db0f934bfe9adcb40b0c475807fd12bf",
+ commit = "1419057b24e41cda9a6ee9d9c431b9005faf8190",
# local_path = "/home/<user>/projects/bazlets",
)
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/AddHashtagsStep.java b/src/main/java/com/googlesource/gerrit/plugins/importer/AddHashtagsStep.java
index f2d241a..213d2d4 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/AddHashtagsStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/AddHashtagsStep.java
@@ -24,7 +24,7 @@
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.change.ChangeTriplet;
import com.google.gerrit.server.change.SetHashtagsOp;
-import com.google.gerrit.server.project.ChangeControl;
+import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gerrit.server.update.BatchUpdate;
import com.google.gerrit.server.update.UpdateException;
@@ -45,7 +45,7 @@
private static final Logger log = LoggerFactory.getLogger(AddHashtagsStep.class);
private final CurrentUser currentUser;
- private final ChangeControl.GenericFactory changeControlFactory;
+ private final ChangeNotes.Factory changeNotesFactory;
private final Change change;
private final ChangeInfo changeInfo;
private final boolean resume;
@@ -56,7 +56,7 @@
@Inject
AddHashtagsStep(
CurrentUser currentUser,
- ChangeControl.GenericFactory changeControlFactory,
+ ChangeNotes.Factory changeNotesFactory,
Provider<ReviewDb> db,
BatchUpdate.Factory batchUpdateFactory,
SetHashtagsOp.Factory hashtagsFactory,
@@ -64,7 +64,7 @@
@Assisted ChangeInfo changeInfo,
@Assisted boolean resume) {
this.currentUser = currentUser;
- this.changeControlFactory = changeControlFactory;
+ this.changeNotesFactory = changeNotesFactory;
this.db = db;
this.batchUpdateFactory = batchUpdateFactory;
this.hashtagsFactory = hashtagsFactory;
@@ -76,12 +76,13 @@
void add()
throws IllegalArgumentException, OrmException, NoSuchChangeException, UpdateException,
RestApiException {
- ChangeControl ctrl = changeControlFactory.controlFor(db.get(), change, currentUser);
+
+ ChangeNotes notes = changeNotesFactory.createChecked(db.get(), change);
try {
if (resume) {
HashtagsInput input = new HashtagsInput();
- input.remove = ctrl.getNotes().load().getHashtags();
+ input.remove = notes.load().getHashtags();
try (BatchUpdate bu =
batchUpdateFactory.create(
db.get(), change.getProject(), currentUser, TimeUtil.nowTs())) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/CopyProject.java b/src/main/java/com/googlesource/gerrit/plugins/importer/CopyProject.java
index c429077..d4ea7b5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/CopyProject.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/CopyProject.java
@@ -28,6 +28,7 @@
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.config.ConfigResource;
+import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.NoSuchChangeException;
@@ -72,7 +73,7 @@
public ImportStatistic apply(ProjectResource rsrc, Input input)
throws RestApiException, OrmException, IOException, ValidationException, GitAPIException,
NoSuchChangeException, NoSuchAccountException, UpdateException, ConfigInvalidException,
- PermissionBackendException {
+ PermissionBackendException, PatchListNotAvailableException {
if (Strings.isNullOrEmpty(input.name)) {
throw new BadRequestException("name is required");
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java
index b6750c0..b399ed1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java
@@ -28,6 +28,7 @@
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.config.ConfigResource;
+import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gerrit.server.project.ProjectCache;
@@ -164,7 +165,7 @@
public ImportStatistic apply(ConfigResource rsrc, Input input)
throws RestApiException, OrmException, IOException, ValidationException, GitAPIException,
NoSuchChangeException, NoSuchAccountException, UpdateException, ConfigInvalidException,
- PermissionBackendException {
+ PermissionBackendException, PatchListNotAvailableException {
if (input == null) {
input = new Input();
}
@@ -180,7 +181,7 @@
public ResumeImportStatistic resume(String user, String pass, boolean force, File importStatus)
throws RestApiException, OrmException, IOException, GitAPIException, NoSuchChangeException,
NoSuchAccountException, UpdateException, ConfigInvalidException,
- PermissionBackendException {
+ PermissionBackendException, PatchListNotAvailableException {
LockFile lockFile = lockForImport();
try {
ImportProjectInfo info = ImportJson.parse(importStatus);
@@ -203,7 +204,7 @@
private ResumeImportStatistic apply(LockFile lockFile, Input input, ImportProjectInfo info)
throws RestApiException, OrmException, IOException, GitAPIException, NoSuchChangeException,
NoSuchAccountException, UpdateException, ConfigInvalidException,
- PermissionBackendException {
+ PermissionBackendException, PatchListNotAvailableException {
boolean resume = info != null;
api = apiFactory.create(input.from, input.user, input.pass);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ProjectCommand.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ProjectCommand.java
index 8aca867..b9b539c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ProjectCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ProjectCommand.java
@@ -20,6 +20,7 @@
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.config.ConfigResource;
+import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gerrit.server.update.UpdateException;
@@ -99,7 +100,7 @@
protected void run()
throws OrmException, IOException, UnloggedFailure, ValidationException, GitAPIException,
NoSuchChangeException, NoSuchAccountException, UpdateException, ConfigInvalidException,
- PermissionBackendException {
+ PermissionBackendException, PatchListNotAvailableException {
ImportProject.Input input = new ImportProject.Input();
input.from = url;
input.name = name;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java
index 7649d00..ab106a6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java
@@ -29,6 +29,7 @@
import com.google.gerrit.server.Sequences;
import com.google.gerrit.server.index.change.ChangeIndexer;
import com.google.gerrit.server.notedb.NotesMigration;
+import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.InternalChangeQuery;
@@ -134,7 +135,8 @@
void replay()
throws IOException, OrmException, NoSuchAccountException, NoSuchChangeException,
- RestApiException, UpdateException, ConfigInvalidException {
+ RestApiException, UpdateException, ConfigInvalidException,
+ PatchListNotAvailableException {
int start = 0;
int limit = GlobalCapability.DEFAULT_MAX_QUERY_LIMIT;
pm.beginTask("Replay Changes", ProgressMonitor.UNKNOWN);
@@ -166,7 +168,8 @@
private void replayChange(RevWalk rw, ChangeInfo c)
throws IOException, OrmException, NoSuchAccountException, NoSuchChangeException,
- RestApiException, IllegalArgumentException, UpdateException, ConfigInvalidException {
+ RestApiException, IllegalArgumentException, UpdateException, ConfigInvalidException,
+ PatchListNotAvailableException {
Change change = resume ? findChange(c) : null;
boolean resumeChange;
if (change == null) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayInlineCommentsStep.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayInlineCommentsStep.java
index cd0e4fd..4895861 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayInlineCommentsStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayInlineCommentsStep.java
@@ -41,9 +41,10 @@
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.PatchSetUtil;
import com.google.gerrit.server.config.GerritServerId;
+import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.notedb.ChangeUpdate;
import com.google.gerrit.server.patch.PatchListCache;
-import com.google.gerrit.server.project.ChangeControl;
+import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
@@ -71,7 +72,7 @@
private final AccountUtil accountUtil;
private final ReviewDb db;
private final IdentifiedUser.GenericFactory genericUserFactory;
- private final ChangeControl.GenericFactory changeControlFactory;
+ private final ChangeNotes.Factory changeNotesFactory;
private final ChangeUpdate.Factory updateFactory;
private final CommentsUtil commentsUtil;
private final PatchListCache patchListCache;
@@ -87,7 +88,7 @@
AccountUtil accountUtil,
ReviewDb db,
IdentifiedUser.GenericFactory genericUserFactory,
- ChangeControl.GenericFactory changeControlFactory,
+ ChangeNotes.Factory changeNotesFactory,
ChangeUpdate.Factory updateFactory,
CommentsUtil commentsUtil,
PatchListCache patchListCache,
@@ -100,7 +101,7 @@
this.accountUtil = accountUtil;
this.db = db;
this.genericUserFactory = genericUserFactory;
- this.changeControlFactory = changeControlFactory;
+ this.changeNotesFactory = changeNotesFactory;
this.updateFactory = updateFactory;
this.commentsUtil = commentsUtil;
this.patchListCache = patchListCache;
@@ -114,9 +115,9 @@
void replay()
throws RestApiException, OrmException, IOException, NoSuchChangeException,
- NoSuchAccountException, ConfigInvalidException {
- ChangeControl ctrl = control(change, change.getOwner());
- for (PatchSet ps : ChangeUtil.PS_ID_ORDER.sortedCopy(psUtil.byChange(db, ctrl.getNotes()))) {
+ NoSuchAccountException, ConfigInvalidException, PatchListNotAvailableException {
+ ChangeNotes notes = changeNotesFactory.createChecked(db, change);
+ for (PatchSet ps : ChangeUtil.PS_ID_ORDER.sortedCopy(psUtil.byChange(db, notes))) {
Iterable<CommentInfo> comments = api.getComments(changeInfo._number, ps.getRevision().get());
if (resume) {
if (comments == null) {
@@ -173,10 +174,10 @@
}
private void insertComments(PatchSet ps, Account.Id author, Collection<CommentInfo> comments)
- throws OrmException, IOException, NoSuchChangeException {
- ChangeControl ctrl = control(change, author);
+ throws OrmException, IOException, NoSuchChangeException, PatchListNotAvailableException {
+ ChangeNotes notes = changeNotesFactory.createChecked(db, change);
- Map<String, Comment> drafts = scanDraftComments(ctrl, ps);
+ Map<String, Comment> drafts = scanDraftComments(notes, ps, author);
List<Comment> del = Lists.newArrayList();
List<Comment> ups = Lists.newArrayList();
@@ -211,7 +212,8 @@
}
Iterables.addAll(del, drafts.values());
- ChangeUpdate update = updateFactory.create(ctrl.getNotes(), ctrl.getUser(), TimeUtil.nowTs());
+ ChangeUpdate update =
+ updateFactory.create(notes, genericUserFactory.create(author), TimeUtil.nowTs());
update.setPatchSetId(ps.getId());
commentsUtil.deleteComments(db, update, del);
@@ -219,22 +221,12 @@
update.commit();
}
- private Map<String, Comment> scanDraftComments(ChangeControl ctrl, PatchSet ps)
+ private Map<String, Comment> scanDraftComments(ChangeNotes notes, PatchSet ps, Account.Id account)
throws OrmException {
Map<String, Comment> drafts = Maps.newHashMap();
- for (Comment c :
- commentsUtil.draftByPatchSetAuthor(
- db, ps.getId(), ((IdentifiedUser) ctrl.getUser()).getAccountId(), ctrl.getNotes())) {
+ for (Comment c : commentsUtil.draftByPatchSetAuthor(db, ps.getId(), account, notes)) {
drafts.put(c.key.uuid, c);
}
return drafts;
}
-
- private ChangeControl control(Change change, Account.Id id) throws NoSuchChangeException {
- try {
- return changeControlFactory.controlFor(db, change, genericUserFactory.create(id));
- } catch (OrmException e) {
- throw new NoSuchChangeException(change.getId());
- }
- }
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayMessagesStep.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayMessagesStep.java
index d439b44..98186f5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayMessagesStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayMessagesStep.java
@@ -24,9 +24,10 @@
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.ChangeMessagesUtil;
+import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
+import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.notedb.ChangeUpdate;
-import com.google.gerrit.server.project.ChangeControl;
import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
@@ -47,7 +48,7 @@
private final ChangeMessagesUtil cmUtil;
private final ReviewDb db;
private final IdentifiedUser.GenericFactory genericUserFactory;
- private final ChangeControl.GenericFactory changeControlFactory;
+ private final ChangeNotes.Factory changeNotesFactory;
private final Change change;
private final ChangeInfo changeInfo;
private final boolean resume;
@@ -58,7 +59,7 @@
ChangeUpdate.Factory updateFactory,
ChangeMessagesUtil cmUtil,
IdentifiedUser.GenericFactory genericUserFactory,
- ChangeControl.GenericFactory changeControlFactory,
+ ChangeNotes.Factory changeNotesFactory,
ReviewDb db,
@Assisted Change change,
@Assisted ChangeInfo changeInfo,
@@ -68,7 +69,7 @@
this.cmUtil = cmUtil;
this.db = db;
this.genericUserFactory = genericUserFactory;
- this.changeControlFactory = changeControlFactory;
+ this.changeNotesFactory = changeNotesFactory;
this.change = change;
this.changeInfo = changeInfo;
this.resume = resume;
@@ -89,8 +90,9 @@
msg._revisionNumber != null ? new PatchSet.Id(change.getId(), msg._revisionNumber) : null;
if (msg.author != null) {
Account.Id userId = accountUtil.resolveUser(api, msg.author);
- ChangeControl ctrl = control(change, userId);
- ChangeUpdate update = updateFactory.create(ctrl.getNotes(), ctrl.getUser(), ts);
+ ChangeNotes notes = changeNotesFactory.createChecked(db, change);
+ CurrentUser user = genericUserFactory.create(userId);
+ ChangeUpdate update = updateFactory.create(notes, user, ts);
ChangeMessage cmsg = new ChangeMessage(msgKey, userId, ts, psId);
cmsg.setMessage(msg.message);
cmUtil.addChangeMessage(db, update, cmsg);
@@ -104,12 +106,4 @@
}
}
}
-
- private ChangeControl control(Change change, Account.Id id) throws NoSuchChangeException {
- try {
- return changeControlFactory.controlFor(db, change, genericUserFactory.create(id));
- } catch (OrmException e) {
- throw new NoSuchChangeException(change.getId());
- }
- }
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ResumeCopyProject.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ResumeCopyProject.java
index 5342508..0b85b8f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ResumeCopyProject.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ResumeCopyProject.java
@@ -28,6 +28,7 @@
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.config.ConfigResource;
+import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.NoSuchChangeException;
@@ -85,7 +86,7 @@
public ResumeImportStatistic apply(ProjectResource rsrc, Input input)
throws RestApiException, IOException, OrmException, ValidationException, GitAPIException,
NoSuchChangeException, NoSuchAccountException, UpdateException, ConfigInvalidException,
- PermissionBackendException {
+ PermissionBackendException, PatchListNotAvailableException {
ImportProjectResource projectResource =
projectsCollection.parse(new ConfigResource(), IdString.fromDecoded(rsrc.getName()));
ResumeProjectImport.Input in = new ResumeProjectImport.Input();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ResumeProjectImport.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ResumeProjectImport.java
index 82a5b53..aa74c1c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ResumeProjectImport.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ResumeProjectImport.java
@@ -29,6 +29,7 @@
import com.google.gerrit.extensions.webui.UiAction;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.config.ConfigResource;
+import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.NoSuchChangeException;
@@ -96,7 +97,7 @@
public ResumeImportStatistic apply(ImportProjectResource rsrc, Input input)
throws RestApiException, IOException, OrmException, ValidationException, GitAPIException,
NoSuchChangeException, NoSuchAccountException, UpdateException, ConfigInvalidException,
- PermissionBackendException {
+ PermissionBackendException, PatchListNotAvailableException {
if (copy) {
input.validateResumeCopy();
} else {
@@ -136,7 +137,7 @@
public ResumeImportStatistic apply(ProjectResource rsrc, Input input)
throws RestApiException, IOException, OrmException, ValidationException, GitAPIException,
NoSuchChangeException, NoSuchAccountException, UpdateException, ConfigInvalidException,
- PermissionBackendException {
+ PermissionBackendException, PatchListNotAvailableException {
ImportProjectResource projectResource =
projectsCollection.parse(new ConfigResource(), IdString.fromDecoded(rsrc.getName()));
return resumeProjectImport.apply(projectResource, input);