assert: GitApplyChangesProcess.moveChanges

`ChangeListCommand` can be invoked twice, if CLM is being updated
 when `CLM.addChangeList` is called.

In this case LocalChangeList that is returned by `CLM.addChangeList`
 and LocalChangeList that will be actually created when update is completed
 will have different IDs (but same names / data / etc).

This broke listener in GitApplyChangesProcess and we couldn't await
 for the changes to be moved (as we waited for the list with different ID).
This commit is contained in:
Aleksey Pivovarov
2017-10-20 13:16:27 +03:00
parent 8838a65464
commit 9f8b001fa2
2 changed files with 10 additions and 7 deletions
@@ -198,19 +198,19 @@ public class ChangeListWorker {
}
@NotNull
public LocalChangeList addChangeList(@NotNull String name, @Nullable String comment, @Nullable ChangeListData data) {
return addChangeList(name, comment, false, data);
public LocalChangeList addChangeList(@NotNull String name, @Nullable String comment, @Nullable String id, @Nullable ChangeListData data) {
return addChangeList(name, comment, id, data, false);
}
@NotNull
private LocalChangeList addChangeList(@NotNull String name, @Nullable String description, boolean inUpdate,
@Nullable ChangeListData data) {
private LocalChangeList addChangeList(@NotNull String name, @Nullable String description, @Nullable String id,
@Nullable ChangeListData data, boolean inUpdate) {
if (myMap.containsKey(name)) {
LOG.error("Attempt to create duplicate changelist " + name);
return myMap.get(name);
}
LocalChangeListImpl newList = LocalChangeListImpl.createEmptyChangeListImpl(myProject, name, null);
LocalChangeListImpl newList = LocalChangeListImpl.createEmptyChangeListImpl(myProject, name, id);
newList.setCommentImpl(description);
newList.setData(data);
@@ -734,7 +734,7 @@ public class ChangeListWorker {
@NotNull
@Override
public LocalChangeList addChangeList(@NotNull String name, @Nullable String comment) {
return myWorker.addChangeList(name, comment, true, null).copy();
return myWorker.addChangeList(name, comment, null, null, true).copy();
}
@NotNull
@@ -42,9 +42,12 @@ public class AddList implements ChangeListCommand {
public void apply(final ChangeListWorker worker) {
LocalChangeList list = worker.getChangeListByName(myName);
if (list == null) {
// Create list with the same id, if we were invoked before (on "temp" worker during CLM update).
String id = myNewListCopy != null ? myNewListCopy.getId() : null;
myWasListCreated = true;
myOldComment = null;
myNewListCopy = worker.addChangeList(myName, myComment, myData).copy();
myNewListCopy = worker.addChangeList(myName, myComment, id, myData).copy();
}
else if (StringUtil.isNotEmpty(myComment)) {
myWasListCreated = false;