From b435acafc13d5d9bb8f82bd5be3127621f38fb8c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Oct 2009 10:28:25 +0300 Subject: [PATCH] Git: an attempt to fix unstash --- .../git4idea/update/GitUpdateEnvironment.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateEnvironment.java b/plugins/git4idea/src/git4idea/update/GitUpdateEnvironment.java index b646b78794fe..cc35099832ee 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateEnvironment.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdateEnvironment.java @@ -15,6 +15,7 @@ */ package git4idea.update; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; @@ -61,6 +62,7 @@ import java.util.concurrent.atomic.AtomicBoolean; * and processed as well. */ public class GitUpdateEnvironment implements UpdateEnvironment { + private static final Logger LOG = Logger.getInstance("#git4idea.update.GitUpdateEnvironment"); /** * The vcs instance */ @@ -106,10 +108,14 @@ public class GitUpdateEnvironment implements UpdateEnvironment { projectManager.blockReloadingProjectOnExternalChanges(); try { HashSet rootsToStash = new HashSet(); + List listsCopy = null; + ChangeListManagerEx changeManager = (ChangeListManagerEx)ChangeListManagerEx.getInstance(myProject); if (mySettings.UPDATE_STASH) { - ChangeListManagerEx changeManager = (ChangeListManagerEx)ChangeListManagerEx.getInstance(myProject); - for (LocalChangeList l : changeManager.getChangeListsCopy()) { - for (Change c : l.getChanges()) { + listsCopy = changeManager.getChangeListsCopy(); + for (LocalChangeList l : listsCopy) { + final Collection changeCollection = l.getChanges(); + LOG.debug("Stashing " + changeCollection.size() + " changes from '" + l.getName() + "'"); + for (Change c : changeCollection) { if (c.getAfterRevision() != null) { VirtualFile r = GitUtil.getGitRootOrNull(c.getAfterRevision().getFile()); if (r != null) { @@ -256,6 +262,13 @@ public class GitUpdateEnvironment implements UpdateEnvironment { if (stashCreated) { try { GitStashUtils.popLastStash(myProject, root); + for (LocalChangeList changeList : listsCopy) { + final Collection changes = changeList.getChanges(); + if (! changes.isEmpty()) { + LOG.debug("After unstash: moving " + changes.size() + " changes to '" + changeList.getName() + "'"); + changeManager.moveChangesTo(changeList, changes.toArray(new Change[changes.size()])); + } + } } catch (final VcsException ue) { exceptions.add(ue);