Merge branch 'stable-2.8'

* stable-2.8:
  Update replication plugin
  Enable creating new branch and push local new commits in one step.
  Add Implementation-Vendor default manifest entry
  Fix incompatibility between "Rebase if Necessary" and "copy*Score*"
  Fix submit rule evaluation for non blocking labels
  Set uploader to current user in "patchset-created" event upon rebasing
  Guard against diff.mnemonicprefix in commit-msg hook

Conflicts:
	gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/BUCK
	gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/changes/AddReviewerInput.java
	gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeJson.java
	gerrit-server/src/main/java/com/google/gerrit/server/git/strategy/RebaseIfNecessary.java

Change-Id: Ie59a530fe2c0fe66244d010e01e3cdf41de150f0
This commit is contained in:
David Pursehouse 2014-03-04 12:21:38 +09:00
commit cfd89cea70
8 changed files with 23 additions and 10 deletions

View File

@ -104,6 +104,7 @@ public class PatchSetInserter {
private boolean draft;
private boolean runHooks;
private boolean sendMail;
private Account.Id uploader;
@Inject
public PatchSetInserter(ChangeHooks hooks,
@ -205,6 +206,11 @@ public class PatchSetInserter {
return this;
}
public PatchSetInserter setUploader(Account.Id uploader) {
this.uploader = uploader;
return this;
}
public Change insert() throws InvalidChangeOperationException, OrmException,
IOException {
init();
@ -321,6 +327,9 @@ public class PatchSetInserter {
patchSet.setRevision(new RevId(commit.name()));
}
patchSet.setDraft(draft);
if (uploader != null) {
patchSet.setUploader(uploader);
}
}
private void validate() throws InvalidChangeOperationException {

View File

@ -299,6 +299,7 @@ public class RebaseChange {
.setCopyLabels(true)
.setValidatePolicy(validate)
.setDraft(originalPatchSet.isDraft())
.setUploader(uploader.getAccountId())
.setSendMail(sendMail)
.setRunHooks(runHooks);

View File

@ -954,7 +954,7 @@ public class ReceiveCommits {
}
RefControl ctl = projectControl.controlForRef(cmd.getRefName());
if (ctl.canCreate(rp.getRevWalk(), obj)) {
if (ctl.canCreate(rp.getRevWalk(), obj, allRefs.values().contains(obj))) {
validateNewCommits(ctl, cmd);
batch.addCommand(cmd);
} else {

View File

@ -99,8 +99,9 @@ public class RebaseIfNecessary extends SubmitStrategy {
args.db, n.notes(), n.getPatchsetId())) {
approvals.add(new PatchSetApproval(newPatchSet.getId(), a));
}
args.db.patchSetApprovals().insert(approvals);
// rebaseChange.rebase() may already have copied some approvals,
// use upsert, not insert, to avoid constraint violation on database
args.db.patchSetApprovals().upsert(approvals);
newMergeTip =
(CodeReviewCommit) args.rw.parseCommit(ObjectId
.fromString(newPatchSet.getRevision().get()));

View File

@ -127,7 +127,7 @@ public class CreateBranch implements RestModifyView<ProjectResource, Input> {
}
}
if (!refControl.canCreate(rw, object)) {
if (!refControl.canCreate(rw, object, true)) {
throw new AuthException("Cannot create \"" + ref + "\"");
}

View File

@ -233,9 +233,10 @@ public class RefControl {
*
* @param rw revision pool {@code object} was parsed in.
* @param object the object the user will start the reference with.
* @param existsOnServer the object exists on server or not.
* @return {@code true} if the user specified can create a new Git ref
*/
public boolean canCreate(RevWalk rw, RevObject object) {
public boolean canCreate(RevWalk rw, RevObject object, boolean existsOnServer) {
if (!canWrite()) {
return false;
}
@ -253,8 +254,8 @@ public class RefControl {
if (object instanceof RevCommit) {
return getCurrentUser().getCapabilities().canAdministrateServer()
|| (owner && !isBlocked(Permission.CREATE))
|| (canPerform(Permission.CREATE) && projectControl.canReadCommit(rw,
(RevCommit) object));
|| (canPerform(Permission.CREATE) && (!existsOnServer && canUpdate() || projectControl
.canReadCommit(rw, (RevCommit) object)));
} else if (object instanceof RevTag) {
final RevTag tag = (RevTag) object;
try {

View File

@ -26,7 +26,7 @@ MSG="$1"
#
add_ChangeId() {
clean_message=`sed -e '
/^diff --git a\/.*/{
/^diff --git .*/{
s///
q
}
@ -81,7 +81,7 @@ add_ChangeId() {
# Skip the line starting with the diff command and everything after it,
# up to the end of the file, assuming it is only patch data.
# If more than one line before the diff was empty, strip all but one.
/^diff --git a/ {
/^diff --git / {
blankLines = 0
while (getline) { }
next

View File

@ -152,7 +152,8 @@ def gerrit_plugin(
mf_src = []
mf_cmd += 'echo "Manifest-Version: 1.0" >$OUT;'
mf_cmd += 'echo "Gerrit-ApiType: %s" >>$OUT;' % type
mf_cmd += 'echo "Implementation-Version: $v" >>$OUT'
mf_cmd += 'echo "Implementation-Version: $v" >>$OUT;'
mf_cmd += 'echo "Implementation-Vendor: Gerrit Code Review" >>$OUT'
for line in manifest_entries:
mf_cmd += ';echo "%s" >> $OUT' % line
genrule(