diff options
Diffstat (limited to 'platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerSerialization.java')
-rw-r--r-- | platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerSerialization.java | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerSerialization.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerSerialization.java index a4c30e62bda5..0e20b4140b56 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerSerialization.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerSerialization.java @@ -22,12 +22,10 @@ import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.text.StringUtil; import org.jdom.Element; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; +import java.util.*; class ChangeListManagerSerialization { @NonNls static final String ATT_ID = "id"; @@ -44,6 +42,8 @@ class ChangeListManagerSerialization { @NonNls static final String NODE_LIST = "list"; @NonNls static final String NODE_IGNORED = "ignored"; @NonNls static final String NODE_CHANGE = "change"; + @NonNls static final String MANUALLY_REMOVED_FROM_IGNORED = "manually-removed-from-ignored"; + @NonNls static final String DIRECTORY_TAG = "directory"; private final IgnoredFilesComponent myIgnoredIdeaLevel; private final ChangeListWorker myWorker; @@ -60,9 +60,17 @@ class ChangeListManagerSerialization { readChangeList(listNode); } final List<Element> ignoredNodes = element.getChildren(NODE_IGNORED); - for (Element ignoredNode: ignoredNodes) { + for (Element ignoredNode : ignoredNodes) { readFileToIgnore(ignoredNode); } + Element manuallyRemovedFromIgnoredTag = element.getChild(MANUALLY_REMOVED_FROM_IGNORED); + Set<String> manuallyRemovedFromIgnoredPaths = new HashSet<String>(); + if (manuallyRemovedFromIgnoredTag != null) { + for (Element tag : manuallyRemovedFromIgnoredTag.getChildren(DIRECTORY_TAG)) { + manuallyRemovedFromIgnoredPaths.add(tag.getAttributeValue(ATT_PATH)); + } + } + myIgnoredIdeaLevel.setDirectoriesManuallyRemovedFromIgnored(manuallyRemovedFromIgnoredPaths); } private void readChangeList(final Element listNode) { @@ -90,7 +98,6 @@ class ChangeListManagerSerialization { if (ATT_VALUE_TRUE.equals(listNode.getAttributeValue(ATT_READONLY))) { list.setReadOnly(true); } - } private void readFileToIgnore(final Element ignoredNode) { @@ -123,7 +130,10 @@ class ChangeListManagerSerialization { listNode.setAttribute(ATT_ID, list.getId()); listNode.setAttribute(ATT_NAME, list.getName()); - listNode.setAttribute(ATT_COMMENT, list.getComment()); + String comment = list.getComment(); + if (comment != null) { + listNode.setAttribute(ATT_COMMENT, comment); + } List<Change> changes = new ArrayList<Change>(list.getChanges()); Collections.sort(changes, new ChangeComparator()); for (Change change : changes) { @@ -131,26 +141,35 @@ class ChangeListManagerSerialization { } } final IgnoredFileBean[] filesToIgnore = myIgnoredIdeaLevel.getFilesToIgnore(); - for(IgnoredFileBean bean: filesToIgnore) { - Element fileNode = new Element(NODE_IGNORED); - element.addContent(fileNode); - String path = bean.getPath(); - if (path != null) { - fileNode.setAttribute("path", path); - } - String mask = bean.getMask(); - if (mask != null) { - fileNode.setAttribute("mask", mask); - } + for (IgnoredFileBean bean : filesToIgnore) { + Element fileNode = new Element(NODE_IGNORED); + element.addContent(fileNode); + String path = bean.getPath(); + if (path != null) { + fileNode.setAttribute("path", path); + } + String mask = bean.getMask(); + if (mask != null) { + fileNode.setAttribute("mask", mask); } + } + Set<String> manuallyRemovedFromIgnored = myIgnoredIdeaLevel.getDirectoriesManuallyRemovedFromIgnored(); + if (!manuallyRemovedFromIgnored.isEmpty()) { + Element list = new Element(MANUALLY_REMOVED_FROM_IGNORED); + for (String path : manuallyRemovedFromIgnored) { + list.addContent(new Element(DIRECTORY_TAG).setAttribute(ATT_PATH, path)); + } + element.addContent(list); + } } private static class ChangeComparator implements Comparator<Change> { @Override - public int compare(Change o1, Change o2) { + public int compare(@NotNull Change o1, @NotNull Change o2) { return Comparing.compare(o1.toString(), o2.toString()); } } + private static void writeChange(final Element listNode, final Change change) { Element changeNode = new Element(NODE_CHANGE); listNode.addContent(changeNode); |