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

View File

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

View File

@ -954,7 +954,7 @@ public class ReceiveCommits {
} }
RefControl ctl = projectControl.controlForRef(cmd.getRefName()); 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); validateNewCommits(ctl, cmd);
batch.addCommand(cmd); batch.addCommand(cmd);
} else { } else {

View File

@ -99,8 +99,9 @@ public class RebaseIfNecessary extends SubmitStrategy {
args.db, n.notes(), n.getPatchsetId())) { args.db, n.notes(), n.getPatchsetId())) {
approvals.add(new PatchSetApproval(newPatchSet.getId(), a)); 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 = newMergeTip =
(CodeReviewCommit) args.rw.parseCommit(ObjectId (CodeReviewCommit) args.rw.parseCommit(ObjectId
.fromString(newPatchSet.getRevision().get())); .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 + "\""); 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 rw revision pool {@code object} was parsed in.
* @param object the object the user will start the reference with. * @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 * @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()) { if (!canWrite()) {
return false; return false;
} }
@ -253,8 +254,8 @@ public class RefControl {
if (object instanceof RevCommit) { if (object instanceof RevCommit) {
return getCurrentUser().getCapabilities().canAdministrateServer() return getCurrentUser().getCapabilities().canAdministrateServer()
|| (owner && !isBlocked(Permission.CREATE)) || (owner && !isBlocked(Permission.CREATE))
|| (canPerform(Permission.CREATE) && projectControl.canReadCommit(rw, || (canPerform(Permission.CREATE) && (!existsOnServer && canUpdate() || projectControl
(RevCommit) object)); .canReadCommit(rw, (RevCommit) object)));
} else if (object instanceof RevTag) { } else if (object instanceof RevTag) {
final RevTag tag = (RevTag) object; final RevTag tag = (RevTag) object;
try { try {

View File

@ -26,7 +26,7 @@ MSG="$1"
# #
add_ChangeId() { add_ChangeId() {
clean_message=`sed -e ' clean_message=`sed -e '
/^diff --git a\/.*/{ /^diff --git .*/{
s/// s///
q q
} }
@ -81,7 +81,7 @@ add_ChangeId() {
# Skip the line starting with the diff command and everything after it, # 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. # 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. # If more than one line before the diff was empty, strip all but one.
/^diff --git a/ { /^diff --git / {
blankLines = 0 blankLines = 0
while (getline) { } while (getline) { }
next next

View File

@ -152,7 +152,8 @@ def gerrit_plugin(
mf_src = [] mf_src = []
mf_cmd += 'echo "Manifest-Version: 1.0" >$OUT;' mf_cmd += 'echo "Manifest-Version: 1.0" >$OUT;'
mf_cmd += 'echo "Gerrit-ApiType: %s" >>$OUT;' % type 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: for line in manifest_entries:
mf_cmd += ';echo "%s" >> $OUT' % line mf_cmd += ';echo "%s" >> $OUT' % line
genrule( genrule(