From 6b49b6c08e611d52e2ea6a43626e976ddb7064e5 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Wed, 11 May 2011 10:29:25 +0200 Subject: [PATCH] IDEA: local history fix --- .../revertion/ChangeRevertingVisitor.java | 6 ++++-- .../openapi/command/impl/ChangeRange.java | 16 +++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/platform/lvcs-impl/src/com/intellij/history/integration/revertion/ChangeRevertingVisitor.java b/platform/lvcs-impl/src/com/intellij/history/integration/revertion/ChangeRevertingVisitor.java index 5a6d57b1ea9a..6bc633ae63c7 100644 --- a/platform/lvcs-impl/src/com/intellij/history/integration/revertion/ChangeRevertingVisitor.java +++ b/platform/lvcs-impl/src/com/intellij/history/integration/revertion/ChangeRevertingVisitor.java @@ -26,6 +26,8 @@ import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.containers.HashSet; import com.intellij.util.io.ReadOnlyAttributeUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.IOException; import java.util.ArrayList; @@ -41,10 +43,10 @@ public class ChangeRevertingVisitor extends ChangeVisitor { private boolean isReverting; - public ChangeRevertingVisitor(IdeaGateway gw, long fromChangeId, long toChangeId) { + public ChangeRevertingVisitor(IdeaGateway gw, @NotNull Long fromChangeId, @Nullable Long toChangeId) { myGateway = gw; myFromChangeId = fromChangeId; - myToChangeId = toChangeId; + myToChangeId = toChangeId == null ? -1 : toChangeId; } protected boolean shouldRevert(Change c) { diff --git a/platform/lvcs-impl/src/com/intellij/openapi/command/impl/ChangeRange.java b/platform/lvcs-impl/src/com/intellij/openapi/command/impl/ChangeRange.java index 33a07a2389fd..ebfd8dc94cbb 100644 --- a/platform/lvcs-impl/src/com/intellij/openapi/command/impl/ChangeRange.java +++ b/platform/lvcs-impl/src/com/intellij/openapi/command/impl/ChangeRange.java @@ -21,20 +21,22 @@ import com.intellij.history.core.changes.Change; import com.intellij.history.integration.IdeaGateway; import com.intellij.history.integration.revertion.ChangeRevertingVisitor; import com.intellij.openapi.util.Ref; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.IOException; public class ChangeRange { private final IdeaGateway myGateway; private final LocalHistoryFacade myVcs; - private final long myFromChangeId; - private final long myToChangeId; + private final Long myFromChangeId; + @Nullable private final Long myToChangeId; - public ChangeRange(IdeaGateway gw, LocalHistoryFacade vcs, long change) { - this(gw, vcs, change, change); + public ChangeRange(IdeaGateway gw, LocalHistoryFacade vcs, @NotNull Long changeId) { + this(gw, vcs, changeId, changeId); } - public ChangeRange(IdeaGateway gw, LocalHistoryFacade vcs, long fromChangeId, long toChangeId) { + private ChangeRange(IdeaGateway gw, LocalHistoryFacade vcs, @Nullable Long fromChangeId, @Nullable Long toChangeId) { myGateway = gw; myVcs = vcs; myFromChangeId = fromChangeId; @@ -54,13 +56,13 @@ public class ChangeRange { try { myVcs.accept(new ChangeRevertingVisitor(myGateway, myToChangeId, myFromChangeId)); } - catch(ChangeRevertingVisitor.RuntimeIOException e) { + catch (ChangeRevertingVisitor.RuntimeIOException e) { throw (IOException)e.getCause(); } finally { myVcs.removeListener(l); } - + if (reverse != null) { if (first.isNull()) first.set(reverse.myFromChangeId); if (last.isNull()) last.set(reverse.myToChangeId);