use of com.intellij.openapi.vcs.impl.LocalChangesUnderRoots in project intellij-community by JetBrains.
the class GitShelveChangesSaver method save.
@Override
protected void save(@NotNull Collection<VirtualFile> rootsToSave) throws VcsException {
LOG.info("save " + rootsToSave);
final Map<String, Map<VirtualFile, Collection<Change>>> lists = new LocalChangesUnderRoots(myChangeManager, myVcsManager).getChangesByLists(rootsToSave);
String oldProgressTitle = myProgressIndicator.getText();
myProgressIndicator.setText(GitBundle.getString("update.shelving.changes"));
List<VcsException> exceptions = new ArrayList<>(1);
myShelvedLists = new HashMap<>();
for (Map.Entry<String, Map<VirtualFile, Collection<Change>>> entry : lists.entrySet()) {
final Map<VirtualFile, Collection<Change>> map = entry.getValue();
final Set<Change> changes = new HashSet<>();
for (Collection<Change> changeCollection : map.values()) {
changes.addAll(changeCollection);
}
if (!changes.isEmpty()) {
final ShelvedChangeList list = GitShelveUtils.shelveChanges(myProject, myShelveManager, changes, myStashMessage + " [" + entry.getKey() + "]", exceptions, false, true);
myShelvedLists.put(entry.getKey(), list);
}
}
if (!exceptions.isEmpty()) {
LOG.info("save " + exceptions, exceptions.get(0));
// no restore here since during shelving changes are not rolled back...
myShelvedLists = null;
throw exceptions.get(0);
} else {
for (VirtualFile root : rootsToSave) {
GitRollbackEnvironment.resetHardLocal(myProject, root);
}
}
myProgressIndicator.setText(oldProgressTitle);
}
use of com.intellij.openapi.vcs.impl.LocalChangesUnderRoots in project intellij-community by JetBrains.
the class GitUpdateProcess method tryFastForwardMergeForRebaseUpdaters.
@NotNull
private Map<VirtualFile, GitUpdater> tryFastForwardMergeForRebaseUpdaters(@NotNull Map<VirtualFile, GitUpdater> updaters) {
Map<VirtualFile, GitUpdater> modifiedUpdaters = new HashMap<>();
Map<VirtualFile, Collection<Change>> changesUnderRoots = new LocalChangesUnderRoots(myChangeListManager, myVcsManager).getChangesUnderRoots(updaters.keySet());
for (Map.Entry<VirtualFile, GitUpdater> updaterEntry : updaters.entrySet()) {
VirtualFile root = updaterEntry.getKey();
GitUpdater updater = updaterEntry.getValue();
Collection<Change> changes = changesUnderRoots.get(root);
LOG.debug("Changes under root '" + getShortVcsRootName(myProject, root) + "': " + changes);
if (updater instanceof GitRebaseUpdater && changes != null && !changes.isEmpty()) {
// check only if there are local changes, otherwise stash won't happen anyway and there would be no optimization
GitRebaseUpdater rebaseUpdater = (GitRebaseUpdater) updater;
if (rebaseUpdater.fastForwardMerge()) {
continue;
}
}
modifiedUpdaters.put(root, updater);
}
return modifiedUpdaters;
}
use of com.intellij.openapi.vcs.impl.LocalChangesUnderRoots in project intellij-community by JetBrains.
the class LocalChangesUnderRootsTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
myChangeListManager = new MockChangeListManager();
myBaseDir = myProject.getBaseDir();
myLocalChangesUnderRoots = new LocalChangesUnderRoots(myChangeListManager, ProjectLevelVcsManager.getInstance(myProject));
}
Aggregations