IDEA-186483 vcs: include selected unversioned files to commit context

* update commit message on "Amend" toggle with roots,
  that contain only unversioned files in selection
This commit is contained in:
Aleksey Pivovarov
2018-02-12 13:42:24 +03:00
parent f4371650f5
commit 3959640214
@@ -42,6 +42,7 @@ import com.intellij.util.ui.GridBag;
import com.intellij.util.ui.JBDimension;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.components.BorderLayoutPanel;
import com.intellij.vcsUtil.VcsUtil;
import one.util.streamex.StreamEx;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -893,7 +894,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
public Collection<VirtualFile> getRoots() {
ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
return map2SetNotNull(myBrowser.getDisplayedChanges(), change -> vcsManager.getVcsRootFor(ChangesUtil.getFilePath(change)));
return map2SetNotNull(getDisplayedPaths(), filePath -> vcsManager.getVcsRootFor(filePath));
}
@NotNull
@@ -910,7 +911,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
@NotNull
@Override
public Collection<VirtualFile> getVirtualFiles() {
return mapNotNull(getIncludedChanges(), change -> ChangesUtil.getFilePath(change).getVirtualFile());
return mapNotNull(getIncludedPaths(), filePath -> filePath.getVirtualFile());
}
@NotNull
@@ -922,7 +923,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
@NotNull
@Override
public Collection<File> getFiles() {
return map(getIncludedChanges(), change -> ChangesUtil.getFilePath(change).getIOFile());
return map(getIncludedPaths(), filePath -> filePath.getIOFile());
}
@NotNull
@@ -999,6 +1000,30 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
return myBrowser.getIncludedChanges();
}
@NotNull
private List<FilePath> getIncludedPaths() {
List<FilePath> paths = new ArrayList<>();
for (Change change : myBrowser.getIncludedChanges()) {
paths.add(ChangesUtil.getFilePath(change));
}
for (VirtualFile file : myBrowser.getIncludedUnversionedFiles()) {
paths.add(VcsUtil.getFilePath(file));
}
return paths;
}
@NotNull
private List<FilePath> getDisplayedPaths() {
List<FilePath> paths = new ArrayList<>();
for (Change change : myBrowser.getDisplayedChanges()) {
paths.add(ChangesUtil.getFilePath(change));
}
for (VirtualFile file : myBrowser.getDisplayedUnversionedFiles()) {
paths.add(VcsUtil.getFilePath(file));
}
return paths;
}
@Override
@NonNls
protected String getDimensionServiceKey() {