newPatchset.number = 1;
newPatchset.rev = 1;
newPatchset.type = PatchsetType.Proposal;
// diffstat from merge base
DiffStat diffStat = DiffUtils.getDiffStat(getRepository(), mergeBase, tip);
newPatchset.insertions = diffStat.getInsertions();
newPatchset.deletions = diffStat.getDeletions();
} else {
/*
* PATCHSET UPDATE
*/
int added = totalCommits - currPatchset.commits;
boolean ff = JGitUtils.isMergedInto(getRepository(), currPatchset.tip, tip);
boolean squash = added < 0;
boolean rebase = !currPatchset.base.equals(mergeBase);
// determine type, number and rev of the patchset
if (ff) {
/*
* FAST-FORWARD
* patchset number preserved, rev incremented
*/
boolean merged = JGitUtils.isMergedInto(getRepository(), currPatchset.tip, ticket.mergeTo);
if (merged) {
// current patchset was already merged
// new patchset, mark as rebase
newPatchset.type = PatchsetType.Rebase;
newPatchset.number = currPatchset.number + 1;
newPatchset.rev = 1;
// diffstat from parent
DiffStat diffStat = DiffUtils.getDiffStat(getRepository(), mergeBase, tip);
newPatchset.insertions = diffStat.getInsertions();
newPatchset.deletions = diffStat.getDeletions();
} else {
// FF update to patchset
newPatchset.type = PatchsetType.FastForward;
newPatchset.number = currPatchset.number;
newPatchset.rev = currPatchset.rev + 1;
newPatchset.parent = currPatchset.tip;
// diffstat from parent
DiffStat diffStat = DiffUtils.getDiffStat(getRepository(), currPatchset.tip, tip);
newPatchset.insertions = diffStat.getInsertions();
newPatchset.deletions = diffStat.getDeletions();
}
} else {
/*
* NON-FAST-FORWARD
* new patchset, rev 1
*/
if (rebase && squash) {
newPatchset.type = PatchsetType.Rebase_Squash;
newPatchset.number = currPatchset.number + 1;
newPatchset.rev = 1;
} else if (squash) {
newPatchset.type = PatchsetType.Squash;
newPatchset.number = currPatchset.number + 1;
newPatchset.rev = 1;
} else if (rebase) {
newPatchset.type = PatchsetType.Rebase;
newPatchset.number = currPatchset.number + 1;
newPatchset.rev = 1;
} else {
newPatchset.type = PatchsetType.Amend;
newPatchset.number = currPatchset.number + 1;
newPatchset.rev = 1;
}
// diffstat from merge base
DiffStat diffStat = DiffUtils.getDiffStat(getRepository(), mergeBase, tip);
newPatchset.insertions = diffStat.getInsertions();
newPatchset.deletions = diffStat.getDeletions();
}
if (added > 0) {
// ignore squash (negative add)
newPatchset.added = added;