mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] IDEA-124821 Don't make the auto-generated changelist default
It is not needed: commit dialog can easily commit a non-default changelist. On the other hand, making the auto-changelist non-default will help to avoid such problems as IDEA-103094, when the changelist is not removed after cherry-pick for some reason and then is used as the default one. This also should help with IDEA-120133.
This commit is contained in:
@@ -170,20 +170,13 @@ public class GitCherryPicker {
|
||||
CherryPickData data = updateChangeListManager(commit.getCommit());
|
||||
boolean committed = showCommitDialogAndWaitForCommit(repository, commit, data.myChangeList, data.myCommitMessage);
|
||||
if (committed) {
|
||||
removeChangeList(data);
|
||||
myChangeListManager.removeChangeList(data.myChangeList);
|
||||
successfulCommits.add(commit);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void removeChangeList(CherryPickData list) {
|
||||
myChangeListManager.setDefaultChangeList(list.myPreviouslyDefaultChangeList);
|
||||
if (!myChangeListManager.getDefaultChangeList().equals(list.myChangeList)) {
|
||||
myChangeListManager.removeChangeList(list.myChangeList);
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyConflictWarning(@NotNull GitRepository repository, @NotNull GitCommitWrapper commit,
|
||||
@NotNull List<GitCommitWrapper> successfulCommits) {
|
||||
NotificationListener resolveLinkListener = new ResolveLinkListener(myProject, myGit, myPlatformFacade, repository.getRoot(),
|
||||
@@ -210,9 +203,8 @@ public class GitCherryPicker {
|
||||
final Collection<FilePath> paths = ChangesUtil.getPaths(commit.getChanges());
|
||||
refreshChangedFiles(paths);
|
||||
final String commitMessage = createCommitMessage(commit);
|
||||
LocalChangeList previouslyDefaultChangeList = myChangeListManager.getDefaultChangeList();
|
||||
LocalChangeList changeList = createChangeListAfterUpdate(commit, paths, commitMessage);
|
||||
return new CherryPickData(changeList, commitMessage, previouslyDefaultChangeList);
|
||||
return new CherryPickData(changeList, commitMessage);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -378,14 +370,12 @@ public class GitCherryPicker {
|
||||
@NotNull
|
||||
private LocalChangeList createChangeList(@NotNull VcsFullCommitDetails commit, @NotNull String commitMessage) {
|
||||
Collection<Change> changes = commit.getChanges();
|
||||
String changeListName = createNameForChangeList(commitMessage, 0).replace('\n', ' ');
|
||||
final LocalChangeList changeList = ((ChangeListManagerEx)myChangeListManager).addChangeList(changeListName, commitMessage, commit);
|
||||
if (!changes.isEmpty()) {
|
||||
String changeListName = createNameForChangeList(commitMessage, 0).replace('\n', ' ');
|
||||
final LocalChangeList changeList = ((ChangeListManagerEx)myChangeListManager).addChangeList(changeListName, commitMessage, commit);
|
||||
myChangeListManager.moveChangesTo(changeList, changes.toArray(new Change[changes.size()]));
|
||||
myChangeListManager.setDefaultChangeList(changeList);
|
||||
return changeList;
|
||||
}
|
||||
return myChangeListManager.getDefaultChangeList();
|
||||
return changeList;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -405,12 +395,10 @@ public class GitCherryPicker {
|
||||
private static class CherryPickData {
|
||||
private final LocalChangeList myChangeList;
|
||||
private final String myCommitMessage;
|
||||
private final LocalChangeList myPreviouslyDefaultChangeList;
|
||||
|
||||
private CherryPickData(LocalChangeList list, String message, LocalChangeList previouslyDefaultChangeList) {
|
||||
private CherryPickData(LocalChangeList list, String message) {
|
||||
myChangeList = list;
|
||||
myCommitMessage = message;
|
||||
myPreviouslyDefaultChangeList = previouslyDefaultChangeList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ Background:
|
||||
M conflict.txt "feature version"
|
||||
"""
|
||||
When I cherry-pick the commit bb6453c and don't resolve conflicts
|
||||
Then active changelist is 'feature content (cherry picked from commit bb6453c)'
|
||||
Then there is changelist 'feature content (cherry picked from commit bb6453c)'
|
||||
And warning notification is shown 'Cherry-picked with conflicts'
|
||||
"""
|
||||
bb6453c feature content
|
||||
@@ -137,7 +137,7 @@ Background:
|
||||
M conflict.txt "feature version"
|
||||
"""
|
||||
When I cherry-pick the commit bb6453c, resolve conflicts and don't commit
|
||||
Then active changelist is 'feature content (cherry picked from commit bb6453c)'
|
||||
Then there is changelist 'feature content (cherry picked from commit bb6453c)'
|
||||
And no notification is shown
|
||||
|
||||
Scenario: Cherry-pick 2 commits
|
||||
|
||||
@@ -15,8 +15,6 @@ Feature: Git Cherry-Pick When Auto-Commit is deselected
|
||||
Scenario: Simple cherry-pick
|
||||
When I cherry-pick the commit f5027a3
|
||||
Then commit dialog should be shown
|
||||
And active changelist is 'fix #1 (cherry picked from commit f5027a3)'
|
||||
|
||||
|
||||
Scenario: Simple cherry-pick, agree to commit
|
||||
When I cherry-pick the commit f5027a3 and commit
|
||||
@@ -34,7 +32,7 @@ Feature: Git Cherry-Pick When Auto-Commit is deselected
|
||||
Scenario: Simple cherry-pick, cancel commit
|
||||
When I cherry-pick the commit f5027a3 and don't commit
|
||||
Then nothing is committed
|
||||
And active changelist is 'fix #1 (cherry picked from commit f5027a3)'
|
||||
And there is changelist 'fix #1 (cherry picked from commit f5027a3)'
|
||||
And no notification is shown
|
||||
|
||||
Scenario: Cherry-pick 2 commits
|
||||
@@ -67,7 +65,7 @@ Feature: Git Cherry-Pick When Auto-Commit is deselected
|
||||
(cherry picked from commit f5027a3)
|
||||
"""
|
||||
And working tree is dirty
|
||||
And active changelist is 'fix #2 (cherry picked from commit abc1234)'
|
||||
And there is changelist 'fix #2 (cherry picked from commit abc1234)'
|
||||
And warning notification is shown 'Cherry-pick cancelled'
|
||||
"""
|
||||
abc1234 fix #2
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
*/
|
||||
package git4idea;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.intellij.mock.MockVirtualFile;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.ThrowableComputable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.FilePathImpl;
|
||||
@@ -40,6 +39,7 @@ import cucumber.annotation.en.When;
|
||||
import git4idea.cherrypick.GitCherryPicker;
|
||||
import git4idea.config.GitVersionSpecialty;
|
||||
import git4idea.test.MockVcsHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -214,30 +214,22 @@ public class GitCherryPickStepdefs {
|
||||
assertTrue("Commit dialog was not shown", myVcsHelper.commitDialogWasShown());
|
||||
}
|
||||
|
||||
@Then("^active changelist is '(.+)'$")
|
||||
public void active_changelist_is(String name) throws Throwable {
|
||||
assertActiveChangeList(virtualCommits.replaceVirtualHashes(name));
|
||||
@Then("^there is changelist '(.*)'$")
|
||||
public void there_is_changelist(@NotNull final String name) throws Throwable {
|
||||
List<LocalChangeList> changeLists = myChangeListManager.getChangeListsCopy();
|
||||
assertTrue("Didn't find changelist with name '" + name + "' among :" + changeLists,
|
||||
ContainerUtil.exists(changeLists, new Condition<LocalChangeList>() {
|
||||
@Override
|
||||
public boolean value(LocalChangeList list) {
|
||||
return list.getName().equals(virtualCommits.replaceVirtualHashes(name));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private static void assertOnlyDefaultChangelist() {
|
||||
String DEFAULT = MockChangeListManager.DEFAULT_CHANGE_LIST_NAME;
|
||||
assertChangeLists(Collections.singleton(DEFAULT), DEFAULT);
|
||||
}
|
||||
|
||||
private static void assertChangeLists(Collection<String> changeLists, String activeChangelist) {
|
||||
List<LocalChangeList> lists = myChangeListManager.getChangeLists();
|
||||
Collection<String> listNames = Collections2.transform(lists, new Function<LocalChangeList, String>() {
|
||||
@Override
|
||||
public String apply(LocalChangeList input) {
|
||||
return input.getName();
|
||||
}
|
||||
});
|
||||
assertEquals("Change lists are different", new ArrayList<String>(changeLists), new ArrayList<String>(listNames));
|
||||
assertActiveChangeList(activeChangelist);
|
||||
}
|
||||
|
||||
private static void assertActiveChangeList(String name) {
|
||||
assertEquals("Wrong active changelist", name, myChangeListManager.getDefaultChangeList().getName());
|
||||
assertEquals("Only default change list is expected", 1, myChangeListManager.getChangeListsNumber());
|
||||
assertEquals("Default changelist is not active", DEFAULT, myChangeListManager.getDefaultChangeList().getName());
|
||||
}
|
||||
|
||||
private static void cherryPick(List<String> virtualHashes) {
|
||||
|
||||
Reference in New Issue
Block a user