Merge changes from topic "matcher-user-cleanup"

* changes:
  PatchSetUtil#isPatchSetLocked: Remove unused 'user' parameter
  ChangeData: Remove unused IdentifiedUser.GenericFactory member


* submodules:
* Update plugins/reviewnotes from branch 'master'
  to 920f28b46021d9c49fac09d869aa4040d13796e7
  - CreateReviewNotes: Remove unused IdentifiedUser.GenericFactory
    
    Change-Id: I2565c5a94d2704b10f763780e2ff8dc0956b2c01
This commit is contained in:
Patrick Hiesel
2018-07-10 06:49:03 +00:00
committed by Gerrit Code Review
12 changed files with 18 additions and 23 deletions

View File

@@ -181,17 +181,16 @@ public class PatchSetUtil {
}
/** Check if the current patch set of the change is locked. */
public void checkPatchSetNotLocked(ChangeNotes notes, CurrentUser user)
public void checkPatchSetNotLocked(ChangeNotes notes)
throws OrmException, IOException, ResourceConflictException {
if (isPatchSetLocked(notes, user)) {
if (isPatchSetLocked(notes)) {
throw new ResourceConflictException(
String.format("The current patch set of change %s is locked", notes.getChangeId()));
}
}
/** Is the current patch set locked against state changes? */
public boolean isPatchSetLocked(ChangeNotes notes, CurrentUser user)
throws OrmException, IOException {
public boolean isPatchSetLocked(ChangeNotes notes) throws OrmException, IOException {
Change change = notes.getChange();
if (change.getStatus() == Change.Status.MERGED) {
return false;

View File

@@ -309,7 +309,7 @@ public class PatchSetInserter implements BatchUpdateOp {
throws AuthException, ResourceConflictException, IOException, PermissionBackendException,
OrmException {
// Not allowed to create a new patch set if the current patch set is locked.
psUtil.checkPatchSetNotLocked(origNotes, ctx.getUser());
psUtil.checkPatchSetNotLocked(origNotes);
if (checkAddPatchSetPermission) {
permissionBackend

View File

@@ -408,7 +408,7 @@ public class ChangeEditModifier {
}
// Not allowed to edit if the current patch set is locked.
patchSetUtil.checkPatchSetNotLocked(notes, currentUser.get());
patchSetUtil.checkPatchSetNotLocked(notes);
try {
permissionBackend
.currentUser()

View File

@@ -2444,7 +2444,7 @@ class ReceiveCommits {
RevCommit priorCommit = revisions.inverse().get(priorPatchSet);
// Not allowed to create a new patch set if the current patch set is locked.
if (psUtil.isPatchSetLocked(notes, user)) {
if (psUtil.isPatchSetLocked(notes)) {
reject(inputCommand, "cannot add patch set to " + ontoChange + ".");
return false;
}

View File

@@ -51,7 +51,6 @@ import com.google.gerrit.server.ApprovalsUtil;
import com.google.gerrit.server.ChangeMessagesUtil;
import com.google.gerrit.server.CommentsUtil;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.PatchSetUtil;
import com.google.gerrit.server.ReviewerByEmailSet;
import com.google.gerrit.server.ReviewerSet;
@@ -325,7 +324,7 @@ public class ChangeData {
ChangeData cd =
new ChangeData(
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, project, id, null, null);
null, null, null, project, id, null, null);
cd.currentPatchSet = new PatchSet(new PatchSet.Id(id, currentPatchSetId));
return cd;
}
@@ -338,7 +337,6 @@ public class ChangeData {
private final ChangeNotes.Factory notesFactory;
private final CommentsUtil commentsUtil;
private final GitRepositoryManager repoManager;
private final IdentifiedUser.GenericFactory userFactory;
private final MergeUtil.Factory mergeUtilFactory;
private final MergeabilityCache mergeabilityCache;
private final NotesMigration notesMigration;
@@ -407,7 +405,6 @@ public class ChangeData {
ChangeNotes.Factory notesFactory,
CommentsUtil commentsUtil,
GitRepositoryManager repoManager,
IdentifiedUser.GenericFactory userFactory,
MergeUtil.Factory mergeUtilFactory,
MergeabilityCache mergeabilityCache,
NotesMigration notesMigration,
@@ -428,7 +425,6 @@ public class ChangeData {
this.notesFactory = notesFactory;
this.commentsUtil = commentsUtil;
this.repoManager = repoManager;
this.userFactory = userFactory;
this.mergeUtilFactory = mergeUtilFactory;
this.mergeabilityCache = mergeabilityCache;
this.notesMigration = notesMigration;

View File

@@ -81,7 +81,7 @@ public class Abandon extends RetryingRestModifyView<ChangeResource, AbandonInput
throws RestApiException, UpdateException, OrmException, PermissionBackendException,
IOException, ConfigInvalidException {
// Not allowed to abandon if the current patch set is locked.
patchSetUtil.checkPatchSetNotLocked(rsrc.getNotes(), rsrc.getUser());
patchSetUtil.checkPatchSetNotLocked(rsrc.getNotes());
rsrc.permissions().database(dbProvider).check(ChangePermission.ABANDON);
@@ -155,7 +155,7 @@ public class Abandon extends RetryingRestModifyView<ChangeResource, AbandonInput
}
try {
if (patchSetUtil.isPatchSetLocked(rsrc.getNotes(), rsrc.getUser())) {
if (patchSetUtil.isPatchSetLocked(rsrc.getNotes())) {
return description;
}
} catch (OrmException | IOException e) {

View File

@@ -128,7 +128,7 @@ public class CreateMergePatchSet
throws OrmException, IOException, RestApiException, UpdateException,
PermissionBackendException {
// Not allowed to create a new patch set if the current patch set is locked.
psUtil.checkPatchSetNotLocked(rsrc.getNotes(), rsrc.getUser());
psUtil.checkPatchSetNotLocked(rsrc.getNotes());
rsrc.permissions().database(db).check(ChangePermission.ADD_PATCH_SET);

View File

@@ -135,7 +135,7 @@ public class Move extends RetryingRestModifyView<ChangeResource, MoveInput, Chan
}
// Not allowed to move if the current patch set is locked.
psUtil.checkPatchSetNotLocked(rsrc.getNotes(), rsrc.getUser());
psUtil.checkPatchSetNotLocked(rsrc.getNotes());
// Move requires abandoning this change, and creating a new change.
try {
@@ -304,7 +304,7 @@ public class Move extends RetryingRestModifyView<ChangeResource, MoveInput, Chan
}
try {
if (psUtil.isPatchSetLocked(rsrc.getNotes(), rsrc.getUser())) {
if (psUtil.isPatchSetLocked(rsrc.getNotes())) {
return description;
}
} catch (OrmException | IOException e) {

View File

@@ -184,7 +184,7 @@ public class PutMessage
}
// Not allowed to put message if the current patch set is locked.
psUtil.checkPatchSetNotLocked(changeNotes, userProvider.get());
psUtil.checkPatchSetNotLocked(changeNotes);
try {
permissionBackend
.user(userProvider.get())

View File

@@ -107,7 +107,7 @@ public class Rebase extends RetryingRestModifyView<RevisionResource, RebaseInput
throws OrmException, UpdateException, RestApiException, IOException,
PermissionBackendException {
// Not allowed to rebase if the current patch set is locked.
patchSetUtil.checkPatchSetNotLocked(rsrc.getNotes(), rsrc.getUser());
patchSetUtil.checkPatchSetNotLocked(rsrc.getNotes());
rsrc.permissions().database(dbProvider).check(ChangePermission.REBASE);
projectCache.checkedGet(rsrc.getProject()).checkStatePermitsWrite();
@@ -228,7 +228,7 @@ public class Rebase extends RetryingRestModifyView<RevisionResource, RebaseInput
}
try {
if (patchSetUtil.isPatchSetLocked(rsrc.getNotes(), rsrc.getUser())) {
if (patchSetUtil.isPatchSetLocked(rsrc.getNotes())) {
return description;
}
} catch (OrmException | IOException e) {

View File

@@ -91,7 +91,7 @@ public class Restore extends RetryingRestModifyView<ChangeResource, RestoreInput
throws RestApiException, UpdateException, OrmException, PermissionBackendException,
IOException {
// Not allowed to restore if the current patch set is locked.
psUtil.checkPatchSetNotLocked(rsrc.getNotes(), rsrc.getUser());
psUtil.checkPatchSetNotLocked(rsrc.getNotes());
rsrc.permissions().database(dbProvider).check(ChangePermission.RESTORE);
projectCache.checkedGet(rsrc.getProject()).checkStatePermitsWrite();
@@ -183,7 +183,7 @@ public class Restore extends RetryingRestModifyView<ChangeResource, RestoreInput
}
try {
if (psUtil.isPatchSetLocked(rsrc.getNotes(), rsrc.getUser())) {
if (psUtil.isPatchSetLocked(rsrc.getNotes())) {
return description;
}
} catch (OrmException | IOException e) {