diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/AddList.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/AddList.java index 5be08d54c56a..ab8d0b82e0d7 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/AddList.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/AddList.java @@ -28,24 +28,32 @@ public class AddList implements ChangeListCommand { @Nullable private final Object myData; private LocalChangeList myNewListCopy; + private String myOldComment; - public AddList(@NotNull final String name, @Nullable final String comment, @Nullable Object data) { + public AddList(@NotNull String name, @Nullable String comment, @Nullable Object data) { myName = name; myComment = comment; myData = data; } public void apply(final ChangeListWorker worker) { - if (! worker.findListByName(myName)) { + myNewListCopy = worker.getCopyByName(myName); + if (myNewListCopy != null) { + myOldComment = worker.editComment(myName, myComment); + } + else { myNewListCopy = worker.addChangeList(myName, myComment, myData); - } else { - worker.editComment(myName, myComment); - myNewListCopy = worker.getCopyByName(myName); + myOldComment = null; } } public void doNotify(final EventDispatcher dispatcher) { - dispatcher.getMulticaster().changeListAdded(myNewListCopy); + if (myOldComment != null) { + dispatcher.getMulticaster().changeListCommentChanged(myNewListCopy, myOldComment); + } + else { + dispatcher.getMulticaster().changeListAdded(myNewListCopy); + } } public LocalChangeList getNewListCopy() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/EditComment.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/EditComment.java index cf60ab475c3d..b82c11dde9ee 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/EditComment.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/EditComment.java @@ -20,25 +20,29 @@ import com.intellij.openapi.vcs.changes.ChangeListListener; import com.intellij.openapi.vcs.changes.ChangeListWorker; import com.intellij.openapi.vcs.changes.LocalChangeList; import com.intellij.util.EventDispatcher; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class EditComment implements ChangeListCommand { private final String myName; private final String myNewComment; + private String myOldComment; private LocalChangeList myListCopy; - public EditComment(final String name, final String newComment) { + public EditComment(@NotNull String name, @Nullable String newComment) { myNewComment = newComment; myName = name; } public void apply(final ChangeListWorker worker) { - myListCopy = worker.getCopyByName(myName); - if (myListCopy != null) { - myOldComment = worker.editComment(myName, myNewComment); - if (Comparing.equal(myOldComment, myNewComment)) { - myListCopy = null; // nothing changed, no notify - } + myOldComment = worker.editComment(myName, myNewComment); + + if (myOldComment != null && !Comparing.equal(myOldComment, myNewComment)) { + myListCopy = worker.getCopyByName(myName); + } + else { + myListCopy = null; // nothing changed, no notify } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/EditName.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/EditName.java index d9522f37a83c..04e0946e500e 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/EditName.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/EditName.java @@ -22,28 +22,25 @@ import com.intellij.util.EventDispatcher; import org.jetbrains.annotations.NotNull; public class EditName implements ChangeListCommand { - @NotNull - private final String myFromName; - @NotNull - private final String myToName; + @NotNull private final String myFromName; + @NotNull private final String myToName; + private boolean myResult; private LocalChangeList myListCopy; - public EditName(@NotNull final String fromName, @NotNull final String toName) { + public EditName(@NotNull String fromName, @NotNull String toName) { myFromName = fromName; myToName = toName; } public void apply(final ChangeListWorker worker) { - final LocalChangeList fromList = worker.getCopyByName(myFromName); - if (fromList != null && (! fromList.isReadOnly())) { - myResult = worker.editName(myFromName, myToName); - myListCopy = worker.getCopyByName(myToName); - } + myResult = worker.editName(myFromName, myToName); + + myListCopy = worker.getCopyByName(myToName); } public void doNotify(final EventDispatcher dispatcher) { - if (myListCopy != null && (! myListCopy.isReadOnly())) { + if (myListCopy != null && myResult) { dispatcher.getMulticaster().changeListRenamed(myListCopy, myFromName); } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/MoveChanges.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/MoveChanges.java index 772dd78eada4..4e0bfd99d38e 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/MoveChanges.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/MoveChanges.java @@ -27,23 +27,25 @@ import java.util.Collection; public class MoveChanges implements ChangeListCommand { private final String myName; private final Change[] myChanges; - private MultiMap myMovedFrom; + + private MultiMap myMovedFrom; private LocalChangeList myListCopy; - public MoveChanges(final String name, final Change[] changes) { + public MoveChanges(String name, Change[] changes) { myName = name; myChanges = changes; } public void apply(final ChangeListWorker worker) { myMovedFrom = worker.moveChangesTo(myName, myChanges); + myListCopy = worker.getCopyByName(myName); } public void doNotify(final EventDispatcher dispatcher) { - if ((myMovedFrom != null) && (myListCopy != null)) { - for(LocalChangeList fromList: myMovedFrom.keySet()) { - final Collection changesInList = myMovedFrom.get(fromList); + if (myMovedFrom != null && myListCopy != null) { + for (LocalChangeList fromList : myMovedFrom.keySet()) { + Collection changesInList = myMovedFrom.get(fromList); dispatcher.getMulticaster().changesMoved(changesInList, fromList, myListCopy); } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/RemoveList.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/RemoveList.java index 22c950e12f83..d41654f89044 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/RemoveList.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/RemoveList.java @@ -23,6 +23,7 @@ import com.intellij.util.EventDispatcher; public class RemoveList implements ChangeListCommand { private final String myName; private boolean myRemoved; + private LocalChangeList myListCopy; private LocalChangeList myDefaultListCopy; @@ -37,8 +38,8 @@ public class RemoveList implements ChangeListCommand { } public void doNotify(final EventDispatcher dispatcher) { - if (myRemoved) { - final ChangeListListener multicaster = dispatcher.getMulticaster(); + if (myListCopy != null && myRemoved ) { + ChangeListListener multicaster = dispatcher.getMulticaster(); multicaster.changesMoved(myListCopy.getChanges(), myListCopy, myDefaultListCopy); multicaster.changeListRemoved(myListCopy); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/SetDefault.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/SetDefault.java index 867211a380b1..966daec6b577 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/SetDefault.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/SetDefault.java @@ -19,25 +19,37 @@ import com.intellij.openapi.vcs.changes.ChangeListListener; import com.intellij.openapi.vcs.changes.ChangeListWorker; import com.intellij.openapi.vcs.changes.LocalChangeList; import com.intellij.util.EventDispatcher; +import org.jetbrains.annotations.Nullable; public class SetDefault implements ChangeListCommand { private final String myNewDefaultName; + private String myPrevious; private LocalChangeList myOldDefaultListCopy; private LocalChangeList myNewDefaultListCopy; - public SetDefault(final String newDefaultName) { + public SetDefault(@Nullable String newDefaultName) { myNewDefaultName = newDefaultName; } - public void apply(final ChangeListWorker worker) { + public void apply(ChangeListWorker worker) { + LocalChangeList list = worker.getCopyByName(myNewDefaultName); + if (list == null || list.isDefault()) { + myOldDefaultListCopy = null; + myPrevious = null; + myNewDefaultListCopy = null; + return; + } + myOldDefaultListCopy = worker.getDefaultListCopy(); myPrevious = worker.setDefault(myNewDefaultName); myNewDefaultListCopy = worker.getDefaultListCopy(); } public void doNotify(final EventDispatcher dispatcher) { - dispatcher.getMulticaster().defaultListChanged(myOldDefaultListCopy, myNewDefaultListCopy); + if (myPrevious != null) { + dispatcher.getMulticaster().defaultListChanged(myOldDefaultListCopy, myNewDefaultListCopy); + } } public String getPrevious() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/SetReadOnly.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/SetReadOnly.java index 34282cc4b2f1..95e1279e5f92 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/SetReadOnly.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/local/SetReadOnly.java @@ -23,26 +23,25 @@ import com.intellij.util.EventDispatcher; public class SetReadOnly implements ChangeListCommand { private final String myName; private final boolean myValue; + private boolean myResult; private LocalChangeList myListCopy; - public SetReadOnly(final String name, final boolean value) { + public SetReadOnly(String name, boolean value) { myName = name; myValue = value; } public void apply(final ChangeListWorker worker) { myResult = worker.setReadOnly(myName, myValue); + myListCopy = worker.getCopyByName(myName); } public void doNotify(final EventDispatcher dispatcher) { - // +- - dispatcher.getMulticaster().changeListChanged(myListCopy); - } - - public void consume(final ChangeListWorker worker) { - myResult = worker.setReadOnly(myName, myValue); + if (myListCopy != null && myResult) { + dispatcher.getMulticaster().changeListChanged(myListCopy); + } } public boolean isResult() {