diff options
Diffstat (limited to 'plugins/svn4idea')
227 files changed, 4958 insertions, 3267 deletions
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/ConflictedSvnChange.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/ConflictedSvnChange.java index 27b1b36800fe..e8361b0eb874 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/ConflictedSvnChange.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/ConflictedSvnChange.java @@ -19,16 +19,15 @@ import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.FileStatus; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.ContentRevision; -import org.tmatesoft.svn.core.internal.wc.SVNTreeConflictUtil; -import org.tmatesoft.svn.core.wc.SVNTreeConflictDescription; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; import javax.swing.*; public class ConflictedSvnChange extends Change { private final ConflictState myConflictState; // also used if not move/rename - private SVNTreeConflictDescription myBeforeDescription; - private SVNTreeConflictDescription myAfterDescription; + private TreeConflictDescription myBeforeDescription; + private TreeConflictDescription myAfterDescription; // +- private final FilePath myTreeConflictMarkHolder; private boolean myIsPhantom; @@ -66,19 +65,19 @@ public class ConflictedSvnChange extends Change { return myIsPhantom; } - public SVNTreeConflictDescription getBeforeDescription() { + public TreeConflictDescription getBeforeDescription() { return myBeforeDescription; } - public void setBeforeDescription(SVNTreeConflictDescription beforeDescription) { + public void setBeforeDescription(TreeConflictDescription beforeDescription) { myBeforeDescription = beforeDescription; } - public SVNTreeConflictDescription getAfterDescription() { + public TreeConflictDescription getAfterDescription() { return myAfterDescription; } - public void setAfterDescription(SVNTreeConflictDescription afterDescription) { + public void setAfterDescription(TreeConflictDescription afterDescription) { myAfterDescription = afterDescription; } @@ -97,14 +96,14 @@ public class ConflictedSvnChange extends Change { if (myAfterDescription != null) { sb.append("before: "); } - sb.append(SVNTreeConflictUtil.getHumanReadableConflictDescription(myBeforeDescription)); + sb.append(myBeforeDescription.toPresentableString()); } if (myAfterDescription != null) { sb.append('\n'); if (myBeforeDescription != null) { sb.append("after: "); } - sb.append(SVNTreeConflictUtil.getHumanReadableConflictDescription(myAfterDescription)); + sb.append(myAfterDescription.toPresentableString()); } return sb.toString(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/DepthCombo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/DepthCombo.java index b55b50bb323a..4eea25ac14ca 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/DepthCombo.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/DepthCombo.java @@ -15,50 +15,32 @@ */ package org.jetbrains.idea.svn; -import org.tmatesoft.svn.core.SVNDepth; +import com.intellij.ui.ListCellRendererWrapper; +import org.jetbrains.idea.svn.api.Depth; import javax.swing.*; public class DepthCombo extends JComboBox { public DepthCombo(final boolean forUpdate) { super(forUpdate ? ourForUpdate : ourForCheckout); - setSelectedIndex(forUpdate ? 0 : 3); + setRenderer(new DepthRenderer()); + setSelectedItem(forUpdate ? Depth.UNKNOWN : Depth.INFINITY); setEditable(false); setToolTipText(SvnBundle.message("label.depth.description")); } - public SVNDepth getDepth() { - return ((SVNDepthWithName) super.getSelectedItem()).getDepth(); + public Depth getDepth() { + return (Depth)super.getSelectedItem(); } - private final static SVNDepthWithName [] ourForUpdate = {new SVNDepthWithName(SVNDepth.UNKNOWN, "working copy"), - new SVNDepthWithName(SVNDepth.EMPTY), new SVNDepthWithName(SVNDepth.FILES), new SVNDepthWithName(SVNDepth.IMMEDIATES), - new SVNDepthWithName(SVNDepth.INFINITY)}; - private final static SVNDepthWithName [] ourForCheckout = { - new SVNDepthWithName(SVNDepth.EMPTY), new SVNDepthWithName(SVNDepth.FILES), new SVNDepthWithName(SVNDepth.IMMEDIATES), - new SVNDepthWithName(SVNDepth.INFINITY)}; + private final static Depth[] ourForUpdate = {Depth.UNKNOWN, Depth.EMPTY, Depth.FILES, Depth.IMMEDIATES, Depth.INFINITY}; + private final static Depth[] ourForCheckout = {Depth.EMPTY, Depth.FILES, Depth.IMMEDIATES, Depth.INFINITY}; - private static class SVNDepthWithName { - private final SVNDepth myDepth; - private final String myName; - - private SVNDepthWithName(SVNDepth depth) { - myDepth = depth; - myName = myDepth.toString(); - } - - private SVNDepthWithName(SVNDepth depth, String name) { - myDepth = depth; - myName = name; - } + private static class DepthRenderer extends ListCellRendererWrapper<Depth> { @Override - public String toString() { - return myName; - } - - public SVNDepth getDepth() { - return myDepth; + public void customize(JList list, Depth value, int index, boolean selected, boolean hasFocus) { + setText(Depth.UNKNOWN.equals(value) ? "working copy" : value.getName()); } } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/ForNestedRootChecker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/ForNestedRootChecker.java index 333cf9e52c01..e87c55dc447d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/ForNestedRootChecker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/ForNestedRootChecker.java @@ -21,10 +21,10 @@ import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.SVNErrorCode; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -108,8 +108,8 @@ public class ForNestedRootChecker { @NotNull private final SvnVcs myVcs; @NotNull private final VirtualFile myFile; @NotNull private final File myIoFile; - @Nullable private SVNInfo myInfo; - @Nullable private SVNException myError; + @Nullable private Info myInfo; + @Nullable private SvnBindException myError; private VcsFileResolver(@NotNull SvnVcs vcs, @NotNull VirtualFile file) { myVcs = vcs; @@ -128,7 +128,7 @@ public class ForNestedRootChecker { try { myInfo = myVcs.getFactory(myIoFile, false).createInfoClient().doInfo(myIoFile, SVNRevision.UNDEFINED); } - catch (SVNException e) { + catch (SvnBindException e) { myError = e; } } @@ -138,9 +138,7 @@ public class ForNestedRootChecker { Node result = null; if (myError != null) { - SVNErrorCode errorCode = myError.getErrorMessage().getErrorCode(); - - if (!SvnUtil.isUnversionedOrNotFound(errorCode)) { + if (!SvnUtil.isUnversionedOrNotFound(myError)) { // error code does not indicate that myFile is unversioned or path is invalid => create result, but indicate error result = new Node(myFile, getFakeUrl(), getFakeUrl(), myError); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java index 7934761fce12..d0eafb77bc4b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java @@ -20,10 +20,10 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.util.HashSet; @@ -42,9 +42,9 @@ public class NestedCopiesBuilder implements StatusReceiver { mySet = new HashSet<NestedCopyInfo>(); } - public void process(final FilePath path, final SVNStatus status) throws SVNException { + public void process(final FilePath path, final Status status) throws SVNException { VirtualFile file = path.getVirtualFile(); - if (file != null && SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_EXTERNAL)) { + if (file != null && status.is(StatusType.STATUS_EXTERNAL)) { // We do not determine here url, repository url - because url, repository url in status will determine location in the // repository where folder is located and not where svn:externals property points. We want the later parameters - they'll // determined while creating RootUrlInfos later. Format will be also determined later. @@ -55,7 +55,7 @@ public class NestedCopiesBuilder implements StatusReceiver { } if (file == null || status.getURL() == null) return; - if (!SvnVcs.svnStatusIsUnversioned(status) && status.isSwitched()) { + if (!status.is(StatusType.STATUS_UNVERSIONED) && status.isSwitched()) { // this one called when there is switched directory under nested working copy // TODO: some other cases? final NestedCopyInfo diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/Node.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/Node.java index 83290a3e05c0..3d1d77e210d1 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/Node.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/Node.java @@ -19,7 +19,7 @@ import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNURL; import java.io.File; @@ -31,13 +31,13 @@ public class Node { @NotNull private final VirtualFile myFile; @NotNull private final SVNURL myUrl; @NotNull private final SVNURL myRepositoryUrl; - @Nullable private final SVNException myError; + @Nullable private final SvnBindException myError; public Node(@NotNull VirtualFile file, @NotNull SVNURL url, @NotNull SVNURL repositoryUrl) { this(file, url, repositoryUrl, null); } - public Node(@NotNull VirtualFile file, @NotNull SVNURL url, @NotNull SVNURL repositoryUrl, @Nullable SVNException error) { + public Node(@NotNull VirtualFile file, @NotNull SVNURL url, @NotNull SVNURL repositoryUrl, @Nullable SvnBindException error) { myFile = file; myUrl = url; myRepositoryUrl = repositoryUrl; @@ -65,7 +65,7 @@ public class Node { } @Nullable - public SVNException getError() { + public SvnBindException getError() { return myError; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/RepeatSvnActionThroughBusy.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/RepeatSvnActionThroughBusy.java index b669f2bfb38b..e078c572d65d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/RepeatSvnActionThroughBusy.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/RepeatSvnActionThroughBusy.java @@ -15,6 +15,7 @@ */ package org.jetbrains.idea.svn; +import com.intellij.openapi.vcs.VcsException; import com.intellij.util.Processor; import org.tmatesoft.sqljet.core.SqlJetErrorCode; import org.tmatesoft.sqljet.core.SqlJetException; @@ -52,20 +53,23 @@ public abstract class RepeatSvnActionThroughBusy { protected int myCnt = REPEAT; protected long myTimeout = 50; - protected abstract void executeImpl() throws SVNException; + + protected abstract void executeImpl() throws VcsException; + protected Object myT; - public <T> T compute() throws SVNException { + public <T> T compute() throws VcsException { execute(); return (T) myT; } - public void execute() throws SVNException { + public void execute() throws VcsException { while (true) { try { executeImpl(); break; - } catch (SVNException e) { + } + catch (VcsException e) { if (ourBusyExceptionProcessor.process(e)) { if (myCnt > 0) { try { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/RootsToWorkingCopies.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/RootsToWorkingCopies.java index 5ca7f9eaa39b..06138b345b74 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/RootsToWorkingCopies.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/RootsToWorkingCopies.java @@ -29,14 +29,9 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Alarm; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNURLUtil; -import org.tmatesoft.svn.core.internal.wc.admin.SVNEntry; -import org.tmatesoft.svn.core.internal.wc.admin.SVNWCAccess; -import org.tmatesoft.svn.core.wc.SVNInfo; -import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNWCUtil; import java.io.File; import java.util.HashMap; @@ -127,7 +122,7 @@ public class RootsToWorkingCopies implements VcsListener { WorkingCopy workingCopy = null; if (workingCopyRoot != null) { - final SVNInfo svnInfo = myVcs.getInfo(workingCopyRoot); + final Info svnInfo = myVcs.getInfo(workingCopyRoot); if (svnInfo != null && svnInfo.getURL() != null) { workingCopy = new WorkingCopy(workingCopyRoot, svnInfo.getURL(), true); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusReceiver.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusReceiver.java index 8524c83366e6..ac165c48f5c3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusReceiver.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusReceiver.java @@ -17,14 +17,14 @@ package org.jetbrains.idea.svn; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.idea.svn.status.Status; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNStatus; import java.util.EventListener; public interface StatusReceiver extends EventListener { - void process(final FilePath path, final SVNStatus status) throws SVNException; + void process(final FilePath path, final Status status) throws SVNException; void processIgnored(final VirtualFile vFile); void processUnversioned(final VirtualFile vFile); void processCopyRoot(VirtualFile file, SVNURL url, WorkingCopyFormat format, SVNURL rootURL); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusWalkerPartner.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusWalkerPartner.java index 09d7d87ec1dc..367ae1bc4619 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusWalkerPartner.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusWalkerPartner.java @@ -25,11 +25,11 @@ import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNCancelException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.ISVNStatusFileProvider; -import org.tmatesoft.svn.core.wc.SVNEvent; public class StatusWalkerPartner { private final SvnVcs myVcs; @@ -50,9 +50,9 @@ public class StatusWalkerPartner { } @NotNull - public ISVNEventHandler getEventHandler() { - return new ISVNEventHandler() { - public void handleEvent(SVNEvent event, double progress) throws SVNException { + public ProgressTracker getEventHandler() { + return new ProgressTracker() { + public void consume(ProgressEvent event) throws SVNException { // } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties index 38418b16ef53..df545b0373a1 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties @@ -322,9 +322,9 @@ progress.title.commit=Commit progress.text.committing.changes.below=Creating commit packets... status.text.committed.revision=Committed revision {0}. checkin.operation.name=Comm_it -checkin.different.formats.involved=Selected changes for {0,choice,0#repository|1#repositories} {1}\nbelong to both before- 1.7 format and 1.7 format \ -Subversion working copies.\nCommit will split into several commits.\n\n\ -You can convert all working copies into 1.7 format in Changes | Subversion Working Copies Information.\nDo you wish to continue with commit? +checkin.different.formats.involved=Selected changes for {0,choice,0#repository|1#repositories} {1}\nbelong to Subversion working copies of \ +different formats.\nCommit will split into several commits.\n\n\ +You can convert all working copies to the same format in Changes | Subversion Working Copies Information.\nDo you wish to continue with commit? progress.text.collecting.commitables=Collecting commitables at ''{0}'' progress.text2.fetching.external.location=Fetching external location to ''{0}'' progress.text2.checked.out=Checked out {1} files, checking out {0} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProvider.java index 3b0195e6079d..073826f6b035 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProvider.java @@ -34,14 +34,15 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.EventDispatcher; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.actions.CleanupWorker; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.commandLine.SvnExceptionWrapper; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import org.tmatesoft.svn.core.wc.ISVNStatusFileProvider; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.util.*; @@ -86,12 +87,12 @@ public class SvnChangeProvider implements ChangeProvider { final SvnRecursiveStatusWalker walker = new SvnRecursiveStatusWalker(myVcs, statusReceiver.getMulticaster(), partner); for (FilePath path : zipper.getRecursiveDirs()) { - walker.go(path, SVNDepth.INFINITY); + walker.go(path, Depth.INFINITY); } partner.setFileProvider(fileProvider); for (SvnScopeZipper.MyDirNonRecursive item : nonRecursiveMap.values()) { - walker.go(item.getDir(), SVNDepth.IMMEDIATES); + walker.go(item.getDir(), Depth.IMMEDIATES); } processCopiedAndDeleted(context, dirtyScope); @@ -111,6 +112,10 @@ public class SvnChangeProvider implements ChangeProvider { } } + /** + * TODO: Currently could not find exact case when "file status is not correctly refreshed after external commit" that is covered by this + * TODO: code. So for now, checks for formats greater than 1.7 are not added here. + */ private static void putAdministrative17UnderVfsListener(Set<NestedCopyInfo> pointInfos) { if (! SvnVcs.ourListenToWcDb) return; final LocalFileSystem lfs = LocalFileSystem.getInstance(); @@ -169,11 +174,12 @@ public class SvnChangeProvider implements ChangeProvider { } } - public void getChanges(final FilePath path, final boolean recursive, final ChangelistBuilder builder) throws SVNException { + public void getChanges(final FilePath path, final boolean recursive, final ChangelistBuilder builder) + throws SVNException, SvnBindException { final SvnChangeProviderContext context = new SvnChangeProviderContext(myVcs, builder, null); final StatusWalkerPartner partner = new StatusWalkerPartner(myVcs, ProgressManager.getInstance().getProgressIndicator()); final SvnRecursiveStatusWalker walker = new SvnRecursiveStatusWalker(myVcs, context, partner); - walker.go(path, recursive ? SVNDepth.INFINITY : SVNDepth.IMMEDIATES); + walker.go(path, recursive ? Depth.INFINITY : Depth.IMMEDIATES); processCopiedAndDeleted(context, null); } @@ -181,7 +187,7 @@ public class SvnChangeProvider implements ChangeProvider { ChangelistBuilder builder, SvnChangeProviderContext context, final VcsDirtyScope dirtyScope) throws SVNException { boolean foundRename = false; - final SVNStatus copiedStatus = copiedFile.getStatus(); + final Status copiedStatus = copiedFile.getStatus(); final String copyFromURL = copiedFile.getCopyFromURL(); final FilePath copiedToPath = copiedFile.getFilePath(); @@ -199,7 +205,7 @@ public class SvnChangeProvider implements ChangeProvider { for (Iterator<SvnChangedFile> iterator = context.getDeletedFiles().iterator(); iterator.hasNext();) { SvnChangedFile deletedFile = iterator.next(); - final SVNStatus deletedStatus = deletedFile.getStatus(); + final Status deletedStatus = deletedFile.getStatus(); if ((deletedStatus != null) && (deletedStatus.getURL() != null) && Comparing.equal(copyFromURL, deletedStatus.getURL().toString())) { final String clName = SvnUtil.getChangelistName(copiedFile.getStatus()); final Change newChange = context.createMovedChange(createBeforeRevision(deletedFile, true), @@ -208,7 +214,7 @@ public class SvnChangeProvider implements ChangeProvider { applyMovedChange(copiedFile.getFilePath(), builder, dirtyScope, deletedToDelete, deletedFile, clName, newChange); for(Iterator<SvnChangedFile> iterChild = context.getDeletedFiles().iterator(); iterChild.hasNext();) { SvnChangedFile deletedChild = iterChild.next(); - final SVNStatus childStatus = deletedChild.getStatus(); + final Status childStatus = deletedChild.getStatus(); if (childStatus == null) { continue; } @@ -243,15 +249,15 @@ public class SvnChangeProvider implements ChangeProvider { // by building a relative url if (!foundRename && copiedStatus.getURL() != null) { File wcPath = guessWorkingCopyPath(copiedStatus.getFile(), copiedStatus.getURL(), copyFromURL); - SVNStatus status; + Status status; try { status = myVcs.getFactory(wcPath).createStatusClient().doStatus(wcPath, false); } - catch(SVNException ex) { + catch(SvnBindException ex) { LOG.info(ex); status = null; } - if (status != null && SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) { + if (status != null && status.is(StatusType.STATUS_DELETED)) { final FilePath filePath = myFactory.createFilePathOnDeleted(wcPath, false); final SvnContentRevision beforeRevision = SvnContentRevision.createBaseRevision(myVcs, filePath, status.getRevision()); final ContentRevision afterRevision = CurrentContentRevision.create(copiedFile.getFilePath()); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProviderContext.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProviderContext.java index f7e5857569ff..716abbe1b20b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProviderContext.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProviderContext.java @@ -26,13 +26,13 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.actions.AbstractShowPropertiesDiffAction; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.lock.Lock; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNLock; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.util.*; @@ -44,7 +44,7 @@ class SvnChangeProviderContext implements StatusReceiver { private List<SvnChangedFile> myCopiedFiles = null; private final List<SvnChangedFile> myDeletedFiles = new ArrayList<SvnChangedFile>(); // for files moved in a subtree, which were the targets of merge (for instance). - private final Map<String, SVNStatus> myTreeConflicted; + private final Map<String, Status> myTreeConflicted; private Map<FilePath, String> myCopyFromURLs = null; private final SvnVcs myVcs; private final SvnBranchConfigurationManager myBranchConfigurationManager; @@ -55,11 +55,11 @@ class SvnChangeProviderContext implements StatusReceiver { myVcs = vcs; myChangelistBuilder = changelistBuilder; myProgress = progress; - myTreeConflicted = new HashMap<String, SVNStatus>(); + myTreeConflicted = new HashMap<String, Status>(); myBranchConfigurationManager = SvnBranchConfigurationManager.getInstance(myVcs.getProject()); } - public void process(FilePath path, SVNStatus status) throws SVNException { + public void process(FilePath path, Status status) throws SVNException { processStatusFirstPass(path, status); } @@ -83,12 +83,12 @@ class SvnChangeProviderContext implements StatusReceiver { return myChangelistBuilder; } - public void reportTreeConflict(final SVNStatus status) { + public void reportTreeConflict(final Status status) { myTreeConflicted.put(status.getFile().getAbsolutePath(), status); } @Nullable - public SVNStatus getTreeConflictStatus(final File file) { + public Status getTreeConflictStatus(final File file) { return myTreeConflicted.get(file.getAbsolutePath()); } @@ -140,7 +140,7 @@ class SvnChangeProviderContext implements StatusReceiver { return null; } - public void addCopiedFile(final FilePath filePath, final SVNStatus status, final String copyFromURL) { + public void addCopiedFile(final FilePath filePath, final Status status, final String copyFromURL) { if (myCopiedFiles == null) { myCopiedFiles = new ArrayList<SvnChangedFile>(); } @@ -160,19 +160,19 @@ class SvnChangeProviderContext implements StatusReceiver { // - void processStatusFirstPass(final FilePath filePath, final SVNStatus status) throws SVNException { + void processStatusFirstPass(final FilePath filePath, final Status status) throws SVNException { if (status == null) { // external to wc return; } if (status.getRemoteLock() != null) { - final SVNLock lock = status.getRemoteLock(); + final Lock lock = status.getRemoteLock(); myChangelistBuilder.processLogicallyLockedFolder(filePath.getVirtualFile(), new LogicalLock(false, lock.getOwner(), lock.getComment(), lock.getCreationDate(), lock.getExpirationDate())); } if (status.getLocalLock() != null) { - final SVNLock lock = status.getLocalLock(); + final Lock lock = status.getLocalLock(); myChangelistBuilder.processLogicallyLockedFolder(filePath.getVirtualFile(), new LogicalLock(true, lock.getOwner(), lock.getComment(), lock.getCreationDate(), lock.getExpirationDate())); @@ -180,11 +180,11 @@ class SvnChangeProviderContext implements StatusReceiver { if (filePath.isDirectory() && status.isLocked()) { myChangelistBuilder.processLockedFolder(filePath.getVirtualFile()); } - if ((SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_ADDED) || SVNStatusType.STATUS_MODIFIED.equals(status.getNodeStatus())) && + if ((status.is(StatusType.STATUS_ADDED) || StatusType.STATUS_MODIFIED.equals(status.getNodeStatus())) && status.getCopyFromURL() != null) { addCopiedFile(filePath, status, status.getCopyFromURL()); } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) { + else if (status.is(StatusType.STATUS_DELETED)) { myDeletedFiles.add(new SvnChangedFile(filePath, status)); } else { @@ -198,7 +198,7 @@ class SvnChangeProviderContext implements StatusReceiver { } } - void processStatus(final FilePath filePath, final SVNStatus status) throws SVNException { + void processStatus(final FilePath filePath, final Status status) throws SVNException { WorkingCopyFormat format = myVcs.getWorkingCopyFormat(filePath.getIOFile()); if (!WorkingCopyFormat.UNKNOWN.equals(format) && format.less(WorkingCopyFormat.ONE_DOT_SEVEN)) { loadEntriesFile(filePath); @@ -207,38 +207,36 @@ class SvnChangeProviderContext implements StatusReceiver { if (status != null) { FileStatus fStatus = SvnStatusConvertor.convertStatus(status); - final SVNStatusType statusType = status.getContentsStatus(); - final SVNStatusType propStatus = status.getPropertiesStatus(); - if (SvnVcs.svnStatusIsUnversioned(status) || SvnVcs.svnStatusIs(status, SVNStatusType.UNKNOWN)) { + final StatusType statusType = status.getContentsStatus(); + final StatusType propStatus = status.getPropertiesStatus(); + if (status.is(StatusType.STATUS_UNVERSIONED, StatusType.UNKNOWN)) { final VirtualFile file = filePath.getVirtualFile(); if (file != null) { myChangelistBuilder.processUnversionedFile(file); } } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_ADDED)) { + else if (status.is(StatusType.STATUS_ADDED)) { myChangelistBuilder.processChangeInList(createChange(null, CurrentContentRevision.create(filePath), fStatus, status), SvnUtil.getChangelistName(status), SvnVcs.getKey()); } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_CONFLICTED) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MODIFIED) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_REPLACED) || - propStatus == SVNStatusType.STATUS_MODIFIED || - propStatus == SVNStatusType.STATUS_CONFLICTED) { + else if (status.is(StatusType.STATUS_CONFLICTED, StatusType.STATUS_MODIFIED, StatusType.STATUS_REPLACED) || + propStatus == StatusType.STATUS_MODIFIED || + propStatus == StatusType.STATUS_CONFLICTED) { myChangelistBuilder.processChangeInList( createChange(SvnContentRevision.createBaseRevision(myVcs, filePath, status), CurrentContentRevision.create(filePath), fStatus, status), SvnUtil.getChangelistName(status), SvnVcs.getKey() ); checkSwitched(filePath, myChangelistBuilder, status, fStatus); } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) { + else if (status.is(StatusType.STATUS_DELETED)) { myChangelistBuilder.processChangeInList( createChange(SvnContentRevision.createBaseRevision(myVcs, filePath, status), null, fStatus, status), SvnUtil.getChangelistName(status), SvnVcs.getKey()); } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MISSING)) { + else if (status.is(StatusType.STATUS_MISSING)) { myChangelistBuilder.processLocallyDeletedFile(createLocallyDeletedChange(filePath, status)); } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_IGNORED)) { + else if (status.is(StatusType.STATUS_IGNORED)) { if (!myVcs.isWcRoot(filePath)) { myChangelistBuilder.processIgnoredFile(filePath.getVirtualFile()); } @@ -246,7 +244,7 @@ class SvnChangeProviderContext implements StatusReceiver { else if (status.isCopied()) { // } - else if ((fStatus == FileStatus.NOT_CHANGED || fStatus == FileStatus.SWITCHED) && statusType != SVNStatusType.STATUS_NONE) { + else if ((fStatus == FileStatus.NOT_CHANGED || fStatus == FileStatus.SWITCHED) && statusType != StatusType.STATUS_NONE) { VirtualFile file = filePath.getVirtualFile(); if (file != null && FileDocumentManager.getInstance().isFileModified(file)) { myChangelistBuilder.processChangeInList( @@ -266,10 +264,10 @@ class SvnChangeProviderContext implements StatusReceiver { public void addModifiedNotSavedChange(final VirtualFile file) throws SVNException { final FilePath filePath = new FilePathImpl(file); - final SVNInfo svnInfo = myVcs.getInfo(file); + final Info svnInfo = myVcs.getInfo(file); if (svnInfo != null) { - final SVNStatus svnStatus = new SVNStatus(); + final Status svnStatus = new Status(); svnStatus.setRevision(svnInfo.getRevision()); myChangelistBuilder.processChangeInList( createChange(SvnContentRevision.createBaseRevision(myVcs, filePath, svnInfo.getRevision()), CurrentContentRevision.create(filePath), @@ -278,7 +276,7 @@ class SvnChangeProviderContext implements StatusReceiver { } } - private void checkSwitched(final FilePath filePath, final ChangelistBuilder builder, final SVNStatus status, + private void checkSwitched(final FilePath filePath, final ChangelistBuilder builder, final Status status, final FileStatus convertedStatus) { if (status.isSwitched() || (convertedStatus == FileStatus.SWITCHED)) { final VirtualFile virtualFile = filePath.getVirtualFile(); @@ -322,8 +320,8 @@ class SvnChangeProviderContext implements StatusReceiver { // seems here we can only have a tree conflict; which can be marked on either path (?) // .. ok try to merge states - Change createMovedChange(final ContentRevision before, final ContentRevision after, final SVNStatus copiedStatus, - final SVNStatus deletedStatus) throws SVNException { + Change createMovedChange(final ContentRevision before, final ContentRevision after, final Status copiedStatus, + final Status deletedStatus) throws SVNException { // todo no convertion needed for the contents status? final ConflictedSvnChange conflictedSvnChange = new ConflictedSvnChange(before, after, ConflictState.mergeState(getState(copiedStatus), getState(deletedStatus)), @@ -340,13 +338,13 @@ class SvnChangeProviderContext implements StatusReceiver { private Change createChange(final ContentRevision before, final ContentRevision after, final FileStatus fStatus, - final SVNStatus svnStatus) + final Status svnStatus) throws SVNException { final ConflictedSvnChange conflictedSvnChange = new ConflictedSvnChange(before, after, correctContentsStatus(fStatus, svnStatus), getState(svnStatus), after == null ? before.getFile() : after.getFile()); if (svnStatus != null) { - if (SVNStatusType.STATUS_DELETED.equals(svnStatus.getNodeStatus()) && !svnStatus.getRevision().isValid()) { + if (StatusType.STATUS_DELETED.equals(svnStatus.getNodeStatus()) && !svnStatus.getRevision().isValid()) { conflictedSvnChange.setIsPhantom(true); } conflictedSvnChange.setBeforeDescription(svnStatus.getTreeConflict()); @@ -354,31 +352,31 @@ class SvnChangeProviderContext implements StatusReceiver { return patchWithPropertyChange(conflictedSvnChange, svnStatus, null); } - private FileStatus correctContentsStatus(final FileStatus fs, final SVNStatus svnStatus) throws SVNException { + private FileStatus correctContentsStatus(final FileStatus fs, final Status svnStatus) throws SVNException { //if (svnStatus.isSwitched()) return FileStatus.SWITCHED; return fs; //return SvnStatusConvertor.convertContentsStatus(svnStatus); } - private LocallyDeletedChange createLocallyDeletedChange(@NotNull FilePath filePath, final SVNStatus status) { + private LocallyDeletedChange createLocallyDeletedChange(@NotNull FilePath filePath, final Status status) { return new SvnLocallyDeletedChange(filePath, getState(status)); } - private Change patchWithPropertyChange(final Change change, final SVNStatus svnStatus, final SVNStatus deletedStatus) + private Change patchWithPropertyChange(final Change change, final Status svnStatus, final Status deletedStatus) throws SVNException { if (svnStatus == null) return change; - final SVNStatusType propertiesStatus = svnStatus.getPropertiesStatus(); - if (SVNStatusType.STATUS_CONFLICTED.equals(propertiesStatus) || SVNStatusType.CHANGED.equals(propertiesStatus) || - SVNStatusType.STATUS_ADDED.equals(propertiesStatus) || SVNStatusType.STATUS_DELETED.equals(propertiesStatus) || - SVNStatusType.STATUS_MODIFIED.equals(propertiesStatus) || SVNStatusType.STATUS_REPLACED.equals(propertiesStatus) || - SVNStatusType.MERGED.equals(propertiesStatus)) { + final StatusType propertiesStatus = svnStatus.getPropertiesStatus(); + if (StatusType.STATUS_CONFLICTED.equals(propertiesStatus) || StatusType.CHANGED.equals(propertiesStatus) || + StatusType.STATUS_ADDED.equals(propertiesStatus) || StatusType.STATUS_DELETED.equals(propertiesStatus) || + StatusType.STATUS_MODIFIED.equals(propertiesStatus) || StatusType.STATUS_REPLACED.equals(propertiesStatus) || + StatusType.MERGED.equals(propertiesStatus)) { final FilePath path = ChangesUtil.getFilePath(change); final File ioFile = path.getIOFile(); final File beforeFile = deletedStatus != null ? deletedStatus.getFile() : ioFile; - final String beforeList = SVNStatusType.STATUS_ADDED.equals(propertiesStatus) && deletedStatus == null ? null : + final String beforeList = StatusType.STATUS_ADDED.equals(propertiesStatus) && deletedStatus == null ? null : AbstractShowPropertiesDiffAction.getPropertyList(myVcs, beforeFile, SVNRevision.BASE); - final String afterList = SVNStatusType.STATUS_DELETED.equals(propertiesStatus) ? null : + final String afterList = StatusType.STATUS_DELETED.equals(propertiesStatus) ? null : AbstractShowPropertiesDiffAction.getPropertyList(myVcs, ioFile, SVNRevision.WORKING); // TODO: There are cases when status output is like (on newly added file with some properties that is locally deleted) @@ -398,16 +396,16 @@ class SvnChangeProviderContext implements StatusReceiver { return change; } - private ConflictState getState(@Nullable final SVNStatus svnStatus) { + private ConflictState getState(@Nullable final Status svnStatus) { if (svnStatus == null) { return ConflictState.none; } - final SVNStatusType propertiesStatus = svnStatus.getPropertiesStatus(); + final StatusType propertiesStatus = svnStatus.getPropertiesStatus(); final boolean treeConflict = svnStatus.getTreeConflict() != null; - final boolean textConflict = SVNStatusType.STATUS_CONFLICTED == svnStatus.getContentsStatus(); - final boolean propertyConflict = SVNStatusType.STATUS_CONFLICTED == propertiesStatus; + final boolean textConflict = StatusType.STATUS_CONFLICTED == svnStatus.getContentsStatus(); + final boolean propertyConflict = StatusType.STATUS_CONFLICTED == propertiesStatus; if (treeConflict) { reportTreeConflict(svnStatus); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangedFile.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangedFile.java index 2bd5ee497102..8d4fab4ec40a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangedFile.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangedFile.java @@ -16,19 +16,19 @@ package org.jetbrains.idea.svn; import com.intellij.openapi.vcs.FilePath; -import org.tmatesoft.svn.core.wc.SVNStatus; +import org.jetbrains.idea.svn.status.Status; class SvnChangedFile { private final FilePath myFilePath; - private final SVNStatus myStatus; + private final Status myStatus; private String myCopyFromURL; - public SvnChangedFile(final FilePath filePath, final SVNStatus status) { + public SvnChangedFile(final FilePath filePath, final Status status) { myFilePath = filePath; myStatus = status; } - public SvnChangedFile(final FilePath filePath, final SVNStatus status, final String copyFromURL) { + public SvnChangedFile(final FilePath filePath, final Status status, final String copyFromURL) { myFilePath = filePath; myStatus = status; myCopyFromURL = copyFromURL; @@ -38,7 +38,7 @@ class SvnChangedFile { return myFilePath; } - public SVNStatus getStatus() { + public Status getStatus() { return myStatus; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangelistListener.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangelistListener.java index 00fa3a1cf9aa..a66146e259a6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangelistListener.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangelistListener.java @@ -28,9 +28,8 @@ import com.intellij.openapi.vcs.changes.ChangeListListener; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.status.Status; import org.tmatesoft.svn.core.SVNErrorCode; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.SVNStatus; import java.io.File; import java.util.ArrayList; @@ -136,12 +135,11 @@ public class SvnChangelistListener implements ChangeListListener { @Nullable public static String getCurrentMapping(final SvnVcs vcs, final File file) { try { - final SVNStatus status = vcs.getFactory(file).createStatusClient().doStatus(file, false); + final Status status = vcs.getFactory(file).createStatusClient().doStatus(file, false); return status == null ? null : status.getChangelistName(); } - catch (SVNException e) { - final SVNErrorCode errorCode = e.getErrorMessage().getErrorCode(); - if (SVNErrorCode.WC_NOT_DIRECTORY.equals(errorCode) || SVNErrorCode.WC_NOT_FILE.equals(errorCode)) { + catch (SvnBindException e) { + if (e.contains(SVNErrorCode.WC_NOT_DIRECTORY) || e.contains(SVNErrorCode.WC_NOT_FILE)) { LOG.debug("Logging only, exception is valid (caught) here", e); } else { LOG.info("Logging only, exception is valid (caught) here", e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java index 790cdae37629..6f5013c4a929 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java @@ -26,13 +26,14 @@ import com.intellij.openapi.util.Ref; import com.intellij.openapi.vcs.changes.VcsAnnotationRefresher; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.auth.SvnAuthenticationManager; import org.jetbrains.idea.svn.auth.SvnAuthenticationProvider; import org.jetbrains.idea.svn.auth.SvnInteractiveAuthenticationProvider; import org.jetbrains.idea.svn.config.SvnServerFileKeys; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.jetbrains.idea.svn.update.MergeRootInfo; import org.jetbrains.idea.svn.update.UpdateRootInfo; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNErrorMessage; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.auth.ISVNAuthenticationProvider; @@ -41,7 +42,6 @@ import org.tmatesoft.svn.core.internal.wc.ISVNAuthenticationStorage; import org.tmatesoft.svn.core.internal.wc.SVNConfigFile; import org.tmatesoft.svn.core.internal.wc.SVNFileUtil; import org.tmatesoft.svn.core.wc.ISVNOptions; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; import org.tmatesoft.svn.core.wc.SVNWCUtil; import java.io.File; @@ -76,9 +76,6 @@ public class SvnConfiguration implements PersistentStateComponent<SvnConfigurati private SvnAuthenticationManager myInteractiveManager; public static final AuthStorage RUNTIME_AUTH_CACHE = new AuthStorage(); - // TODO: update depth is not stored in configuration as SVNDepth has wrong type for DefaultJDOMExternalizer - // TODO: check if it should be stored - public SVNDepth UPDATE_DEPTH = SVNDepth.UNKNOWN; private final Map<File, MergeRootInfo> myMergeRootInfos = new HashMap<File, MergeRootInfo>(); private final Map<File, UpdateRootInfo> myUpdateRootInfos = new HashMap<File, UpdateRootInfo>(); @@ -109,8 +106,9 @@ public class SvnConfiguration implements PersistentStateComponent<SvnConfigurati } } - public SVNDiffOptions getMergeOptions() { - return new SVNDiffOptions(isIgnoreSpacesInMerge(), isIgnoreSpacesInMerge(), isIgnoreSpacesInMerge()); + @NotNull + public DiffOptions getMergeOptions() { + return new DiffOptions(isIgnoreSpacesInMerge(), isIgnoreSpacesInMerge(), isIgnoreSpacesInMerge()); } private void initServers() { @@ -180,12 +178,12 @@ public class SvnConfiguration implements PersistentStateComponent<SvnConfigurati myState.sslProtocols = sslProtocols; } - public SVNDepth getUpdateDepth() { - return UPDATE_DEPTH; + public Depth getUpdateDepth() { + return myState.UPDATE_DEPTH; } - public void setUpdateDepth(SVNDepth updateDepth) { - this.UPDATE_DEPTH = updateDepth; + public void setUpdateDepth(Depth updateDepth) { + myState.UPDATE_DEPTH = updateDepth; } public UseAcceleration getUseAcceleration() { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurationState.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurationState.java index 8d155399c101..5d5585accf1a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurationState.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurationState.java @@ -17,6 +17,7 @@ package org.jetbrains.idea.svn; import com.intellij.openapi.util.SystemInfo; import com.intellij.util.xmlb.annotations.*; +import org.jetbrains.idea.svn.api.Depth; /** * @author Konstantin Kolosovsky. @@ -70,6 +71,7 @@ public class SvnConfigurationState { public boolean SHOW_MERGE_SOURCES_IN_ANNOTATE = true; public boolean FORCE_UPDATE; public boolean IGNORE_EXTERNALS; + public Depth UPDATE_DEPTH = Depth.UNKNOWN; @Tag("configuration") public static class ConfigurationDirectory { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java index 6e9693bdd6eb..d2dbe84f5505 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java @@ -29,8 +29,8 @@ import com.intellij.openapi.vcs.impl.CurrentRevisionProvider; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.status.Status; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatus; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -56,7 +56,7 @@ public class SvnContentRevision implements ContentRevision, MarkerVcsContentRevi myFile = file; } - public static SvnContentRevision createBaseRevision(@NotNull SvnVcs vcs, @NotNull final FilePath file, final SVNStatus status) { + public static SvnContentRevision createBaseRevision(@NotNull SvnVcs vcs, @NotNull final FilePath file, final Status status) { SVNRevision revision = status.getRevision().isValid() ? status.getRevision() : status.getCommittedRevision(); return createBaseRevision(vcs, file, revision); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java index 8aade42edc1c..49ea87d44f6e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java @@ -32,7 +32,12 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.history.LatestExistentSearcher; +import org.jetbrains.idea.svn.info.InfoConsumer; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.SVNURL; @@ -55,13 +60,13 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif } public VcsRevisionNumber getCurrentRevision(VirtualFile file) { - final SVNInfo svnInfo = myVcs.getInfo(new File(file.getPresentableUrl())); + final Info svnInfo = myVcs.getInfo(new File(file.getPresentableUrl())); return getRevision(svnInfo); } @Nullable - private static VcsRevisionNumber getRevision(@Nullable SVNInfo info) { + private static VcsRevisionNumber getRevision(@Nullable Info info) { VcsRevisionNumber result = null; if (info != null) { @@ -106,11 +111,11 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif } @NotNull - private static ISVNInfoHandler createInfoHandler(@NotNull final Map<VirtualFile, VcsRevisionNumber> revisionMap, + private static InfoConsumer createInfoHandler(@NotNull final Map<VirtualFile, VcsRevisionNumber> revisionMap, @NotNull final Map<String, VirtualFile> fileMap) { - return new ISVNInfoHandler() { + return new InfoConsumer() { @Override - public void handleInfo(SVNInfo info) throws SVNException { + public void consume(Info info) throws SVNException { if (info != null) { VirtualFile file = fileMap.get(info.getFile().getAbsolutePath()); @@ -132,7 +137,7 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif } private VcsRevisionDescription getCurrentRevisionDescription(File path) { - final SVNInfo svnInfo = myVcs.getInfo(path); + final Info svnInfo = myVcs.getInfo(path); if (svnInfo == null) { return null; } @@ -187,20 +192,20 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif } // not clear why we need it, with remote check.. - SVNStatus svnStatus = getFileStatus(new File(selectedFile.getPresentableUrl()), false); + Status svnStatus = getFileStatus(new File(selectedFile.getPresentableUrl()), false); if (svnStatus != null && svnRevision.equals(svnStatus.getRevision())) { return SvnContentRevision.createBaseRevision(myVcs, filePath, svnRevision); } return SvnContentRevision.createRemote(myVcs, filePath, svnRevision); } - private SVNStatus getFileStatus(File file, boolean remote) { - SVNStatus result = null; + private Status getFileStatus(File file, boolean remote) { + Status result = null; try { - result = myVcs.getFactory(file).createStatusClient().doStatus(file, remote, false); + result = myVcs.getFactory(file).createStatusClient().doStatus(file, remote); } - catch (SVNException e) { + catch (SvnBindException e) { LOG.debug(e); } @@ -217,10 +222,10 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif } private ItemLatestState getLastRevision(final File file) { - final SVNStatus svnStatus = getFileStatus(file, true); + final Status svnStatus = getFileStatus(file, true); if (svnStatus == null || itemExists(svnStatus) && SVNRevision.UNDEFINED.equals(svnStatus.getRemoteRevision())) { // IDEADEV-21785 (no idea why this can happen) - final SVNInfo info = myVcs.getInfo(file, SVNRevision.HEAD); + final Info info = myVcs.getInfo(file, SVNRevision.HEAD); if (info == null || info.getURL() == null) { LOG.info("No SVN status returned for " + file.getPath()); return defaultResult(); @@ -232,8 +237,8 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif WorkingCopyFormat format = myVcs.getWorkingCopyFormat(file); long revision = -1; - // skipped for 1.8 - if (!WorkingCopyFormat.ONE_DOT_EIGHT.equals(format)) { + // skipped for >= 1.8 + if (format.less(WorkingCopyFormat.ONE_DOT_EIGHT)) { // get really latest revision // TODO: Algorithm seems not to be correct in all cases - for instance, when some subtree was deleted and replaced by other // TODO: with same names. pegRevision should be used somehow but this complicates the algorithm @@ -254,8 +259,8 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif return createResult(svnStatus.getRevision(), exists, false); } - private boolean itemExists(SVNStatus svnStatus) { - return ! SVNStatusType.STATUS_DELETED.equals(svnStatus.getRemoteContentsStatus()) && - ! SVNStatusType.STATUS_DELETED.equals(svnStatus.getRemoteNodeStatus()); + private boolean itemExists(Status svnStatus) { + return ! StatusType.STATUS_DELETED.equals(svnStatus.getRemoteContentsStatus()) && + ! StatusType.STATUS_DELETED.equals(svnStatus.getRemoteNodeStatus()); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileSystemListener.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileSystemListener.java index 5c5419d10ade..02185ec7f9a0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileSystemListener.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileSystemListener.java @@ -45,13 +45,16 @@ import com.intellij.util.containers.MultiMap; import com.intellij.vcsUtil.ActionWithTempFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.NodeKind; import org.jetbrains.idea.svn.commandLine.SvnBindException; -import org.tmatesoft.svn.core.*; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; +import org.tmatesoft.svn.core.SVNErrorCode; +import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.internal.wc.SVNFileUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNMoveClient; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.io.IOException; @@ -153,8 +156,8 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp return null; } - final SVNStatus fileStatus = getFileStatus(vcs, srcFile); - if (fileStatus != null && SvnVcs.svnStatusIs(fileStatus, SVNStatusType.STATUS_ADDED)) { + final Status fileStatus = getFileStatus(vcs, srcFile); + if (fileStatus != null && fileStatus.is(StatusType.STATUS_ADDED)) { myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(toDir, copyName, null, false)); return null; } @@ -189,9 +192,9 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp @Nullable public String getRepositoryUUID(final Project project, final VirtualFile dir) { try { - final SVNInfo info1 = new RepeatSvnActionThroughBusy() { + final Info info1 = new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { + protected void executeImpl() { myT = myVcs.getInfo(new File(dir.getPath())); } }.compute(); @@ -207,7 +210,8 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp } else { return info1.getRepositoryUUID(); } - } catch (SVNException e) { + } + catch (VcsException e) { // go to return default } return null; @@ -264,18 +268,18 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp final String list = isUndo ? null : SvnChangelistListener.getCurrentMapping(vcs, src); WorkingCopyFormat format = vcs.getWorkingCopyFormat(src); - final boolean is17OrLater = WorkingCopyFormat.ONE_DOT_EIGHT.equals(format) || WorkingCopyFormat.ONE_DOT_SEVEN.equals(format); + final boolean is17OrLater = format.isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN); if (is17OrLater) { - SVNStatus srcStatus = getFileStatus(vcs, src); + Status srcStatus = getFileStatus(vcs, src); final File toDir = dst.getParentFile(); - SVNStatus dstStatus = getFileStatus(vcs, toDir); - final boolean srcUnversioned = srcStatus == null || SvnVcs.svnStatusIsUnversioned(srcStatus); - if (srcUnversioned && (dstStatus == null || SvnVcs.svnStatusIsUnversioned(dstStatus))) { + Status dstStatus = getFileStatus(vcs, toDir); + final boolean srcUnversioned = srcStatus == null || srcStatus.is(StatusType.STATUS_UNVERSIONED); + if (srcUnversioned && (dstStatus == null || dstStatus.is(StatusType.STATUS_UNVERSIONED))) { return false; } if (srcUnversioned) { - SVNStatus dstWasStatus = getFileStatus(vcs, dst); - if (dstWasStatus == null || SvnVcs.svnStatusIsUnversioned(dstWasStatus)) { + Status dstWasStatus = getFileStatus(vcs, dst); + if (dstWasStatus == null || dstWasStatus.is(StatusType.STATUS_UNVERSIONED)) { return false; } } @@ -289,10 +293,6 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp } dst.setLastModified(srcTime); } - catch (SVNException e) { - addToMoveExceptions(vcs.getProject(), e); - return false; - } catch(VcsException e) { addToMoveExceptions(vcs.getProject(), e); return false; @@ -300,12 +300,12 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp return true; } - private final static Set<SVNStatusType> ourStatusesForUndoMove = new HashSet<SVNStatusType>(); + private final static Set<StatusType> ourStatusesForUndoMove = new HashSet<StatusType>(); static { - ourStatusesForUndoMove.add(SVNStatusType.STATUS_ADDED); + ourStatusesForUndoMove.add(StatusType.STATUS_ADDED); } - private boolean for17move(final SvnVcs vcs, final File src, final File dst, boolean undo, SVNStatus srcStatus) throws SVNException { + private boolean for17move(final SvnVcs vcs, final File src, final File dst, boolean undo, Status srcStatus) throws VcsException { if (srcStatus != null && srcStatus.getCopyFromURL() == null) { undo = false; } @@ -313,7 +313,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp myUndoingMove = true; createRevertAction(vcs, dst, true).execute(); copyUnversionedMembersOfDirectory(src, dst); - if (srcStatus == null || SvnVcs.svnStatusIsUnversioned(srcStatus)) { + if (srcStatus == null || srcStatus.is(StatusType.STATUS_UNVERSIONED)) { FileUtil.delete(src); } else { createRevertAction(vcs, src, true).execute(); @@ -322,13 +322,13 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp } else { if (doUsualMove(vcs, src)) return true; // check destination directory - final SVNStatus dstParentStatus = getFileStatus(vcs, dst.getParentFile()); - if (dstParentStatus == null || SvnVcs.svnStatusIsUnversioned(dstParentStatus)) { + final Status dstParentStatus = getFileStatus(vcs, dst.getParentFile()); + if (dstParentStatus == null || dstParentStatus.is(StatusType.STATUS_UNVERSIONED)) { try { copyFileOrDir(src, dst); } catch (IOException e) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } createDeleteAction(vcs, src, true).execute(); return false; @@ -338,23 +338,18 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp return false; } - public static void moveFileWithSvn(final SvnVcs vcs, final File src, final File dst) throws SVNException { + public static void moveFileWithSvn(final SvnVcs vcs, final File src, final File dst) throws VcsException { new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { - try { - vcs.getFactory(src).createCopyMoveClient().copy(src, dst, false, true); - } - catch (VcsException e) { - wrapAndThrow(e); - } + protected void executeImpl() throws VcsException { + vcs.getFactory(src).createCopyMoveClient().copy(src, dst, false, true); } }.execute(); } - private void copyUnversionedMembersOfDirectory(final File src, final File dst) throws SVNException { + private void copyUnversionedMembersOfDirectory(final File src, final File dst) throws SvnBindException { if (src.isDirectory()) { - final SVNException[] exc = new SVNException[1]; + final SvnBindException[] exc = new SvnBindException[1]; FileUtil.processFilesRecursively(src, new Processor<File>() { @Override public boolean process(File file) { @@ -365,7 +360,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp copyFileOrDir(src, dst); } catch (IOException e) { - exc[0] = new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + exc[0] = new SvnBindException(e); return false; } } @@ -388,25 +383,25 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp private boolean doUsualMove(SvnVcs vcs, File src) { // if src is not under version control, do usual move. - SVNStatus srcStatus = getFileStatus(vcs, src); - if (srcStatus == null || SvnVcs.svnStatusIsUnversioned(srcStatus) || - SvnVcs.svnStatusIs(srcStatus, SVNStatusType.STATUS_OBSTRUCTED) || - SvnVcs.svnStatusIs(srcStatus, SVNStatusType.STATUS_MISSING) || - SvnVcs.svnStatusIs(srcStatus, SVNStatusType.STATUS_EXTERNAL)) { - return true; - } - return false; + Status srcStatus = getFileStatus(vcs, src); + return srcStatus == null || + srcStatus.is(StatusType.STATUS_UNVERSIONED, StatusType.STATUS_OBSTRUCTED, StatusType.STATUS_MISSING, StatusType.STATUS_EXTERNAL); } - private boolean for16move(SvnVcs vcs, final File src, final File dst, boolean undo) throws SVNException { + private boolean for16move(SvnVcs vcs, final File src, final File dst, boolean undo) throws VcsException { final SVNMoveClient mover = vcs.getSvnKitManager().createMoveClient(); if (undo) { myUndoingMove = true; restoreFromUndoStorage(dst); new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { - mover.undoMove(src, dst); + protected void executeImpl() throws VcsException { + try { + mover.undoMove(src, dst); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } }.execute(); } @@ -415,8 +410,13 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp if (doUsualMove(vcs, src)) return true; new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { - mover.doMove(src, dst); + protected void executeImpl() throws VcsException { + try { + mover.doMove(src, dst); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } }.execute(); } @@ -488,16 +488,14 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp return false; } - SVNStatus status = getFileStatus(vcs, ioFile); + Status status = getFileStatus(vcs, ioFile); if (status == null || - SvnVcs.svnStatusIsUnversioned(status) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_OBSTRUCTED) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MISSING) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_EXTERNAL) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_IGNORED)) { + status.is(StatusType.STATUS_UNVERSIONED, StatusType.STATUS_OBSTRUCTED, StatusType.STATUS_MISSING, StatusType.STATUS_EXTERNAL, + StatusType.STATUS_IGNORED)) { return false; - } else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) { + } + else if (status.is(StatusType.STATUS_DELETED)) { if (isUndo(vcs)) { moveToUndoStorage(file); } @@ -509,11 +507,11 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp myDeletedFiles.putValue(vcs.getProject(), ioFile); return true; } - if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_ADDED)) { + if (status.is(StatusType.STATUS_ADDED)) { try { createRevertAction(vcs, ioFile, false).execute(); } - catch (SVNException e) { + catch (VcsException e) { // ignore } } @@ -531,13 +529,8 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp private RepeatSvnActionThroughBusy createRevertAction(@NotNull final SvnVcs vcs, @NotNull final File file, final boolean recursive) { return new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { - try { - vcs.getFactory(file).createRevertClient().revert(new File[]{file}, SVNDepth.fromRecurse(recursive), null); - } - catch (VcsException e) { - wrapAndThrow(e); - } + protected void executeImpl() throws VcsException { + vcs.getFactory(file).createRevertClient().revert(new File[]{file}, Depth.allOrFiles(recursive), null); } }; } @@ -546,22 +539,12 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp private RepeatSvnActionThroughBusy createDeleteAction(@NotNull final SvnVcs vcs, @NotNull final File file, final boolean force) { return new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { - try { - vcs.getFactory(file).createDeleteClient().delete(file, force, false, null); - } - catch (VcsException e) { - wrapAndThrow(e); - } + protected void executeImpl() throws VcsException { + vcs.getFactory(file).createDeleteClient().delete(file, force, false, null); } }; } - private static void wrapAndThrow(VcsException e) throws SVNException { - // TODO: probably we should wrap into new exception only if e.getCause is not SVNException - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.FS_GENERAL, e), e); - } - private boolean isAboveSourceOfCopyOrMove(final Project p, File ioFile) { for (MovedFileInfo file : myMovedFiles) { if (FileUtil.isAncestor(ioFile, file.mySrc, false)) return true; @@ -617,20 +600,20 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp return false; } final File targetFile = new File(ioDir, name); - SVNStatus status = getFileStatus(vcs, targetFile); + Status status = getFileStatus(vcs, targetFile); - if (status == null || status.getContentsStatus() == SVNStatusType.STATUS_NONE || - status.getContentsStatus() == SVNStatusType.STATUS_UNVERSIONED) { + if (status == null || status.getContentsStatus() == StatusType.STATUS_NONE || + status.getContentsStatus() == StatusType.STATUS_UNVERSIONED) { myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(dir, name, null, recursive)); return false; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MISSING)) { + else if (status.is(StatusType.STATUS_MISSING)) { return false; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) { - SVNNodeKind kind = status.getKind(); + else if (status.is(StatusType.STATUS_DELETED)) { + NodeKind kind = status.getKind(); // kind differs. - if (directory && kind != SVNNodeKind.DIR || !directory && kind != SVNNodeKind.FILE) { + if (directory && !kind.isDirectory() || !directory && !kind.isFile()) { return false; } try { @@ -641,7 +624,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(dir, name, null, recursive)); return false; } - catch (SVNException e) { + catch (VcsException e) { SVNFileUtil.deleteAll(targetFile, true); return false; } @@ -794,23 +777,13 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp try { new ActionWithTempFile(ioFile) { protected void executeInternal() throws VcsException { - try { - // not recursive - new RepeatSvnActionThroughBusy() { - @Override - protected void executeImpl() throws SVNException { - try { - vcs.getFactory(copyFrom).createCopyMoveClient().copy(copyFrom, ioFile, true, false); - } - catch (VcsException e) { - wrapAndThrow(e); - } - } - }.execute(); - } - catch (SVNException e) { - throw new VcsException(e); - } + // not recursive + new RepeatSvnActionThroughBusy() { + @Override + protected void executeImpl() throws VcsException { + vcs.getFactory(copyFrom).createCopyMoveClient().copy(copyFrom, ioFile, true, false); + } + }.execute(); } }.execute(); } @@ -821,20 +794,15 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp else { new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { - try { - vcs.getFactory(ioFile).createAddClient().add(ioFile, null, false, false, true, null); - } - catch (VcsException e) { - wrapAndThrow(e); - } + protected void executeImpl() throws VcsException { + vcs.getFactory(ioFile).createAddClient().add(ioFile, null, false, false, true, null); } }.execute(); } VcsDirtyScopeManager.getInstance(project).fileDirty(file); } - catch (SVNException e) { - exceptions.add(new VcsException(e)); + catch (VcsException e) { + exceptions.add(e); } } } @@ -880,8 +848,8 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp addedFile = myLfs.refreshAndFindFileByIoFile(ioFile); } if (addedFile != null) { - final SVNStatus fileStatus = getFileStatus(vcs, ioFile); - if (fileStatus == null || ! SvnVcs.svnStatusIs(fileStatus, SVNStatusType.STATUS_IGNORED)) { + final Status fileStatus = getFileStatus(vcs, ioFile); + if (fileStatus == null || !fileStatus.is(StatusType.STATUS_IGNORED)) { boolean isIgnored = changeListManager.isIgnoredFile(addedFile); if (!isIgnored) { addedVFiles.add(addedFile); @@ -935,8 +903,8 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp FileUtil.delete(file.getIOFile()); } } - } catch (SVNException e) { - exceptions.add(new VcsException(e)); + } catch (VcsException e) { + exceptions.add(e); } if (! exceptions.isEmpty()) { vcsHelper.showErrors(exceptions, SvnBundle.message("delete.files.errors.title")); @@ -962,8 +930,8 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp VcsDirtyScopeManager.getInstance(project).fileDirty(file); } } - catch (SVNException e) { - exceptions.add(new VcsException(e)); + catch (VcsException e) { + exceptions.add(e); } } } @@ -988,7 +956,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp final String singleFilePrompt; if (deletedFiles.size() == 1 && deletedFiles.get(0).getFirst().isDirectory()) { - singleFilePrompt = WorkingCopyFormat.ONE_DOT_SEVEN.equals(deletedFiles.get(0).getSecond()) ? + singleFilePrompt = deletedFiles.get(0).getSecond().isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN) ? SvnBundle.getString("confirmation.text.delete.dir.17") : SvnBundle.getString("confirmation.text.delete.dir"); } @@ -1004,17 +972,17 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp } private void fillDeletedFiles(Project project, List<Pair<FilePath, WorkingCopyFormat>> deletedFiles, Collection<FilePath> deleteAnyway) - throws SVNException { + throws VcsException { final SvnVcs vcs = SvnVcs.getInstance(project); final Collection<File> files = myDeletedFiles.remove(project); for (final File file : files) { - final SVNStatus status = new RepeatSvnActionThroughBusy() { + final Status status = new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { + protected void executeImpl() throws VcsException { myT = vcs.getFactory(file).createStatusClient().doStatus(file, false); } }.compute(); - boolean isAdded = SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus()); + boolean isAdded = StatusType.STATUS_ADDED.equals(status.getNodeStatus()); final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file); if (isAdded) { deleteAnyway.add(filePath); @@ -1059,16 +1027,16 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp } @Nullable - private static SVNStatus getFileStatus(@NotNull final SvnVcs vcs, @NotNull final File file) { + private static Status getFileStatus(@NotNull final SvnVcs vcs, @NotNull final File file) { try { return new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { + protected void executeImpl() throws VcsException { myT = vcs.getFactory(file).createStatusClient().doStatus(file, false); } }.compute(); } - catch (SVNException e) { + catch (VcsException e) { return null; } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java index f55f877fc965..11838314acbd 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java @@ -33,10 +33,10 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.messages.MessageBus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import java.io.File; import java.util.List; @@ -388,7 +388,7 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState if (copyRoot == null || vcsRoot == null) continue; final SvnVcs vcs = SvnVcs.getInstance(myProject); - final SVNInfo svnInfo = vcs.getInfo(copyRoot); + final Info svnInfo = vcs.getInfo(copyRoot); if ((svnInfo == null) || (svnInfo.getRepositoryRootURL() == null)) continue; Node node = new Node(copyRoot, svnInfo.getURL(), svnInfo.getRepositoryRootURL()); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnProgressCanceller.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnProgressCanceller.java index 5163dfa0ffea..dbad319b413a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnProgressCanceller.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnProgressCanceller.java @@ -17,15 +17,15 @@ package org.jetbrains.idea.svn; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNCancelException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; /** * @author yole */ -public class SvnProgressCanceller implements ISVNEventHandler { +public class SvnProgressCanceller implements ProgressTracker { public void checkCancelled() throws SVNCancelException { final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null && indicator.isCanceled()) { @@ -33,6 +33,6 @@ public class SvnProgressCanceller implements ISVNEventHandler { } } - public void handleEvent(final SVNEvent event, final double progress) throws SVNException { + public void consume(final ProgressEvent event) throws SVNException { } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRecursiveStatusWalker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRecursiveStatusWalker.java index 45b28e34b3d0..1b1cd00589d0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRecursiveStatusWalker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRecursiveStatusWalker.java @@ -31,16 +31,16 @@ import com.intellij.util.Processor; import com.intellij.vcsUtil.VcsUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.status.Status; import org.jetbrains.idea.svn.status.StatusClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.status.StatusConsumer; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNErrorCode; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.internal.wc.SVNFileUtil; -import org.tmatesoft.svn.core.wc.ISVNStatusHandler; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.util.LinkedList; @@ -63,7 +63,7 @@ public class SvnRecursiveStatusWalker { myHandler = new MyHandler(); } - public void go(final FilePath rootPath, final SVNDepth depth) throws SVNException { + public void go(final FilePath rootPath, final Depth depth) throws SvnBindException { final MyItem root = createItem(rootPath, depth, false); myQueue.add(root); @@ -81,23 +81,26 @@ public class SvnRecursiveStatusWalker { client.doStatus(ioFile, SVNRevision.WORKING, item.getDepth(), false, false, true, true, myHandler, null); myHandler.checkIfCopyRootWasReported(null, ioFile); } - catch (SVNException e) { + catch (SvnBindException e) { handleStatusException(item, path, e); } } else { try { - final SVNStatus status = item.getClient().doStatus(ioFile, false, false); + final Status status = item.getClient().doStatus(ioFile, false); myReceiver.process(path, status); - } catch (SVNException e) { + } + catch (SvnBindException e) { handleStatusException(item, path, e); } + catch (SVNException e) { + handleStatusException(item, path, new SvnBindException(e)); + } } } } - private void handleStatusException(MyItem item, FilePath path, SVNException e) throws SVNException { - final SVNErrorCode errorCode = e.getErrorMessage().getErrorCode(); - if (SVNErrorCode.WC_NOT_DIRECTORY.equals(errorCode) || SVNErrorCode.WC_NOT_FILE.equals(errorCode)) { + private void handleStatusException(MyItem item, FilePath path, SvnBindException e) throws SvnBindException { + if (e.contains(SVNErrorCode.WC_NOT_DIRECTORY) || e.contains(SVNErrorCode.WC_NOT_FILE)) { final VirtualFile virtualFile = path.getVirtualFile(); if (virtualFile != null) { if (! myPartner.isExcluded(virtualFile)) { @@ -116,11 +119,11 @@ public class SvnRecursiveStatusWalker { private static class MyItem { @NotNull private final FilePath myPath; - @NotNull private final SVNDepth myDepth; + @NotNull private final Depth myDepth; @NotNull private final StatusClient myStatusClient; private final boolean myIsInnerCopyRoot; - private MyItem(@NotNull FilePath path, @NotNull SVNDepth depth, boolean isInnerCopyRoot, @NotNull StatusClient statusClient) { + private MyItem(@NotNull FilePath path, @NotNull Depth depth, boolean isInnerCopyRoot, @NotNull StatusClient statusClient) { myPath = path; myDepth = depth; myStatusClient = statusClient; @@ -133,7 +136,7 @@ public class SvnRecursiveStatusWalker { } @NotNull - public SVNDepth getDepth() { + public Depth getDepth() { return myDepth; } @@ -147,13 +150,13 @@ public class SvnRecursiveStatusWalker { } } - private void processRecursively(final VirtualFile vFile, final SVNDepth prevDepth) { - if (SVNDepth.EMPTY.equals(prevDepth)) return; + private void processRecursively(final VirtualFile vFile, final Depth prevDepth) { + if (Depth.EMPTY.equals(prevDepth)) return; if (myPartner.isIgnoredIdeaLevel(vFile)) { myReceiver.processIgnored(vFile); return; } - final SVNDepth newDepth = SVNDepth.INFINITY.equals(prevDepth) ? SVNDepth.INFINITY : SVNDepth.EMPTY; + final Depth newDepth = Depth.INFINITY.equals(prevDepth) ? Depth.INFINITY : Depth.EMPTY; final File ioFile = new File(vFile.getPath()); final Processor<File> processor; @@ -180,7 +183,7 @@ public class SvnRecursiveStatusWalker { return true; } }; - if (SVNDepth.EMPTY.equals(newDepth)) { + if (Depth.EMPTY.equals(newDepth)) { directoryFilter = Processor.TRUE; processor = new Processor<File>() { @Override @@ -205,14 +208,14 @@ public class SvnRecursiveStatusWalker { } @NotNull - private MyItem createItem(@NotNull FilePath path, @NotNull SVNDepth depth, boolean isInnerCopyRoot) { + private MyItem createItem(@NotNull FilePath path, @NotNull Depth depth, boolean isInnerCopyRoot) { StatusClient statusClient = myVcs.getFactory(path.getIOFile()).createStatusClient(myPartner.getFileProvider(), myPartner.getEventHandler()); return new MyItem(path, depth, isInnerCopyRoot, statusClient); } - private class MyHandler implements ISVNStatusHandler { + private class MyHandler implements StatusConsumer { private MyItem myCurrentItem; private boolean myMetCurrentItem; @@ -221,37 +224,36 @@ public class SvnRecursiveStatusWalker { myMetCurrentItem = false; } - public void checkIfCopyRootWasReported(@Nullable final SVNStatus ioFileStatus, final File ioFile) { + public void checkIfCopyRootWasReported(@Nullable final Status ioFileStatus, final File ioFile) { File itemFile = myCurrentItem.getPath().getIOFile(); if (! myMetCurrentItem && FileUtil.filesEqual(ioFile, itemFile)) { myMetCurrentItem = true; - SVNStatus statusInner; + Status statusInner; try { - statusInner = ioFileStatus != null ? ioFileStatus : - myCurrentItem.getClient().doStatus(itemFile, false); + statusInner = ioFileStatus != null ? ioFileStatus : myCurrentItem.getClient().doStatus(itemFile, false); } - catch (SVNException e) { + catch (SvnBindException e) { LOG.info(e); statusInner = null; } if (statusInner == null) return; - final SVNStatusType status = statusInner.getNodeStatus(); + final StatusType status = statusInner.getNodeStatus(); final VirtualFile vf = myCurrentItem.getPath().getVirtualFile(); - if (SVNStatusType.STATUS_IGNORED.equals(status)) { + if (StatusType.STATUS_IGNORED.equals(status)) { if (vf != null) { myReceiver.processIgnored(vf); } return; } - if (SVNStatusType.STATUS_UNVERSIONED.equals(status) || SVNStatusType.UNKNOWN.equals(status)) { + if (StatusType.STATUS_UNVERSIONED.equals(status) || StatusType.UNKNOWN.equals(status)) { if (vf != null) { myReceiver.processUnversioned(vf); processRecursively(vf, myCurrentItem.getDepth()); } return; } - if (SVNStatusType.OBSTRUCTED.equals(status) || SVNStatusType.STATUS_NONE.equals(status)) { + if (StatusType.OBSTRUCTED.equals(status) || StatusType.STATUS_NONE.equals(status)) { return; } if (vf != null) { @@ -264,7 +266,8 @@ public class SvnRecursiveStatusWalker { } } - public void handleStatus(final SVNStatus status) throws SVNException { + @Override + public void consume(final Status status) throws SVNException { myPartner.checkCanceled(); final File ioFile = status.getFile(); checkIfCopyRootWasReported(status, ioFile); @@ -282,20 +285,20 @@ public class SvnRecursiveStatusWalker { } if (myProject.isDisposed()) throw new ProcessCanceledException(); - if ((vFile != null) && (SvnVcs.svnStatusIsUnversioned(status))) { + if ((vFile != null) && (status.is(StatusType.STATUS_UNVERSIONED))) { if (vFile.isDirectory()) { if (FileUtil.filesEqual(myCurrentItem.getPath().getIOFile(), ioFile)) { //myReceiver.processUnversioned(vFile); //processRecursively(vFile, myCurrentItem.getDepth()); } else { - final MyItem childItem = createItem(new FilePathImpl(vFile), SVNDepth.INFINITY, true); + final MyItem childItem = createItem(new FilePathImpl(vFile), Depth.INFINITY, true); myQueue.add(childItem); } } else { myReceiver.processUnversioned(vFile); } } else { - final FilePath path = VcsUtil.getFilePath(ioFile, status.getKind().equals(SVNNodeKind.DIR)); + final FilePath path = VcsUtil.getFilePath(ioFile, status.getKind().isDirectory()); myReceiver.process(path, status); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRootsDetector.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRootsDetector.java index fd77d80fc565..78a02d28f2c0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRootsDetector.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRootsDetector.java @@ -29,9 +29,9 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.status.Status; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNURLUtil; -import org.tmatesoft.svn.core.wc.SVNStatus; import java.io.File; import java.util.ArrayList; @@ -165,7 +165,7 @@ public class SvnRootsDetector { // TODO: No checked exceptions are thrown - remove catch/LOG.error/rethrow to fix real cause if any try { final File infoFile = VfsUtilCore.virtualToIoFile(info.getFile()); - final SVNStatus svnStatus = SvnUtil.getStatus(myVcs, infoFile); + final Status svnStatus = SvnUtil.getStatus(myVcs, infoFile); if (svnStatus != null && svnStatus.getURL() != null) { info.setUrl(svnStatus.getURL()); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnStatusConvertor.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnStatusConvertor.java index 84c316691c1e..ced496e9fa2b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnStatusConvertor.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnStatusConvertor.java @@ -19,15 +19,15 @@ import com.intellij.openapi.vcs.FileStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.status.PortableStatus; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; public class SvnStatusConvertor { private SvnStatusConvertor() { } @NotNull - public static FileStatus convertStatus(@Nullable SVNStatusType itemStatus, @Nullable SVNStatusType propertiesStatus) { + public static FileStatus convertStatus(@Nullable StatusType itemStatus, @Nullable StatusType propertiesStatus) { PortableStatus status = new PortableStatus(); status.setContentsStatus(itemStatus); @@ -37,47 +37,47 @@ public class SvnStatusConvertor { } @NotNull - public static FileStatus convertStatus(@Nullable final SVNStatus status) { + public static FileStatus convertStatus(@Nullable final Status status) { if (status == null) { return FileStatus.UNKNOWN; } - if (SvnVcs.svnStatusIsUnversioned(status)) { + if (status.is(StatusType.STATUS_UNVERSIONED)) { return FileStatus.UNKNOWN; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MISSING)) { + else if (status.is(StatusType.STATUS_MISSING)) { return FileStatus.DELETED_FROM_FS; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_EXTERNAL)) { + else if (status.is(StatusType.STATUS_EXTERNAL)) { return SvnFileStatus.EXTERNAL; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_OBSTRUCTED)) { + else if (status.is(StatusType.STATUS_OBSTRUCTED)) { return SvnFileStatus.OBSTRUCTED; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_IGNORED)) { + else if (status.is(StatusType.STATUS_IGNORED)) { return FileStatus.IGNORED; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_ADDED)) { + else if (status.is(StatusType.STATUS_ADDED)) { return FileStatus.ADDED; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) { + else if (status.is(StatusType.STATUS_DELETED)) { return FileStatus.DELETED; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_REPLACED)) { + else if (status.is(StatusType.STATUS_REPLACED)) { return SvnFileStatus.REPLACED; } - else if (status.getContentsStatus() == SVNStatusType.STATUS_CONFLICTED || - status.getPropertiesStatus() == SVNStatusType.STATUS_CONFLICTED) { - if (status.getContentsStatus() == SVNStatusType.STATUS_CONFLICTED && - status.getPropertiesStatus() == SVNStatusType.STATUS_CONFLICTED) { + else if (status.getContentsStatus() == StatusType.STATUS_CONFLICTED || + status.getPropertiesStatus() == StatusType.STATUS_CONFLICTED) { + if (status.getContentsStatus() == StatusType.STATUS_CONFLICTED && + status.getPropertiesStatus() == StatusType.STATUS_CONFLICTED) { return FileStatus.MERGED_WITH_BOTH_CONFLICTS; } - else if (status.getContentsStatus() == SVNStatusType.STATUS_CONFLICTED) { + else if (status.getContentsStatus() == StatusType.STATUS_CONFLICTED) { return FileStatus.MERGED_WITH_CONFLICTS; } return FileStatus.MERGED_WITH_PROPERTY_CONFLICTS; } - else if (status.getContentsStatus() == SVNStatusType.STATUS_MODIFIED || - status.getPropertiesStatus() == SVNStatusType.STATUS_MODIFIED) { + else if (status.getContentsStatus() == StatusType.STATUS_MODIFIED || + status.getPropertiesStatus() == StatusType.STATUS_MODIFIED) { return FileStatus.MODIFIED; } else if (status.isSwitched()) { @@ -90,38 +90,38 @@ public class SvnStatusConvertor { } @NotNull - public static FileStatus convertPropertyStatus(final SVNStatusType status) { + public static FileStatus convertPropertyStatus(final StatusType status) { if (status == null) { return FileStatus.UNKNOWN; } - if (SVNStatusType.STATUS_UNVERSIONED.equals(status)) { + if (StatusType.STATUS_UNVERSIONED.equals(status)) { return FileStatus.UNKNOWN; } - else if (SVNStatusType.STATUS_MISSING.equals(status)) { + else if (StatusType.STATUS_MISSING.equals(status)) { return FileStatus.DELETED_FROM_FS; } - else if (SVNStatusType.STATUS_EXTERNAL.equals(status)) { + else if (StatusType.STATUS_EXTERNAL.equals(status)) { return SvnFileStatus.EXTERNAL; } - else if (SVNStatusType.STATUS_OBSTRUCTED.equals(status)) { + else if (StatusType.STATUS_OBSTRUCTED.equals(status)) { return SvnFileStatus.OBSTRUCTED; } - else if (SVNStatusType.STATUS_IGNORED.equals(status)) { + else if (StatusType.STATUS_IGNORED.equals(status)) { return FileStatus.IGNORED; } - else if (SVNStatusType.STATUS_ADDED.equals(status)) { + else if (StatusType.STATUS_ADDED.equals(status)) { return FileStatus.ADDED; } - else if (SVNStatusType.STATUS_DELETED.equals(status)) { + else if (StatusType.STATUS_DELETED.equals(status)) { return FileStatus.DELETED; } - else if (SVNStatusType.STATUS_REPLACED.equals(status)) { + else if (StatusType.STATUS_REPLACED.equals(status)) { return SvnFileStatus.REPLACED; } - else if (status == SVNStatusType.STATUS_CONFLICTED) { + else if (status == StatusType.STATUS_CONFLICTED) { return FileStatus.MERGED_WITH_PROPERTY_CONFLICTS; } - else if (status == SVNStatusType.STATUS_MODIFIED) { + else if (status == StatusType.STATUS_MODIFIED) { return FileStatus.MODIFIED; } return FileStatus.NOT_CHANGED; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java index bd2882562404..43407f4b2064 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java @@ -45,9 +45,17 @@ import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.branchConfig.SvnBranchConfigurationNew; +import org.jetbrains.idea.svn.browse.DirectoryEntry; +import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.dialogs.LockDialog; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.status.Status; import org.tmatesoft.sqljet.core.SqlJetException; import org.tmatesoft.sqljet.core.table.SqlJetDb; import org.tmatesoft.svn.core.*; @@ -99,7 +107,7 @@ public class SvnUtil { } public static boolean isSvnVersioned(final @NotNull SvnVcs vcs, File parent) { - final SVNInfo info = vcs.getInfo(parent); + final Info info = vcs.getInfo(parent); return info != null; } @@ -157,7 +165,7 @@ public class SvnUtil { @Nullable public static String getExactLocation(final SvnVcs vcs, File path) { - SVNInfo info = vcs.getInfo(path); + Info info = vcs.getInfo(path); return info != null && info.getURL() != null ? info.getURL().toString() : null; } @@ -182,9 +190,9 @@ public class SvnUtil { final VcsException[] exception = new VcsException[1]; final Collection<String> failedLocks = new ArrayList<String>(); final int[] count = new int[]{ioFiles.length}; - final ISVNEventHandler eventHandler = new ISVNEventHandler() { - public void handleEvent(SVNEvent event, double progress) { - if (event.getAction() == SVNEventAction.LOCK_FAILED) { + final ProgressTracker eventHandler = new ProgressTracker() { + public void consume(ProgressEvent event) { + if (event.getAction() == EventAction.LOCK_FAILED) { failedLocks.add(event.getErrorMessage() != null ? event.getErrorMessage().getFullMessage() : event.getFile().getAbsolutePath()); @@ -247,9 +255,9 @@ public class SvnUtil { final VcsException[] exception = new VcsException[1]; final Collection<String> failedUnlocks = new ArrayList<String>(); final int[] count = new int[]{ioFiles.length}; - final ISVNEventHandler eventHandler = new ISVNEventHandler() { - public void handleEvent(SVNEvent event, double progress) { - if (event.getAction() == SVNEventAction.UNLOCK_FAILED) { + final ProgressTracker eventHandler = new ProgressTracker() { + public void consume(ProgressEvent event) { + if (event.getAction() == EventAction.UNLOCK_FAILED) { failedUnlocks.add(event.getErrorMessage() != null ? event.getErrorMessage().getFullMessage() : event.getFile().getAbsolutePath()); @@ -398,40 +406,41 @@ public class SvnUtil { @Nullable public static String getRepositoryUUID(final SvnVcs vcs, final File file) { - final SVNInfo info = vcs.getInfo(file); + final Info info = vcs.getInfo(file); return info != null ? info.getRepositoryUUID() : null; } @Nullable public static String getRepositoryUUID(final SvnVcs vcs, final SVNURL url) { try { - final SVNInfo info = vcs.getInfo(url, SVNRevision.UNDEFINED); + final Info info = vcs.getInfo(url, SVNRevision.UNDEFINED); return (info == null) ? null : info.getRepositoryUUID(); - } catch (SVNException e) { + } + catch (SvnBindException e) { return null; } } @Nullable public static SVNURL getRepositoryRoot(final SvnVcs vcs, final File file) { - final SVNInfo info = vcs.getInfo(file); + final Info info = vcs.getInfo(file); return info != null ? info.getRepositoryRootURL() : null; } @Nullable public static SVNURL getRepositoryRoot(final SvnVcs vcs, final String url) { try { - return getRepositoryRoot(vcs, SVNURL.parseURIEncoded(url)); + return getRepositoryRoot(vcs, createUrl(url)); } - catch (SVNException e) { + catch (SvnBindException e) { return null; } } @Nullable - public static SVNURL getRepositoryRoot(final SvnVcs vcs, final SVNURL url) throws SVNException { - SVNInfo info = vcs.getInfo(url, SVNRevision.HEAD); + public static SVNURL getRepositoryRoot(final SvnVcs vcs, final SVNURL url) throws SvnBindException { + Info info = vcs.getInfo(url, SVNRevision.HEAD); return (info == null) ? null : info.getRepositoryRootURL(); } @@ -496,17 +505,6 @@ public class SvnUtil { } @Nullable - public static String getPathForProgress(final SVNEvent event) { - if (event.getFile() != null) { - return event.getFile().getName(); - } - if (event.getURL() != null) { - return event.getURL().toString(); - } - return null; - } - - @Nullable public static VirtualFile correctRoot(final Project project, final VirtualFile file) { if (file.getPath().length() == 0) { // project root @@ -533,19 +531,19 @@ public class SvnUtil { } @Nullable - public static SVNStatus getStatus(@NotNull final SvnVcs vcs, @NotNull final File file) { + public static Status getStatus(@NotNull final SvnVcs vcs, @NotNull final File file) { try { return vcs.getFactory(file).createStatusClient().doStatus(file, false); } - catch (SVNException e) { + catch (SvnBindException e) { return null; } } - public static SVNDepth getDepth(final SvnVcs vcs, final File file) { - SVNInfo info = vcs.getInfo(file); + public static Depth getDepth(final SvnVcs vcs, final File file) { + Info info = vcs.getInfo(file); - return info != null && info.getDepth() != null ? info.getDepth() : SVNDepth.UNKNOWN; + return info != null && info.getDepth() != null ? info.getDepth() : Depth.UNKNOWN; } public static boolean seemsLikeVersionedDir(final VirtualFile file) { @@ -579,7 +577,7 @@ public class SvnUtil { @Nullable public static SVNURL getUrl(final SvnVcs vcs, final File file) { // todo for moved items? - final SVNInfo info = vcs.getInfo(file); + final Info info = vcs.getInfo(file); return info == null ? null : info.getURL(); } @@ -587,15 +585,17 @@ public class SvnUtil { public static boolean remoteFolderIsEmpty(final SvnVcs vcs, final String url) throws VcsException { SvnTarget target = SvnTarget.fromURL(createUrl(url)); final Ref<Boolean> result = new Ref<Boolean>(true); - ISVNDirEntryHandler handler = new ISVNDirEntryHandler() { - public void handleDirEntry(final SVNDirEntry dirEntry) throws SVNException { - if (dirEntry != null) { + DirectoryEntryConsumer handler = new DirectoryEntryConsumer() { + + @Override + public void consume(final DirectoryEntry entry) throws SVNException { + if (entry != null) { result.set(false); } } }; - vcs.getFactory(target).createBrowseClient().list(target, null, SVNDepth.IMMEDIATES, handler); + vcs.getFactory(target).createBrowseClient().list(target, null, Depth.IMMEDIATES, handler); return result.get(); } @@ -637,9 +637,7 @@ public class SvnUtil { WorkingCopyFormat format = getFormat(current); - return WorkingCopyFormat.ONE_DOT_EIGHT.equals(format) || WorkingCopyFormat.ONE_DOT_SEVEN.equals(format) - ? current - : getWorkingCopyRoot(file); + return format.isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN) ? current : getWorkingCopyRoot(file); } private static File getParentWithDb(File file) { @@ -695,14 +693,19 @@ public class SvnUtil { } @NotNull - public static SVNRevision getHeadRevision(@NotNull SvnVcs vcs, @NotNull SVNURL url) throws SVNException { - SVNInfo info = vcs.getInfo(url, SVNRevision.HEAD); + public static SVNURL removePathTail(@NotNull SVNURL url) throws SvnBindException { + return createUrl(SVNPathUtil.removeTail(url.toDecodedString())); + } + + @NotNull + public static SVNRevision getHeadRevision(@NotNull SvnVcs vcs, @NotNull SVNURL url) throws SvnBindException { + Info info = vcs.getInfo(url, SVNRevision.HEAD); if (info == null) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "Could not get info for " + url)); + throw new SvnBindException("Could not get info for " + url); } if (info.getRevision() == null) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "Could not get revision for " + url)); + throw new SvnBindException("Could not get revision for " + url); } return info.getRevision(); @@ -771,18 +774,18 @@ public class SvnUtil { } @Nullable - public static String getChangelistName(@NotNull final SVNStatus status) { + public static String getChangelistName(@NotNull final Status status) { // no explicit check on working copy format supports change lists as they are supported from svn 1.5 // and anyway status.getChangelistName() should just return null if change lists are not supported. - return SVNNodeKind.FILE.equals(status.getKind()) ? status.getChangelistName() : null; + return status.getKind().isFile() ? status.getChangelistName() : null; } - public static boolean isUnversionedOrNotFound(@NotNull SVNErrorCode code) { - return SVNErrorCode.WC_PATH_NOT_FOUND.equals(code) || - SVNErrorCode.UNVERSIONED_RESOURCE.equals(code) || - SVNErrorCode.WC_NOT_WORKING_COPY.equals(code) || + public static boolean isUnversionedOrNotFound(@NotNull SvnBindException e) { + return e.contains(SVNErrorCode.WC_PATH_NOT_FOUND) || + e.contains(SVNErrorCode.UNVERSIONED_RESOURCE) || + e.contains(SVNErrorCode.WC_NOT_WORKING_COPY) || // thrown when getting info from repository for non-existent item - like HEAD revision for deleted file - SVNErrorCode.ILLEGAL_TARGET.equals(code); + e.contains(SVNErrorCode.ILLEGAL_TARGET); } // TODO: Create custom Target class and implement append there diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java index ee4233fca1b2..5010ac580750 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java @@ -65,10 +65,12 @@ import org.jetbrains.idea.svn.actions.SvnMergeProvider; import org.jetbrains.idea.svn.annotate.SvnAnnotationProvider; import org.jetbrains.idea.svn.api.ClientFactory; import org.jetbrains.idea.svn.api.CmdClientFactory; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.api.SvnKitClientFactory; import org.jetbrains.idea.svn.auth.SvnAuthenticationNotifier; import org.jetbrains.idea.svn.checkin.SvnCheckinEnvironment; import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.commandLine.SvnExecutableChecker; import org.jetbrains.idea.svn.dialogs.SvnBranchPointsCalculator; import org.jetbrains.idea.svn.dialogs.WCInfo; @@ -76,14 +78,19 @@ import org.jetbrains.idea.svn.history.LoadedRevisionsCache; import org.jetbrains.idea.svn.history.SvnChangeList; import org.jetbrains.idea.svn.history.SvnCommittedChangesProvider; import org.jetbrains.idea.svn.history.SvnHistoryProvider; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.info.InfoConsumer; import org.jetbrains.idea.svn.properties.PropertyClient; import org.jetbrains.idea.svn.rollback.SvnRollbackEnvironment; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.jetbrains.idea.svn.svnkit.SvnKitManager; import org.jetbrains.idea.svn.update.SvnIntegrateEnvironment; import org.jetbrains.idea.svn.update.SvnUpdateEnvironment; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.wc.SVNAdminUtil; -import org.tmatesoft.svn.core.wc.*; +import org.tmatesoft.svn.core.wc.SVNPropertyData; +import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -213,6 +220,10 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { myWorkingCopiesContent.activate(); } + /** + * TODO: This seems to be related to some issues when upgrading from 1.6 to 1.7. So it is not currently required for 1.8 and later + * TODO: formats. And should be removed when 1.6 working copies are no longer supported by IDEA. + */ private void cleanup17copies() { final Runnable callCleanupWorker = new Runnable() { public void run() { @@ -251,7 +262,7 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { public boolean checkCommandLineVersion() { boolean isValid = true; - if (!isProject16() && (myConfiguration.isCommandLine() || isProject18())) { + if (!isProject16() && (myConfiguration.isCommandLine() || isProject18OrGreater())) { isValid = myChecker.checkExecutableAndNotifyIfNeeded(); } @@ -588,30 +599,19 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { public boolean fileExistsInVcs(FilePath path) { File file = path.getIOFile(); try { - SVNStatus status = getFactory(file).createStatusClient().doStatus(file, false); + Status status = getFactory(file).createStatusClient().doStatus(file, false); if (status != null) { - if (svnStatusIs(status, SVNStatusType.STATUS_ADDED)) { - return status.isCopied(); - } - return !(svnStatusIsUnversioned(status) || - svnStatusIs(status, SVNStatusType.STATUS_IGNORED) || - svnStatusIs(status, SVNStatusType.STATUS_OBSTRUCTED)); + return status.is(StatusType.STATUS_ADDED) + ? status.isCopied() + : !status.is(StatusType.STATUS_UNVERSIONED, StatusType.STATUS_IGNORED, StatusType.STATUS_OBSTRUCTED); } } - catch (SVNException e) { + catch (SvnBindException e) { LOG.info(e); } return false; } - public static boolean svnStatusIsUnversioned(final SVNStatus status) { - return svnStatusIs(status, SVNStatusType.STATUS_UNVERSIONED); - } - - public static boolean svnStatusIs(final SVNStatus status, @NotNull final SVNStatusType value) { - return value.equals(status.getNodeStatus()) || value.equals(status.getContentsStatus()); - } - @Override public boolean fileIsUnderVcs(FilePath path) { final ChangeListManager clManager = ChangeListManager.getInstance(myProject); @@ -623,33 +623,33 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { } @Nullable - public SVNInfo getInfo(@NotNull SVNURL url, + public Info getInfo(@NotNull SVNURL url, SVNRevision pegRevision, - SVNRevision revision) throws SVNException { + SVNRevision revision) throws SvnBindException { return getFactory().createInfoClient().doInfo(url, pegRevision, revision); } @Nullable - public SVNInfo getInfo(@NotNull SVNURL url, SVNRevision revision) throws SVNException { + public Info getInfo(@NotNull SVNURL url, SVNRevision revision) throws SvnBindException { return getInfo(url, SVNRevision.UNDEFINED, revision); } @Nullable - public SVNInfo getInfo(@NotNull final VirtualFile file) { + public Info getInfo(@NotNull final VirtualFile file) { return getInfo(new File(file.getPath())); } @Nullable - public SVNInfo getInfo(@NotNull String path) { + public Info getInfo(@NotNull String path) { return getInfo(new File(path)); } @Nullable - public SVNInfo getInfo(@NotNull File ioFile) { + public Info getInfo(@NotNull File ioFile) { return getInfo(ioFile, SVNRevision.UNDEFINED); } - public void collectInfo(@NotNull Collection<File> files, @Nullable ISVNInfoHandler handler) { + public void collectInfo(@NotNull Collection<File> files, @Nullable InfoConsumer handler) { File first = ContainerUtil.getFirstItem(files); if (first != null) { @@ -663,41 +663,42 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { // TODO: Generally this should be moved in SvnKit info client implementation. // TODO: Currently left here to have exception logic as in handleInfoException to be applied for each file separately. for (File file : files) { - SVNInfo info = getInfo(file); + Info info = getInfo(file); if (handler != null) { - handler.handleInfo(info); + handler.consume(info); } } } } catch (SVNException e) { + handleInfoException(new SvnBindException(e)); + } + catch (SvnBindException e) { handleInfoException(e); } } } @Nullable - public SVNInfo getInfo(@NotNull File ioFile, @NotNull SVNRevision revision) { - SVNInfo result = null; + public Info getInfo(@NotNull File ioFile, @NotNull SVNRevision revision) { + Info result = null; try { result = getFactory(ioFile).createInfoClient().doInfo(ioFile, revision); } - catch (SVNException e) { + catch (SvnBindException e) { handleInfoException(e); } return result; } - private void handleInfoException(SVNException e) { - final SVNErrorCode errorCode = e.getErrorMessage().getErrorCode(); - + private void handleInfoException(@NotNull SvnBindException e) { if (!myLogExceptions || - SvnUtil.isUnversionedOrNotFound(errorCode) || + SvnUtil.isUnversionedOrNotFound(e) || // do not log working copy format vs client version inconsistencies as errors - SVNErrorCode.WC_UNSUPPORTED_FORMAT.equals(errorCode) || - SVNErrorCode.WC_UPGRADE_REQUIRED.equals(errorCode)) { + e.contains(SVNErrorCode.WC_UNSUPPORTED_FORMAT) || + e.contains(SVNErrorCode.WC_UPGRADE_REQUIRED)) { LOG.debug(e); } else { @@ -797,7 +798,7 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { List<WCInfo> result = new ArrayList<WCInfo>(getAllWcInfos()); for (RootUrlInfo info : getSvnFileUrlMapping().getErrorRoots()) { - result.add(new WCInfo(info, SvnUtil.isWorkingCopyRoot(info.getIoFile()), SVNDepth.UNKNOWN)); + result.add(new WCInfo(info, SvnUtil.isWorkingCopyRoot(info.getIoFile()), Depth.UNKNOWN)); } return result; @@ -948,14 +949,15 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { return svnKitManager; } - public boolean isProject18() { - return WorkingCopyFormat.ONE_DOT_EIGHT.equals(getProjectRootFormat()); + public boolean isProject18OrGreater() { + return getProjectRootFormat().isOrGreater(WorkingCopyFormat.ONE_DOT_EIGHT); } public boolean isProject16() { return WorkingCopyFormat.ONE_DOT_SIX.equals(getProjectRootFormat()); } + @NotNull private WorkingCopyFormat getProjectRootFormat() { return !getProject().isDefault() ? getWorkingCopyFormat(new File(getProject().getBaseDir().getPath())) : WorkingCopyFormat.UNKNOWN; } @@ -993,11 +995,11 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { @NotNull private ClientFactory getFactory(@NotNull WorkingCopyFormat format, boolean useProjectRootForUnknown) { - boolean is18 = WorkingCopyFormat.ONE_DOT_EIGHT.equals(format); + boolean is18OrGreater = format.isOrGreater(WorkingCopyFormat.ONE_DOT_EIGHT); boolean is16 = WorkingCopyFormat.ONE_DOT_SIX.equals(format); boolean isUnknown = WorkingCopyFormat.UNKNOWN.equals(format); - return is18 + return is18OrGreater ? cmdClientFactory : (is16 ? svnKitClientFactory : (useProjectRootForUnknown && isUnknown ? getFactory() : getFactoryFromSettings())); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java index 223c69ab1c6f..97e6a618ba7c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java @@ -40,8 +40,8 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.history.SvnRepositoryContentRevision; -import org.jetbrains.idea.svn.properties.PropertyClient; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.ISVNPropertyHandler; import org.tmatesoft.svn.core.wc.SVNPropertyData; @@ -276,7 +276,7 @@ public abstract class AbstractShowPropertiesDiffAction extends AnAction implemen final List<SVNPropertyData> lines = new ArrayList<SVNPropertyData>(); final ISVNPropertyHandler propertyHandler = createHandler(revision, lines); - vcs.getFactory(target).createPropertyClient().list(target, revision, SVNDepth.EMPTY, propertyHandler); + vcs.getFactory(target).createPropertyClient().list(target, revision, Depth.EMPTY, propertyHandler); return toSortedStringPresentation(lines); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CleanupWorker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CleanupWorker.java index 7623f083eb86..dc6fb8c0d55b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CleanupWorker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CleanupWorker.java @@ -30,10 +30,10 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNCancelException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; import java.io.File; import java.util.LinkedList; @@ -69,9 +69,9 @@ public class CleanupWorker { final File path = new File(root.getPath()); indicator.setText(SvnBundle.message("action.Subversion.cleanup.progress.text", path)); - ISVNEventHandler handler = new ISVNEventHandler() { + ProgressTracker handler = new ProgressTracker() { @Override - public void handleEvent(SVNEvent event, double progress) throws SVNException { + public void consume(ProgressEvent event) throws SVNException { } @Override diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateBranchOrTagAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateBranchOrTagAction.java index 7655751ded40..c6f633416a15 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateBranchOrTagAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateBranchOrTagAction.java @@ -37,6 +37,7 @@ import org.jetbrains.idea.svn.SvnStatusUtil; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.checkin.CommitEventHandler; import org.jetbrains.idea.svn.checkin.IdeaCommitHandler; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.dialogs.CreateBranchOrTagDialog; import org.jetbrains.idea.svn.update.AutoSvnUpdater; import org.jetbrains.idea.svn.update.SingleRootSwitcher; @@ -86,17 +87,17 @@ public class CreateBranchOrTagAction extends BasicAction { srcUrl = SVNURL.parseURIEncoded(dialog.getCopyFromUrl()); dstSvnUrl = SVNURL.parseURIEncoded(dstURL); parentUrl = dstSvnUrl.removePathTail(); - - if (!dirExists(activeVcs, parentUrl)) { - int rc = Messages.showYesNoDialog(project, "The repository path '" + parentUrl + "' does not exist. Would you like to create it?", - "Branch or Tag", Messages.getQuestionIcon()); - if (rc == Messages.NO) { - return; - } - } } catch (SVNException e) { - throw new VcsException(e); + throw new SvnBindException(e); + } + + if (!dirExists(activeVcs, parentUrl)) { + int rc = Messages.showYesNoDialog(project, "The repository path '" + parentUrl + "' does not exist. Would you like to create it?", + "Branch or Tag", Messages.getQuestionIcon()); + if (rc == Messages.NO) { + return; + } } Runnable copyCommand = new Runnable() { @@ -145,8 +146,8 @@ public class CreateBranchOrTagAction extends BasicAction { } } - private static boolean dirExists(@NotNull final SvnVcs vcs, @NotNull final SVNURL url) throws SVNException { - final Ref<SVNException> excRef = new Ref<SVNException>(); + private static boolean dirExists(@NotNull final SvnVcs vcs, @NotNull final SVNURL url) throws SvnBindException { + final Ref<SvnBindException> excRef = new Ref<SvnBindException>(); final Ref<Boolean> resultRef = new Ref<Boolean>(Boolean.TRUE); final Runnable taskImpl = new Runnable() { @@ -154,8 +155,8 @@ public class CreateBranchOrTagAction extends BasicAction { try { vcs.getInfo(url, SVNRevision.HEAD); } - catch (SVNException e) { - if (e.getErrorMessage().getErrorCode().equals(SVNErrorCode.RA_ILLEGAL_URL)) { + catch (SvnBindException e) { + if (e.contains(SVNErrorCode.RA_ILLEGAL_URL)) { resultRef.set(Boolean.FALSE); } else { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateExternalAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateExternalAction.java index b65332a44604..31206eec045c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateExternalAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateExternalAction.java @@ -18,7 +18,6 @@ package org.jetbrains.idea.svn.actions; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; @@ -38,11 +37,13 @@ import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnPropertyKeys; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.api.ClientFactory; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.dialogs.SelectCreateExternalTargetDialog; import org.jetbrains.idea.svn.update.UpdateClient; import org.tmatesoft.svn.core.SVNCancelException; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.internal.wc.SVNExternal; @@ -100,9 +101,9 @@ public class CreateExternalAction extends DumbAwareAction { if (checkout) { // +- final UpdateClient client = vcs.getFactory(ioFile).createUpdateClient(); - client.setEventHandler(new ISVNEventHandler() { + client.setEventHandler(new ProgressTracker() { @Override - public void handleEvent(SVNEvent event, double progress) throws SVNException { + public void consume(ProgressEvent event) throws SVNException { } @Override @@ -111,7 +112,7 @@ public class CreateExternalAction extends DumbAwareAction { if (pi != null && pi.isCanceled()) throw new SVNCancelException(); } }); - client.doUpdate(ioFile, SVNRevision.HEAD, SVNDepth.UNKNOWN, false, false); + client.doUpdate(ioFile, SVNRevision.HEAD, Depth.UNKNOWN, false, false); vf.refresh(true, true, new Runnable() { @Override public void run() { @@ -148,7 +149,7 @@ public class CreateExternalAction extends DumbAwareAction { } else { newValue = createExternalDefinitionString(url, target); } - factory.createPropertyClient().setProperty(ioFile, SvnPropertyKeys.SVN_EXTERNALS, SVNPropertyValue.create(newValue), SVNDepth.EMPTY, + factory.createPropertyClient().setProperty(ioFile, SvnPropertyKeys.SVN_EXTERNALS, SVNPropertyValue.create(newValue), Depth.EMPTY, false); return false; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkLocallyDeletedTreeConflictResolvedAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkLocallyDeletedTreeConflictResolvedAction.java index 10793269c041..2e400adfd8fa 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkLocallyDeletedTreeConflictResolvedAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkLocallyDeletedTreeConflictResolvedAction.java @@ -36,7 +36,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnLocallyDeletedChange; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import java.util.Collections; import java.util.List; @@ -93,7 +93,7 @@ public class MarkLocallyDeletedTreeConflictResolvedAction extends AnAction { SvnVcs vcs = SvnVcs.getInstance(project); try { - vcs.getFactory(path.getIOFile()).createConflictClient().resolve(path.getIOFile(), SVNDepth.EMPTY, false, false, true); + vcs.getFactory(path.getIOFile()).createConflictClient().resolve(path.getIOFile(), Depth.EMPTY, false, false, true); } catch (VcsException e) { exception.set(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkResolvedAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkResolvedAction.java index d20b5f14d6b5..6d51d9d90dd8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkResolvedAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkResolvedAction.java @@ -33,12 +33,15 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnStatusUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.conflict.ConflictClient; import org.jetbrains.idea.svn.dialogs.SelectFilesDialog; +import org.jetbrains.idea.svn.status.Status; import org.jetbrains.idea.svn.status.StatusClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.*; +import org.jetbrains.idea.svn.status.StatusConsumer; +import org.jetbrains.idea.svn.status.StatusType; +import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; import java.util.Collection; @@ -98,7 +101,7 @@ public class MarkResolvedAction extends BasicAction { ConflictClient client = vcs.getFactory(ioFile).createConflictClient(); // TODO: Probably false should be passed to "resolveTree", but previous logic used true implicitly - client.resolve(ioFile, SVNDepth.EMPTY, true, true, true); + client.resolve(ioFile, Depth.EMPTY, true, true, true); } } finally { @@ -124,16 +127,17 @@ public class MarkResolvedAction extends BasicAction { File path = new File(file.getPath()); StatusClient client = vcs.getFactory(path).createStatusClient(); - client.doStatus(path, true, false, false, false, new ISVNStatusHandler() { - public void handleStatus(SVNStatus status) { - if (status.getContentsStatus() == SVNStatusType.STATUS_CONFLICTED || - status.getPropertiesStatus() == SVNStatusType.STATUS_CONFLICTED) { + client.doStatus(path, SVNRevision.UNDEFINED, Depth.INFINITY, false, false, false, false, new StatusConsumer() { + @Override + public void consume(Status status) { + if (status.getContentsStatus() == StatusType.STATUS_CONFLICTED || + status.getPropertiesStatus() == StatusType.STATUS_CONFLICTED) { target.add(status.getFile().getAbsolutePath()); } } - }); + }, null); } - catch (SVNException e) { + catch (SvnBindException e) { LOG.warn(e); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkTreeConflictResolvedAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkTreeConflictResolvedAction.java index 73d9c28eb48d..10330ded734c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkTreeConflictResolvedAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkTreeConflictResolvedAction.java @@ -37,7 +37,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.ConflictedSvnChange; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import java.util.ArrayList; import java.util.Collection; @@ -114,7 +114,7 @@ public class MarkTreeConflictResolvedAction extends AnAction implements DumbAwar SvnVcs vcs = SvnVcs.getInstance(checker.getProject()); try { - vcs.getFactory(path.getIOFile()).createConflictClient().resolve(path.getIOFile(), SVNDepth.EMPTY, false, false, true); + vcs.getFactory(path.getIOFile()).createConflictClient().resolve(path.getIOFile(), Depth.EMPTY, false, false, true); } catch (VcsException e) { exception.set(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/RelocateAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/RelocateAction.java index 87615a08588c..af601f3cd126 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/RelocateAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/RelocateAction.java @@ -28,7 +28,7 @@ import com.intellij.util.WaitForProgressToShow; import org.jetbrains.idea.svn.SvnStatusUtil; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.dialogs.RelocateDialog; -import org.tmatesoft.svn.core.wc.SVNInfo; +import org.jetbrains.idea.svn.info.Info; import java.io.File; @@ -49,7 +49,7 @@ public class RelocateAction extends BasicAction { } protected void perform(final Project project, final SvnVcs activeVcs, final VirtualFile file, DataContext context) throws VcsException { - SVNInfo info = activeVcs.getInfo(file); + Info info = activeVcs.getInfo(file); assert info != null; RelocateDialog dlg = new RelocateDialog(project, info.getURL()); dlg.show(); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SetPropertyAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SetPropertyAction.java index 3f740bad1bef..cdc738cf2d40 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SetPropertyAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SetPropertyAction.java @@ -27,9 +27,9 @@ import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.dialogs.SetPropertyDialog; import org.jetbrains.idea.svn.properties.PropertyClient; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNPropertyValue; import java.io.File; @@ -79,7 +79,7 @@ public class SetPropertyAction extends BasicAction { // TODO: most likely SVNDepth.getInfinityOrEmptyDepth should be used instead of SVNDepth.fromRecursive - to have either "infinity" // TODO: or "empty" depth, and not "infinity" or "files" depth. But previous logic used SVNDepth.fromRecursive implicitly - client.setProperty(ioFile, name, SVNPropertyValue.create(value), SVNDepth.fromRecurse(recursive), false); + client.setProperty(ioFile, name, SVNPropertyValue.create(value), Depth.allOrFiles(recursive), false); } for(int i = 0; i < file.length; i++) { if (recursive && file[i].isDirectory()) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java index 7f648dce75b9..012a870676a0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java @@ -35,9 +35,9 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.*; import org.jetbrains.idea.svn.api.ClientFactory; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider; import org.jetbrains.idea.svn.dialogs.ShareDialog; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -167,7 +167,7 @@ public class ShareProjectAction extends BasicAction { final ClientFactory factory = SvnCheckoutProvider.getFactory(activeVcs, format); factory.createCheckoutClient() - .checkout(SvnTarget.fromURL(checkoutUrl), path, revision, SVNDepth.INFINITY, false, false, format, null); + .checkout(SvnTarget.fromURL(checkoutUrl), path, revision, Depth.INFINITY, false, false, format, null); addRecursively(activeVcs, factory, file); } catch (SVNException e) { error[0] = e; @@ -254,9 +254,9 @@ public class ShareProjectAction extends BasicAction { indicator.checkCanceled(); indicator.setText(SvnBundle.message("share.or.import.add.progress.text", virtualFile.getPath())); } - factory.createAddClient().add(ioFile, SVNDepth.EMPTY, false, false, true, null); + factory.createAddClient().add(ioFile, Depth.EMPTY, false, false, true, null); } - }, SVNDepth.INFINITY); + }, Depth.INFINITY); operation.execute(file); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnExcludingIgnoredOperation.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnExcludingIgnoredOperation.java index 49fdc0279dd5..c206cd3451d8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnExcludingIgnoredOperation.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnExcludingIgnoredOperation.java @@ -26,14 +26,14 @@ import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileVisitor; import org.jetbrains.annotations.NotNull; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; public class SvnExcludingIgnoredOperation { private final Operation myImportAction; - private final SVNDepth myDepth; + private final Depth myDepth; private final Filter myFilter; - public SvnExcludingIgnoredOperation(final Project project, final Operation importAction, final SVNDepth depth) { + public SvnExcludingIgnoredOperation(final Project project, final Operation importAction, final Depth depth) { myImportAction = importAction; myDepth = depth; @@ -48,17 +48,18 @@ public class SvnExcludingIgnoredOperation { public Filter(final Project project) { myProject = project; - if (! project.isDefault()) { + if (!project.isDefault()) { myIndex = PeriodicalTasksCloser.getInstance().safeGetService(project, FileIndexFacade.class); myClManager = ChangeListManager.getInstance(project); - } else { + } + else { myIndex = null; myClManager = null; } } public boolean accept(final VirtualFile file) { - if (! myProject.isDefault()) { + if (!myProject.isDefault()) { if (isExcluded(file)) { return false; } @@ -80,7 +81,7 @@ public class SvnExcludingIgnoredOperation { } private boolean operation(final VirtualFile file) throws VcsException { - if (! myFilter.accept(file)) return false; + if (!myFilter.accept(file)) return false; myImportAction.doOperation(file); return true; @@ -101,21 +102,21 @@ public class SvnExcludingIgnoredOperation { } public void execute(final VirtualFile file) throws VcsException { - if (SVNDepth.INFINITY.equals(myDepth)) { + if (Depth.INFINITY.equals(myDepth)) { executeDown(file); return; } - if (! operation(file)) { + if (!operation(file)) { return; } - if (SVNDepth.EMPTY.equals(myDepth)) { + if (Depth.EMPTY.equals(myDepth)) { return; } for (VirtualFile child : file.getChildren()) { - if (SVNDepth.FILES.equals(myDepth) && child.isDirectory()) { + if (Depth.FILES.equals(myDepth) && child.isDirectory()) { continue; } operation(child); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnMergeProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnMergeProvider.java index a4d71ceb9241..912bd970f7b0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnMergeProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnMergeProvider.java @@ -29,8 +29,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.info.Info; import org.jetbrains.idea.svn.properties.PropertyClient; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNProperty; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.wc.*; @@ -64,7 +65,7 @@ public class SvnMergeProvider implements MergeProvider { File workingFile = null; boolean mergeCase = false; SvnVcs vcs = SvnVcs.getInstance(myProject); - SVNInfo info = vcs.getInfo(file); + Info info = vcs.getInfo(file); if (info != null) { oldFile = info.getConflictOldFile(); @@ -142,7 +143,7 @@ public class SvnMergeProvider implements MergeProvider { File path = new File(file.getPath()); try { // TODO: Probably false should be passed to "resolveTree", but previous logic used true implicitly - vcs.getFactory(path).createConflictClient().resolve(path, SVNDepth.EMPTY, false, true, true); + vcs.getFactory(path).createConflictClient().resolve(path, Depth.EMPTY, false, true, true); } catch (VcsException e) { LOG.warn(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/add/AddClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/add/AddClient.java index 718a56dea9af..872e290db0c0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/add/AddClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/add/AddClient.java @@ -3,9 +3,9 @@ package org.jetbrains.idea.svn.add; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import java.io.File; @@ -15,9 +15,9 @@ import java.io.File; public interface AddClient extends SvnClient { void add(@NotNull File file, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean makeParents, boolean includeIgnored, boolean force, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/add/CmdAddClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/add/CmdAddClient.java index 4811e3286d70..6894800427c2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/add/CmdAddClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/add/CmdAddClient.java @@ -4,15 +4,12 @@ import com.intellij.openapi.vcs.VcsException; import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.api.FileStatusResultParser; +import org.jetbrains.idea.svn.api.*; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNStatusType; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -33,11 +30,11 @@ public class CmdAddClient extends BaseSvnClient implements AddClient { @Override public void add(@NotNull File file, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean makeParents, boolean includeIgnored, boolean force, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { List<String> parameters = prepareParameters(file, depth, makeParents, includeIgnored, force); // TODO: handler should be called in parallel with command execution, but this will be in other thread @@ -48,7 +45,7 @@ public class CmdAddClient extends BaseSvnClient implements AddClient { parser.parse(command.getOutput()); } - private static List<String> prepareParameters(File file, SVNDepth depth, boolean makeParents, boolean includeIgnored, boolean force) { + private static List<String> prepareParameters(File file, Depth depth, boolean makeParents, boolean includeIgnored, boolean force) { List<String> parameters = new ArrayList<String>(); CommandUtil.put(parameters, file); @@ -60,14 +57,13 @@ public class CmdAddClient extends BaseSvnClient implements AddClient { return parameters; } - private static class AddStatusConvertor implements Convertor<Matcher, SVNEvent> { + private static class AddStatusConvertor implements Convertor<Matcher, ProgressEvent> { @Override - public SVNEvent convert(Matcher o) { - SVNStatusType contentStatus = CommandUtil.getStatusType(o.group(1)); + public ProgressEvent convert(Matcher o) { + StatusType contentStatus = CommandUtil.getStatusType(o.group(1)); String path = o.group(3); - return new SVNEvent(new File(path), null, null, 0, contentStatus, null, null, null, null, null, null, null, - null, null, null); + return new ProgressEvent(new File(path), 0, contentStatus, null, null, null, null); } } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/add/SvnKitAddClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/add/SvnKitAddClient.java index 66e122d80232..7b05f0bd17d3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/add/SvnKitAddClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/add/SvnKitAddClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -22,19 +22,19 @@ public class SvnKitAddClient extends BaseSvnClient implements AddClient { */ @Override public void add(@NotNull File file, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean makeParents, boolean includeIgnored, boolean force, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { try { SVNWCClient client = myVcs.getSvnKitManager().createWCClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); client.doAdd(file, force, false, // directory should already be created makeParents, // not used but will be passed as makeParents value - SVNDepth.recurseFromDepth(depth)); + Depth.isRecursive(depth)); } catch (SVNException e) { throw new VcsException(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotateClient.java index df30cfd89ae2..90be057af431 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotateClient.java @@ -4,8 +4,7 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.wc.ISVNAnnotateHandler; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -19,6 +18,6 @@ public interface AnnotateClient extends SvnClient { @NotNull SVNRevision endRevision, @Nullable SVNRevision pegRevision, boolean includeMergedRevisions, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNAnnotateHandler handler) throws VcsException; + @Nullable DiffOptions diffOptions, + @Nullable AnnotationConsumer handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotationConsumer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotationConsumer.java new file mode 100644 index 000000000000..8d33be224b99 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotationConsumer.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.annotate; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.checkin.CommitInfo; +import org.tmatesoft.svn.core.SVNException; + +/** + * @author Konstantin Kolosovsky. + */ +public interface AnnotationConsumer { + + void consume(int lineNumber, @NotNull CommitInfo info, @Nullable CommitInfo mergeInfo) throws SVNException; +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/BaseSvnFileAnnotation.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/BaseSvnFileAnnotation.java index f4fa9f950a32..00a529e11b4d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/BaseSvnFileAnnotation.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/BaseSvnFileAnnotation.java @@ -19,6 +19,7 @@ import com.intellij.openapi.vcs.VcsKey; import com.intellij.openapi.vcs.annotate.*; import com.intellij.openapi.vcs.history.VcsFileRevision; import com.intellij.openapi.vcs.history.VcsRevisionNumber; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.DateFormatUtil; import com.intellij.xml.util.XmlStringUtil; import org.jetbrains.annotations.NotNull; @@ -27,6 +28,7 @@ import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.checkin.CommitInfo; import org.jetbrains.idea.svn.history.SvnFileRevision; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -46,27 +48,19 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { protected final SvnVcs myVcs; private final Map<Long, SvnFileRevision> myRevisionMap = new HashMap<Long, SvnFileRevision>(); - private final LineAnnotationAspect DATE_ASPECT = new SvnAnnotationAspect(SvnAnnotationAspect.DATE, true) { - public String getValue(int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return ""; - } - else { - final LineInfo lineInfo = myInfos.get(lineNumber); - return (lineInfo == null) ? "" : DateFormatUtil.formatPrettyDate(lineInfo.getDate()); - } + private final LineAnnotationAspect DATE_ASPECT = new SvnAnnotationAspect(LineAnnotationAspect.DATE, true) { + + @Override + public String getValue(@NotNull CommitInfo info) { + return DateFormatUtil.formatPrettyDate(info.getDate()); } }; - private final LineAnnotationAspect REVISION_ASPECT = new SvnAnnotationAspect(SvnAnnotationAspect.REVISION, false) { - public String getValue(int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return ""; - } - else { - final long revision = getRevision(lineNumber); - return (revision == -1) ? "" : String.valueOf(revision); - } + private final LineAnnotationAspect REVISION_ASPECT = new SvnAnnotationAspect(LineAnnotationAspect.REVISION, false) { + + @Override + public String getValue(@NotNull CommitInfo info) { + return String.valueOf(info.getRevision()); } }; @@ -84,31 +78,25 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { @Override public String getTooltipText(int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return ""; - } - final LineInfo info = myInfos.get(lineNumber); + // TODO: Check what is the difference in returning "" or null + if (!myInfos.isValid(lineNumber)) return ""; + + CommitInfo info = myInfos.get(lineNumber); if (info == null) return null; - SvnFileRevision svnRevision = myRevisionMap.get(info.getRevision()); - if (svnRevision != null) { - final String tooltip = "Revision " + info.getRevision() + ": " + svnRevision.getCommitMessage(); - return XmlStringUtil.escapeString(tooltip); - } - return ""; + + SvnFileRevision revision = myRevisionMap.get(info.getRevision()); + return revision != null ? XmlStringUtil.escapeString("Revision " + info.getRevision() + ": " + revision.getCommitMessage()) : ""; } }; - private final LineAnnotationAspect AUTHOR_ASPECT = new SvnAnnotationAspect(SvnAnnotationAspect.AUTHOR, true) { - public String getValue(int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return ""; - } - else { - final LineInfo lineInfo = myInfos.get(lineNumber); - return (lineInfo == null) ? "" : lineInfo.getAuthor(); - } + private final LineAnnotationAspect AUTHOR_ASPECT = new SvnAnnotationAspect(LineAnnotationAspect.AUTHOR, true) { + + @Override + public String getValue(@NotNull CommitInfo info) { + return info.getAuthor(); } }; + private final SvnConfiguration myConfiguration; private boolean myShowMergeSources; // null if full annotation @@ -118,10 +106,6 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { myRevisionMap.put(revision, svnRevision); } - public void clearRevisions() { - myRevisionMap.clear(); - } - public SvnFileRevision getRevision(final long revision) { return myRevisionMap.get(revision); } @@ -134,30 +118,6 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { return myFirstRevisionNumber; } - static class LineInfo { - private final Date myDate; - private final long myRevision; - private final String myAuthor; - - public LineInfo(final Date date, final long revision, final String author) { - myDate = date; - myRevision = revision; - myAuthor = author; - } - - public Date getDate() { - return myDate; - } - - public long getRevision() { - return myRevision; - } - - public String getAuthor() { - return myAuthor; - } - } - public BaseSvnFileAnnotation(final SvnVcs vcs, final String contents, final VcsRevisionNumber baseRevision) { super(vcs.getProject()); myVcs = vcs; @@ -174,18 +134,14 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { } public String getToolTip(final int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return ""; - } - final LineInfo info = myInfos.get(lineNumber); + final CommitInfo info = myInfos.getOrNull(lineNumber); if (info == null) return ""; - SvnFileRevision svnRevision = myRevisionMap.get(info.getRevision()); - if (svnRevision != null) { - if (myInfos.getAnnotationSource(lineNumber).showMerged()) { - return "Merge source revision " + info.getRevision() + ": " + svnRevision.getCommitMessage(); - } else { - return "Revision " + info.getRevision() + ": " + svnRevision.getCommitMessage(); - } + + SvnFileRevision revision = myRevisionMap.get(info.getRevision()); + if (revision != null) { + String prefix = myInfos.getAnnotationSource(lineNumber).showMerged() ? "Merge source revision" : "Revision"; + + return prefix + " " + info.getRevision() + ": " + revision.getCommitMessage(); } return ""; } @@ -194,53 +150,35 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { return myContents; } - public void setLineInfo(final int lineNumber, final Date date, final long revision, final String author, - @Nullable final Date mergeDate, final long mergeRevision, @Nullable final String mergeAuthor) { - myInfos.appendNumberedLineInfo(lineNumber, date, revision, author, mergeDate, mergeRevision, mergeAuthor); - } - - public void appendLineInfo(final Date date, final long revision, final String author, - @Nullable final Date mergeDate, final long mergeRevision, @Nullable final String mergeAuthor) { - myInfos.appendNumberedLineInfo(date, revision, author, mergeDate, mergeRevision, mergeAuthor); + public void setLineInfo(int lineNumber, @NotNull CommitInfo info, @Nullable CommitInfo mergeInfo) { + myInfos.appendNumberedLineInfo(lineNumber, info, mergeInfo); } @Nullable public VcsRevisionNumber originalRevision(final int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return null; - } - final SvnFileRevision revision = myRevisionMap.get(myInfos.originalRevision(lineNumber)); - return revision == null ? null : revision.getRevisionNumber(); + SvnFileRevision revision = myInfos.isValid(lineNumber) ? myRevisionMap.get(myInfos.originalRevision(lineNumber)) : null; + + return revision != null ? revision.getRevisionNumber() : null; } public VcsRevisionNumber getLineRevisionNumber(final int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return null; - } - final LineInfo info = myInfos.get(lineNumber); - if (info == null) return null; - final long revision = info.getRevision(); - if (revision >= 0) { - return new SvnRevisionNumber(SVNRevision.create(revision)); - } - return null; + CommitInfo info = myInfos.getOrNull(lineNumber); + + return info != null && info.getRevision() >= 0 ? new SvnRevisionNumber(SVNRevision.create(info.getRevision())) : null; } @Override public Date getLineDate(int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return null; - } - final LineInfo info = myInfos.get(lineNumber); - if (info == null) return null; - return info.getDate(); + CommitInfo info = myInfos.getOrNull(lineNumber); + + return info != null ? info.getDate() : null; } public List<VcsFileRevision> getRevisions() { final List<VcsFileRevision> result = new ArrayList<VcsFileRevision>(myRevisionMap.values()); Collections.sort(result, new Comparator<VcsFileRevision>() { public int compare(final VcsFileRevision o1, final VcsFileRevision o2) { - return -1 * o1.getRevisionNumber().compareTo(o2.getRevisionNumber()); + return o2.getRevisionNumber().compareTo(o1.getRevisionNumber()); } }); return result; @@ -250,10 +188,6 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { return ! myRevisionMap.isEmpty(); } - public int getNumLines() { - return myInfos.size(); - } - @Nullable public AnnotationSourceSwitcher getAnnotationSourceSwitcher() { if (! myShowMergeSources) return null; @@ -285,7 +219,7 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { @Override public int getLineCount() { - return getNumLines(); + return myInfos.size(); } @Override @@ -294,44 +228,52 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { } private abstract class SvnAnnotationAspect extends LineAnnotationAspectAdapter { + public SvnAnnotationAspect(String id, boolean showByDefault) { super(id, showByDefault); } protected long getRevision(final int lineNum) { - final LineInfo lineInfo = myInfos.get(lineNum); + final CommitInfo lineInfo = myInfos.get(lineNum); return (lineInfo == null) ? -1 : lineInfo.getRevision(); } @Override protected void showAffectedPaths(int lineNum) { - if (lineNum >= 0 && lineNum < myInfos.size()) { + if (myInfos.isValid(lineNum)) { final long revision = getRevision(lineNum); if (revision >= 0) { showAllAffectedPaths(new SvnRevisionNumber(SVNRevision.create(revision))); } } } + + @Override + public String getValue(int lineNumber) { + CommitInfo info = myInfos.getOrNull(lineNumber); + + return info == null ? "" : getValue(info); + } + + public String getValue(@NotNull CommitInfo info) { + return ""; + } } protected abstract void showAllAffectedPaths(SvnRevisionNumber number); private static class MyPartiallyCreatedInfos { private boolean myShowMergeSource; - private final Map<Integer, LineInfo> myMappedLineInfo; - private final Map<Integer, LineInfo> myMergeSourceInfos; + private final Map<Integer, CommitInfo> myMappedLineInfo; + private final Map<Integer, CommitInfo> myMergeSourceInfos; private int myMaxIdx; private MyPartiallyCreatedInfos() { - myMergeSourceInfos = new HashMap<Integer, LineInfo>(); - myMappedLineInfo = new HashMap<Integer, LineInfo>(); + myMergeSourceInfos = ContainerUtil.newHashMap(); + myMappedLineInfo = ContainerUtil.newHashMap(); myMaxIdx = 0; } - boolean isShowMergeSource() { - return myShowMergeSource; - } - void setShowMergeSource(boolean showMergeSource) { myShowMergeSource = showMergeSource; } @@ -340,25 +282,18 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { return myMaxIdx + 1; } - void appendNumberedLineInfo(final Date date, final long revision, final String author, - @Nullable final Date mergeDate, final long mergeRevision, @Nullable final String mergeAuthor) { - appendNumberedLineInfo(myMaxIdx + 1, date, revision, author, mergeDate, mergeRevision, mergeAuthor); - } - - void appendNumberedLineInfo(final int lineNumber, final Date date, final long revision, final String author, - @Nullable final Date mergeDate, final long mergeRevision, @Nullable final String mergeAuthor) { - if (date == null) return; + void appendNumberedLineInfo(final int lineNumber, @NotNull CommitInfo info, @Nullable CommitInfo mergeInfo) { if (myMappedLineInfo.get(lineNumber) != null) return; myMaxIdx = (myMaxIdx < lineNumber) ? lineNumber : myMaxIdx; - myMappedLineInfo.put(lineNumber, new LineInfo(date, revision, author)); - if (mergeDate != null) { - myMergeSourceInfos.put(lineNumber, new LineInfo(mergeDate, mergeRevision, mergeAuthor)); + myMappedLineInfo.put(lineNumber, info); + if (mergeInfo != null) { + myMergeSourceInfos.put(lineNumber, mergeInfo); } } - LineInfo get(final int idx) { + CommitInfo get(final int idx) { if (myShowMergeSource) { - final LineInfo lineInfo = myMergeSourceInfos.get(idx); + final CommitInfo lineInfo = myMergeSourceInfos.get(idx); if (lineInfo != null) { return lineInfo; } @@ -366,14 +301,23 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { return myMappedLineInfo.get(idx); } + @Nullable + CommitInfo getOrNull(int lineNumber) { + return isValid(lineNumber) ? get(lineNumber) : null; + } + + private boolean isValid(int lineNumber) { + return lineNumber >= 0 && lineNumber < size(); + } + AnnotationSource getAnnotationSource(final int line) { return myShowMergeSource ? AnnotationSource.getInstance(myMergeSourceInfos.containsKey(line)) : AnnotationSource.LOCAL; } public long originalRevision(final int line) { - if (line >= size()) return -1; - final LineInfo lineInfo = myMappedLineInfo.get(line); - return lineInfo == null ? -1 : lineInfo.getRevision(); + CommitInfo info = line < size() ? myMappedLineInfo.get(line) : null; + + return info == null ? -1 : info.getRevision(); } public boolean mergeSourceAvailable(int lineNumber) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java index 5cb18a35fc5c..b48f14a41779 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java @@ -4,12 +4,12 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.checkin.CommitInfo; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNAnnotateHandler; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -18,7 +18,6 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; -import java.util.Date; import java.util.List; /** @@ -32,8 +31,8 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { @NotNull SVNRevision endRevision, @Nullable SVNRevision pegRevision, boolean includeMergedRevisions, - @Nullable SVNDiffOptions diffOptions, - @Nullable final ISVNAnnotateHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable final AnnotationConsumer handler) throws VcsException { List<String> parameters = new ArrayList<String>(); CommandUtil.put(parameters, target.getPathOrUrlString(), pegRevision); parameters.add("--revision"); @@ -47,7 +46,7 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { parseOutput(command.getOutput(), handler); } - public void parseOutput(@NotNull String output, @Nullable ISVNAnnotateHandler handler) throws VcsException { + public void parseOutput(@NotNull String output, @Nullable AnnotationConsumer handler) throws VcsException { try { BlameInfo info = CommandUtil.parse(output, BlameInfo.class); @@ -65,12 +64,11 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { } } - private static void invokeHandler(ISVNAnnotateHandler handler, LineEntry entry) throws SVNException { - // line numbers in our api start from 0 - not from 1 like in svn output - // "line" value is not used in handlers - so null is passed - handler - .handleLine(entry.date(), entry.revision(), entry.author(), null, entry.mergedDate(), entry.mergedRevision(), entry.mergedAuthor(), - entry.mergedPath(), entry.lineNumber - 1); + private static void invokeHandler(@NotNull AnnotationConsumer handler, @NotNull LineEntry entry) throws SVNException { + if (entry.commit != null) { + // line numbers in our api start from 0 - not from 1 like in svn output + handler.consume(entry.lineNumber - 1, entry.commit.build(), entry.mergedCommit()); + } } @XmlRootElement(name = "blame") @@ -91,70 +89,15 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { @XmlAttribute(name = "line-number") public int lineNumber; - @XmlElement(name = "commit") - public CommitEntry commit; + public CommitInfo.Builder commit; @XmlElement(name = "merged") public MergedEntry merged; - public long revision() { - return revision(commit); - } - - @Nullable - public String author() { - return author(commit); - } - - @Nullable - public Date date() { - return date(commit); - } - - @Nullable - public String mergedPath() { - return merged != null ? merged.path : null; - } - - public long mergedRevision() { - return merged != null ? revision(merged.commit) : 0; - } - - @Nullable - public String mergedAuthor() { - return merged != null ? author(merged.commit) : null; - } - - @Nullable - public Date mergedDate() { - return merged != null ? date(merged.commit) : null; - } - - private static long revision(@Nullable CommitEntry commit) { - return commit != null ? commit.revision : 0; - } - @Nullable - private static String author(@Nullable CommitEntry commit) { - return commit != null ? commit.author : null; + public CommitInfo mergedCommit() { + return merged != null && merged.commit != null ? merged.commit.build() : null; } - - @Nullable - private static Date date(@Nullable CommitEntry commit) { - return commit != null ? commit.date : null; - } - } - - public static class CommitEntry { - - @XmlAttribute(name = "revision") - public long revision; - - @XmlElement(name = "author") - public String author; - - @XmlElement(name = "date") - public Date date; } public static class MergedEntry { @@ -162,7 +105,6 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { @XmlAttribute(name = "path") public String path; - @XmlElement(name = "commit") - public CommitEntry commit; + public CommitInfo.Builder commit; } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java index c51f4dbcdaa3..a615fd4e3afa 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java @@ -35,11 +35,15 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; -import org.jetbrains.idea.svn.history.HistoryClient; -import org.jetbrains.idea.svn.history.SvnChangeList; -import org.jetbrains.idea.svn.history.SvnFileRevision; -import org.tmatesoft.svn.core.*; -import org.tmatesoft.svn.core.wc.*; +import org.jetbrains.idea.svn.checkin.CommitInfo; +import org.jetbrains.idea.svn.diff.DiffOptions; +import org.jetbrains.idea.svn.history.*; +import org.jetbrains.idea.svn.info.Info; +import org.tmatesoft.svn.core.SVNErrorCode; +import org.tmatesoft.svn.core.SVNErrorMessage; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -86,7 +90,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn public void run() { final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator(); final File ioFile = new File(file.getPath()).getAbsoluteFile(); - SVNInfo info = null; + Info info = null; try { final String contents; @@ -116,7 +120,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn } // ignore mime type=true : IDEA-19562 - final ISVNAnnotateHandler annotateHandler = createAnnotationHandler(progress, result); + final AnnotationConsumer annotateHandler = createAnnotationHandler(progress, result); final boolean calculateMergeinfo = SvnConfiguration.getInstance(myVcs.getProject()).isShowMergeSourcesInAnnotate() && SvnUtil.checkRepositoryVersion15(myVcs, url); @@ -166,7 +170,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn } private void handleSvnException(File ioFile, - SVNInfo info, + Info info, SVNException e, VirtualFile file, VcsFileRevision revision, @@ -221,7 +225,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn private SvnRemoteFileAnnotation annotateNonExisting(Pair<SvnChangeList, FilePath> pair, VcsFileRevision revision, - SVNInfo info, + Info info, Charset charset, final VirtualFile current) throws VcsException, SVNException, IOException { final File wasFile = pair.getSecond().getIOFile(); final File root = getCommonAncestor(wasFile, info.getFile()); @@ -231,7 +235,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn final String relativePath = FileUtil.getRelativePath(root.getPath(), wasFile.getPath(), File.separatorChar); if (relativePath == null) throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString()); - SVNInfo wcRootInfo = myVcs.getInfo(root); + Info wcRootInfo = myVcs.getInfo(root); if (wcRootInfo == null || wcRootInfo.getURL() == null) { throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString()); } @@ -244,9 +248,8 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn final SVNRevision svnRevision = ((SvnRevisionNumber)revision.getRevisionNumber()).getRevision(); byte[] data = SvnUtil.getFileContents(myVcs, SvnTarget.fromURL(wasUrl), svnRevision, svnRevision); final String contents = LoadTextUtil.getTextByBinaryPresentation(data, charset == null ? CharsetToolkit.UTF8_CHARSET : charset).toString(); - final SvnRemoteFileAnnotation result = new SvnRemoteFileAnnotation(myVcs, contents, revision.getRevisionNumber(), pair.getFirst(), - pair.getSecond().getPath(), current); - final ISVNAnnotateHandler annotateHandler = createAnnotationHandler(ProgressManager.getInstance().getProgressIndicator(), result); + final SvnRemoteFileAnnotation result = new SvnRemoteFileAnnotation(myVcs, contents, revision.getRevisionNumber(), current); + final AnnotationConsumer annotateHandler = createAnnotationHandler(ProgressManager.getInstance().getProgressIndicator(), result); final boolean calculateMergeinfo = SvnConfiguration.getInstance(myVcs.getProject()).isShowMergeSourcesInAnnotate() && SvnUtil.checkRepositoryVersion15(myVcs, wasUrl.toString()); @@ -256,45 +259,18 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn return result; } - private ISVNAnnotateHandler createAnnotationHandler(final ProgressIndicator progress, final BaseSvnFileAnnotation result) { - return new ISVNAnnotateHandler() { - public void handleLine(Date date, long revision, String author, String line) { - if (progress != null) { - progress.checkCanceled(); - } - result.appendLineInfo(date, revision, author, null, -1, null); - } - - public void handleLine(final Date date, - final long revision, - final String author, - final String line, - final Date mergedDate, - final long mergedRevision, - final String mergedAuthor, - final String mergedPath, - final int lineNumber) throws SVNException { - if (progress != null) { - progress.checkCanceled(); - } - if (revision == -1) return; - if ((mergedDate != null) && (revision > mergedRevision)) { - // !!! merged date = date of merge, i.e. date -> date of original change etc. - result.setLineInfo(lineNumber, date, revision, author, mergedDate, mergedRevision, mergedAuthor); - } else { - result.setLineInfo(lineNumber, date, revision, author, null, -1, null); - } - } + @NotNull + private static AnnotationConsumer createAnnotationHandler(@Nullable final ProgressIndicator progress, + @NotNull final BaseSvnFileAnnotation result) { + return new AnnotationConsumer() { - public boolean handleRevision(final Date date, final long revision, final String author, final File contents) - throws SVNException { + @Override + public void consume(int lineNumber, @NotNull CommitInfo info, @Nullable CommitInfo mergeInfo) throws SVNException { if (progress != null) { progress.checkCanceled(); } - return false; - } - public void handleEOF() { + result.setLineInfo(lineNumber, info, mergeInfo != null && info.getRevision() > mergeInfo.getRevision() ? mergeInfo : null); } }; } @@ -307,7 +283,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn if (annotationSourceSwitcher != null) { annotationSourceSwitcher.switchTo(AnnotationSource.LOCAL); } - final int size = svnFileAnnotation.getNumLines(); + final int size = svnFileAnnotation.getLineCount(); final VcsUsualLineAnnotationData lineAnnotationData = new VcsUsualLineAnnotationData(size); for (int i = 0; i < size; i++) { @@ -356,17 +332,15 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn for (int i = 0; i < basicAnnotation.getNumLines(); i++) { final VcsRevisionNumber revision = basicAnnotation.getRevision(i); final VcsRevisionNumber mergedData = data == null ? null : data.getRevision(i); - final VcsFileRevision fileRevision = historyAsMap.get(revision); + final SvnFileRevision fileRevision = (SvnFileRevision)historyAsMap.get(revision); if (fileRevision == null) return null; + if (mergedData == null) { - annotation.setLineInfo(i, fileRevision.getRevisionDate(), ((SvnRevisionNumber) revision).getRevision().getNumber(), - fileRevision.getAuthor(), null, -1, null); + annotation.setLineInfo(i, fileRevision.getCommitInfo(), null); } else { - final VcsFileRevision mergedRevision = cachedOtherRevisions.get(mergedData); + final SvnFileRevision mergedRevision = (SvnFileRevision)cachedOtherRevisions.get(mergedData); if (mergedRevision == null) return null; - annotation.setLineInfo(i, fileRevision.getRevisionDate(), ((SvnRevisionNumber) revision).getRevision().getNumber(), - fileRevision.getAuthor(), mergedRevision.getRevisionDate(), - ((SvnRevisionNumber) mergedRevision.getRevisionNumber()).getRevision().getNumber(), mergedRevision.getAuthor()); + annotation.setLineInfo(i, fileRevision.getCommitInfo(), mergedRevision.getCommitInfo()); } } if (vcsAnnotation.getFirstRevision() != null) { @@ -453,8 +427,9 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn private void doLog(final boolean includeMerged, final SVNRevision truncateTo, final int max) throws VcsException { myClient.doLog(SvnTarget.fromFile(myIoFile), myEndRevision, truncateTo == null ? SVNRevision.create(1L) : truncateTo, false, false, includeMerged, max, null, - new ISVNLogEntryHandler() { - public void handleLogEntry(SVNLogEntry logEntry) { + new LogEntryConsumer() { + @Override + public void consume(LogEntry logEntry) { if (SVNRevision.UNDEFINED.getNumber() == logEntry.getRevision()) { return; } @@ -477,7 +452,8 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn return true; } - private static SVNDiffOptions getLogClientOptions(@NotNull SvnVcs vcs) { - return SvnConfiguration.getInstance(vcs.getProject()).isIgnoreSpacesInAnnotate() ? new SVNDiffOptions(true, true, true) : null; + @Nullable + private static DiffOptions getLogClientOptions(@NotNull SvnVcs vcs) { + return SvnConfiguration.getInstance(vcs.getProject()).isIgnoreSpacesInAnnotate() ? new DiffOptions(true, true, true) : null; } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnKitAnnotateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnKitAnnotateClient.java index 191bd9079237..c2423de0b70d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnKitAnnotateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnKitAnnotateClient.java @@ -4,13 +4,17 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.checkin.CommitInfo; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.ISVNAnnotateHandler; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; import org.tmatesoft.svn.core.wc.SVNLogClient; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; +import java.io.File; +import java.util.Date; + /** * @author Konstantin Kolosovsky. */ @@ -22,21 +26,68 @@ public class SvnKitAnnotateClient extends BaseSvnClient implements AnnotateClien @NotNull SVNRevision endRevision, @Nullable SVNRevision pegRevision, boolean includeMergedRevisions, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNAnnotateHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable AnnotationConsumer handler) throws VcsException { try { SVNLogClient client = myVcs.getSvnKitManager().createLogClient(); - client.setDiffOptions(diffOptions); + client.setDiffOptions(toDiffOptions(diffOptions)); if (target.isFile()) { - client.doAnnotate(target.getFile(), pegRevision, startRevision, endRevision, true, includeMergedRevisions, handler, null); + client + .doAnnotate(target.getFile(), pegRevision, startRevision, endRevision, true, includeMergedRevisions, toAnnotateHandler(handler), + null); } else { - client.doAnnotate(target.getURL(), pegRevision, startRevision, endRevision, true, includeMergedRevisions, handler, null); + client + .doAnnotate(target.getURL(), pegRevision, startRevision, endRevision, true, includeMergedRevisions, toAnnotateHandler(handler), + null); } } catch (SVNException e) { throw new VcsException(e); } } + + @Nullable + private static ISVNAnnotateHandler toAnnotateHandler(@Nullable final AnnotationConsumer handler) { + ISVNAnnotateHandler result = null; + + if (handler != null) { + result = new ISVNAnnotateHandler() { + @Override + public void handleLine(Date date, long revision, String author, String line) throws SVNException { + // deprecated - not called + } + + @Override + public void handleLine(Date date, + long revision, + String author, + String line, + Date mergedDate, + long mergedRevision, + String mergedAuthor, + String mergedPath, + int lineNumber) throws SVNException { + if (revision > 0) { + CommitInfo info = new CommitInfo.Builder(revision, date, author).build(); + CommitInfo mergeInfo = mergedDate != null ? new CommitInfo.Builder(mergedRevision, mergedDate, mergedAuthor).build() : null; + + handler.consume(lineNumber, info, mergeInfo); + } + } + + @Override + public boolean handleRevision(Date date, long revision, String author, File contents) throws SVNException { + return false; + } + + @Override + public void handleEOF() throws SVNException { + } + }; + } + + return result; + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnRemoteFileAnnotation.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnRemoteFileAnnotation.java index f00bc7b97aaa..3f0924650c5f 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnRemoteFileAnnotation.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnRemoteFileAnnotation.java @@ -29,15 +29,10 @@ import org.jetbrains.idea.svn.history.SvnChangeList; * Time: 12:10 PM */ public class SvnRemoteFileAnnotation extends BaseSvnFileAnnotation { - private final SvnChangeList mySvnChangeList; - private final String myPathToSelect; private final VirtualFile myCurrentFile; - public SvnRemoteFileAnnotation(SvnVcs vcs, String contents, VcsRevisionNumber baseRevision, SvnChangeList svnChangeList, - final String pathToSelect, final VirtualFile currentFile) { + public SvnRemoteFileAnnotation(SvnVcs vcs, String contents, VcsRevisionNumber baseRevision, final VirtualFile currentFile) { super(vcs, contents, baseRevision); - mySvnChangeList = svnChangeList; - myPathToSelect = pathToSelect; myCurrentFile = currentFile; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseNodeDescription.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseNodeDescription.java new file mode 100644 index 000000000000..03e2e07a339c --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseNodeDescription.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.api; + +import org.jetbrains.annotations.NotNull; + +/** + * @author Konstantin Kolosovsky. + */ +public abstract class BaseNodeDescription { + + @NotNull protected final NodeKind myKind; + + protected BaseNodeDescription(@NotNull NodeKind kind) { + myKind = kind; + } + + public boolean isFile() { + return myKind.isFile(); + } + + public boolean isDirectory() { + return myKind.isDirectory(); + } + + public boolean isNone() { + return myKind.isNone(); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseSvnClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseSvnClient.java index bb8c613c8135..0d58355543ba 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseSvnClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseSvnClient.java @@ -8,10 +8,11 @@ import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.auth.IdeaSvnkitBasedAuthenticationCallback; import org.jetbrains.idea.svn.commandLine.*; +import org.jetbrains.idea.svn.diff.DiffOptions; +import org.tmatesoft.svn.core.SVNCancelException; +import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; +import org.tmatesoft.svn.core.wc.*; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -109,10 +110,10 @@ public abstract class BaseSvnClient implements SvnClient { return runtime.runWithAuthenticationAttempt(command); } - protected static void callHandler(@Nullable ISVNEventHandler handler, @NotNull SVNEvent event) throws VcsException { + protected static void callHandler(@Nullable ProgressTracker handler, @NotNull ProgressEvent event) throws VcsException { if (handler != null) { try { - handler.handleEvent(event, 0); + handler.consume(event); } catch (SVNException e) { throw new SvnBindException(e); @@ -121,7 +122,44 @@ public abstract class BaseSvnClient implements SvnClient { } @NotNull - protected static SVNEvent createEvent(@NotNull File path, @Nullable SVNEventAction action) { - return new SVNEvent(path, null, null, 0, null, null, null, null, action, null, null, null, null, null, null); + protected static ProgressEvent createEvent(@NotNull File path, @Nullable EventAction action) { + return new ProgressEvent(path, 0, null, null, action, null, null); + } + + @Nullable + protected static ISVNEventHandler toEventHandler(@Nullable final ProgressTracker handler) { + ISVNEventHandler result = null; + + if (handler != null) { + result = new ISVNEventHandler() { + @Override + public void handleEvent(SVNEvent event, double progress) throws SVNException { + handler.consume(ProgressEvent.create(event)); + } + + @Override + public void checkCancelled() throws SVNCancelException { + handler.checkCancelled(); + } + }; + } + + return result; + } + + @Nullable + protected static SVNDiffOptions toDiffOptions(@Nullable DiffOptions options) { + return options != null ? new SVNDiffOptions(options.isIgnoreAllWhitespace(), options.isIgnoreAmountOfWhitespace(), + options.isIgnoreEOLStyle()) : null; + } + + @Nullable + protected static SVNDepth toDepth(@Nullable Depth depth) { + return depth != null ? SVNDepth.fromString(depth.getName()) : null; + } + + @NotNull + protected static SVNRevision notNullize(@Nullable SVNRevision revision) { + return revision != null ? revision : SVNRevision.UNDEFINED; } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ClientFactory.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ClientFactory.java index 99e00a373d7d..ba3e56de8e63 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ClientFactory.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ClientFactory.java @@ -27,7 +27,6 @@ import org.jetbrains.idea.svn.revert.RevertClient; import org.jetbrains.idea.svn.update.RelocateClient; import org.jetbrains.idea.svn.update.UpdateClient; import org.jetbrains.idea.svn.upgrade.UpgradeClient; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.ISVNStatusFileProvider; /** @@ -102,7 +101,7 @@ public abstract class ClientFactory { } @NotNull - public StatusClient createStatusClient(@Nullable ISVNStatusFileProvider provider, @NotNull ISVNEventHandler handler) { + public StatusClient createStatusClient(@Nullable ISVNStatusFileProvider provider, @NotNull ProgressTracker handler) { return createStatusClient(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/Depth.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/Depth.java new file mode 100644 index 000000000000..9ccc96e81f67 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/Depth.java @@ -0,0 +1,93 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.api; + +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.tmatesoft.svn.core.SVNDepth; + +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +public enum Depth { + + UNKNOWN("unknown"), + INFINITY("infinity"), + IMMEDIATES("immediates"), + FILES("files"), + EMPTY("empty"); + + @NotNull private static final Map<String, Depth> ourAllDepths = ContainerUtil.newHashMap(); + + static { + for (Depth action : Depth.values()) { + register(action); + } + } + + @NotNull private final String myName; + + Depth(@NotNull String name) { + myName = name; + } + + @NotNull + public String getName() { + return myName; + } + + @Override + public String toString() { + return myName; + } + + private static void register(@NotNull Depth depth) { + ourAllDepths.put(depth.myName, depth); + } + + @NotNull + public static Depth from(@NotNull String depthName) { + Depth result = ourAllDepths.get(depthName); + + if (result == null) { + throw new IllegalArgumentException("Unknown depth " + depthName); + } + + return result; + } + + @NotNull + public static Depth from(@Nullable SVNDepth depth) { + return depth != null ? from(depth.getName()) : UNKNOWN; + } + + @NotNull + public static Depth allOrFiles(boolean recursive) { + return recursive ? INFINITY : FILES; + } + + @NotNull + public static Depth allOrEmpty(boolean recursive) { + return recursive ? INFINITY : EMPTY; + } + + public static boolean isRecursive(@Nullable Depth depth) { + return depth == null || depth == INFINITY || depth == UNKNOWN; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/EventAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/EventAction.java new file mode 100644 index 000000000000..3a1d3fc80ef1 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/EventAction.java @@ -0,0 +1,91 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.api; + +import com.intellij.util.ObjectUtils; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.tmatesoft.svn.core.wc.SVNEventAction; + +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +public enum EventAction { + + // currently used to represent some not used event action from SVNKit + UNKNOWN("unknown"), + + ADD("add"), + DELETE("delete"), + RESTORE("restore"), + REVERT("revert"), + FAILED_REVERT("failed_revert"), + SKIP("skip"), + + UPDATE_DELETE("update_delete"), + UPDATE_ADD("update_add"), + UPDATE_UPDATE("update_update"), + UPDATE_NONE("update_none"), + UPDATE_COMPLETED("update_completed"), + UPDATE_EXTERNAL("update_external"), + UPDATE_SKIP_OBSTRUCTION("update_skip_obstruction"), + UPDATE_STARTED("update_started"), + + COMMIT_MODIFIED("commit_modified"), + COMMIT_ADDED("commit_added"), + COMMIT_DELETED("commit_deleted"), + COMMIT_REPLACED("commit_replaced"), + COMMIT_DELTA_SENT("commit_delta_sent"), + FAILED_OUT_OF_DATE("failed_out_of_date"), + + LOCKED("locked"), + UNLOCKED("unlocked"), + LOCK_FAILED("lock_failed"), + UNLOCK_FAILED("unlock_failed"), + + UPGRADED_PATH("upgraded_path"), + + TREE_CONFLICT("tree_conflict"); + + @NotNull private static final Map<String, EventAction> ourAllActions = ContainerUtil.newHashMap(); + + static { + for (EventAction action : EventAction.values()) { + register(action); + } + } + + private String myKey; + + EventAction(String key) { + myKey = key; + } + + public String toString() { + return myKey; + } + + private static void register(@NotNull EventAction action) { + ourAllActions.put(action.myKey, action); + } + + @NotNull + public static EventAction from(@NotNull SVNEventAction action) { + return ObjectUtils.notNull(ourAllActions.get(action.toString()), UNKNOWN); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/FileStatusResultParser.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/FileStatusResultParser.java index fc202c265a6a..7bc0b32a2e04 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/FileStatusResultParser.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/FileStatusResultParser.java @@ -6,8 +6,6 @@ import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -17,20 +15,18 @@ import java.util.regex.Pattern; */ public class FileStatusResultParser { - private static final double DEFAULT_PROGRESS = 0.0; - @NotNull private Pattern myLinePattern; @Nullable - private ISVNEventHandler handler; + private ProgressTracker handler; @NotNull - private Convertor<Matcher, SVNEvent> myConvertor; + private Convertor<Matcher, ProgressEvent> myConvertor; public FileStatusResultParser(@NotNull Pattern linePattern, - @Nullable ISVNEventHandler handler, - @NotNull Convertor<Matcher, SVNEvent> convertor) { + @Nullable ProgressTracker handler, + @NotNull Convertor<Matcher, ProgressEvent> convertor) { myLinePattern = linePattern; this.handler = handler; myConvertor = convertor; @@ -59,7 +55,7 @@ public class FileStatusResultParser { public void process(@NotNull Matcher matcher) throws VcsException { if (handler != null) { try { - handler.handleEvent(myConvertor.convert(matcher), DEFAULT_PROGRESS); + handler.consume(myConvertor.convert(matcher)); } catch (SVNException e) { throw new VcsException(e); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/InfoCommandRepositoryProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/InfoCommandRepositoryProvider.java index c2be897dc3a1..bfcf37de3a0d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/InfoCommandRepositoryProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/InfoCommandRepositoryProvider.java @@ -18,8 +18,7 @@ package org.jetbrains.idea.svn.api; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.wc.SVNInfo; -import org.tmatesoft.svn.core.wc.SVNRevision; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.wc2.SvnTarget; /** @@ -42,7 +41,7 @@ public class InfoCommandRepositoryProvider extends BaseRepositoryProvider { result = new Repository(myTarget.getURL()); } else { - SVNInfo info = myVcs.getInfo(myTarget.getFile()); + Info info = myVcs.getInfo(myTarget.getFile()); result = info != null ? new Repository(info.getRepositoryRootURL()) : null; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/NodeKind.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/NodeKind.java new file mode 100644 index 000000000000..e4820b844c23 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/NodeKind.java @@ -0,0 +1,94 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.api; + +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.tmatesoft.svn.core.SVNNodeKind; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +@XmlEnum +public enum NodeKind { + + // see comments in LogEntryPath.Builder for cases when "" kind could appear + @XmlEnumValue("") UNKNOWN("unknown"), + @XmlEnumValue("file") FILE("file"), + @XmlEnumValue("dir") DIR("dir"), + // used in ConflictVersion when node is missing + @XmlEnumValue("none") NONE("none"); + + @NotNull private static final Map<String, NodeKind> ourAllNodeKinds = ContainerUtil.newHashMap(); + + static { + for (NodeKind kind : NodeKind.values()) { + register(kind); + } + } + + @NotNull private final String myKey; + + NodeKind(@NotNull String key) { + myKey = key; + } + + public boolean isFile() { + return FILE.equals(this); + } + + public boolean isDirectory() { + return DIR.equals(this); + } + + public boolean isNone() { + return NONE.equals(this); + } + + @Override + public String toString() { + return myKey; + } + + private static void register(@NotNull NodeKind kind) { + ourAllNodeKinds.put(kind.myKey, kind); + } + + @NotNull + public static NodeKind from(@NotNull String nodeKindName) { + NodeKind result = ourAllNodeKinds.get(nodeKindName); + + if (result == null) { + throw new IllegalArgumentException("Unknown node kind " + nodeKindName); + } + + return result; + } + + @NotNull + public static NodeKind from(@NotNull SVNNodeKind nodeKind) { + return from(nodeKind.toString()); + } + + @NotNull + public static NodeKind from(boolean isDirectory) { + return isDirectory ? DIR : FILE; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ProgressEvent.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ProgressEvent.java new file mode 100644 index 000000000000..12bd2e1a91f4 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ProgressEvent.java @@ -0,0 +1,118 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.api; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.status.StatusType; +import org.tmatesoft.svn.core.SVNErrorMessage; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.wc.SVNEvent; + +import java.io.File; + +/** + * @author Konstantin Kolosovsky. + */ +public class ProgressEvent { + + private final File myFile; + + private final long myRevision; + private final SVNURL myURL; + + @NotNull private final StatusType myContentsStatus; + @NotNull private final StatusType myPropertiesStatus; + private final SVNErrorMessage myErrorMessage; + private final EventAction myAction; + + @Nullable + public static ProgressEvent create(@Nullable SVNEvent event) { + ProgressEvent result = null; + + if (event != null) { + if (event.getFile() == null && event.getURL() == null) { + result = new ProgressEvent(event.getErrorMessage()); + } + else { + result = + new ProgressEvent(event.getFile(), event.getRevision(), StatusType.from(event.getContentsStatus()), StatusType.from(event.getPropertiesStatus()), + EventAction.from(event.getAction()), event.getErrorMessage(), event.getURL()); + } + } + + return result; + } + + public ProgressEvent(SVNErrorMessage errorMessage) { + this(null, 0, null, null, EventAction.SKIP, errorMessage, null); + } + + public ProgressEvent(File file, + long revision, + @Nullable StatusType contentStatus, + @Nullable StatusType propertiesStatus, + EventAction action, + SVNErrorMessage error, + SVNURL url) { + myFile = file != null ? file.getAbsoluteFile() : null; + myRevision = revision; + myContentsStatus = contentStatus == null ? StatusType.INAPPLICABLE : contentStatus; + myPropertiesStatus = propertiesStatus == null ? StatusType.INAPPLICABLE : propertiesStatus; + myAction = action; + myErrorMessage = error; + myURL = url; + } + + public File getFile() { + return myFile; + } + + public EventAction getAction() { + return myAction; + } + + @NotNull + public StatusType getContentsStatus() { + return myContentsStatus; + } + + public SVNErrorMessage getErrorMessage() { + return myErrorMessage; + } + + @NotNull + public StatusType getPropertiesStatus() { + return myPropertiesStatus; + } + + public long getRevision() { + return myRevision; + } + + public SVNURL getURL() { + return myURL; + } + + @Nullable + public String getPath() { + return myFile != null ? myFile.getName() : myURL != null ? myURL.toString() : null; + } + + public String toString() { + return getAction() + " " + getFile() + " " + getURL(); + } +}
\ No newline at end of file diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ProgressTracker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ProgressTracker.java new file mode 100644 index 000000000000..303b66a00c62 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ProgressTracker.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.api; + +import com.intellij.util.ThrowableConsumer; +import org.tmatesoft.svn.core.SVNCancelException; +import org.tmatesoft.svn.core.SVNException; + +/** + * @author Konstantin Kolosovsky. + */ +public interface ProgressTracker extends ThrowableConsumer<ProgressEvent, SVNException> { + + void checkCancelled() throws SVNCancelException; +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/SvnKitClientFactory.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/SvnKitClientFactory.java index 1b834c16585b..f46f5f06ebdb 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/SvnKitClientFactory.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/SvnKitClientFactory.java @@ -29,7 +29,6 @@ import org.jetbrains.idea.svn.update.SvnKitRelocateClient; import org.jetbrains.idea.svn.update.SvnKitUpdateClient; import org.jetbrains.idea.svn.update.UpdateClient; import org.jetbrains.idea.svn.upgrade.SvnKitUpgradeClient; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.ISVNStatusFileProvider; /** @@ -72,7 +71,7 @@ public class SvnKitClientFactory extends ClientFactory { @NotNull @Override - public StatusClient createStatusClient(@Nullable ISVNStatusFileProvider provider, @NotNull ISVNEventHandler handler) { + public StatusClient createStatusClient(@Nullable ISVNStatusFileProvider provider, @NotNull ProgressTracker handler) { return prepare(new SvnKitStatusClient(provider, handler)); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java index 698ed90418c7..10f4574c7f39 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java @@ -20,6 +20,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.browse.DirectoryEntry; +import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer; import org.jetbrains.idea.svn.integrate.SvnBranchItem; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.SVNLogClient; @@ -42,13 +45,14 @@ public class BranchesLoader { SVNURL branchesUrl = SVNURL.parseURIEncoded(url); List<SvnBranchItem> result = new LinkedList<SvnBranchItem>(); SvnTarget target = SvnTarget.fromURL(branchesUrl); - ISVNDirEntryHandler handler = createHandler(branchesUrl, result); if (!passive) { // TODO: Implement ability to specify interactive/non-interactive auth mode for clients - vcs.getFactory(target).createBrowseClient().list(target, SVNRevision.HEAD, SVNDepth.IMMEDIATES, handler); + DirectoryEntryConsumer handler = createConsumer(branchesUrl, result); + vcs.getFactory(target).createBrowseClient().list(target, SVNRevision.HEAD, Depth.IMMEDIATES, handler); } else { + ISVNDirEntryHandler handler = createHandler(branchesUrl, result); SVNLogClient client = vcs.getSvnKitManager().createLogClient(configuration.getPassiveAuthenticationManager(project)); client .doList(target.getURL(), target.getPegRevision(), SVNRevision.HEAD, false, SVNDepth.IMMEDIATES, SVNDirEntry.DIRENT_ALL, handler); @@ -69,4 +73,18 @@ public class BranchesLoader { } }; } + + @NotNull + private static DirectoryEntryConsumer createConsumer(@NotNull final SVNURL branchesUrl, @NotNull final List<SvnBranchItem> result) { + return new DirectoryEntryConsumer() { + + @Override + public void consume(final DirectoryEntry entry) throws SVNException { + // TODO: Remove equality check with branchesUrl when SVNLogClient will not be used directly, but rather through BrowseClient. + if (!branchesUrl.equals(entry.getUrl()) && entry.getDate() != null) { + result.add(new SvnBranchItem(entry.getUrl().toDecodedString(), entry.getDate(), entry.getRevision())); + } + } + }; + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/DefaultConfigLoader.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/DefaultConfigLoader.java index 315954e7b520..d52798e6bfc3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/DefaultConfigLoader.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/DefaultConfigLoader.java @@ -24,10 +24,13 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.browse.DirectoryEntry; +import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer; +import org.jetbrains.idea.svn.info.Info; import org.jetbrains.idea.svn.integrate.SvnBranchItem; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -52,7 +55,7 @@ public class DefaultConfigLoader { final SvnVcs vcs = SvnVcs.getInstance(project); File rootFile = new File(vcsRoot.getPath()); - final SVNInfo info = vcs.getInfo(rootFile); + final Info info = vcs.getInfo(rootFile); if (info == null || info.getURL() == null) { LOG.info("Directory is not a working copy: " + vcsRoot.getPresentableUrl()); return null; @@ -67,7 +70,7 @@ public class DefaultConfigLoader { SVNURL rootPath = baseUrl.removePathTail(); SvnTarget target = SvnTarget.fromURL(rootPath); - vcs.getFactory(target).createBrowseClient().list(target, SVNRevision.HEAD, SVNDepth.IMMEDIATES, createHandler(result, rootPath)); + vcs.getFactory(target).createBrowseClient().list(target, SVNRevision.HEAD, Depth.IMMEDIATES, createHandler(result, rootPath)); break; } if (SVNPathUtil.removeTail(baseUrl.getPath()).length() == 0) { @@ -88,13 +91,15 @@ public class DefaultConfigLoader { } @NotNull - private static ISVNDirEntryHandler createHandler(final SvnBranchConfigurationNew result, final SVNURL rootPath) { - return new ISVNDirEntryHandler() { - public void handleDirEntry(final SVNDirEntry dirEntry) throws SVNException { - if (SVNNodeKind.DIR.equals(dirEntry.getKind())) { - SVNURL childUrl = rootPath.appendPath(dirEntry.getName(), false); + private static DirectoryEntryConsumer createHandler(final SvnBranchConfigurationNew result, final SVNURL rootPath) { + return new DirectoryEntryConsumer() { - if (StringUtil.endsWithIgnoreCase(dirEntry.getName(), DEFAULT_TRUNK_NAME)) { + @Override + public void consume(final DirectoryEntry entry) throws SVNException { + if (entry.isDirectory()) { + SVNURL childUrl = rootPath.appendPath(entry.getName(), false); + + if (StringUtil.endsWithIgnoreCase(entry.getName(), DEFAULT_TRUNK_NAME)) { result.setTrunkUrl(childUrl.toString()); } else { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SvnBranchConfigurationNew.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SvnBranchConfigurationNew.java index b3554ce89c74..4102210a657a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SvnBranchConfigurationNew.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SvnBranchConfigurationNew.java @@ -23,12 +23,12 @@ import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.info.Info; import org.jetbrains.idea.svn.integrate.SvnBranchItem; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import org.tmatesoft.svn.core.internal.util.SVNURLUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import java.io.File; import java.util.*; @@ -221,7 +221,7 @@ public class SvnBranchConfigurationNew { private BranchRootSearcher(final SvnVcs vcs, final VirtualFile root) throws SVNException { myRoot = root; myBranchesUnder = new HashMap<String, String>(); - final SVNInfo info = vcs.getInfo(myRoot.getPath()); + final Info info = vcs.getInfo(myRoot.getPath()); myRootUrl = info != null ? info.getURL() : null; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/BrowseClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/BrowseClient.java index 92e64bb5230e..f5c46cb32842 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/BrowseClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/BrowseClient.java @@ -18,9 +18,8 @@ package org.jetbrains.idea.svn.browse; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.ISVNDirEntryHandler; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -29,7 +28,7 @@ import org.tmatesoft.svn.core.wc2.SvnTarget; */ public interface BrowseClient extends SvnClient { - void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable SVNDepth depth, @Nullable ISVNDirEntryHandler handler) + void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable Depth depth, @Nullable DirectoryEntryConsumer handler) throws VcsException; long createDirectory(@NotNull SvnTarget target, @NotNull String message, boolean makeParents) throws VcsException; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/CmdBrowseClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/CmdBrowseClient.java index 20d60a9e50bf..bceb516caef3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/CmdBrowseClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/CmdBrowseClient.java @@ -21,12 +21,17 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.NodeKind; import org.jetbrains.idea.svn.checkin.CmdCheckinClient; +import org.jetbrains.idea.svn.checkin.CommitInfo; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.*; +import org.jetbrains.idea.svn.lock.Lock; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -35,7 +40,6 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; -import java.util.Date; import java.util.List; /** @@ -46,8 +50,8 @@ public class CmdBrowseClient extends BaseSvnClient implements BrowseClient { @Override public void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, - @Nullable ISVNDirEntryHandler handler) throws VcsException { + @Nullable Depth depth, + @Nullable DirectoryEntryConsumer handler) throws VcsException { assertUrl(target); List<String> parameters = new ArrayList<String>(); @@ -85,15 +89,15 @@ public class CmdBrowseClient extends BaseSvnClient implements BrowseClient { return listener.getCommittedRevision(); } - private static void parseOutput(@NotNull SVNURL url, @NotNull CommandExecutor command, @Nullable ISVNDirEntryHandler handler) - throws VcsException, SVNException { + private static void parseOutput(@NotNull SVNURL url, @NotNull CommandExecutor command, @Nullable DirectoryEntryConsumer handler) + throws VcsException, SVNException { try { TargetLists lists = CommandUtil.parse(command.getOutput(), TargetLists.class); if (handler != null && lists != null) { for (TargetList list : lists.lists) { for (Entry entry : list.entries) { - handler.handleDirEntry(entry.toDirEntry(url)); + handler.consume(entry.toDirectoryEntry(url)); } } } @@ -122,8 +126,8 @@ public class CmdBrowseClient extends BaseSvnClient implements BrowseClient { public static class Entry { - @XmlAttribute(name = "kind") - public String kind; + @XmlAttribute(name = "kind", required = true) + public NodeKind kind; @XmlElement(name = "name") public String name; @@ -131,68 +135,15 @@ public class CmdBrowseClient extends BaseSvnClient implements BrowseClient { @XmlElement(name = "size") public long size; - @XmlElement(name = "commit") - public Commit commit; + public CommitInfo.Builder commit; - @XmlElement(name = "lock") - public Lock lock; + public Lock.Builder lock; - public long revision() { - return commit != null ? commit.revision : 0; - } - - public String author() { - return commit != null ? commit.author : ""; - } - - public Date date() { - return commit != null ? commit.date : null; - } - - public SVNDirEntry toDirEntry(@NotNull SVNURL url) throws SVNException { + @NotNull + public DirectoryEntry toDirectoryEntry(@NotNull SVNURL url) throws SVNException { // TODO: repository is not used for now - SVNDirEntry entry = - new SVNDirEntry(url.appendPath(name, false), null, PathUtil.getFileName(name), SVNNodeKind.parseKind(kind), size, false, revision(), - date(), author()); - - entry.setRelativePath(name); - entry.setLock(lock != null ? lock.toLock(entry.getRelativePath()) : null); - - return entry; - } - } - - public static class Commit { - - @XmlAttribute(name = "revision") - public long revision; - - @XmlElement(name = "author") - public String author; - - @XmlElement(name = "date") - public Date date; - } - - public static class Lock { - - @XmlElement(name = "token") - public String token; - - @XmlElement(name = "owner") - public String owner; - - @XmlElement(name = "comment") - public String comment; - - @XmlElement(name = "created") - public Date created; - - @XmlElement(name = "expires") - public Date expires; - - public SVNLock toLock(@NotNull String path) { - return new SVNLock(path, token, owner, comment, created, expires); + return new DirectoryEntry(url.appendPath(name, false), null, PathUtil.getFileName(name), kind, + commit != null ? commit.build() : null, name); } } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntry.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntry.java new file mode 100644 index 000000000000..e29e6e468bd1 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntry.java @@ -0,0 +1,100 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.browse; + +import com.intellij.util.ObjectUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.BaseNodeDescription; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.checkin.CommitInfo; +import org.tmatesoft.svn.core.SVNDirEntry; +import org.tmatesoft.svn.core.SVNURL; + +import java.util.Date; + +/** + * @author Konstantin Kolosovsky. + */ +public class DirectoryEntry extends BaseNodeDescription implements Comparable<DirectoryEntry> { + + private final String myName; + @NotNull private final CommitInfo myCommitInfo; + private final String myPath; + private final SVNURL myUrl; + private final SVNURL myRepositoryRoot; + + @NotNull + public static DirectoryEntry create(@NotNull SVNDirEntry entry) { + return new DirectoryEntry(entry.getURL(), entry.getRepositoryRoot(), entry.getName(), NodeKind.from(entry.getKind()), + new CommitInfo.Builder(entry.getRevision(), entry.getDate(), entry.getAuthor()).build(), + entry.getRelativePath()); + } + + public DirectoryEntry(SVNURL url, + SVNURL repositoryRoot, + String name, + @NotNull NodeKind kind, + @Nullable CommitInfo commitInfo, + String path) { + super(kind); + myUrl = url; + myRepositoryRoot = repositoryRoot; + myName = name; + myCommitInfo = ObjectUtils.notNull(commitInfo, CommitInfo.EMPTY); + myPath = path; + } + + public SVNURL getUrl() { + return myUrl; + } + + public SVNURL getRepositoryRoot() { + return myRepositoryRoot; + } + + public String getName() { + return myName; + } + + @NotNull + public NodeKind getKind() { + return myKind; + } + + public Date getDate() { + return myCommitInfo.getDate(); + } + + public long getRevision() { + return myCommitInfo.getRevision(); + } + + public String getAuthor() { + return myCommitInfo.getAuthor(); + } + + public String getRelativePath() { + return myPath == null ? myName : myPath; + } + + @Override + public int compareTo(@NotNull DirectoryEntry o) { + int result = getKind().compareTo(o.getKind()); + + return result != 0 ? result : myUrl.toString().compareTo(o.getUrl().toString()); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntryConsumer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntryConsumer.java new file mode 100644 index 000000000000..f404413a6996 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntryConsumer.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.browse; + +import com.intellij.util.ThrowableConsumer; +import org.tmatesoft.svn.core.SVNException; + +/** + * @author Konstantin Kolosovsky. + */ +public interface DirectoryEntryConsumer extends ThrowableConsumer<DirectoryEntry, SVNException> { +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/SvnKitBrowseClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/SvnKitBrowseClient.java index 42ac680a6ab8..cdbb1ff1e67b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/SvnKitBrowseClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/SvnKitBrowseClient.java @@ -20,6 +20,7 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.SVNLogClient; @@ -33,8 +34,8 @@ public class SvnKitBrowseClient extends BaseSvnClient implements BrowseClient { @Override public void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, - @Nullable ISVNDirEntryHandler handler) throws VcsException { + @Nullable Depth depth, + @Nullable DirectoryEntryConsumer handler) throws VcsException { assertUrl(target); SVNLogClient client = myVcs.getSvnKitManager().createLogClient(); @@ -42,10 +43,10 @@ public class SvnKitBrowseClient extends BaseSvnClient implements BrowseClient { try { if (target.isFile()) { - client.doList(target.getFile(), target.getPegRevision(), revision, true, depth, SVNDirEntry.DIRENT_ALL, wrappedHandler); + client.doList(target.getFile(), target.getPegRevision(), notNullize(revision), true, toDepth(depth), SVNDirEntry.DIRENT_ALL, wrappedHandler); } else { - client.doList(target.getURL(), target.getPegRevision(), revision, true, depth, SVNDirEntry.DIRENT_ALL, wrappedHandler); + client.doList(target.getURL(), target.getPegRevision(), notNullize(revision), true, toDepth(depth), SVNDirEntry.DIRENT_ALL, wrappedHandler); } } catch (SVNException e) { @@ -69,26 +70,26 @@ public class SvnKitBrowseClient extends BaseSvnClient implements BrowseClient { } @Nullable - private static ISVNDirEntryHandler wrapHandler(@Nullable ISVNDirEntryHandler handler) { + private static ISVNDirEntryHandler wrapHandler(@Nullable DirectoryEntryConsumer handler) { return handler == null ? null : new SkipEmptyNameDirectoriesHandler(handler); } public static class SkipEmptyNameDirectoriesHandler implements ISVNDirEntryHandler { - @NotNull private final ISVNDirEntryHandler handler; + @NotNull private final DirectoryEntryConsumer handler; - public SkipEmptyNameDirectoriesHandler(@NotNull ISVNDirEntryHandler handler) { + public SkipEmptyNameDirectoriesHandler(@NotNull DirectoryEntryConsumer handler) { this.handler = handler; } @Override public void handleDirEntry(SVNDirEntry dirEntry) throws SVNException { if (!isEmptyNameDirectory(dirEntry)) { - handler.handleDirEntry(dirEntry); + handler.consume(DirectoryEntry.create(dirEntry)); } } - private static boolean isEmptyNameDirectory(SVNDirEntry dirEntry) { + private static boolean isEmptyNameDirectory(@NotNull SVNDirEntry dirEntry) { return SVNNodeKind.DIR.equals(dirEntry.getKind()) && StringUtil.isEmpty(dirEntry.getName()); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/change/CmdChangeListClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/change/CmdChangeListClient.java index 2791ce87af12..dc9feddf61d7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/change/CmdChangeListClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/change/CmdChangeListClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -25,7 +25,7 @@ public class CmdChangeListClient extends BaseSvnClient implements ChangeListClie parameters.add(changeList); CommandUtil.put(parameters, path); - CommandUtil.put(parameters, SVNDepth.EMPTY); + CommandUtil.put(parameters, Depth.EMPTY); if (changeListsToOperate != null) { CommandUtil.putChangeLists(parameters, Arrays.asList(changeListsToOperate)); } @@ -41,7 +41,7 @@ public class CmdChangeListClient extends BaseSvnClient implements ChangeListClie parameters.add("--remove"); CommandUtil.put(parameters, path); - CommandUtil.put(parameters, SVNDepth.EMPTY); + CommandUtil.put(parameters, Depth.EMPTY); // for now parsing of the output is not required as command is executed only for one file // and will be either successful or exception will be thrown diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CheckinClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CheckinClient.java index 628c22219e11..cc8e2ef0e352 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CheckinClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CheckinClient.java @@ -18,7 +18,6 @@ package org.jetbrains.idea.svn.checkin; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNCommitInfo; import java.io.File; import java.util.Collection; @@ -29,5 +28,5 @@ import java.util.Collection; public interface CheckinClient extends SvnClient { @NotNull - SVNCommitInfo[] commit(@NotNull Collection<File> paths, @NotNull String comment) throws VcsException; + CommitInfo[] commit(@NotNull Collection<File> paths, @NotNull String comment) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdCheckinClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdCheckinClient.java index ce95c6420204..ced5e62b0f33 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdCheckinClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdCheckinClient.java @@ -29,13 +29,14 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.commandLine.*; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.CommandUtil; +import org.jetbrains.idea.svn.commandLine.LineCommandAdapter; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.commandLine.SvnCommandName; +import org.jetbrains.idea.svn.status.Status; import org.jetbrains.idea.svn.status.StatusClient; -import org.tmatesoft.svn.core.SVNCommitInfo; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -57,26 +58,21 @@ public class CmdCheckinClient extends BaseSvnClient implements CheckinClient { @NotNull @Override - public SVNCommitInfo[] commit(@NotNull Collection<File> paths, @NotNull String message) throws VcsException { + public CommitInfo[] commit(@NotNull Collection<File> paths, @NotNull String message) throws VcsException { // if directory renames were used, IDEA reports all files under them as moved, but for svn we can not pass some of them // to commit command - since not all paths are registered as changes -> so we need to filter these cases, but only if // there at least some child-parent relationships in passed paths - try { - paths = filterCommittables(paths); - } - catch (SVNException e) { - throw new SvnBindException(e); - } + paths = filterCommittables(paths); return commit(ArrayUtil.toObjectArray(paths, File.class), message); } @NotNull - public SVNCommitInfo[] commit(@NotNull File[] paths, @NotNull String message) throws VcsException { - if (paths.length == 0) return new SVNCommitInfo[]{SVNCommitInfo.NULL}; + public CommitInfo[] commit(@NotNull File[] paths, @NotNull String message) throws VcsException { + if (paths.length == 0) return new CommitInfo[]{CommitInfo.EMPTY}; final List<String> parameters = new ArrayList<String>(); - CommandUtil.put(parameters, SVNDepth.EMPTY); + CommandUtil.put(parameters, Depth.EMPTY); CommandUtil.put(parameters, false, "--no-unlock"); CommandUtil.put(parameters, false, "--keep-changelists"); CommandUtil.putChangeLists(parameters, null); @@ -95,7 +91,7 @@ public class CmdCheckinClient extends BaseSvnClient implements CheckinClient { long revision = validateRevisionNumber(listener.getCommittedRevision()); - return new SVNCommitInfo[]{new SVNCommitInfo(revision, null, null, null)}; + return new CommitInfo[]{new CommitInfo.Builder().setRevision(revision).build()}; } private static long validateRevisionNumber(long revision) throws VcsException { @@ -106,7 +102,7 @@ public class CmdCheckinClient extends BaseSvnClient implements CheckinClient { return revision; } - private Collection<File> filterCommittables(@NotNull Collection<File> committables) throws SVNException { + private Collection<File> filterCommittables(@NotNull Collection<File> committables) throws SvnBindException { final Set<String> childrenOfSomebody = ContainerUtil.newHashSet(); new AbstractFilterChildren<File>() { @Override @@ -135,13 +131,13 @@ public class CmdCheckinClient extends BaseSvnClient implements CheckinClient { } else { try { - final SVNStatus status = statusClient.doStatus(file, false); - if (status != null && !SVNStatusType.STATUS_NONE.equals(status.getContentsStatus()) && - !SVNStatusType.STATUS_UNVERSIONED.equals(status.getContentsStatus())) { + final Status status = statusClient.doStatus(file, false); + if (status != null && !StatusType.STATUS_NONE.equals(status.getContentsStatus()) && + !StatusType.STATUS_UNVERSIONED.equals(status.getContentsStatus())) { result.add(file); } } - catch (SVNException e) { + catch (SvnBindException e) { // not versioned LOG.info(e); throw e; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdImportClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdImportClient.java index 74eeadbb2fa1..a06c2800714a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdImportClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdImportClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.ISVNCommitHandler; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -23,7 +23,7 @@ public class CmdImportClient extends BaseSvnClient implements ImportClient { @Override public long doImport(@NotNull File path, @NotNull SVNURL url, - @Nullable SVNDepth depth, + @Nullable Depth depth, @NotNull String message, boolean noIgnore, @Nullable CommitEventHandler handler, diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitEventHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitEventHandler.java index 87be3fae7dd5..54a92197d2c7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitEventHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitEventHandler.java @@ -15,7 +15,7 @@ */ package org.jetbrains.idea.svn.checkin; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; +import org.jetbrains.idea.svn.api.ProgressTracker; import java.io.File; @@ -26,7 +26,7 @@ import java.io.File; * Date: 2/26/13 * Time: 10:12 AM */ -public interface CommitEventHandler extends ISVNEventHandler { +public interface CommitEventHandler extends ProgressTracker { void commitEvent(final CommitEventType type, final File target); void committedRevision(final long revNum); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitInfo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitInfo.java new file mode 100644 index 000000000000..a09d3c0295db --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitInfo.java @@ -0,0 +1,127 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.checkin; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.tmatesoft.svn.core.SVNErrorMessage; + +import javax.xml.bind.annotation.*; +import java.util.Date; + +/** + * @author Konstantin Kolosovsky. + */ +public class CommitInfo { + + public static final CommitInfo EMPTY = new CommitInfo.Builder().setRevision(-1).build(); + + private final long myRevision; + private final Date myDate; + private final String myAuthor; + @Nullable private final SVNErrorMessage myErrorMessage; + + private CommitInfo(@NotNull CommitInfo.Builder builder) { + myRevision = builder.revision; + myAuthor = builder.author; + myDate = builder.date; + myErrorMessage = builder.error; + } + + public long getRevision() { + return myRevision; + } + + public String getAuthor() { + return myAuthor; + } + + public Date getDate() { + return myDate; + } + + @Nullable + public SVNErrorMessage getErrorMessage() { + return myErrorMessage; + } + + @XmlAccessorType(XmlAccessType.NONE) + @XmlType(name = "commit") + @XmlRootElement(name = "commit") + public static class Builder { + + @XmlAttribute(name = "revision") + private long revision; + + @XmlElement(name = "author") + private String author; + + @XmlElement(name = "date") + private Date date; + + @Nullable private SVNErrorMessage error; + + public Builder() { + } + + public Builder(long revision, Date date, String author) { + this.revision = revision; + this.date = date; + this.author = author; + } + + public long getRevision() { + return revision; + } + + public String getAuthor() { + return author; + } + + public Date getDate() { + return date; + } + + @NotNull + public Builder setRevision(long revision) { + this.revision = revision; + return this; + } + + @NotNull + public Builder setAuthor(String author) { + this.author = author; + return this; + } + + @NotNull + public Builder setDate(Date date) { + this.date = date; + return this; + } + + @NotNull + public Builder setError(@Nullable SVNErrorMessage error) { + this.error = error; + return this; + } + + @NotNull + public CommitInfo build() { + return new CommitInfo(this); + } + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/IdeaCommitHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/IdeaCommitHandler.java index 3b78ac667efa..2dc46692cf59 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/IdeaCommitHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/IdeaCommitHandler.java @@ -27,11 +27,10 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; -import org.jetbrains.idea.svn.SvnUtil; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNCancelException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; import java.io.File; import java.util.List; @@ -42,7 +41,7 @@ import java.util.List; * Date: 2/26/13 * Time: 11:13 AM */ -public class IdeaCommitHandler implements CommitEventHandler, ISVNEventHandler { +public class IdeaCommitHandler implements CommitEventHandler, ProgressTracker { private static final Logger LOG = Logger.getInstance(IdeaCommitHandler.class); @@ -81,8 +80,8 @@ public class IdeaCommitHandler implements CommitEventHandler, ISVNEventHandler { myProgress.setText2(SvnBundle.message("status.text.comitted.revision", revNum)); } - public void handleEvent(SVNEvent event, double p) { - final String path = SvnUtil.getPathForProgress(event); + public void consume(ProgressEvent event) { + final String path = event.getPath(); if (path != null) { CommitEventType eventType = convert(event.getAction()); @@ -120,7 +119,7 @@ public class IdeaCommitHandler implements CommitEventHandler, ISVNEventHandler { } } - private void trackDeletedFile(@NotNull SVNEvent event) { + private void trackDeletedFile(@NotNull ProgressEvent event) { @NonNls final String filePath = "file://" + event.getFile().getAbsolutePath().replace(File.separatorChar, '/'); VirtualFile virtualFile = ApplicationManager.getApplication().runReadAction(new Computable<VirtualFile>() { @Nullable @@ -135,22 +134,22 @@ public class IdeaCommitHandler implements CommitEventHandler, ISVNEventHandler { } @NotNull - private static CommitEventType convert(@NotNull SVNEventAction action) { + private static CommitEventType convert(@NotNull EventAction action) { CommitEventType result = CommitEventType.unknown; - if (SVNEventAction.COMMIT_ADDED.equals(action)) { + if (EventAction.COMMIT_ADDED.equals(action)) { result = CommitEventType.adding; - } else if (SVNEventAction.COMMIT_DELETED.equals(action)) { + } else if (EventAction.COMMIT_DELETED.equals(action)) { result = CommitEventType.deleting; - } else if (SVNEventAction.COMMIT_MODIFIED.equals(action)) { + } else if (EventAction.COMMIT_MODIFIED.equals(action)) { result = CommitEventType.sending; - } else if (SVNEventAction.COMMIT_REPLACED.equals(action)) { + } else if (EventAction.COMMIT_REPLACED.equals(action)) { result = CommitEventType.replacing; - } else if (SVNEventAction.COMMIT_DELTA_SENT.equals(action)) { + } else if (EventAction.COMMIT_DELTA_SENT.equals(action)) { result = CommitEventType.transmittingDeltas; - } else if (SVNEventAction.SKIP.equals(action)) { + } else if (EventAction.SKIP.equals(action)) { result = CommitEventType.skipped; - } else if (SVNEventAction.FAILED_OUT_OF_DATE.equals(action)) { + } else if (EventAction.FAILED_OUT_OF_DATE.equals(action)) { result = CommitEventType.failedOutOfDate; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/ImportClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/ImportClient.java index d3c273ee1449..9338c5db47c6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/ImportClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/ImportClient.java @@ -3,8 +3,8 @@ package org.jetbrains.idea.svn.checkin; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.ISVNCommitHandler; @@ -17,7 +17,7 @@ public interface ImportClient extends SvnClient { long doImport(@NotNull File path, @NotNull SVNURL url, - @Nullable SVNDepth depth, + @Nullable Depth depth, @NotNull String message, boolean noIgnore, @Nullable CommitEventHandler handler, diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinEnvironment.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinEnvironment.java index 6fb1b95b7afe..c9a843501253 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinEnvironment.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinEnvironment.java @@ -45,14 +45,14 @@ import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; -import org.tmatesoft.svn.core.SVNCommitInfo; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import javax.swing.*; import java.awt.*; @@ -130,18 +130,18 @@ public class SvnCheckinEnvironment implements CheckinEnvironment { return; } - SVNCommitInfo[] results = mySvnVcs.getFactory(format).createCheckinClient().commit(committables, comment); + CommitInfo[] results = mySvnVcs.getFactory(format).createCheckinClient().commit(committables, comment); final StringBuilder committedRevisions = new StringBuilder(); - for (SVNCommitInfo result : results) { + for (CommitInfo result : results) { if (result.getErrorMessage() != null) { exception.add(new VcsException(result.getErrorMessage().getFullMessage())); } - else if (result != SVNCommitInfo.NULL && result.getNewRevision() > 0) { + else if (result != CommitInfo.EMPTY && result.getRevision() > 0) { if (committedRevisions.length() > 0) { committedRevisions.append(", "); } - committedRevisions.append(result.getNewRevision()); + committedRevisions.append(result.getRevision()); } } if (committedRevisions.length() > 0) { @@ -199,11 +199,9 @@ public class SvnCheckinEnvironment implements CheckinEnvironment { } private void addParents(File file, final Adder adder) { - SVNStatus status = getStatus(file); + Status status = getStatus(file); - if (status != null && - (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_ADDED) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_REPLACED))) { + if (status != null && status.is(StatusType.STATUS_ADDED, StatusType.STATUS_REPLACED)) { // file should be added adder.add(file); file = file.getParentFile(); @@ -214,13 +212,13 @@ public class SvnCheckinEnvironment implements CheckinEnvironment { } @Nullable - private SVNStatus getStatus(@NotNull File file) { - SVNStatus result = null; + private Status getStatus(@NotNull File file) { + Status result = null; try { result = mySvnVcs.getFactory(file).createStatusClient().doStatus(file, false); } - catch (SVNException e) { + catch (SvnBindException e) { LOG.info(e); } @@ -287,9 +285,9 @@ public class SvnCheckinEnvironment implements CheckinEnvironment { public static List<VcsException> scheduleUnversionedFilesForAddition(@NotNull SvnVcs vcs, List<VirtualFile> files, final boolean recursive) { Collections.sort(files, FilePathComparator.getInstance()); - ISVNEventHandler eventHandler = new SvnProgressCanceller() { + ProgressTracker eventHandler = new SvnProgressCanceller() { @Override - public void handleEvent(SVNEvent event, double progress) throws SVNException { + public void consume(ProgressEvent event) throws SVNException { // TODO: indicator is null here when invoking "Add" action ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); File file = event.getFile(); @@ -301,7 +299,7 @@ public class SvnCheckinEnvironment implements CheckinEnvironment { }; List<VcsException> exceptions = new ArrayList<VcsException>(); - SVNDepth depth = recursive ? SVNDepth.INFINITY : SVNDepth.EMPTY; + Depth depth = Depth.allOrEmpty(recursive); for (VirtualFile file : files) { try { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinHandlerFactory.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinHandlerFactory.java index 8af993b9aefc..29e5fe9d7f72 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinHandlerFactory.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinHandlerFactory.java @@ -32,15 +32,15 @@ import com.intellij.openapi.vcs.checkin.CheckinHandler; import com.intellij.openapi.vcs.checkin.VcsCheckinHandlerFactory; import com.intellij.openapi.vcs.ui.RefreshableOnComponent; import com.intellij.openapi.vcs.update.ActionInfo; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.PairConsumer; +import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; import org.jetbrains.idea.svn.update.AutoSvnUpdater; -import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -74,22 +74,20 @@ public class SvnCheckinHandlerFactory extends VcsCheckinHandlerFactory { public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) { if (executor instanceof LocalCommitExecutor) return ReturnResult.COMMIT; final SvnVcs vcs = SvnVcs.getInstance(project); - final Map<String, Integer> copiesInfo = splitIntoCopies(vcs, myChanges); + final MultiMap<String, WorkingCopyFormat> copiesInfo = splitIntoCopies(vcs, myChanges); final List<String> repoUrls = new ArrayList<String>(); - for (Map.Entry<String, Integer> entry : copiesInfo.entrySet()) { - if (entry.getValue() == 3) { + for (Map.Entry<String, Collection<WorkingCopyFormat>> entry : copiesInfo.entrySet()) { + if (entry.getValue().size() > 1) { repoUrls.add(entry.getKey()); } } if (! repoUrls.isEmpty()) { - final String join = StringUtil.join(repoUrls.toArray(new String[repoUrls.size()]), ",\n"); + final String join = StringUtil.join(repoUrls, ",\n"); final int isOk = Messages.showOkCancelDialog(project, SvnBundle.message("checkin.different.formats.involved", repoUrls.size() > 1 ? 1 : 0, join), "Subversion: Commit Will Split", Messages.getWarningIcon()); - if (Messages.OK == isOk) { - return ReturnResult.COMMIT; - } - return ReturnResult.CANCEL; + + return Messages.OK == isOk ? ReturnResult.COMMIT : ReturnResult.CANCEL; } return ReturnResult.COMMIT; } @@ -104,17 +102,17 @@ public class SvnCheckinHandlerFactory extends VcsCheckinHandlerFactory { if (SvnConfiguration.getInstance(project).isAutoUpdateAfterCommit()) { final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(SvnVcs.getInstance(project)); final List<FilePath> paths = new ArrayList<FilePath>(); - for (int i = 0; i < roots.length; i++) { - VirtualFile root = roots[i]; + for (VirtualFile root : roots) { boolean take = false; for (VirtualFile commitRoot : commitRoots) { - if (VfsUtil.isAncestor(root, commitRoot, false)) { + if (VfsUtilCore.isAncestor(root, commitRoot, false)) { take = true; break; } } - if (! take) continue; - paths.add(new FilePathImpl(root)); + if (take) { + paths.add(new FilePathImpl(root)); + } } if (paths.isEmpty()) return; ApplicationManager.getApplication().invokeLater(new Runnable() { @@ -128,25 +126,19 @@ public class SvnCheckinHandlerFactory extends VcsCheckinHandlerFactory { }; } - private static Map<String, Integer> splitIntoCopies(SvnVcs vcs, final Collection<Change> changes) { - final SvnFileUrlMapping mapping = vcs.getSvnFileUrlMapping(); + @NotNull + private static MultiMap<String, WorkingCopyFormat> splitIntoCopies(@NotNull SvnVcs vcs, @NotNull Collection<Change> changes) { + MultiMap<String, WorkingCopyFormat> result = MultiMap.createSet(); + SvnFileUrlMapping mapping = vcs.getSvnFileUrlMapping(); - final Map<String, Integer> copiesInfo = new java.util.HashMap<String, Integer>(); for (Change change : changes) { - final File ioFile = ChangesUtil.getFilePath(change).getIOFile(); - final RootUrlInfo path = mapping.getWcRootForFilePath(ioFile); - if (path == null) continue; - final Integer integer = copiesInfo.get(path.getRepositoryUrl()); - int result = integer == null ? 0 : integer; - if (result != 3) { - if (WorkingCopyFormat.ONE_DOT_SEVEN.equals(path.getFormat())) { - result |= 2; - } else { - result |= 1; - } - copiesInfo.put(path.getRepositoryUrl(), result); + RootUrlInfo path = mapping.getWcRootForFilePath(ChangesUtil.getFilePath(change).getIOFile()); + + if (path != null) { + result.putValue(path.getRepositoryUrl(), path.getFormat()); } } - return copiesInfo; + + return result; } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitCheckinClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitCheckinClient.java index a81aecd94ba2..c3f203a9e02f 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitCheckinClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitCheckinClient.java @@ -20,6 +20,8 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.api.BaseSvnClient; import org.jetbrains.idea.svn.commandLine.SvnBindException; @@ -41,7 +43,7 @@ public class SvnKitCheckinClient extends BaseSvnClient implements CheckinClient @NotNull @Override - public SVNCommitInfo[] commit(@NotNull Collection<File> paths, @NotNull String comment) throws VcsException { + public CommitInfo[] commit(@NotNull Collection<File> paths, @NotNull String comment) throws VcsException { File[] pathsToCommit = ArrayUtil.toObjectArray(paths, File.class); boolean keepLocks = myVcs.getSvnConfiguration().isKeepLocks(); SVNCommitPacket[] commitPackets = null; @@ -49,7 +51,7 @@ public class SvnKitCheckinClient extends BaseSvnClient implements CheckinClient SVNCommitClient committer = myVcs.getSvnKitManager().createCommitClient(); IdeaCommitHandler handler = new IdeaCommitHandler(ProgressManager.getInstance().getProgressIndicator(), true, true); - committer.setEventHandler(handler); + committer.setEventHandler(toEventHandler(handler)); try { commitPackets = committer.doCollectCommitItems(pathsToCommit, keepLocks, true, SVNDepth.EMPTY, true, null); results = committer.doCommit(commitPackets, keepLocks, comment); @@ -76,6 +78,17 @@ public class SvnKitCheckinClient extends BaseSvnClient implements CheckinClient f.putUserData(VirtualFile.REQUESTOR_MARKER, this); } - return results; + return convert(results); + } + + @NotNull + private static CommitInfo[] convert(@NotNull SVNCommitInfo[] infos) { + return ContainerUtil.map(infos, new Function<SVNCommitInfo, CommitInfo>() { + @Override + public CommitInfo fun(SVNCommitInfo info) { + return new CommitInfo.Builder(info.getNewRevision(), info.getDate(), info.getAuthor()) + .setError(info.getErrorMessage()).build(); + } + }, new CommitInfo[0]); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitImportClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitImportClient.java index 23edc8f22253..d64f8c3f95a9 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitImportClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitImportClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNCommitInfo; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.ISVNCommitHandler; @@ -22,18 +22,18 @@ public class SvnKitImportClient extends BaseSvnClient implements ImportClient { @Override public long doImport(@NotNull File path, @NotNull SVNURL url, - @Nullable SVNDepth depth, + @Nullable Depth depth, @NotNull String message, boolean noIgnore, @Nullable CommitEventHandler handler, @Nullable ISVNCommitHandler commitHandler) throws VcsException { SVNCommitClient client = myVcs.getSvnKitManager().createCommitClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); client.setCommitHandler(commitHandler); try { - SVNCommitInfo info = client.doImport(path, url, message, null, !noIgnore, false, depth); + SVNCommitInfo info = client.doImport(path, url, message, null, !noIgnore, false, toDepth(depth)); return info.getNewRevision(); } catch (SVNException e) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutClient.java index b31d0da1dc48..d338ca12e55d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.WorkingCopyFormat; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -21,11 +21,11 @@ public interface CheckoutClient extends SvnClient { void checkout(@NotNull SvnTarget source, @NotNull File destination, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean ignoreExternals, boolean force, @NotNull WorkingCopyFormat format, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable ProgressTracker handler) throws VcsException; List<WorkingCopyFormat> getSupportedFormats() throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutEventHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutEventHandler.java index 88f2a6940c10..868c38b8b364 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutEventHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutEventHandler.java @@ -22,16 +22,15 @@ import com.intellij.openapi.wm.StatusBar; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; -import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNCancelException; import org.tmatesoft.svn.core.SVNErrorCode; import org.tmatesoft.svn.core.SVNErrorMessage; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; -public class CheckoutEventHandler implements ISVNEventHandler { +public class CheckoutEventHandler implements ProgressTracker { @Nullable private final ProgressIndicator myIndicator; private int myExternalsCount; @NotNull private final SvnVcs myVCS; @@ -46,20 +45,19 @@ public class CheckoutEventHandler implements ISVNEventHandler { myCnt = 0; } - public void handleEvent(SVNEvent event, double progress) { - final String path = SvnUtil.getPathForProgress(event); - if (path == null) { + public void consume(ProgressEvent event) { + if (event.getPath() == null) { return; } - if (event.getAction() == SVNEventAction.UPDATE_EXTERNAL) { + if (event.getAction() == EventAction.UPDATE_EXTERNAL) { myExternalsCount++; progress(SvnBundle.message("progress.text2.fetching.external.location", event.getFile().getAbsolutePath())); } - else if (event.getAction() == SVNEventAction.UPDATE_ADD) { + else if (event.getAction() == EventAction.UPDATE_ADD) { progress2(SvnBundle.message(myIsExport ? "progress.text2.exported" : "progress.text2.checked.out", event.getFile().getName(), myCnt)); ++ myCnt; } - else if (event.getAction() == SVNEventAction.UPDATE_COMPLETED) { + else if (event.getAction() == EventAction.UPDATE_COMPLETED) { myExternalsCount--; progress2( (SvnBundle.message(myIsExport ? "progress.text2.exported.revision" : "progress.text2.checked.out.revision", event.getRevision()))); @@ -70,10 +68,10 @@ public class CheckoutEventHandler implements ISVNEventHandler { StatusBar.Info.set(SvnBundle.message(myIsExport ? "progress.text2.exported.revision" : "status.text.checked.out.revision", event.getRevision()), project); } } - } else if (event.getAction() == SVNEventAction.COMMIT_ADDED) { - progress2((SvnBundle.message("progress.text2.adding", path))); - } else if (event.getAction() == SVNEventAction.COMMIT_DELTA_SENT) { - progress2((SvnBundle.message("progress.text2.transmitting.delta", path))); + } else if (event.getAction() == EventAction.COMMIT_ADDED) { + progress2((SvnBundle.message("progress.text2.adding", event.getPath()))); + } else if (event.getAction() == EventAction.COMMIT_DELTA_SENT) { + progress2((SvnBundle.message("progress.text2.transmitting.delta", event.getPath()))); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdCheckoutClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdCheckoutClient.java index b292e43b9c1b..7ea00c69d5d6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdCheckoutClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdCheckoutClient.java @@ -6,11 +6,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.BaseUpdateCommandListener; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -26,11 +26,11 @@ public class CmdCheckoutClient extends BaseSvnClient implements CheckoutClient { public void checkout(@NotNull SvnTarget source, @NotNull File destination, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean ignoreExternals, boolean force, @NotNull WorkingCopyFormat format, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { validateFormat(format, getSupportedFormats()); List<String> parameters = new ArrayList<String>(); @@ -57,7 +57,7 @@ public class CmdCheckoutClient extends BaseSvnClient implements CheckoutClient { private void run(@NotNull SvnTarget source, @NotNull File destination, - @Nullable ISVNEventHandler handler, + @Nullable ProgressTracker handler, @NotNull List<String> parameters) throws VcsException { BaseUpdateCommandListener listener = new BaseUpdateCommandListener(destination, handler); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdExportClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdExportClient.java index 1e4011378fb7..a35c7a475d02 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdExportClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdExportClient.java @@ -5,11 +5,11 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.BaseUpdateCommandListener; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -26,11 +26,11 @@ public class CmdExportClient extends BaseSvnClient implements ExportClient { public void export(@NotNull SvnTarget from, @NotNull File to, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable String nativeLineEnd, boolean force, boolean ignoreExternals, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { List<String> parameters = new ArrayList<String>(); CommandUtil.put(parameters, from); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/ExportClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/ExportClient.java index 6ddd6debe763..4033ead72bcc 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/ExportClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/ExportClient.java @@ -3,9 +3,9 @@ package org.jetbrains.idea.svn.checkout; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -19,9 +19,9 @@ public interface ExportClient extends SvnClient { void export(@NotNull SvnTarget from, @NotNull File to, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable String nativeLineEnd, boolean force, boolean ignoreExternals, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnCheckoutProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnCheckoutProvider.java index 634d528c17f1..c7422ef2a220 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnCheckoutProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnCheckoutProvider.java @@ -44,12 +44,13 @@ import org.jetbrains.idea.svn.*; import org.jetbrains.idea.svn.actions.ExclusiveBackgroundVcsAction; import org.jetbrains.idea.svn.actions.SvnExcludingIgnoredOperation; import org.jetbrains.idea.svn.api.ClientFactory; -import org.jetbrains.idea.svn.checkin.IdeaCommitHandler; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.checkin.CommitEventHandler; +import org.jetbrains.idea.svn.checkin.IdeaCommitHandler; import org.jetbrains.idea.svn.dialogs.CheckoutDialog; import org.jetbrains.idea.svn.dialogs.UpgradeFormatDialog; import org.tmatesoft.svn.core.SVNCancelException; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.*; @@ -68,8 +69,8 @@ public class SvnCheckoutProvider implements CheckoutProvider { dialog.show(); } - public static void doCheckout(final Project project, final File target, final String url, final SVNRevision revision, - final SVNDepth depth, final boolean ignoreExternals, @Nullable final Listener listener) { + public static void doCheckout(@NotNull Project project, @NotNull File target, final String url, final SVNRevision revision, + final Depth depth, final boolean ignoreExternals, @Nullable final Listener listener) { if (! target.exists()) { target.mkdirs(); } @@ -95,7 +96,7 @@ public class SvnCheckoutProvider implements CheckoutProvider { final File target, final String url, final SVNRevision revision, - final SVNDepth depth, + final Depth depth, final boolean ignoreExternals, final Listener listener, final WorkingCopyFormat selectedFormat) { final Ref<Boolean> checkoutSuccessful = new Ref<Boolean>(); @@ -108,7 +109,7 @@ public class SvnCheckoutProvider implements CheckoutProvider { SvnWorkingCopyFormatHolder.setPresetFormat(format); SvnVcs vcs = SvnVcs.getInstance(project); - ISVNEventHandler handler = new CheckoutEventHandler(vcs, false, ProgressManager.getInstance().getProgressIndicator()); + ProgressTracker handler = new CheckoutEventHandler(vcs, false, ProgressManager.getInstance().getProgressIndicator()); ProgressManager.progress(SvnBundle.message("progress.text.checking.out", target.getAbsolutePath())); try { getFactory(vcs, format).createCheckoutClient() @@ -186,11 +187,11 @@ public class SvnCheckoutProvider implements CheckoutProvider { @CalledInAwt @NotNull - public static WorkingCopyFormat promptForWCopyFormat(final File target, final Project project) { + public static WorkingCopyFormat promptForWCopyFormat(@NotNull File target, @NotNull Project project) { return new CheckoutFormatFromUserProvider(project, target).prompt(); } - public static void doExport(final Project project, final File target, final SVNURL url, final SVNDepth depth, + public static void doExport(final Project project, final File target, final SVNURL url, final Depth depth, final boolean ignoreExternals, final boolean force, final String eolStyle) { try { final VcsException[] exception = new VcsException[1]; @@ -199,7 +200,7 @@ public class SvnCheckoutProvider implements CheckoutProvider { ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { public void run() { ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); - ISVNEventHandler handler = new CheckoutEventHandler(vcs, true, progressIndicator); + ProgressTracker handler = new CheckoutEventHandler(vcs, true, progressIndicator); try { progressIndicator.setText(SvnBundle.message("progress.text.export", target.getAbsolutePath())); @@ -221,7 +222,7 @@ public class SvnCheckoutProvider implements CheckoutProvider { } } - public static void doImport(final Project project, final File target, final SVNURL url, final SVNDepth depth, + public static void doImport(final Project project, final File target, final SVNURL url, final Depth depth, final boolean includeIgnored, final String message) { final Ref<String> errorMessage = new Ref<String>(); final SvnVcs vcs = SvnVcs.getInstance(project); @@ -312,14 +313,15 @@ public class SvnCheckoutProvider implements CheckoutProvider { public WorkingCopyFormat prompt() { assert !ApplicationManager.getApplication().isUnitTestMode(); - final WorkingCopyFormat result = displayUpgradeDialog(WorkingCopyFormat.ONE_DOT_SEVEN); + final WorkingCopyFormat result = displayUpgradeDialog(); ApplicationManager.getApplication().getMessageBus().syncPublisher(SvnVcs.WC_CONVERTED).run(); return result; } - private WorkingCopyFormat displayUpgradeDialog(@NotNull WorkingCopyFormat defaultSelection) { + @NotNull + private WorkingCopyFormat displayUpgradeDialog() { final UpgradeFormatDialog dialog = new UpgradeFormatDialog(myProject, myPath, false); final ModalityState dialogState = ModalityState.any(); @@ -354,6 +356,7 @@ public class SvnCheckoutProvider implements CheckoutProvider { return dialog.isOK() ? dialog.getUpgradeMode() : WorkingCopyFormat.UNKNOWN; } + @NotNull private List<WorkingCopyFormat> loadSupportedFormats() { List<WorkingCopyFormat> result = ContainerUtil.newArrayList(); @@ -368,6 +371,7 @@ public class SvnCheckoutProvider implements CheckoutProvider { return result; } + @NotNull private static List<WorkingCopyFormat> getOtherFactoryFormats(@NotNull ClientFactory otherFactory) { List<WorkingCopyFormat> result; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitCheckoutClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitCheckoutClient.java index 9abd2da1b35c..d8f0ea5be3d2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitCheckoutClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitCheckoutClient.java @@ -5,11 +5,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.SvnBindException; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.internal.wc2.SvnWcGeneration; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNUpdateClient; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -39,11 +39,11 @@ public class SvnKitCheckoutClient extends BaseSvnClient implements CheckoutClien public void checkout(@NotNull SvnTarget source, @NotNull File destination, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean ignoreExternals, boolean force, @NotNull WorkingCopyFormat format, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { assertUrl(source); validateFormat(format, getSupportedFormats()); @@ -54,10 +54,10 @@ public class SvnKitCheckoutClient extends BaseSvnClient implements CheckoutClien } client.setIgnoreExternals(ignoreExternals); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); try { - client.doCheckout(source.getURL(), destination, source.getPegRevision(), revision, depth, force); + client.doCheckout(source.getURL(), destination, source.getPegRevision(), revision, toDepth(depth), force); } catch (SVNException e) { throw new SvnBindException(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitExportClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitExportClient.java index df7b496f9811..66eac246f3b7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitExportClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitExportClient.java @@ -4,10 +4,10 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.SvnBindException; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNUpdateClient; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -23,22 +23,22 @@ public class SvnKitExportClient extends BaseSvnClient implements ExportClient { public void export(@NotNull SvnTarget from, @NotNull File to, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable String nativeLineEnd, boolean force, boolean ignoreExternals, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { SVNUpdateClient client = myVcs.getSvnKitManager().createUpdateClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); client.setIgnoreExternals(ignoreExternals); try { if (from.isFile()) { - client.doExport(from.getFile(), to, from.getPegRevision(), revision, nativeLineEnd, force, depth); + client.doExport(from.getFile(), to, from.getPegRevision(), revision, nativeLineEnd, force, toDepth(depth)); } else { - client.doExport(from.getURL(), to, from.getPegRevision(), revision, nativeLineEnd, force, depth); + client.doExport(from.getURL(), to, from.getPegRevision(), revision, nativeLineEnd, force, toDepth(depth)); } } catch (SVNException e) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CleanupClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CleanupClient.java index 3d1b9ee88b7c..6bf861062894 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CleanupClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CleanupClient.java @@ -3,8 +3,8 @@ package org.jetbrains.idea.svn.cleanup; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import java.io.File; @@ -13,5 +13,5 @@ import java.io.File; */ public interface CleanupClient extends SvnClient { - void cleanup(@NotNull File path, @Nullable ISVNEventHandler handler) throws VcsException; + void cleanup(@NotNull File path, @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CmdCleanupClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CmdCleanupClient.java index 6ee1763d4120..478144579045 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CmdCleanupClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CmdCleanupClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -19,7 +19,7 @@ import java.util.List; public class CmdCleanupClient extends BaseSvnClient implements CleanupClient { @Override - public void cleanup(@NotNull File path, @Nullable ISVNEventHandler handler) throws VcsException { + public void cleanup(@NotNull File path, @Nullable ProgressTracker handler) throws VcsException { // TODO: Implement event handler support - currently in SVNKit implementation handler is used to support cancelling List<String> parameters = new ArrayList<String>(); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/SvnKitCleanupClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/SvnKitCleanupClient.java index b19a505ef63a..00ae19a5d8d6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/SvnKitCleanupClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/SvnKitCleanupClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -17,10 +17,10 @@ import java.io.File; public class SvnKitCleanupClient extends BaseSvnClient implements CleanupClient { @Override - public void cleanup(@NotNull File path, @Nullable ISVNEventHandler handler) throws VcsException { + public void cleanup(@NotNull File path, @Nullable ProgressTracker handler) throws VcsException { SVNWCClient client = myVcs.getSvnKitManager().createWCClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); try { client.doCleanup(path); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/BaseUpdateCommandListener.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/BaseUpdateCommandListener.java index eb80bad0c70f..a8ef20b21765 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/BaseUpdateCommandListener.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/BaseUpdateCommandListener.java @@ -2,12 +2,11 @@ package org.jetbrains.idea.svn.commandLine; import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.openapi.util.Key; -import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; import java.io.File; import java.util.concurrent.atomic.AtomicReference; @@ -21,12 +20,12 @@ public class BaseUpdateCommandListener extends LineCommandAdapter { private final UpdateOutputLineConverter converter; @Nullable - private final ISVNEventHandler handler; + private final ProgressTracker handler; @NotNull private final AtomicReference<SVNException> exception; - public BaseUpdateCommandListener(@NotNull File base, @Nullable ISVNEventHandler handler) { + public BaseUpdateCommandListener(@NotNull File base, @Nullable ProgressTracker handler) { this.handler = handler; this.converter = new UpdateOutputLineConverter(base); exception = new AtomicReference<SVNException>(); @@ -35,7 +34,7 @@ public class BaseUpdateCommandListener extends LineCommandAdapter { @Override public void onLineAvailable(String line, Key outputType) { if (ProcessOutputTypes.STDOUT.equals(outputType)) { - final SVNEvent event = converter.convert(line); + final ProgressEvent event = converter.convert(line); if (event != null) { beforeHandler(event); try { @@ -49,28 +48,20 @@ public class BaseUpdateCommandListener extends LineCommandAdapter { } } - private void callHandler(SVNEvent event) throws SVNException { + private void callHandler(ProgressEvent event) throws SVNException { if (handler != null) { - handler.handleEvent(event, 0.5); + handler.consume(event); } } - public void throwIfException() throws SVNException { + public void throwWrappedIfException() throws SvnBindException { SVNException e = exception.get(); if (e != null) { - throw e; + throw new SvnBindException(e); } } - public void throwWrappedIfException() throws VcsException { - SVNException e = exception.get(); - - if (e != null) { - throw new VcsException(e); - } - } - - protected void beforeHandler(@NotNull SVNEvent event) { + protected void beforeHandler(@NotNull ProgressEvent event) { } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/Command.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/Command.java index 66216d39a3c0..50215fba76c8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/Command.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/Command.java @@ -5,7 +5,7 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.ISVNCanceller; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -31,7 +31,7 @@ public class Command { @Nullable private volatile SVNURL myRepositoryUrl; @NotNull private SvnTarget myTarget; - @Nullable private ISVNCanceller myCanceller; + @Nullable private ProgressTracker myCanceller; public Command(@NotNull SvnCommandName name) { myName = name; @@ -52,11 +52,11 @@ public class Command { } @Nullable - public ISVNCanceller getCanceller() { + public ProgressTracker getCanceller() { return myCanceller; } - public void setCanceller(@Nullable ISVNCanceller canceller) { + public void setCanceller(@Nullable ProgressTracker canceller) { myCanceller = canceller; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandUtil.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandUtil.java index 84794b7249a8..eee798737846 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandUtil.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandUtil.java @@ -4,10 +4,10 @@ import com.intellij.openapi.application.PathManager; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.diff.DiffOptions; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatusType; import org.tmatesoft.svn.core.wc2.SvnTarget; import javax.xml.bind.JAXBContext; @@ -90,12 +90,12 @@ public class CommandUtil { } } - public static void put(@NotNull List<String> parameters, @Nullable SVNDepth depth) { + public static void put(@NotNull List<String> parameters, @Nullable Depth depth) { put(parameters, depth, false); } - public static void put(@NotNull List<String> parameters, @Nullable SVNDepth depth, boolean sticky) { - if (depth != null && !SVNDepth.UNKNOWN.equals(depth)) { + public static void put(@NotNull List<String> parameters, @Nullable Depth depth, boolean sticky) { + if (depth != null && !Depth.UNKNOWN.equals(depth)) { parameters.add("--depth"); parameters.add(depth.getName()); @@ -113,7 +113,7 @@ public class CommandUtil { } } - public static void put(@NotNull List<String> parameters, @Nullable SVNDiffOptions diffOptions) { + public static void put(@NotNull List<String> parameters, @Nullable DiffOptions diffOptions) { if (diffOptions != null) { StringBuilder builder = new StringBuilder(); @@ -172,29 +172,29 @@ public class CommandUtil { } @NotNull - public static SVNStatusType getStatusType(@Nullable String type) { + public static StatusType getStatusType(@Nullable String type) { return getStatusType(getStatusChar(type)); } @NotNull - public static SVNStatusType getStatusType(char first) { - final SVNStatusType contentsStatus; + public static StatusType getStatusType(char first) { + final StatusType contentsStatus; if ('A' == first) { - contentsStatus = SVNStatusType.STATUS_ADDED; + contentsStatus = StatusType.STATUS_ADDED; } else if ('D' == first) { - contentsStatus = SVNStatusType.STATUS_DELETED; + contentsStatus = StatusType.STATUS_DELETED; } else if ('U' == first) { - contentsStatus = SVNStatusType.CHANGED; + contentsStatus = StatusType.CHANGED; } else if ('C' == first) { - contentsStatus = SVNStatusType.CONFLICTED; + contentsStatus = StatusType.CONFLICTED; } else if ('G' == first) { - contentsStatus = SVNStatusType.MERGED; + contentsStatus = StatusType.MERGED; } else if ('R' == first) { - contentsStatus = SVNStatusType.STATUS_REPLACED; + contentsStatus = StatusType.STATUS_REPLACED; } else if ('E' == first) { - contentsStatus = SVNStatusType.STATUS_OBSTRUCTED; + contentsStatus = StatusType.STATUS_OBSTRUCTED; } else { - contentsStatus = SVNStatusType.STATUS_NORMAL; + contentsStatus = StatusType.STATUS_NORMAL; } return contentsStatus; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnBindException.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnBindException.java index 80c1f4078f85..6694083b4d81 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnBindException.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnBindException.java @@ -42,9 +42,16 @@ public class SvnBindException extends VcsException { public static final int ERROR_BASE = 120000; public static final int CATEGORY_SIZE = 5000; + public static final String ERROR_MESSAGE_FORMAT = "svn: E%d: %s"; + @NotNull private final MultiMap<Integer, String> errors = MultiMap.create(); @NotNull private final MultiMap<Integer, String> warnings = MultiMap.create(); + public SvnBindException(@NotNull SVNErrorCode code, @NotNull String message) { + super(String.format(ERROR_MESSAGE_FORMAT, code.getCode(), message)); + errors.putValue(code.getCode(), getMessage()); + } + public SvnBindException(String message) { super(message); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnExceptionWrapper.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnExceptionWrapper.java index cd451e149d09..d7b849655ce7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnExceptionWrapper.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnExceptionWrapper.java @@ -40,4 +40,8 @@ public class SvnExceptionWrapper extends RuntimeException { public SvnExceptionWrapper(SVNException cause) { super(cause); } + + public SvnExceptionWrapper(SvnBindException cause) { + super(cause); + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/UpdateOutputLineConverter.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/UpdateOutputLineConverter.java index a5a1ab80b75b..602a6e8c460e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/UpdateOutputLineConverter.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/UpdateOutputLineConverter.java @@ -18,12 +18,11 @@ package org.jetbrains.idea.svn.commandLine; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNErrorCode; import org.tmatesoft.svn.core.SVNErrorMessage; -import org.tmatesoft.svn.core.SVNNodeKind; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.util.Arrays; @@ -80,7 +79,7 @@ public class UpdateOutputLineConverter { myCurrentFile = base; } - public SVNEvent convert(final String line) { + public ProgressEvent convert(final String line) { // TODO: Add direct processing of "Summary of conflicts" lines at the end of "svn update" output (if there are conflicts). // TODO: Now it works ok because parseNormalLine could not determine necessary statuses from that and further lines if (StringUtil.isEmptyOrSpaces(line)) return null; @@ -89,23 +88,19 @@ public class UpdateOutputLineConverter { return null; } else if (line.startsWith(UPDATING)) { myCurrentFile = parseForPath(line); - return new SVNEvent(myCurrentFile, myCurrentFile == null ? null : (myCurrentFile.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE), - null, -1, null, null, null, null, SVNEventAction.UPDATE_NONE, SVNEventAction.UPDATE_NONE, null, null, null, null, null); + return new ProgressEvent(myCurrentFile, -1, null, null, EventAction.UPDATE_NONE, null, null); } else if (line.startsWith(RESTORED)) { myCurrentFile = parseForPath(line); - return new SVNEvent(myCurrentFile, myCurrentFile == null ? null : (myCurrentFile.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE), - null, -1, null, null, null, null, SVNEventAction.RESTORE, SVNEventAction.RESTORE, null, null, null, null, null); + return new ProgressEvent(myCurrentFile, -1, null, null, EventAction.RESTORE, null, null); } else if (line.startsWith(SKIPPED)) { // called, for instance, when folder is not working copy myCurrentFile = parseForPath(line); final String comment = parseComment(line); - return new SVNEvent(myCurrentFile, myCurrentFile == null ? null : (myCurrentFile.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE), - null, -1, null, null, null, null, SVNEventAction.SKIP, SVNEventAction.SKIP, - comment == null ? null : SVNErrorMessage.create(SVNErrorCode.WC_OBSTRUCTED_UPDATE, comment), null, null, null, null); + return new ProgressEvent(myCurrentFile, -1, null, null, EventAction.SKIP, + comment == null ? null : SVNErrorMessage.create(SVNErrorCode.WC_OBSTRUCTED_UPDATE, comment), null); } else if (line.startsWith(FETCHING_EXTERNAL)) { myCurrentFile = parseForPath(line); - return new SVNEvent(myCurrentFile, myCurrentFile == null ? null : (myCurrentFile.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE), - null, -1, null, null, null, null, SVNEventAction.UPDATE_EXTERNAL, SVNEventAction.UPDATE_EXTERNAL, null, null, null, null, null); + return new ProgressEvent(myCurrentFile, -1, null, null, EventAction.UPDATE_EXTERNAL, null, null); } for (int i = 0; i < ourCompletePatterns.length; i++) { @@ -114,10 +109,7 @@ public class UpdateOutputLineConverter { if (revision != -1) { // TODO: seems that myCurrentFile will not always be correct - complete update message could be right after complete externals update // TODO: check this and use Stack instead - return new SVNEvent(myCurrentFile, - myCurrentFile == null ? null : (myCurrentFile.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE), - null, revision, null, null, null, null, SVNEventAction.UPDATE_COMPLETED, SVNEventAction.UPDATE_COMPLETED, null, - null, null, null, null); + return new ProgressEvent(myCurrentFile, revision, null, null, EventAction.UPDATE_COMPLETED, null, null); } } @@ -127,13 +119,13 @@ public class UpdateOutputLineConverter { private final static Set<Character> ourActions = new HashSet<Character>(Arrays.asList(new Character[] {'A', 'D', 'U', 'C', 'G', 'E', 'R'})); @Nullable - private SVNEvent parseNormalString(final String line) { + private ProgressEvent parseNormalString(final String line) { if (line.length() < 5) return null; final char first = line.charAt(0); if (' ' != first && ! ourActions.contains(first)) return null; - final SVNStatusType contentsStatus = CommandUtil.getStatusType(first); + final StatusType contentsStatus = CommandUtil.getStatusType(first); final char second = line.charAt(1); - final SVNStatusType propertiesStatus = CommandUtil.getStatusType(second); + final StatusType propertiesStatus = CommandUtil.getStatusType(second); final char lock = line.charAt(2); // dont know what to do with stolen lock info if (' ' != lock && 'B' != lock) return null; final char treeConflict = line.charAt(3); @@ -143,29 +135,26 @@ public class UpdateOutputLineConverter { final String path = line.substring(4).trim(); if (StringUtil.isEmptyOrSpaces(path)) return null; final File file = createFile(path); - if (SVNStatusType.STATUS_OBSTRUCTED.equals(contentsStatus)) { + if (StatusType.STATUS_OBSTRUCTED.equals(contentsStatus)) { // obstructed - return new SVNEvent(file, file.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE, - null, -1, contentsStatus, propertiesStatus, null, null, SVNEventAction.UPDATE_SKIP_OBSTRUCTION, SVNEventAction.UPDATE_ADD, - null, null, null, null, null); + return new ProgressEvent(file, -1, contentsStatus, propertiesStatus, EventAction.UPDATE_SKIP_OBSTRUCTION, null, null); } - SVNEventAction action; - SVNEventAction expectedAction; - if (SVNStatusType.STATUS_ADDED.equals(contentsStatus)) { - expectedAction = SVNEventAction.UPDATE_ADD; - } else if (SVNStatusType.STATUS_DELETED.equals(contentsStatus)) { - expectedAction = SVNEventAction.UPDATE_DELETE; + EventAction action; + EventAction expectedAction; + if (StatusType.STATUS_ADDED.equals(contentsStatus)) { + expectedAction = EventAction.UPDATE_ADD; + } else if (StatusType.STATUS_DELETED.equals(contentsStatus)) { + expectedAction = EventAction.UPDATE_DELETE; } else { - expectedAction = SVNEventAction.UPDATE_UPDATE; + expectedAction = EventAction.UPDATE_UPDATE; } action = expectedAction; if (haveTreeConflict) { - action = SVNEventAction.TREE_CONFLICT; + action = EventAction.TREE_CONFLICT; } - return new SVNEvent(file, file.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE, null, -1, contentsStatus, propertiesStatus, null, - null, action, expectedAction, null, null, null, null, null); + return new ProgressEvent(file, -1, contentsStatus, propertiesStatus, action, null, null); } private File createFile(String path) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/config/SvnConfigureProxiesDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/config/SvnConfigureProxiesDialog.java index c966737f9603..a70a4f28d0fd 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/config/SvnConfigureProxiesDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/config/SvnConfigureProxiesDialog.java @@ -25,7 +25,6 @@ import com.intellij.openapi.util.Ref; import com.intellij.ui.components.JBTabbedPane; import org.jetbrains.idea.svn.*; import org.jetbrains.idea.svn.commandLine.SvnBindException; -import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.SVNRevision; import javax.swing.*; @@ -43,7 +42,7 @@ public class SvnConfigureProxiesDialog extends DialogWrapper implements Validati super(project, true); valid = true; myProject = project; - + setTitle(SvnBundle.message("dialog.title.edit.http.proxies.settings")); final Ref<SvnServerFileManager> systemManager = new Ref<SvnServerFileManager>(); @@ -56,7 +55,7 @@ public class SvnConfigureProxiesDialog extends DialogWrapper implements Validati myUserTab = new SvnConfigureProxiesComponent(userManager.get(), myValidator, this); init(); - + mySystemTab.reset(); myUserTab.reset(); myValidator.run(); @@ -140,9 +139,6 @@ public class SvnConfigureProxiesDialog extends DialogWrapper implements Validati try { SvnVcs.getInstance(myProject).getInfo(SvnUtil.createUrl(url), SVNRevision.HEAD); } - catch (SVNException exc) { - excRef.set(exc); - } catch (SvnBindException e) { excRef.set(e); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/CmdConflictClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/CmdConflictClient.java index 39a222dbeaf3..a07425dd1133 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/CmdConflictClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/CmdConflictClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -22,7 +22,7 @@ public class CmdConflictClient extends BaseSvnClient implements ConflictClient { // TODO: Or rewrite logic to have one "Resolve conflicts" action instead of separate actions for each conflict type. @Override public void resolve(@NotNull File path, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean resolveProperty, boolean resolveContent, boolean resolveTree) throws VcsException { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictAction.java new file mode 100644 index 000000000000..f4111ce2d981 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictAction.java @@ -0,0 +1,72 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.conflict; + +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +public enum ConflictAction { + + EDIT("edit", "edited"), + ADD("add", "added"), + DELETE("delete", "deleted"), + REPLACE("replace", "replaced"); + + @NotNull private static final Map<String, ConflictAction> ourAllActions = ContainerUtil.newHashMap(); + + static { + for (ConflictAction action : ConflictAction.values()) { + register(action); + } + } + + @NotNull private final String myKey; + @NotNull private final String[] myOtherKeys; + + ConflictAction(@NotNull String key, @NotNull String... otherKeys) { + myKey = key; + myOtherKeys = otherKeys; + } + + @Override + public String toString() { + return myKey; + } + + private static void register(@NotNull ConflictAction action) { + ourAllActions.put(action.myKey, action); + + for (String otherKey : action.myOtherKeys) { + ourAllActions.put(otherKey, action); + } + } + + @NotNull + public static ConflictAction from(@NotNull String actionName) { + ConflictAction result = ourAllActions.get(actionName); + + if (result == null) { + throw new IllegalArgumentException("Unknown conflict action " + actionName); + } + + return result; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictClient.java index 64e50b874d93..7d862067cea2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictClient.java @@ -3,8 +3,8 @@ package org.jetbrains.idea.svn.conflict; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; import java.io.File; @@ -13,6 +13,6 @@ import java.io.File; */ public interface ConflictClient extends SvnClient { - void resolve(@NotNull File path, @Nullable SVNDepth depth, boolean resolveProperty, boolean resolveContent, boolean resolveTree) + void resolve(@NotNull File path, @Nullable Depth depth, boolean resolveProperty, boolean resolveContent, boolean resolveTree) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictOperation.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictOperation.java new file mode 100644 index 000000000000..d0936a538945 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictOperation.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.conflict; + +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +/** + * @author Konstantin Kolosovsky. + */ +public enum ConflictOperation { + NONE, + UPDATE, + SWITCH, + MERGE; + + @NotNull + public static ConflictOperation from(@NotNull @NonNls String operationName) { + return valueOf(ConflictOperation.class, operationName.toUpperCase()); + } + + @Override + @NonNls + public String toString() { + return super.toString().toLowerCase(); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictReason.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictReason.java new file mode 100644 index 000000000000..71eaf6d96b1a --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictReason.java @@ -0,0 +1,89 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.conflict; + +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +public enum ConflictReason { + + EDITED("edit", "edited"), + OBSTRUCTED("obstruction", "obstruct", "obstructed"), + DELETED("delete", "deleted"), + MISSING("missing", "miss"), + UNVERSIONED("unversioned", "unversion"), + + /** + * @since 1.6 + */ + ADDED("add", "added"), + + /** + * @since 1.7 + */ + REPLACED("replace", "replaced"), + + /** + * @since 1.8 + */ + MOVED_AWAY("moved-away"), + MOVED_HERE("moved-here"); + + @NotNull private static final Map<String, ConflictReason> ourAllReasons = ContainerUtil.newHashMap(); + + static { + for (ConflictReason reason : ConflictReason.values()) { + register(reason); + } + } + + @NotNull private final String myKey; + @NotNull private final String[] myOtherKeys; + + ConflictReason(@NotNull String key, @NotNull String... otherKeys) { + myKey = key; + myOtherKeys = otherKeys; + } + + @Override + public String toString() { + return myKey; + } + + private static void register(@NotNull ConflictReason reason) { + ourAllReasons.put(reason.myKey, reason); + + for (String key : reason.myOtherKeys) { + ourAllReasons.put(key, reason); + } + } + + @NotNull + public static ConflictReason from(@NotNull String reasonName) { + ConflictReason result = ourAllReasons.get(reasonName); + + if (result == null) { + throw new IllegalArgumentException("Unknown conflict reason " + reasonName); + } + + return result; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictVersion.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictVersion.java new file mode 100644 index 000000000000..cee4cf56ac93 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictVersion.java @@ -0,0 +1,85 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.conflict; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.BaseNodeDescription; +import org.jetbrains.idea.svn.api.NodeKind; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.internal.wc.SVNConflictVersion; + +/** + * @author Konstantin Kolosovsky. + */ +public class ConflictVersion extends BaseNodeDescription { + + private final SVNURL myRepositoryRoot; + private final String myPath; + private final long myPegRevision; + + @Nullable + public static ConflictVersion create(@Nullable SVNConflictVersion conflictVersion) { + ConflictVersion result = null; + + if (conflictVersion != null) { + result = new ConflictVersion(conflictVersion.getRepositoryRoot(), conflictVersion.getPath(), conflictVersion.getPegRevision(), + NodeKind.from(conflictVersion.getKind())); + } + + return result; + } + + public ConflictVersion(SVNURL repositoryRoot, String path, long pegRevision, @NotNull NodeKind kind) { + super(kind); + myRepositoryRoot = repositoryRoot; + myPath = path; + myPegRevision = pegRevision; + } + + public SVNURL getRepositoryRoot() { + return myRepositoryRoot; + } + + public String getPath() { + return myPath; + } + + public long getPegRevision() { + return myPegRevision; + } + + @NotNull + public NodeKind getKind() { + return myKind; + } + + @NotNull + public String toPresentableString() { + StringBuilder urlBuilder = new StringBuilder(); + + urlBuilder.append(myRepositoryRoot != null ? myRepositoryRoot : ""); + urlBuilder.append("/"); + urlBuilder.append(myPath != null ? myPath : "..."); + + return "(" + getKind() + ") " + urlBuilder + "@" + getPegRevision(); + } + + @NotNull + public static String toPresentableString(@Nullable ConflictVersion version) { + return version == null ? "" : version.toPresentableString(); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/SvnKitConflictClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/SvnKitConflictClient.java index b60ea38bd422..80fab5aede64 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/SvnKitConflictClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/SvnKitConflictClient.java @@ -4,7 +4,7 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.SVNConflictChoice; @@ -16,13 +16,13 @@ import java.io.File; public class SvnKitConflictClient extends BaseSvnClient implements ConflictClient { @Override public void resolve(@NotNull File path, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean resolveProperty, boolean resolveContent, boolean resolveTree) throws VcsException { try { myVcs.getSvnKitManager().createWCClient() - .doResolve(path, depth, resolveContent, resolveProperty, resolveTree, SVNConflictChoice.MERGED); + .doResolve(path, toDepth(depth), resolveContent, resolveProperty, resolveTree, SVNConflictChoice.MERGED); } catch (SVNException e) { throw new VcsException(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/TreeConflictDescription.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/TreeConflictDescription.java new file mode 100644 index 000000000000..541b6ae667bc --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/TreeConflictDescription.java @@ -0,0 +1,119 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.conflict; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.BaseNodeDescription; +import org.jetbrains.idea.svn.api.NodeKind; +import org.tmatesoft.svn.core.wc.SVNTreeConflictDescription; + +import java.io.File; + +/** + * @author Konstantin Kolosovsky. + */ +public class TreeConflictDescription extends BaseNodeDescription { + + private final File myPath; + private final ConflictAction myConflictAction; + private final ConflictReason myConflictReason; + + private final ConflictOperation myOperation; + private final ConflictVersion mySourceLeftVersion; + private final ConflictVersion mySourceRightVersion; + + @Nullable + public static TreeConflictDescription create(@Nullable SVNTreeConflictDescription conflict) { + TreeConflictDescription result = null; + + if (conflict != null) { + result = + new TreeConflictDescription(conflict.getPath(), NodeKind.from(conflict.getNodeKind()), + ConflictAction.from(conflict.getConflictAction().getName()), + ConflictReason.from(conflict.getConflictReason().getName()), + ConflictOperation.from(conflict.getOperation().getName()), + ConflictVersion.create(conflict.getSourceLeftVersion()), + ConflictVersion.create(conflict.getSourceRightVersion())); + } + + return result; + } + + public TreeConflictDescription(File path, + @NotNull NodeKind nodeKind, + ConflictAction conflictAction, + ConflictReason conflictReason, + ConflictOperation operation, + ConflictVersion sourceLeftVersion, + ConflictVersion sourceRightVersion) { + super(nodeKind); + myPath = path; + myConflictAction = conflictAction; + myConflictReason = conflictReason; + + myOperation = operation; + mySourceLeftVersion = sourceLeftVersion; + mySourceRightVersion = sourceRightVersion; + } + + // TODO: is*Conflict() methods are not really necessary in any logic - remove them + public boolean isTextConflict() { + return false; + } + + public boolean isPropertyConflict() { + return false; + } + + public boolean isTreeConflict() { + return true; + } + + public File getPath() { + return myPath; + } + + public ConflictAction getConflictAction() { + return myConflictAction; + } + + public ConflictReason getConflictReason() { + return myConflictReason; + } + + @NotNull + public NodeKind getNodeKind() { + return myKind; + } + + public ConflictOperation getOperation() { + return myOperation; + } + + public ConflictVersion getSourceLeftVersion() { + return mySourceLeftVersion; + } + + public ConflictVersion getSourceRightVersion() { + return mySourceRightVersion; + } + + @NotNull + public String toPresentableString() { + return "local " + getConflictReason() + ", incoming " + getConflictAction() + " upon " + getOperation(); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CmdCopyMoveClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CmdCopyMoveClient.java index e73e9fb4013f..6a42a0fcf07e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CmdCopyMoveClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CmdCopyMoveClient.java @@ -6,12 +6,12 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.checkin.CmdCheckinClient; import org.jetbrains.idea.svn.checkin.CommitEventHandler; import org.jetbrains.idea.svn.commandLine.BaseUpdateCommandListener; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -78,7 +78,7 @@ public class CmdCopyMoveClient extends BaseSvnClient implements CopyMoveClient { @NotNull File destination, @Nullable SVNRevision revision, boolean makeParents, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { List<String> parameters = new ArrayList<String>(); CommandUtil.put(parameters, source); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CopyMoveClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CopyMoveClient.java index dd4395f612b6..b4b9ed961e5f 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CopyMoveClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CopyMoveClient.java @@ -3,9 +3,9 @@ package org.jetbrains.idea.svn.copy; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; import org.jetbrains.idea.svn.checkin.CommitEventHandler; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -41,5 +41,5 @@ public interface CopyMoveClient extends SvnClient { @NotNull File destination, @Nullable SVNRevision revision, boolean makeParents, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/SvnKitCopyMoveClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/SvnKitCopyMoveClient.java index 1a46e7ce26b4..7f6f64c9ff17 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/SvnKitCopyMoveClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/SvnKitCopyMoveClient.java @@ -4,11 +4,11 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.checkin.CommitEventHandler; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNCommitInfo; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNCopyClient; import org.tmatesoft.svn.core.wc.SVNCopySource; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -50,7 +50,7 @@ public class SvnKitCopyMoveClient extends BaseSvnClient implements CopyMoveClien final SVNCopySource copySource = createCopySource(source, revision); SVNCopyClient client = myVcs.getSvnKitManager().createCopyClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); SVNCommitInfo info; try { @@ -69,9 +69,9 @@ public class SvnKitCopyMoveClient extends BaseSvnClient implements CopyMoveClien @NotNull File destination, @Nullable SVNRevision revision, boolean makeParents, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { SVNCopyClient client = myVcs.getSvnKitManager().createCopyClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); try { client.doCopy(new SVNCopySource[]{createCopySource(source, revision)}, destination, false, makeParents, true); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/CmdDeleteClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/CmdDeleteClient.java index dfd6d72cc0f9..9d1d0c082c5b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/CmdDeleteClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/CmdDeleteClient.java @@ -5,12 +5,12 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.checkin.CmdCheckinClient; import org.jetbrains.idea.svn.commandLine.BaseUpdateCommandListener; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -23,7 +23,7 @@ import java.util.List; public class CmdDeleteClient extends BaseSvnClient implements DeleteClient { @Override - public void delete(@NotNull File path, boolean force, boolean dryRun, @Nullable ISVNEventHandler handler) throws VcsException { + public void delete(@NotNull File path, boolean force, boolean dryRun, @Nullable ProgressTracker handler) throws VcsException { // TODO: no actual support for dryRun in 'svn delete', SvnKit performs certain validation on file status and svn:externals property // TODO: probably add some widespread checks for dryRun delete - but most likely this should be placed upper - in merge logic if (!dryRun) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/DeleteClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/DeleteClient.java index ec6f01481d44..a60935436bf8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/DeleteClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/DeleteClient.java @@ -3,9 +3,9 @@ package org.jetbrains.idea.svn.delete; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import java.io.File; @@ -14,7 +14,7 @@ import java.io.File; */ public interface DeleteClient extends SvnClient { - void delete(@NotNull File path, boolean force, boolean dryRun, @Nullable ISVNEventHandler handler) throws VcsException; + void delete(@NotNull File path, boolean force, boolean dryRun, @Nullable ProgressTracker handler) throws VcsException; long delete(@NotNull SVNURL url, @NotNull String message) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/SvnKitDeleteClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/SvnKitDeleteClient.java index 7e67b1770009..c2cdb42e17dd 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/SvnKitDeleteClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/SvnKitDeleteClient.java @@ -4,11 +4,11 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNCommitInfo; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -19,9 +19,9 @@ import java.io.File; public class SvnKitDeleteClient extends BaseSvnClient implements DeleteClient { @Override - public void delete(@NotNull File path, boolean force, boolean dryRun, @Nullable ISVNEventHandler handler) throws VcsException { + public void delete(@NotNull File path, boolean force, boolean dryRun, @Nullable ProgressTracker handler) throws VcsException { SVNWCClient client = myVcs.getSvnKitManager().createWCClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); try { client.doDelete(path, force, dryRun); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/BranchMerger.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/BranchMerger.java index 463ed6ec01ba..4dfcf57b8049 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/BranchMerger.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/BranchMerger.java @@ -21,13 +21,14 @@ import com.intellij.util.Consumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.jetbrains.idea.svn.integrate.IMerger; import org.jetbrains.idea.svn.integrate.MergeClient; import org.jetbrains.idea.svn.update.UpdateEventHandler; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -81,12 +82,13 @@ public class BranchMerger implements IMerger { client.merge(SvnTarget.fromURL(mySourceUrl), destination, false, createDiffOptions(), myHandler); } else { client.merge(SvnTarget.fromURL(mySourceUrl, SVNRevision.create(mySourceCopyRevision)), - SvnTarget.fromURL(mySourceUrl, mySourceLatestRevision), destination, SVNDepth.INFINITY, true, false, false, true, + SvnTarget.fromURL(mySourceUrl, mySourceLatestRevision), destination, Depth.INFINITY, true, false, false, true, createDiffOptions(), myHandler); } } - private SVNDiffOptions createDiffOptions() { + @NotNull + private DiffOptions createDiffOptions() { return myVcs.getSvnConfiguration().getMergeOptions(); } @@ -110,7 +112,7 @@ public class BranchMerger implements IMerger { try { result = SvnUtil.getHeadRevision(myVcs, mySourceUrl); } - catch (SVNException e) { + catch (SvnBindException e) { LOG.info(e); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java index 37dd5a5230f4..9ca5b89d517a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java @@ -47,10 +47,10 @@ import org.jetbrains.idea.svn.*; import org.jetbrains.idea.svn.actions.CleanupWorker; import org.jetbrains.idea.svn.actions.SelectBranchPopup; import org.jetbrains.idea.svn.api.ClientFactory; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.branchConfig.SvnBranchConfigurationNew; import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider; import org.jetbrains.idea.svn.integrate.QuickMergeInteractionImpl; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -228,7 +228,7 @@ public class CopiesPanel { if (result == Messages.OK) { // update of view will be triggered by roots changed event SvnCheckoutProvider.checkout(myVcs.getProject(), new File(wcInfo.getPath()), wcInfo.getRootUrl(), SVNRevision.HEAD, - SVNDepth.INFINITY, false, null, wcInfo.getFormat()); + Depth.INFINITY, false, null, wcInfo.getFormat()); } } else if (CHANGE_FORMAT.equals(e.getDescription())) { changeFormat(wcInfo, upgradeFormats); @@ -296,7 +296,7 @@ public class CopiesPanel { sb.append("<tr valign=\"top\"><td>Format:</td><td colspan=\"2\">").append(info.getFormat().getName()).append("</td></tr>"); } - if (!SVNDepth.INFINITY.equals(info.getStickyDepth()) && !info.hasError()) { + if (!Depth.INFINITY.equals(info.getStickyDepth()) && !info.hasError()) { // can fix sb.append("<tr valign=\"top\"><td>Depth:</td><td>").append(info.getStickyDepth().getName()).append("</td><td><a href=\""). append(FIX_DEPTH).append("\">Fix</a></td></tr>"); @@ -312,7 +312,7 @@ public class CopiesPanel { sb.append("<tr valign=\"top\"><td colspan=\"3\"><i>").append("Working copy root</i></td></tr>"); } if (!info.hasError()) { - if (WorkingCopyFormat.ONE_DOT_SEVEN.equals(info.getFormat()) || WorkingCopyFormat.ONE_DOT_EIGHT.equals(info.getFormat())) { + if (info.getFormat().isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN)) { sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"").append(CLEANUP).append("\">Cleanup</a></td></tr>"); } sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"").append(CONFIGURE_BRANCHES).append("\">Configure Branches</a></td></tr>"); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CreateBranchOrTagDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CreateBranchOrTagDialog.java index 9c5d19420399..a09de54fdbc4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CreateBranchOrTagDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CreateBranchOrTagDialog.java @@ -37,10 +37,10 @@ import org.jetbrains.idea.svn.SvnBranchConfigurationManager; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.branchConfig.SvnBranchConfigurationNew; +import org.jetbrains.idea.svn.info.Info; import org.jetbrains.idea.svn.update.SvnRevisionPanel; import org.tmatesoft.svn.core.internal.util.SVNEncodingUtil; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import javax.swing.*; @@ -264,7 +264,7 @@ public class CreateBranchOrTagDialog extends DialogWrapper { super.init(); SvnVcs vcs = SvnVcs.getInstance(myProject); String revStr = ""; - SVNInfo info = vcs.getInfo(mySrcFile); + Info info = vcs.getInfo(mySrcFile); if (info != null) { mySrcURL = info.getURL() == null ? null : info.getURL().toString(); revStr = String.valueOf(info.getRevision()); @@ -349,7 +349,7 @@ public class CreateBranchOrTagDialog extends DialogWrapper { return true; } else if (myWorkingCopyRadioButton.isSelected()) { - SVNInfo info = SvnVcs.getInstance(myProject).getInfo(mySrcFile); + Info info = SvnVcs.getInstance(myProject).getInfo(mySrcFile); String srcUrl = info != null && info.getURL() != null ? info.getURL().toString() : null; if (srcUrl == null) { myErrorLabel.setText(SvnBundle.message("create.branch.no.working.copy.error", myWorkingCopyField.getText())); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/LoadRecentBranchRevisions.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/LoadRecentBranchRevisions.java index 5748aa59280e..b71082390a55 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/LoadRecentBranchRevisions.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/LoadRecentBranchRevisions.java @@ -27,12 +27,8 @@ import com.intellij.util.continuation.TaskDescriptor; import com.intellij.util.continuation.Where; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; -import org.jetbrains.idea.svn.history.SvnChangeList; -import org.jetbrains.idea.svn.history.SvnCommittedChangesProvider; -import org.jetbrains.idea.svn.history.SvnRepositoryLocation; -import org.jetbrains.idea.svn.history.TreeStructureNode; +import org.jetbrains.idea.svn.history.*; import org.jetbrains.idea.svn.mergeinfo.OneShotMergeInfoHelper; -import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import java.util.ArrayList; @@ -94,12 +90,12 @@ public class LoadRecentBranchRevisions extends TaskDescriptor { ProgressManager.progress2( SvnBundle.message("progress.text2.collecting.history", myMergeContext.getSourceUrl() + (myFirst > 0 ? ("@" + myFirst) : ""))); - final List<Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>> list = new ArrayList<Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>>(); + final List<Pair<SvnChangeList, LogHierarchyNode>> list = new ArrayList<Pair<SvnChangeList, LogHierarchyNode>>(); try { committedChangesProvider.getCommittedChangesWithMergedRevisons(settings, new SvnRepositoryLocation(myMergeContext.getSourceUrl()), myBunchSize + (myFirst > 0 ? 2 : 1), - new PairConsumer<SvnChangeList, TreeStructureNode<SVNLogEntry>>() { - public void consume(SvnChangeList svnList, TreeStructureNode<SVNLogEntry> tree) { + new PairConsumer<SvnChangeList, LogHierarchyNode>() { + public void consume(SvnChangeList svnList, LogHierarchyNode tree) { indicator.setText2(SvnBundle.message("progress.text2.processing.revision", svnList.getNumber())); list.add(Pair.create(svnList, tree)); } @@ -109,7 +105,7 @@ public class LoadRecentBranchRevisions extends TaskDescriptor { return; } myCommittedChangeLists = new ArrayList<CommittedChangeList>(); - for (Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>> pair : list) { + for (Pair<SvnChangeList, LogHierarchyNode> pair : list) { // do not take first since it's equal if (myFirst > 0 && myFirst == pair.getFirst().getNumber()) continue; // TODO: Currently path filtering with QuickMerge.checkListForPaths is not applied as it removes some necessary revisions diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/PropertiesComponent.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/PropertiesComponent.java index 81116e669870..860c524ed591 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/PropertiesComponent.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/PropertiesComponent.java @@ -36,6 +36,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnPropertyKeys; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.ISVNPropertyHandler; import org.tmatesoft.svn.core.wc.SVNPropertyData; @@ -166,7 +167,7 @@ public class PropertiesComponent extends JPanel { public void handleProperty(long revision, SVNPropertyData property) throws SVNException { } }; - vcs.getFactory(file).createPropertyClient().list(SvnTarget.fromFile(file, SVNRevision.UNDEFINED), SVNRevision.WORKING, SVNDepth.EMPTY, + vcs.getFactory(file).createPropertyClient().list(SvnTarget.fromFile(file, SVNRevision.UNDEFINED), SVNRevision.WORKING, Depth.EMPTY, handler); } catch (VcsException e) { @@ -272,7 +273,7 @@ public class PropertiesComponent extends JPanel { try { myVcs.getFactory(myFile).createPropertyClient() .setProperty(myFile, property, value != null ? SVNPropertyValue.create(value) : null, - SVNDepth.getInfinityOrEmptyDepth(recursive), force); + Depth.allOrEmpty(recursive), force); } catch (VcsException error) { VcsBalloonProblemNotifier diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserComponent.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserComponent.java index 78acfe32cf53..0fd1f06bf7cb 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserComponent.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserComponent.java @@ -18,7 +18,6 @@ package org.jetbrains.idea.svn.dialogs; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataProvider; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.project.Project; @@ -37,11 +36,10 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import org.jetbrains.idea.svn.dialogs.browserCache.Expander; import org.jetbrains.idea.svn.history.SvnFileRevision; -import org.tmatesoft.svn.core.SVNDirEntry; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -152,7 +150,7 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da } @Nullable - public SVNDirEntry getSelectedEntry() { + public DirectoryEntry getSelectedEntry() { TreePath selection = myRepositoryTree.getSelectionPath(); if (selection == null) { return null; @@ -241,8 +239,8 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da final RepositoryTreeNode node = getSelectedNode(); if (node == null) return null; - SVNDirEntry entry = node.getSVNDirEntry(); - if (entry == null || entry.getKind() != SVNNodeKind.FILE) { + DirectoryEntry entry = node.getSVNDirEntry(); + if (entry == null || !entry.isFile()) { return null; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java index 5fe19963cf93..191acf387b86 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java @@ -53,6 +53,7 @@ import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.actions.BrowseRepositoryAction; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.dialogs.browser.*; @@ -60,7 +61,9 @@ import org.jetbrains.idea.svn.dialogs.browserCache.Expander; import org.jetbrains.idea.svn.dialogs.browserCache.KeepingExpandedExpander; import org.jetbrains.idea.svn.dialogs.browserCache.SyntheticWorker; import org.jetbrains.idea.svn.history.SvnRepositoryLocation; -import org.tmatesoft.svn.core.*; +import org.tmatesoft.svn.core.SVNErrorCode; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -345,8 +348,8 @@ public class RepositoryBrowserDialog extends DialogWrapper { if (node == null) { return; } - boolean isDirectory = node.getUserObject() instanceof SVNURL || - (node.getSVNDirEntry() != null && node.getSVNDirEntry().getKind() == SVNNodeKind.DIR); + boolean isDirectory = + node.getUserObject() instanceof SVNURL || (node.getSVNDirEntry() != null && node.getSVNDirEntry().isDirectory()); String url = node.getURL().toDecodedString(); AbstractVcsHelper.getInstance(myProject) @@ -500,14 +503,8 @@ public class RepositoryBrowserDialog extends DialogWrapper { } public void update(AnActionEvent e) { - RepositoryTreeNode node = myBrowserComponent.getSelectedNode(); //e.getPresentation().setText(SvnBundle.message("repository.browser.new.folder.action"), true); - if (node != null) { - SVNDirEntry entry = node.getSVNDirEntry(); - e.getPresentation().setEnabled(entry == null || entry.getKind() == SVNNodeKind.DIR); - } else { - e.getPresentation().setEnabled(false); - } + setEnabled(e, myBrowserComponent.getSelectedNode()); } public void actionPerformed(AnActionEvent e) { @@ -537,14 +534,8 @@ public class RepositoryBrowserDialog extends DialogWrapper { protected class DiffAction extends AnAction { public void update(AnActionEvent e) { - RepositoryTreeNode node = getRepositoryBrowser().getSelectedNode(); e.getPresentation().setText("Compare With...", true); - if (node != null) { - SVNDirEntry entry = node.getSVNDirEntry(); - e.getPresentation().setEnabled(entry == null || entry.getKind() == SVNNodeKind.DIR); - } else { - e.getPresentation().setEnabled(false); - } + setEnabled(e, getRepositoryBrowser().getSelectedNode()); } public void actionPerformed(AnActionEvent e) { @@ -854,14 +845,8 @@ public class RepositoryBrowserDialog extends DialogWrapper { public void update(AnActionEvent e) { e.getPresentation().setVisible(showImportAction()); e.getPresentation().setText(SvnBundle.message("repository.browser.import.action")); - RepositoryTreeNode node = getRepositoryBrowser().getSelectedNode(); - final boolean running = ProjectLevelVcsManager.getInstance(myProject).isBackgroundVcsOperationRunning(); - if (node != null) { - SVNDirEntry entry = node.getSVNDirEntry(); - e.getPresentation().setEnabled((entry == null || entry.getKind() == SVNNodeKind.DIR) && (! running)); - } else { - e.getPresentation().setEnabled(false); - } + setEnabled(e, getRepositoryBrowser().getSelectedNode(), + ProjectLevelVcsManager.getInstance(myProject).isBackgroundVcsOperationRunning()); } public void actionPerformed(AnActionEvent e) { @@ -897,13 +882,7 @@ public class RepositoryBrowserDialog extends DialogWrapper { protected class CheckoutAction extends AnAction { public void update(AnActionEvent e) { e.getPresentation().setText("_Checkout...", true); - RepositoryTreeNode node = getRepositoryBrowser().getSelectedNode(); - if (node != null) { - SVNDirEntry entry = node.getSVNDirEntry(); - e.getPresentation().setEnabled(entry == null || entry.getKind() == SVNNodeKind.DIR); - } else { - e.getPresentation().setEnabled(false); - } + setEnabled(e, getRepositoryBrowser().getSelectedNode()); } public void actionPerformed(AnActionEvent e) { final RepositoryTreeNode selectedNode = getSelectedNode(); @@ -914,6 +893,14 @@ public class RepositoryBrowserDialog extends DialogWrapper { } } + private static void setEnabled(@NotNull AnActionEvent e, @Nullable RepositoryTreeNode node) { + setEnabled(e, node, false); + } + + private static void setEnabled(@NotNull AnActionEvent e, @Nullable RepositoryTreeNode node, boolean isRunning) { + e.getPresentation().setEnabled(node != null && (node.getSVNDirEntry() == null || node.getSVNDirEntry().isDirectory()) && !isRunning); + } + protected class BrowseChangesAction extends AnAction { public BrowseChangesAction() { super(SvnBundle.message("repository.browser.browse.changes.action"), @@ -1051,14 +1038,14 @@ public class RepositoryBrowserDialog extends DialogWrapper { SVNURL url = selectedNode.getURL(); String relativePath = ""; - final SVNDirEntry dirEntry = selectedNode.getSVNDirEntry(); - if (dirEntry != null) { - if (dirEntry.getRepositoryRoot() != null) { - if (! dirEntry.getRepositoryRoot().equals(url)) { - relativePath = SVNPathUtil.getRelativePath(dirEntry.getRepositoryRoot().toString(), url.toDecodedString()); + final DirectoryEntry entry = selectedNode.getSVNDirEntry(); + if (entry != null) { + if (entry.getRepositoryRoot() != null) { + if (! entry.getRepositoryRoot().equals(url)) { + relativePath = SVNPathUtil.getRelativePath(entry.getRepositoryRoot().toString(), url.toDecodedString()); } } else { - relativePath = dirEntry.getRelativePath(); + relativePath = entry.getRelativePath(); } } else { relativePath = url.getPath(); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryTreeNode.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryTreeNode.java index d3ef02da19c6..f21ca1735ff4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryTreeNode.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryTreeNode.java @@ -21,11 +21,9 @@ import com.intellij.util.NotNullFunction; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import org.jetbrains.idea.svn.dialogs.browserCache.Expander; import org.jetbrains.idea.svn.dialogs.browserCache.NodeLoadState; -import org.tmatesoft.svn.core.SVNDirEntry; -import org.tmatesoft.svn.core.SVNErrorMessage; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; @@ -89,7 +87,7 @@ public class RepositoryTreeNode implements TreeNode, Disposable { } public boolean isLeaf() { - return myUserObject instanceof SVNDirEntry ? ((SVNDirEntry) myUserObject).getKind() == SVNNodeKind.FILE : false; + return myUserObject instanceof DirectoryEntry && ((DirectoryEntry)myUserObject).isFile(); } public TreeNode getParent() { @@ -146,9 +144,9 @@ public class RepositoryTreeNode implements TreeNode, Disposable { } @Nullable - public SVNDirEntry getSVNDirEntry() { - if (myUserObject instanceof SVNDirEntry) { - return (SVNDirEntry) myUserObject; + public DirectoryEntry getSVNDirEntry() { + if (myUserObject instanceof DirectoryEntry) { + return (DirectoryEntry) myUserObject; } return null; } @@ -161,7 +159,7 @@ public class RepositoryTreeNode implements TreeNode, Disposable { } public boolean isRepositoryRoot() { - return ! (myUserObject instanceof SVNDirEntry); + return ! (myUserObject instanceof DirectoryEntry); } @NotNull @@ -194,13 +192,13 @@ public class RepositoryTreeNode implements TreeNode, Disposable { return myModel.isDisposed(); } - public void setChildren(final List<SVNDirEntry> children, final NodeLoadState state) { + public void setChildren(final List<DirectoryEntry> children, final NodeLoadState state) { final List<TreeNode> nodes = new ArrayList<TreeNode>(); - for (final SVNDirEntry entry : children) { - if (!myModel.isShowFiles() && entry.getKind() != SVNNodeKind.DIR) { + for (final DirectoryEntry entry : children) { + if (!myModel.isShowFiles() && !entry.isDirectory()) { continue; } - nodes.add(new RepositoryTreeNode(myModel, this, entry.getURL(), entry, state)); + nodes.add(new RepositoryTreeNode(myModel, this, entry.getUrl(), entry, state)); } myChildrenLoadState = state; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SelectLocationDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SelectLocationDialog.java index 10bfc0971cc9..a6ca6ad54f11 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SelectLocationDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SelectLocationDialog.java @@ -28,8 +28,8 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.dialogs.browser.UrlOpeningExpander; -import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNEncodingUtil; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; @@ -79,7 +79,7 @@ public class SelectLocationDialog extends DialogWrapper { boolean showFiles, String errorMessage) { try { - SVNURL svnUrl = SVNURL.parseURIEncoded(url); + SVNURL svnUrl = SvnUtil.createUrl(url); final SVNURL repositoryUrl = initRoot(project, svnUrl); if (repositoryUrl == null) { Messages.showErrorDialog(project, "Can not detect repository root for URL: " + url, @@ -91,7 +91,7 @@ public class SelectLocationDialog extends DialogWrapper { dialog.show(); return dialog; } - catch (SVNException e) { + catch (SvnBindException e) { Messages.showErrorDialog(project, errorMessage != null ? errorMessage : e.getMessage(), SvnBundle.message("dialog.title.select.repository.location")); return null; @@ -124,15 +124,15 @@ public class SelectLocationDialog extends DialogWrapper { } @Nullable - private static SVNURL initRoot(final Project project, final SVNURL url) throws SVNException { + private static SVNURL initRoot(final Project project, final SVNURL url) throws SvnBindException { final Ref<SVNURL> result = new Ref<SVNURL>(); - final Ref<SVNException> excRef = new Ref<SVNException>(); + final Ref<SvnBindException> excRef = new Ref<SvnBindException>(); ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { public void run() { try { result.set(SvnUtil.getRepositoryRoot(SvnVcs.getInstance(project), url)); - } catch (SVNException e) { + } catch (SvnBindException e) { excRef.set(e); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java index 421f0a0ce138..28375d28b7ba 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java @@ -27,8 +27,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnPropertyKeys; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.properties.PropertyClient; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.ISVNPropertyHandler; @@ -221,7 +221,7 @@ public class SetPropertyDialog extends DialogWrapper { }; PropertyClient client = myVCS.getFactory(file).createPropertyClient(); - client.list(SvnTarget.fromFile(file, SVNRevision.WORKING), SVNRevision.WORKING, SVNDepth.EMPTY, handler); + client.list(SvnTarget.fromFile(file, SVNRevision.WORKING), SVNRevision.WORKING, Depth.EMPTY, handler); } catch (VcsException e) { LOG.info(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnFormatWorker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnFormatWorker.java index 8e99055ef94d..bfdadef54cc8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnFormatWorker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnFormatWorker.java @@ -33,11 +33,11 @@ import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.api.ClientFactory; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNCancelException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; import java.io.File; import java.util.ArrayList; @@ -111,7 +111,7 @@ public class SvnFormatWorker extends Task.Backgroundable { String cleanupMessage = SvnBundle.message("action.Subversion.cleanup.progress.text", path.getAbsolutePath()); String upgradeMessage = SvnBundle.message("action.change.wcopy.format.task.progress.text", path.getAbsolutePath(), wcInfo.getFormat(), myNewFormat); - ISVNEventHandler handler = createUpgradeHandler(indicator, cleanupMessage, upgradeMessage); + ProgressTracker handler = createUpgradeHandler(indicator, cleanupMessage, upgradeMessage); getFactory(path, myNewFormat).createUpgradeClient().upgrade(path, myNewFormat, handler); } catch (Throwable e) { @@ -155,22 +155,22 @@ public class SvnFormatWorker extends Task.Backgroundable { return result; } - private static ISVNEventHandler createUpgradeHandler(@NotNull final ProgressIndicator indicator, + private static ProgressTracker createUpgradeHandler(@NotNull final ProgressIndicator indicator, @NotNull final String cleanupMessage, @NotNull final String upgradeMessage) { - return new ISVNEventHandler() { + return new ProgressTracker() { @Override - public void handleEvent(SVNEvent event, double progress) throws SVNException { + public void consume(ProgressEvent event) throws SVNException { if (event.getFile() != null) { - if (SVNEventAction.UPGRADED_PATH.equals(event.getAction())) { + if (EventAction.UPGRADED_PATH.equals(event.getAction())) { indicator.setText2("Upgraded path " + VcsUtil.getPathForProgressPresentation(event.getFile())); } // fake event indicating cleanup start - if (SVNEventAction.UPDATE_STARTED.equals(event.getAction())) { + if (EventAction.UPDATE_STARTED.equals(event.getAction())) { indicator.setText(cleanupMessage); } // fake event indicating upgrade start - if (SVNEventAction.UPDATE_COMPLETED.equals(event.getAction())) { + if (EventAction.UPDATE_COMPLETED.equals(event.getAction())) { indicator.setText(upgradeMessage); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnRepositoryTreeCellRenderer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnRepositoryTreeCellRenderer.java index 1215be72c18a..6ecd89f82fd7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnRepositoryTreeCellRenderer.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnRepositoryTreeCellRenderer.java @@ -21,9 +21,8 @@ import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.PlatformIcons; import com.intellij.util.text.DateFormatUtil; -import org.tmatesoft.svn.core.SVNDirEntry; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import org.tmatesoft.svn.core.SVNErrorMessage; -import org.tmatesoft.svn.core.SVNNodeKind; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; @@ -44,7 +43,7 @@ public class SvnRepositoryTreeCellRenderer extends ColoredTreeCellRenderer { String name = node.getSVNDirEntry().getName(); append(name, node.isCached() ? SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES); if (myIsShowDetails) { - SVNDirEntry entry = node.getSVNDirEntry(); + DirectoryEntry entry = node.getSVNDirEntry(); append(" " + entry.getRevision(), SimpleTextAttributes.GRAY_ATTRIBUTES); if (entry.getAuthor() != null) { append(" " + entry.getAuthor(), SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES); @@ -53,11 +52,9 @@ public class SvnRepositoryTreeCellRenderer extends ColoredTreeCellRenderer { append(" " + DateFormatUtil.formatPrettyDateTime(entry.getDate()), SimpleTextAttributes.GRAY_ATTRIBUTES); } } - if (node.getSVNDirEntry().getKind() == SVNNodeKind.FILE) { - setIcon(FileTypeManager.getInstance().getFileTypeByFileName(name).getIcon()); - } else { - setIcon(PlatformIcons.DIRECTORY_CLOSED_ICON); - } + setIcon(node.getSVNDirEntry().isFile() + ? FileTypeManager.getInstance().getFileTypeByFileName(name).getIcon() + : PlatformIcons.DIRECTORY_CLOSED_ICON); } } else if (value instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/WCInfo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/WCInfo.java index a75fa4a847db..8fc57db64cdc 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/WCInfo.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/WCInfo.java @@ -20,22 +20,22 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.NestedCopyType; import org.jetbrains.idea.svn.RootUrlInfo; import org.jetbrains.idea.svn.WorkingCopyFormat; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNURL; public class WCInfo implements WCPaths { private final boolean myIsWcRoot; - private final SVNDepth myStickyDepth; + private final Depth myStickyDepth; @NotNull private final RootUrlInfo myRootInfo; - public WCInfo(@NotNull RootUrlInfo rootInfo, boolean isWcRoot, SVNDepth stickyDepth) { + public WCInfo(@NotNull RootUrlInfo rootInfo, boolean isWcRoot, Depth stickyDepth) { myRootInfo = rootInfo; myIsWcRoot = isWcRoot; myStickyDepth = stickyDepth; } - public SVNDepth getStickyDepth() { + public Depth getStickyDepth() { return myStickyDepth; } @@ -70,7 +70,7 @@ public class WCInfo implements WCPaths { public String getErrorMessage() { @SuppressWarnings("ThrowableResultOfMethodCallIgnored") - SVNException error = getRootInfo().getNode().getError(); + SvnBindException error = getRootInfo().getNode().getError(); return error != null ? error.getMessage() : ""; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/CheckoutOptionsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/CheckoutOptionsDialog.java index b5c3782d3cdc..e42fdd5d1585 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/CheckoutOptionsDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/CheckoutOptionsDialog.java @@ -30,9 +30,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.DepthCombo; import org.jetbrains.idea.svn.SvnBundle; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.revision.SvnSelectRevisionPanel; import org.jetbrains.idea.svn.update.SvnRevisionPanel; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -147,7 +147,7 @@ public class CheckoutOptionsDialog extends DialogWrapper { return (objects == null) || (objects.length != 1) ? null : (File) objects[0]; } - public SVNDepth getDepth() { + public Depth getDepth() { return myDepthCombo.getDepth(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ExportOptionsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ExportOptionsDialog.java index 38aff96752bb..7f6de72703f2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ExportOptionsDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ExportOptionsDialog.java @@ -26,7 +26,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.DepthCombo; import org.jetbrains.idea.svn.SvnBundle; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.SVNURL; import javax.swing.*; @@ -64,7 +64,7 @@ public class ExportOptionsDialog extends DialogWrapper implements ActionListener return new File(myPathField.getText()); } - public SVNDepth getDepth() { + public Depth getDepth() { return myDepth.getDepth(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ImportOptionsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ImportOptionsDialog.java index aba7cf7a09d3..0694247fd542 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ImportOptionsDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ImportOptionsDialog.java @@ -29,7 +29,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.DepthCombo; import org.jetbrains.idea.svn.SvnBundle; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.SVNURL; import javax.swing.*; @@ -68,7 +68,7 @@ public class ImportOptionsDialog extends DialogWrapper implements ActionListener return new File(myPathField.getText()); } - public SVNDepth getDepth() { + public Depth getDepth() { return myDepth.getDepth(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/CacheLoader.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/CacheLoader.java index 07d2d607de91..d80efb97a123 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/CacheLoader.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/CacheLoader.java @@ -16,9 +16,8 @@ package org.jetbrains.idea.svn.dialogs.browserCache; import com.intellij.openapi.components.ServiceManager; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import org.jetbrains.idea.svn.dialogs.RepositoryTreeNode; -import org.tmatesoft.svn.core.SVNDirEntry; -import org.tmatesoft.svn.core.SVNErrorMessage; import javax.swing.*; import java.util.List; @@ -40,7 +39,7 @@ public class CacheLoader extends Loader { public void run() { final String nodeUrl = node.getURL().toString(); - final List<SVNDirEntry> cached = myCache.getChildren(nodeUrl); + final List<DirectoryEntry> cached = myCache.getChildren(nodeUrl); if (cached != null) { refreshNode(node, cached, expander); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/Loader.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/Loader.java index 774b07187b98..ab2b6ddb67f3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/Loader.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/Loader.java @@ -15,9 +15,8 @@ */ package org.jetbrains.idea.svn.dialogs.browserCache; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import org.jetbrains.idea.svn.dialogs.RepositoryTreeNode; -import org.tmatesoft.svn.core.SVNDirEntry; -import org.tmatesoft.svn.core.SVNErrorMessage; import java.util.List; @@ -47,7 +46,7 @@ public abstract class Loader { existingNode.setErrorNode(text, getNodeLoadState()); } - protected void refreshNode(final RepositoryTreeNode node, final List<SVNDirEntry> data, final Expander expander) { + protected void refreshNode(final RepositoryTreeNode node, final List<DirectoryEntry> data, final Expander expander) { if (node.isDisposed()) { return; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/RepositoryLoader.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/RepositoryLoader.java index 4c9fc92751e5..319699cfc1b8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/RepositoryLoader.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/RepositoryLoader.java @@ -23,7 +23,10 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.auth.SvnAuthenticationProvider; +import org.jetbrains.idea.svn.browse.DirectoryEntry; +import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer; import org.jetbrains.idea.svn.dialogs.RepositoryTreeNode; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -56,7 +59,7 @@ class RepositoryLoader extends Loader { } } - private void setResults(final Pair<RepositoryTreeNode, Expander> data, final List<SVNDirEntry> children) { + private void setResults(final Pair<RepositoryTreeNode, Expander> data, final List<DirectoryEntry> children) { myCache.put(data.first.getURL().toString(), children); refreshNode(data.first, children, data.second); } @@ -114,19 +117,21 @@ class RepositoryLoader extends Loader { } public void run() { - final Collection<SVNDirEntry> entries = new TreeSet<SVNDirEntry>(); + final Collection<DirectoryEntry> entries = new TreeSet<DirectoryEntry>(); final RepositoryTreeNode node = myData.first; final SvnVcs vcs = node.getVcs(); SvnAuthenticationProvider.forceInteractive(); - ISVNDirEntryHandler handler = new ISVNDirEntryHandler() { - public void handleDirEntry(final SVNDirEntry dirEntry) throws SVNException { - entries.add(dirEntry); + DirectoryEntryConsumer handler = new DirectoryEntryConsumer() { + + @Override + public void consume(final DirectoryEntry entry) throws SVNException { + entries.add(entry); } }; try { SvnTarget target = SvnTarget.fromURL(node.getURL()); - vcs.getFactoryFromSettings().createBrowseClient().list(target, SVNRevision.HEAD, SVNDepth.IMMEDIATES, handler); + vcs.getFactoryFromSettings().createBrowseClient().list(target, SVNRevision.HEAD, Depth.IMMEDIATES, handler); } catch (final VcsException e) { SwingUtilities.invokeLater(new Runnable() { @@ -142,7 +147,7 @@ class RepositoryLoader extends Loader { SwingUtilities.invokeLater(new Runnable() { public void run() { - setResults(myData, new ArrayList<SVNDirEntry>(entries)); + setResults(myData, new ArrayList<DirectoryEntry>(entries)); startNext(); } }); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SvnRepositoryCache.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SvnRepositoryCache.java index b615abbce8ea..d038dc127b90 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SvnRepositoryCache.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SvnRepositoryCache.java @@ -18,15 +18,14 @@ package org.jetbrains.idea.svn.dialogs.browserCache; import com.intellij.openapi.components.ServiceManager; import com.intellij.util.containers.SoftHashMap; import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.SVNDirEntry; -import org.tmatesoft.svn.core.SVNErrorMessage; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import java.util.Iterator; import java.util.List; import java.util.Map; public class SvnRepositoryCache { - private final Map<String, List<SVNDirEntry>> myMap; + private final Map<String, List<DirectoryEntry>> myMap; private final Map<String, String> myErrorsMap; public static SvnRepositoryCache getInstance() { @@ -34,12 +33,12 @@ public class SvnRepositoryCache { } private SvnRepositoryCache() { - myMap = new SoftHashMap<String, List<SVNDirEntry>>(); + myMap = new SoftHashMap<String, List<DirectoryEntry>>(); myErrorsMap = new SoftHashMap<String, String>(); } @Nullable - public List<SVNDirEntry> getChildren(final String parent) { + public List<DirectoryEntry> getChildren(final String parent) { return myMap.get(parent); } @@ -53,7 +52,7 @@ public class SvnRepositoryCache { myErrorsMap.put(parent, error); } - public void put(final String parent, List<SVNDirEntry> children) { + public void put(final String parent, List<DirectoryEntry> children) { myErrorsMap.remove(parent); myMap.put(parent, children); } @@ -64,8 +63,8 @@ public class SvnRepositoryCache { } public void clear(final String repositoryRootUrl) { - for (Iterator<Map.Entry<String, List<SVNDirEntry>>> iterator = myMap.entrySet().iterator(); iterator.hasNext();) { - final Map.Entry<String, List<SVNDirEntry>> entry = iterator.next(); + for (Iterator<Map.Entry<String, List<DirectoryEntry>>> iterator = myMap.entrySet().iterator(); iterator.hasNext();) { + final Map.Entry<String, List<DirectoryEntry>> entry = iterator.next(); if (entry.getKey().startsWith(repositoryRootUrl)) { iterator.remove(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SyntheticWorker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SyntheticWorker.java index 5ee07d8db8fe..5d7c3c3c55c7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SyntheticWorker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SyntheticWorker.java @@ -17,12 +17,12 @@ package org.jetbrains.idea.svn.dialogs.browserCache; import com.intellij.util.NotNullFunction; import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.browse.DirectoryEntry; +import org.jetbrains.idea.svn.checkin.CommitInfo; import org.jetbrains.idea.svn.dialogs.RepositoryTreeNode; -import org.tmatesoft.svn.core.SVNDirEntry; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNRevision; import java.util.*; @@ -44,13 +44,13 @@ public class SyntheticWorker { return; } - final List<SVNDirEntry> children = myCache.getChildren(parentUrl); + final List<DirectoryEntry> children = myCache.getChildren(parentUrl); if (children == null) { return; } - for (Iterator<SVNDirEntry> iterator = children.iterator(); iterator.hasNext();) { - final SVNDirEntry entry = iterator.next(); - if (myUrl.equals(entry.getURL())) { + for (Iterator<DirectoryEntry> iterator = children.iterator(); iterator.hasNext(); ) { + final DirectoryEntry entry = iterator.next(); + if (myUrl.equals(entry.getUrl())) { iterator.remove(); } } @@ -60,21 +60,14 @@ public class SyntheticWorker { public void addSyntheticChildToSelf(final SVNURL newUrl, final SVNURL repositoryUrl, final String name, final boolean isDir) { final String currentUrlAsString = myUrl.toString(); - final List<SVNDirEntry> children = myCache.getChildren(currentUrlAsString); + final List<DirectoryEntry> children = myCache.getChildren(currentUrlAsString); if (children == null) { return; } children.add(createSyntheticEntry(newUrl, repositoryUrl, name, isDir)); - Collections.sort(children, new Comparator<SVNDirEntry>() { - public int compare(final SVNDirEntry o1, final SVNDirEntry o2) { - final boolean dirStatus = SVNNodeKind.DIR.equals(o1.getKind()) ^ SVNNodeKind.DIR.equals(o1.getKind()); - if (dirStatus) { - return SVNNodeKind.DIR.equals(o1.getKind()) ? -1 : 1; - } - return o1.toString().compareTo(o2.toString()); - } - }); + // TODO: Seems that just Set instead of List could be used in cache - so no sort() after add() will be required + Collections.sort(children); myCache.put(currentUrlAsString, children); } @@ -91,8 +84,8 @@ public class SyntheticWorker { node.doOnSubtree(new Remover()); } - public static SVNDirEntry createSyntheticEntry(final SVNURL newUrl, final SVNURL repositoryUrl, final String name, final boolean isDir) { - return new SVNDirEntry(newUrl, repositoryUrl, name, isDir ? SVNNodeKind.DIR : SVNNodeKind.FILE, 0, false, SVNRevision.UNDEFINED.getNumber(), null, null); + public static DirectoryEntry createSyntheticEntry(final SVNURL newUrl, final SVNURL repositoryUrl, final String name, final boolean isDir) { + return new DirectoryEntry(newUrl, repositoryUrl, name, NodeKind.from(isDir), CommitInfo.EMPTY, null); } private static class Remover implements NotNullFunction<RepositoryTreeNode, Object> { @@ -116,15 +109,15 @@ public class SyntheticWorker { @NotNull public Object fun(final RepositoryTreeNode repositoryTreeNode) { - final List<SVNDirEntry> children = myCache.getChildren(repositoryTreeNode.getURL().toString()); + final List<DirectoryEntry> children = myCache.getChildren(repositoryTreeNode.getURL().toString()); if (children == null) { return Boolean.FALSE; } - final List<SVNDirEntry> newChildren = new ArrayList<SVNDirEntry>(children.size()); + final List<DirectoryEntry> newChildren = new ArrayList<DirectoryEntry>(children.size()); try { - for (SVNDirEntry child : children) { - newChildren.add(createSyntheticEntry(convertUrl(child.getURL()), child.getRepositoryRoot(), child.getName(), SVNNodeKind.DIR.equals(child.getKind()))); + for (DirectoryEntry child : children) { + newChildren.add(createSyntheticEntry(convertUrl(child.getUrl()), child.getRepositoryRoot(), child.getName(), child.isDirectory())); } myCache.put(convertUrl(repositoryTreeNode.getURL()).toString(), newChildren); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/CmdDiffClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/CmdDiffClient.java index 10890d18cd6d..497134727ee4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/CmdDiffClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/CmdDiffClient.java @@ -30,21 +30,18 @@ import org.jetbrains.idea.svn.SvnStatusConvertor; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.NodeKind; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.commandLine.SvnCommandName; import org.jetbrains.idea.svn.history.SvnRepositoryContentRevision; import org.jetbrains.idea.svn.status.SvnStatusHandler; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import javax.xml.bind.JAXBException; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.*; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; @@ -64,7 +61,7 @@ public class CmdDiffClient extends BaseSvnClient implements DiffClient { assertDirectory(target1); WorkingCopyFormat format = WorkingCopyFormat.from(myFactory.createVersionClient().getVersion()); - if (!format.isOrGreater(WorkingCopyFormat.ONE_DOT_EIGHT)) { + if (format.less(WorkingCopyFormat.ONE_DOT_EIGHT)) { throw new SvnBindException("Could not compare local file and remote url with executable for svn " + format); } } @@ -104,8 +101,8 @@ public class CmdDiffClient extends BaseSvnClient implements DiffClient { DiffInfo diffInfo = CommandUtil.parse(executor.getOutput(), DiffInfo.class); List<Change> result = ContainerUtil.newArrayList(); - if (diffInfo != null && diffInfo.paths != null) { - for (DiffPath path : diffInfo.paths.diffPaths) { + if (diffInfo != null) { + for (DiffPath path : diffInfo.diffPaths) { result.add(createChange(target1, target2, path)); } } @@ -194,20 +191,15 @@ public class CmdDiffClient extends BaseSvnClient implements DiffClient { @XmlRootElement(name = "diff") public static class DiffInfo { - @XmlElement(name = "paths") - public DiffPaths paths; - } - - public static class DiffPaths { - + @XmlElementWrapper(name = "paths") @XmlElement(name = "path") public List<DiffPath> diffPaths = new ArrayList<DiffPath>(); } public static class DiffPath { - @XmlAttribute(name = "kind") - public String kind; + @XmlAttribute(name = "kind", required = true) + public NodeKind kind; @XmlAttribute(name = "props") public String propertiesStatus; @@ -219,7 +211,7 @@ public class CmdDiffClient extends BaseSvnClient implements DiffClient { public String path; public boolean isDirectory() { - return SVNNodeKind.DIR.equals(SVNNodeKind.parseKind(kind)); + return kind.isDirectory(); } } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DiffOptions.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DiffOptions.java new file mode 100644 index 000000000000..1e44a8389505 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DiffOptions.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.diff; + +/** + * @author Konstantin Kolosovsky. + */ +public class DiffOptions { + + private final boolean myIgnoreAllWhitespace; + private final boolean myIgnoreAmountOfWhitespace; + private final boolean myIgnoreEOLStyle; + + public DiffOptions(boolean ignoreAllWhitespace, boolean ignoreAmountOfWhiteSpace, boolean ignoreEOLStyle) { + myIgnoreAllWhitespace = ignoreAllWhitespace; + myIgnoreAmountOfWhitespace = ignoreAmountOfWhiteSpace; + myIgnoreEOLStyle = ignoreEOLStyle; + } + + public boolean isIgnoreAllWhitespace() { + return myIgnoreAllWhitespace; + } + + public boolean isIgnoreAmountOfWhitespace() { + return myIgnoreAmountOfWhitespace; + } + + public boolean isIgnoreEOLStyle() { + return myIgnoreEOLStyle; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DirectoryWithBranchComparer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DirectoryWithBranchComparer.java index 4d3a09a39e26..0f0e6a714037 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DirectoryWithBranchComparer.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DirectoryWithBranchComparer.java @@ -65,7 +65,7 @@ public class DirectoryWithBranchComparer extends ElementWithBranchComparer { // svn 1.7 command line "--summarize" option for "diff" command does not support comparing working copy directories with repository // directories - that is why command line is only used explicitly for svn 1.8 - return WorkingCopyFormat.ONE_DOT_EIGHT.equals(format) ? myVcs.getCommandLineFactory() : myVcs.getSvnKitFactory(); + return format.isOrGreater(WorkingCopyFormat.ONE_DOT_EIGHT) ? myVcs.getCommandLineFactory() : myVcs.getSvnKitFactory(); } @Override diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/SvnKitDiffClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/SvnKitDiffClient.java index 850fb1b2a295..0a1b14837b7e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/SvnKitDiffClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/SvnKitDiffClient.java @@ -19,10 +19,11 @@ import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.Change; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.idea.svn.SvnProgressCanceller; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.api.BaseSvnClient; import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.svnkit.SvnKitProgressCanceller; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.wc.SVNCancellableEditor; import org.tmatesoft.svn.core.internal.wc.SVNErrorManager; @@ -38,7 +39,6 @@ import org.tmatesoft.svn.core.io.ISVNReporterBaton; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import org.tmatesoft.svn.util.SVNDebugLog; @@ -114,7 +114,7 @@ public class SvnKitDiffClient extends BaseSvnClient implements DiffClient { private Collection<Change> runUrlDiff() throws SVNException { SVNRepository sourceRepository = myVcs.getSvnKitManager().createRepository(myTarget1.getURL()); - sourceRepository.setCanceller(new SvnProgressCanceller()); + sourceRepository.setCanceller(new SvnKitProgressCanceller()); SvnDiffEditor diffEditor; final long rev; SVNRepository targetRepository = null; @@ -123,7 +123,7 @@ public class SvnKitDiffClient extends BaseSvnClient implements DiffClient { // generate Map of path->Change targetRepository = myVcs.getSvnKitManager().createRepository(myTarget2.getURL()); diffEditor = new SvnDiffEditor(sourceRepository, targetRepository, -1, false); - final ISVNEditor cancellableEditor = SVNCancellableEditor.newInstance(diffEditor, new SvnProgressCanceller(), null); + final ISVNEditor cancellableEditor = SVNCancellableEditor.newInstance(diffEditor, new SvnKitProgressCanceller(), null); sourceRepository.diff(myTarget2.getURL(), rev, rev, null, true, true, false, new ISVNReporterBaton() { public void report(ISVNReporter reporter) throws SVNException { reporter.setPath("", null, rev, false); @@ -142,7 +142,7 @@ public class SvnKitDiffClient extends BaseSvnClient implements DiffClient { } private Collection<Change> run17Diff() throws SVNException { - final SVNInfo info1 = myVcs.getInfo(myTarget1.getFile(), SVNRevision.HEAD); + final Info info1 = myVcs.getInfo(myTarget1.getFile(), SVNRevision.HEAD); if (info1 == null) { SVNErrorMessage err = @@ -172,7 +172,7 @@ public class SvnKitDiffClient extends BaseSvnClient implements DiffClient { repository2 = myVcs.getSvnKitManager().createRepository(myTarget2.getURL()); SvnDiffEditor diffEditor = new SvnDiffEditor(myTarget1.getFile(), repository2, rev, true); repository.diff(myTarget2.getURL(), rev, rev, null, true, SVNDepth.INFINITY, false, reporter17, - SVNCancellableEditor.newInstance(diffEditor, new SvnProgressCanceller(), null)); + SVNCancellableEditor.newInstance(diffEditor, new SvnKitProgressCanceller(), null)); return diffEditor.getChangesMap().values(); } @@ -219,7 +219,7 @@ public class SvnKitDiffClient extends BaseSvnClient implements DiffClient { SvnDiffEditor diffEditor = new SvnDiffEditor(target == null ? myTarget1.getFile() : myTarget1.getFile().getParentFile(), repository2, rev, true); repository.diff(myTarget2.getURL(), rev, rev, target, true, true, false, reporter, - SVNCancellableEditor.newInstance(diffEditor, new SvnProgressCanceller(), null)); + SVNCancellableEditor.newInstance(diffEditor, new SvnKitProgressCanceller(), null)); return diffEditor.getChangesMap().values(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java index 3494b9ac9d28..ca934d4a40e4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java @@ -9,19 +9,15 @@ import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.*; +import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import javax.xml.bind.JAXBException; -import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; import java.util.ArrayList; -import java.util.Date; import java.util.List; -import java.util.Map; /** * @author Konstantin Kolosovsky. @@ -37,7 +33,7 @@ public class CmdHistoryClient extends BaseSvnClient implements HistoryClient { boolean includeMergedRevisions, long limit, @Nullable String[] revisionProperties, - @Nullable ISVNLogEntryHandler handler) throws VcsException { + @Nullable LogEntryConsumer handler) throws VcsException { // TODO: add revision properties parameter if necessary List<String> parameters = @@ -54,13 +50,13 @@ public class CmdHistoryClient extends BaseSvnClient implements HistoryClient { } } - private static void parseOutput(@NotNull CommandExecutor command, @Nullable ISVNLogEntryHandler handler) + private static void parseOutput(@NotNull CommandExecutor command, @Nullable LogEntryConsumer handler) throws VcsException, SVNException { try { LogInfo log = CommandUtil.parse(command.getOutput(), LogInfo.class); if (handler != null && log != null) { - for (LogEntry entry : log.entries) { + for (LogEntry.Builder entry : log.entries) { iterateRecursively(entry, handler); } } @@ -70,16 +66,16 @@ public class CmdHistoryClient extends BaseSvnClient implements HistoryClient { } } - private static void iterateRecursively(@NotNull LogEntry entry, @NotNull ISVNLogEntryHandler handler) throws SVNException { - handler.handleLogEntry(entry.toLogEntry()); + private static void iterateRecursively(@NotNull LogEntry.Builder entry, @NotNull LogEntryConsumer handler) throws SVNException { + handler.consume(entry.build()); - for (LogEntry childEntry : entry.childEntries) { + for (LogEntry.Builder childEntry : entry.getChildEntries()) { iterateRecursively(childEntry, handler); } if (entry.hasChildren()) { // empty log entry passed to handler to fully correspond to SVNKit behavior. - handler.handleLogEntry(SVNLogEntry.EMPTY_ENTRY); + handler.consume(LogEntry.EMPTY); } } @@ -109,81 +105,6 @@ public class CmdHistoryClient extends BaseSvnClient implements HistoryClient { public static class LogInfo { @XmlElement(name = "logentry") - public List<LogEntry> entries = new ArrayList<LogEntry>(); - } - - public static class LogEntry { - - @XmlAttribute(name = "revision") - public long revision; - - @XmlElement(name = "author") - public String author; - - @XmlElement(name = "date") - public Date date; - - @XmlElement(name = "msg") - public String message; - - @XmlElement(name = "paths") - public ChangedPaths changedPaths; - - @XmlElement(name = "logentry") - public List<LogEntry> childEntries = new ArrayList<LogEntry>(); - - public boolean hasChildren() { - return !childEntries.isEmpty(); - } - - public SVNLogEntry toLogEntry() { - SVNLogEntry entry = new SVNLogEntry(toChangedPathsMap(), revision, author, date, message); - - entry.setHasChildren(hasChildren()); - - return entry; - } - - public Map<String, SVNLogEntryPath> toChangedPathsMap() { - return changedPaths != null ? changedPaths.toMap() : ContainerUtil.<String, SVNLogEntryPath>newHashMap(); - } - } - - public static class ChangedPaths { - - @XmlElement(name = "path") - public List<ChangedPath> changedPaths = new ArrayList<ChangedPath>(); - - public Map<String, SVNLogEntryPath> toMap() { - Map<String, SVNLogEntryPath> changes = ContainerUtil.newHashMap(); - - for (ChangedPath path : changedPaths) { - changes.put(path.path, path.toLogEntryPath()); - } - - return changes; - } - } - - public static class ChangedPath { - - @XmlAttribute(name = "kind") - public String kind; - - @XmlAttribute(name = "action") - public String action; - - @XmlAttribute(name = "copyfrom-path") - public String copyFromPath; - - @XmlAttribute(name = "copyfrom-rev") - public long copyFromRevision; - - @XmlValue - public String path; - - public SVNLogEntryPath toLogEntryPath() { - return new SVNLogEntryPath(path, CommandUtil.getStatusChar(action), copyFromPath, copyFromRevision); - } + public List<LogEntry.Builder> entries = ContainerUtil.newArrayList(); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/FirstInBranch.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/FirstInBranch.java index f871ee09855a..a075251e7675 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/FirstInBranch.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/FirstInBranch.java @@ -125,7 +125,7 @@ public class FirstInBranch implements Runnable { } } - private static class MyLogEntryHandler implements ISVNLogEntryHandler { + private static class MyLogEntryHandler implements LogEntryConsumer { @NotNull private final SvnPathThroughHistoryCorrection myTrunkCorrector; @NotNull private final SvnPathThroughHistoryCorrection myBranchCorrector; @@ -137,17 +137,18 @@ public class FirstInBranch implements Runnable { myBranchCorrector = new SvnPathThroughHistoryCorrection(branchUrl); } - public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { + @Override + public void consume(LogEntry logEntry) throws SVNException { final Map map = logEntry.getChangedPaths(); checkEntries(logEntry, map); - myTrunkCorrector.handleLogEntry(logEntry); - myBranchCorrector.handleLogEntry(logEntry); + myTrunkCorrector.consume(logEntry); + myBranchCorrector.consume(logEntry); checkEntries(logEntry, map); } - private void checkEntries(SVNLogEntry logEntry, Map map) throws SVNCancelException { + private void checkEntries(LogEntry logEntry, Map map) throws SVNCancelException { for (Object o : map.values()) { - final SVNLogEntryPath path = (SVNLogEntryPath) o; + final LogEntryPath path = (LogEntryPath) o; final String localPath = path.getPath(); final String copyPath = path.getCopyPath(); @@ -159,7 +160,7 @@ public class FirstInBranch implements Runnable { } } - private boolean checkForCopyCase(SVNLogEntry logEntry, SVNLogEntryPath path, String localPath, String copyPath, + private boolean checkForCopyCase(LogEntry logEntry, LogEntryPath path, String localPath, String copyPath, final String trunkUrl, final String branchUrl) { if (equalOrParent(localPath, branchUrl) && equalOrParent(copyPath, trunkUrl)) { myCopyDataConsumer.consume(new CopyData(path.getCopyRevision(), logEntry.getRevision(), true)); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/HistoryClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/HistoryClient.java index d719e755e661..c85eb9e65968 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/HistoryClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/HistoryClient.java @@ -4,7 +4,6 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.ISVNLogEntryHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -21,5 +20,5 @@ public interface HistoryClient extends SvnClient { boolean includeMergedRevisions, long limit, @Nullable String[] revisionProperties, - @Nullable ISVNLogEntryHandler handler) throws VcsException; + @Nullable LogEntryConsumer handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LatestExistentSearcher.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LatestExistentSearcher.java index dc1def418e99..030db0db6ef3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LatestExistentSearcher.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LatestExistentSearcher.java @@ -25,9 +25,10 @@ import org.jetbrains.idea.svn.RootUrlInfo; import org.jetbrains.idea.svn.SvnFileUrlMapping; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.util.SVNURLUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -84,9 +85,6 @@ public class LatestExistentSearcher { myVcs.getFactory(target).createHistoryClient().doLog(target, startRevision, SVNRevision.HEAD, false, true, false, 0, null, createHandler(latest)); } - catch (SVNException e) { - LOG.info(e); - } catch (VcsException e) { LOG.info(e); } @@ -95,12 +93,13 @@ public class LatestExistentSearcher { } @NotNull - private ISVNLogEntryHandler createHandler(@NotNull final Ref<Long> latest) { - return new ISVNLogEntryHandler() { - public void handleLogEntry(final SVNLogEntry logEntry) throws SVNException { + private LogEntryConsumer createHandler(@NotNull final Ref<Long> latest) { + return new LogEntryConsumer() { + @Override + public void consume(final LogEntry logEntry) throws SVNException { final Map changedPaths = logEntry.getChangedPaths(); for (Object o : changedPaths.values()) { - final SVNLogEntryPath path = (SVNLogEntryPath)o; + final LogEntryPath path = (LogEntryPath)o; if ((path.getType() == 'D') && (myRelativeUrl.equals(path.getPath()))) { latest.set(logEntry.getRevision()); throw new SVNException(SVNErrorMessage.UNKNOWN_ERROR_MESSAGE); @@ -125,7 +124,7 @@ public class LatestExistentSearcher { } } } - catch (SVNException e) { + catch (SvnBindException e) { LOG.info(e); } @@ -138,7 +137,7 @@ public class LatestExistentSearcher { final RootUrlInfo rootUrlInfo = mapping.getWcRootForUrl(myUrl.toString()); if (rootUrlInfo == null) return true; final VirtualFile vf = rootUrlInfo.getVirtualFile(); - final SVNInfo info = myVcs.getInfo(vf); + final Info info = myVcs.getInfo(vf); if ((info == null) || (info.getRevision() == null)) { return false; } @@ -149,24 +148,24 @@ public class LatestExistentSearcher { } @Nullable - private SVNURL getExistingParent(SVNURL url) throws SVNException { + private SVNURL getExistingParent(SVNURL url) throws SvnBindException { while (url != null && !url.equals(myRepositoryUrl) && !existsInRevision(url, myEndNumber)) { - url = url.removePathTail(); + url = SvnUtil.removePathTail(url); } return url; } - private boolean existsInRevision(@NotNull SVNURL url, long revisionNumber) throws SVNException { + private boolean existsInRevision(@NotNull SVNURL url, long revisionNumber) throws SvnBindException { SVNRevision revision = SVNRevision.create(revisionNumber); - SVNInfo info = null; + Info info = null; try { info = myVcs.getInfo(url, revision, revision); } - catch (SVNException e) { + catch (SvnBindException e) { // throw error if not "does not exist" error code - if (!SVNErrorCode.RA_ILLEGAL_URL.equals(e.getErrorMessage().getErrorCode())) { + if (!e.contains(SVNErrorCode.RA_ILLEGAL_URL)) { throw e; } } @@ -174,7 +173,7 @@ public class LatestExistentSearcher { return info != null; } - private long getLatestRevision() throws SVNException { + private long getLatestRevision() throws SvnBindException { return SvnUtil.getHeadRevision(myVcs, myRepositoryUrl).getNumber(); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntry.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntry.java new file mode 100644 index 000000000000..1b3d12656d2b --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntry.java @@ -0,0 +1,187 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.history; + +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.tmatesoft.svn.core.SVNLogEntry; +import org.tmatesoft.svn.core.SVNLogEntryPath; + +import javax.xml.bind.annotation.*; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +public class LogEntry { + + public static final LogEntry EMPTY = new LogEntry.Builder().setRevision(-1).setHasChildren(false).build(); + + private final long myRevision; + private final Date myDate; + private final String myMessage; + private final String myAuthor; + @NotNull private final Map<String, LogEntryPath> myChangedPaths; + private boolean myHasChildren; + + @Nullable + public static LogEntry create(@Nullable SVNLogEntry entry) { + LogEntry result = null; + + if (entry != null) { + LogEntry.Builder builder = new LogEntry.Builder(); + + if (entry.getChangedPaths() != null) { + for (SVNLogEntryPath path : entry.getChangedPaths().values()) { + builder.addPath(LogEntryPath.create(path)); + } + } + + result = builder.setRevision(entry.getRevision()).setAuthor(entry.getAuthor()).setDate(entry.getDate()).setMessage(entry.getMessage()) + .setHasChildren(entry.hasChildren()).build(); + } + + return result; + } + + public LogEntry(@NotNull LogEntry.Builder builder) { + myRevision = builder.revision; + myChangedPaths = toImmutable(builder.changedPaths); + myAuthor = builder.author; + myDate = builder.date; + myMessage = builder.message; + myHasChildren = builder.hasChildren(); + } + + @NotNull + private static Map<String, LogEntryPath> toImmutable(@NotNull List<LogEntryPath.Builder> paths) { + ContainerUtil.ImmutableMapBuilder<String, LogEntryPath> builder = ContainerUtil.immutableMapBuilder(); + + for (LogEntryPath.Builder path : paths) { + builder.put(path.getPath(), path.build()); + } + + return builder.build(); + } + + @NotNull + public Map<String, LogEntryPath> getChangedPaths() { + return myChangedPaths; + } + + public String getAuthor() { + return myAuthor; + } + + public Date getDate() { + return myDate; + } + + public String getMessage() { + return myMessage; + } + + public long getRevision() { + return myRevision; + } + + public boolean hasChildren() { + return myHasChildren; + } + + @XmlAccessorType(XmlAccessType.NONE) + // type explicitly specified not to conflict with LogEntryPath.Builder + @XmlType(name = "logentry") + public static class Builder { + + @XmlAttribute(name = "revision") + private long revision; + + @XmlElement(name = "author") + private String author; + + @XmlElement(name = "date") + private Date date; + + @XmlElement(name = "msg") + private String message; + + @XmlElementWrapper(name = "paths") + @XmlElement(name = "path") + private List<LogEntryPath.Builder> changedPaths = ContainerUtil.newArrayList(); + + @XmlElement(name = "logentry") + private List<LogEntry.Builder> childEntries = ContainerUtil.newArrayList(); + + @NotNull + public List<LogEntry.Builder> getChildEntries() { + return childEntries; + } + + public boolean hasChildren() { + return !childEntries.isEmpty(); + } + + @NotNull + public Builder setRevision(long revision) { + this.revision = revision; + return this; + } + + @NotNull + public Builder setAuthor(String author) { + this.author = author; + return this; + } + + @NotNull + public Builder setDate(Date date) { + this.date = date; + return this; + } + + @NotNull + public Builder setMessage(String message) { + this.message = message; + return this; + } + + @NotNull + public Builder setHasChildren(boolean hasChildren) { + // probably LogEntry interface will be changed and child entries will be specified explicitly later, but for now just use such "fake" + // implementation for setting "hasChildren" value + childEntries.clear(); + if (hasChildren) { + childEntries.add(this); + } + return this; + } + + @NotNull + public Builder addPath(@NotNull LogEntryPath.Builder path) { + changedPaths.add(path); + return this; + } + + @NotNull + public LogEntry build() { + return new LogEntry(this); + } + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntryConsumer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntryConsumer.java new file mode 100644 index 000000000000..b3269b1afb41 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntryConsumer.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.history; + +import com.intellij.util.ThrowableConsumer; +import org.tmatesoft.svn.core.SVNException; + +/** + * @author Konstantin Kolosovsky. + */ +public interface LogEntryConsumer extends ThrowableConsumer<LogEntry, SVNException> { +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntryPath.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntryPath.java new file mode 100644 index 000000000000..41215f71f76e --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntryPath.java @@ -0,0 +1,132 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.history; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.api.BaseNodeDescription; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.commandLine.CommandUtil; +import org.tmatesoft.svn.core.SVNLogEntryPath; + +import javax.xml.bind.annotation.*; + +/** + * @author Konstantin Kolosovsky. + */ +public class LogEntryPath extends BaseNodeDescription { + + private final String myPath; + private final char myType; + private final String myCopyPath; + private final long myCopyRevision; + + @NotNull + public static LogEntryPath.Builder create(@NotNull SVNLogEntryPath path) { + return new LogEntryPath.Builder().setPath(path.getPath()).setType(path.getType()).setCopyFromPath( + path.getCopyPath()).setCopyFromRevision(path.getCopyRevision()).setKind(NodeKind.from(path.getKind())); + } + + public LogEntryPath(@NotNull LogEntryPath.Builder builder) { + super(builder.kind); + myPath = builder.path; + myType = CommandUtil.getStatusChar(builder.action); + myCopyPath = builder.copyFromPath; + myCopyRevision = builder.copyFromRevision; + } + + public String getCopyPath() { + return myCopyPath; + } + + public long getCopyRevision() { + return myCopyRevision; + } + + public String getPath() { + return myPath; + } + + public char getType() { + return myType; + } + + @NotNull + public NodeKind getKind() { + return myKind; + } + + @XmlAccessorType(XmlAccessType.NONE) + // type explicitly specified not to conflict with LogEntry.Builder + @XmlType(name = "logentrypath") + public static class Builder { + + // empty string could be here if repository was < 1.6 when committing (see comments in schema for svn client xml output , in + // svn source code repository) - this will result in kind = NodeKind.UNKNOWN + @XmlAttribute(name = "kind", required = true) + private NodeKind kind; + + @XmlAttribute(name = "action") + private String action; + + @XmlAttribute(name = "copyfrom-path") + private String copyFromPath; + + @XmlAttribute(name = "copyfrom-rev") + private long copyFromRevision; + + @XmlValue + private String path; + + public String getPath() { + return path; + } + + @NotNull + public Builder setKind(@NotNull NodeKind kind) { + this.kind = kind; + return this; + } + + @NotNull + public Builder setType(char type) { + this.action = String.valueOf(type); + return this; + } + + @NotNull + public Builder setCopyFromPath(String copyFromPath) { + this.copyFromPath = copyFromPath; + return this; + } + + @NotNull + public Builder setCopyFromRevision(long copyFromRevision) { + this.copyFromRevision = copyFromRevision; + return this; + } + + @NotNull + public Builder setPath(String path) { + this.path = path; + return this; + } + + @NotNull + public LogEntryPath build() { + return new LogEntryPath(this); + } + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/TreeStructureNode.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogHierarchyNode.java index 370f54f9ef22..d9ce35a100e4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/TreeStructureNode.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogHierarchyNode.java @@ -18,24 +18,24 @@ package org.jetbrains.idea.svn.history; import java.util.LinkedList; import java.util.List; -public class TreeStructureNode<T> { - private final T myMe; - private final List<TreeStructureNode<T>> myChildren; +public class LogHierarchyNode { + private final LogEntry myMe; + private final List<LogHierarchyNode> myChildren; - public TreeStructureNode(final T me) { - myChildren = new LinkedList<TreeStructureNode<T>>(); + public LogHierarchyNode(final LogEntry me) { + myChildren = new LinkedList<LogHierarchyNode>(); myMe = me; } - public void add(final T child) { - myChildren.add(new TreeStructureNode<T>(child)); + public void add(final LogEntry child) { + myChildren.add(new LogHierarchyNode(child)); } - public List<TreeStructureNode<T>> getChildren() { + public List<LogHierarchyNode> getChildren() { return myChildren; } - public T getMe() { + public LogEntry getMe() { return myMe; } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/MergeSourceHierarchyBuilder.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/MergeSourceHierarchyBuilder.java index f0a77198925d..87896a739bca 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/MergeSourceHierarchyBuilder.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/MergeSourceHierarchyBuilder.java @@ -20,24 +20,23 @@ import com.intellij.util.Consumer; import com.intellij.util.ThrowableConsumer; import org.jetbrains.annotations.NotNull; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNLogEntry; import java.util.List; /** * @author Konstantin Kolosovsky. */ -public class MergeSourceHierarchyBuilder implements ThrowableConsumer<Pair<SVNLogEntry, Integer>, SVNException> { +public class MergeSourceHierarchyBuilder implements ThrowableConsumer<Pair<LogEntry, Integer>, SVNException> { - private TreeStructureNode<SVNLogEntry> myCurrentHierarchy; - @NotNull private final Consumer<TreeStructureNode<SVNLogEntry>> myConsumer; + private LogHierarchyNode myCurrentHierarchy; + @NotNull private final Consumer<LogHierarchyNode> myConsumer; - public MergeSourceHierarchyBuilder(@NotNull Consumer<TreeStructureNode<SVNLogEntry>> consumer) { + public MergeSourceHierarchyBuilder(@NotNull Consumer<LogHierarchyNode> consumer) { myConsumer = consumer; } - public void consume(Pair<SVNLogEntry, Integer> svnLogEntryIntegerPair) throws SVNException { - final SVNLogEntry logEntry = svnLogEntryIntegerPair.getFirst(); + public void consume(Pair<LogEntry, Integer> svnLogEntryIntegerPair) throws SVNException { + final LogEntry logEntry = svnLogEntryIntegerPair.getFirst(); final Integer mergeLevel = svnLogEntryIntegerPair.getSecond(); if (mergeLevel < 0) { @@ -45,11 +44,11 @@ public class MergeSourceHierarchyBuilder implements ThrowableConsumer<Pair<SVNLo myConsumer.consume(myCurrentHierarchy); } if (logEntry.hasChildren()) { - myCurrentHierarchy = new TreeStructureNode<SVNLogEntry>(logEntry); + myCurrentHierarchy = new LogHierarchyNode(logEntry); } else { // just pass myCurrentHierarchy = null; - myConsumer.consume(new TreeStructureNode<SVNLogEntry>(logEntry)); + myConsumer.consume(new LogHierarchyNode(logEntry)); } } else { addToLevel(myCurrentHierarchy, logEntry, mergeLevel); @@ -62,12 +61,12 @@ public class MergeSourceHierarchyBuilder implements ThrowableConsumer<Pair<SVNLo } } - private static void addToLevel(final TreeStructureNode<SVNLogEntry> tree, final SVNLogEntry entry, final int left) { + private static void addToLevel(final LogHierarchyNode tree, final LogEntry entry, final int left) { assert tree != null; if (left == 0) { tree.add(entry); } else { - final List<TreeStructureNode<SVNLogEntry>> children = tree.getChildren(); + final List<LogHierarchyNode> children = tree.getChildren(); assert ! children.isEmpty(); addToLevel(children.get(children.size() - 1), entry, left - 1); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SingleCommittedListProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SingleCommittedListProvider.java index 6ac6adc3b5cd..d9b37e003961 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SingleCommittedListProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SingleCommittedListProvider.java @@ -125,8 +125,9 @@ public class SingleCommittedListProvider { SvnTarget target = SvnTarget.fromURL(url); myVcs.getFactory(target).createHistoryClient().doLog(target, SVNRevision.HEAD, revisionBefore, false, true, false, 0, null, - new ISVNLogEntryHandler() { - public void handleLogEntry(SVNLogEntry logEntry) { + new LogEntryConsumer() { + @Override + public void consume(LogEntry logEntry) { checkDisposed(); // date could be null for lists where there are paths that user has no rights to observe if (logEntry.getDate() != null) { @@ -144,7 +145,7 @@ public class SingleCommittedListProvider { } @NotNull - private SvnChangeList createChangeList(@NotNull SVNLogEntry logEntry) { + private SvnChangeList createChangeList(@NotNull LogEntry logEntry) { return new SvnChangeList(myVcs, svnRootLocation, logEntry, repositoryUrl.toDecodedString()); } @@ -155,8 +156,9 @@ public class SingleCommittedListProvider { } private boolean searchForUrl(@NotNull SVNURL url) throws VcsException { - ISVNLogEntryHandler handler = new ISVNLogEntryHandler() { - public void handleLogEntry(SVNLogEntry logEntry) { + LogEntryConsumer handler = new LogEntryConsumer() { + @Override + public void consume(LogEntry logEntry) { checkDisposed(); // date could be null for lists where there are paths that user has no rights to observe if (logEntry.getDate() != null) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnChangeList.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnChangeList.java index f894bb3f423e..01f9a213907c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnChangeList.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnChangeList.java @@ -40,10 +40,13 @@ import com.intellij.vcsUtil.VcsUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.browse.DirectoryEntry; +import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer; import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -102,7 +105,7 @@ public class SvnChangeList implements CommittedChangeList { myKnownAsDirectories = new HashSet<String>(0); } - public SvnChangeList(SvnVcs vcs, @NotNull final SvnRepositoryLocation location, final SVNLogEntry logEntry, String repositoryRoot) { + public SvnChangeList(SvnVcs vcs, @NotNull final SvnRepositoryLocation location, final LogEntry logEntry, String repositoryRoot) { myVcs = vcs; myLocation = location; myRevision = logEntry.getRevision(); @@ -114,10 +117,10 @@ public class SvnChangeList implements CommittedChangeList { myCommonPathSearcher = new CommonPathSearcher(); myKnownAsDirectories = new HashSet<String>(0); - for(SVNLogEntryPath entry : logEntry.getChangedPaths().values()) { + for(LogEntryPath entry : logEntry.getChangedPaths().values()) { final String path = entry.getPath(); - if (SVNNodeKind.DIR.equals(entry.getKind())) { + if (entry.isDirectory()) { myKnownAsDirectories.add(path); } @@ -394,8 +397,8 @@ public class SvnChangeList implements CommittedChangeList { // TODO: Logic with detecting "isDirectory" status is not clear enough. Why we can't just collect this info from logEntry and // TODO: if loading from disk - use cached values? Not to invoke separate call here. SVNRevision beforeRevision = SVNRevision.create(getRevision(idxData.second.booleanValue())); - SVNInfo info = myVcs.getInfo(SvnUtil.createUrl(revision.getFullPath()), beforeRevision, beforeRevision); - boolean isDirectory = info != null && SVNNodeKind.DIR.equals(info.getKind()); + Info info = myVcs.getInfo(SvnUtil.createUrl(revision.getFullPath()), beforeRevision, beforeRevision); + boolean isDirectory = info != null && info.isDirectory(); Change replacingChange = new Change(createRevision((SvnRepositoryContentRevision)sourceChange.getBeforeRevision(), isDirectory), createRevision((SvnRepositoryContentRevision)sourceChange.getAfterRevision(), isDirectory)); replacingChange.setIsReplaced(sourceChange.isIsReplaced()); @@ -478,12 +481,14 @@ public class SvnChangeList implements CommittedChangeList { SVNRevision revisionNumber = SVNRevision.create(getRevision(isBefore)); SvnTarget target = SvnTarget.fromURL(fullPath, revisionNumber); - myVcs.getFactory(target).createBrowseClient().list(target, revisionNumber, SVNDepth.INFINITY, new ISVNDirEntryHandler() { - public void handleDirEntry(final SVNDirEntry dirEntry) throws SVNException { - final String childPath = path + '/' + dirEntry.getRelativePath(); + myVcs.getFactory(target).createBrowseClient().list(target, revisionNumber, Depth.INFINITY, new DirectoryEntryConsumer() { + + @Override + public void consume(final DirectoryEntry entry) throws SVNException { + final String childPath = path + '/' + entry.getRelativePath(); if (!duplicates.contains(Pair.create(isBefore, childPath))) { - final ContentRevision contentRevision = createRevision(childPath, isBefore, SVNNodeKind.DIR.equals(dirEntry.getKind())); + final ContentRevision contentRevision = createRevision(childPath, isBefore, entry.isDirectory()); result.add(new Change(isBefore ? contentRevision : null, isBefore ? null : contentRevision)); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java index 556ef1e9ebbe..83642894711e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java @@ -49,12 +49,13 @@ import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.actions.ConfigureBranchesAction; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusConsumer; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.*; -import org.tmatesoft.svn.core.wc.ISVNStatusHandler; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.DataInput; @@ -139,8 +140,8 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi final String repositoryRoot = getRepositoryRoot(svnLocation); final ChangeBrowserSettings.Filter filter = settings.createFilter(); - getCommittedChangesImpl(settings, svnLocation, maxCount, new Consumer<SVNLogEntry>() { - public void consume(final SVNLogEntry svnLogEntry) { + getCommittedChangesImpl(settings, svnLocation, maxCount, new Consumer<LogEntry>() { + public void consume(final LogEntry svnLogEntry) { final SvnChangeList cl = new SvnChangeList(myVcs, svnLocation, svnLogEntry, repositoryRoot); if (filter.accepts(cl)) { consumer.consume(cl); @@ -158,8 +159,8 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi final ArrayList<SvnChangeList> result = new ArrayList<SvnChangeList>(); final String repositoryRoot = getRepositoryRoot(svnLocation); - getCommittedChangesImpl(settings, svnLocation, maxCount, new Consumer<SVNLogEntry>() { - public void consume(final SVNLogEntry svnLogEntry) { + getCommittedChangesImpl(settings, svnLocation, maxCount, new Consumer<LogEntry>() { + public void consume(final LogEntry svnLogEntry) { result.add(new SvnChangeList(myVcs, svnLocation, svnLogEntry, repositoryRoot)); } }, false, true); @@ -169,24 +170,24 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi public void getCommittedChangesWithMergedRevisons(final ChangeBrowserSettings settings, final RepositoryLocation location, final int maxCount, - final PairConsumer<SvnChangeList, TreeStructureNode<SVNLogEntry>> finalConsumer) + final PairConsumer<SvnChangeList, LogHierarchyNode> finalConsumer) throws VcsException { final SvnRepositoryLocation svnLocation = (SvnRepositoryLocation) location; final String repositoryRoot = getRepositoryRoot(svnLocation); - final MergeSourceHierarchyBuilder builder = new MergeSourceHierarchyBuilder(new Consumer<TreeStructureNode<SVNLogEntry>>() { - public void consume(TreeStructureNode<SVNLogEntry> node) { + final MergeSourceHierarchyBuilder builder = new MergeSourceHierarchyBuilder(new Consumer<LogHierarchyNode>() { + public void consume(LogHierarchyNode node) { finalConsumer.consume(new SvnChangeList(myVcs, svnLocation, node.getMe(), repositoryRoot), node); } }); - final SvnMergeSourceTracker mergeSourceTracker = new SvnMergeSourceTracker(new ThrowableConsumer<Pair<SVNLogEntry, Integer>, SVNException>() { - public void consume(Pair<SVNLogEntry, Integer> svnLogEntryIntegerPair) throws SVNException { + final SvnMergeSourceTracker mergeSourceTracker = new SvnMergeSourceTracker(new ThrowableConsumer<Pair<LogEntry, Integer>, SVNException>() { + public void consume(Pair<LogEntry, Integer> svnLogEntryIntegerPair) throws SVNException { builder.consume(svnLogEntryIntegerPair); } }); - getCommittedChangesImpl(settings, svnLocation, maxCount, new Consumer<SVNLogEntry>() { - public void consume(final SVNLogEntry svnLogEntry) { + getCommittedChangesImpl(settings, svnLocation, maxCount, new Consumer<LogEntry>() { + public void consume(final LogEntry svnLogEntry) { try { mergeSourceTracker.consume(svnLogEntry); } @@ -204,13 +205,7 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi // TODO: Additionally SvnRepositoryLocation could possibly be refactored to always contain FilePath (or similar local item) // TODO: So here we could get repository url without performing remote svn command - SVNURL rootUrl; - try { - rootUrl = SvnUtil.getRepositoryRoot(myVcs, svnLocation.toSvnUrl()); - } - catch (SVNException e) { - throw new SvnBindException(e); - } + SVNURL rootUrl = SvnUtil.getRepositoryRoot(myVcs, svnLocation.toSvnUrl()); if (rootUrl == null) { throw new SvnBindException("Could not resolve repository root url for " + svnLocation); @@ -220,7 +215,7 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi } private void getCommittedChangesImpl(ChangeBrowserSettings settings, final SvnRepositoryLocation location, - final int maxCount, final Consumer<SVNLogEntry> resultConsumer, final boolean includeMergedRevisions, + final int maxCount, final Consumer<LogEntry> resultConsumer, final boolean includeMergedRevisions, final boolean filterOutByDate) throws VcsException { setCollectingChangesProgress(location); @@ -258,11 +253,12 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi } @NotNull - private ISVNLogEntryHandler createLogHandler(final Consumer<SVNLogEntry> resultConsumer, + private LogEntryConsumer createLogHandler(final Consumer<LogEntry> resultConsumer, final boolean filterOutByDate, final String author) { - return new ISVNLogEntryHandler() { - public void handleLogEntry(SVNLogEntry logEntry) { + return new LogEntryConsumer() { + @Override + public void consume(LogEntry logEntry) { if (myProject.isDisposed()) throw new ProcessCanceledException(); ProgressManager.progress2(SvnBundle.message("progress.text2.processing.revision", logEntry.getRevision())); @@ -381,31 +377,26 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi final Set<FilePath> result = ContainerUtil.newHashSet(); File rootFile = root.getIOFile(); - try { - myVcs.getFactory(rootFile).createStatusClient() - .doStatus(rootFile, SVNRevision.UNDEFINED, SVNDepth.INFINITY, true, false, false, false, new ISVNStatusHandler() { - @Override - public void handleStatus(SVNStatus status) throws SVNException { - File file = status.getFile(); - boolean changedOnServer = isNotNone(status.getRemoteContentsStatus()) || - isNotNone(status.getRemoteNodeStatus()) || - isNotNone(status.getRemotePropertiesStatus()); - - if (file != null && changedOnServer) { - result.add(VcsUtil.getFilePath(file, file.isDirectory())); - } + myVcs.getFactory(rootFile).createStatusClient() + .doStatus(rootFile, SVNRevision.UNDEFINED, Depth.INFINITY, true, false, false, false, new StatusConsumer() { + @Override + public void consume(Status status) throws SVNException { + File file = status.getFile(); + boolean changedOnServer = isNotNone(status.getRemoteContentsStatus()) || + isNotNone(status.getRemoteNodeStatus()) || + isNotNone(status.getRemotePropertiesStatus()); + + if (file != null && changedOnServer) { + result.add(VcsUtil.getFilePath(file, file.isDirectory())); } - }, null); - } - catch (SVNException e) { - throw new SvnBindException(e); - } + } + }, null); return result; } - private static boolean isNotNone(@Nullable SVNStatusType status) { - return status != null && !SVNStatusType.STATUS_NONE.equals(status); + private static boolean isNotNone(@Nullable StatusType status) { + return status != null && !StatusType.STATUS_NONE.equals(status); } public boolean refreshCacheByNumber() { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCopyPathTracker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCopyPathTracker.java index 70e982aeff8e..413e05bdd781 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCopyPathTracker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCopyPathTracker.java @@ -22,8 +22,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnFileUrlMapping; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNLogEntry; -import org.tmatesoft.svn.core.SVNLogEntryPath; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import java.io.File; @@ -45,12 +43,12 @@ public class SvnCopyPathTracker { myCurrentPath = relativeUrl; } - public void accept(@NotNull final SVNLogEntry entry) { + public void accept(@NotNull final LogEntry entry) { final Map changedPaths = entry.getChangedPaths(); if (changedPaths == null) return; for (Object o : changedPaths.values()) { - final SVNLogEntryPath entryPath = (SVNLogEntryPath) o; + final LogEntryPath entryPath = (LogEntryPath) o; if (entryPath != null && 'A' == entryPath.getType() && entryPath.getCopyPath() != null) { if (myCurrentPath.equals(entryPath.getPath())) { myHadChanged = true; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnFileRevision.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnFileRevision.java index 046e16c148a4..007df92a403b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnFileRevision.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnFileRevision.java @@ -26,12 +26,13 @@ import com.intellij.openapi.vcs.actions.VcsContextFactory; import com.intellij.openapi.vcs.history.VcsFileRevision; import com.intellij.openapi.vcs.history.VcsRevisionNumber; import com.intellij.openapi.vcs.impl.ContentRevisionCache; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNLogEntry; +import org.jetbrains.idea.svn.checkin.CommitInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -47,7 +48,7 @@ public class SvnFileRevision implements VcsFileRevision { private final Date myDate; private String myCommitMessage; private final String myAuthor; - private final VcsRevisionNumber myRevisionNumber; + private final SvnRevisionNumber myRevisionNumber; private final SvnVcs myVCS; private final String myURL; private final SVNRevision myPegRevision; @@ -79,7 +80,7 @@ public class SvnFileRevision implements VcsFileRevision { public SvnFileRevision(SvnVcs vcs, SVNRevision pegRevision, - SVNLogEntry logEntry, + LogEntry logEntry, String url, String copyFromPath, Charset charset) { myCharset = charset; @@ -96,6 +97,11 @@ public class SvnFileRevision implements VcsFileRevision { myMergeSources = new ArrayList<SvnFileRevision>(); } + @NotNull + public CommitInfo getCommitInfo() { + return new CommitInfo.Builder(myRevisionNumber.getRevision().getNumber(), myDate, myAuthor).build(); + } + public String getURL() { return myURL; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java index 92b619a7465f..9e9dd7e1befc 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java @@ -40,10 +40,11 @@ import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import org.tmatesoft.svn.core.internal.wc.SVNErrorManager; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import org.tmatesoft.svn.util.SVNLogType; @@ -284,7 +285,7 @@ public class SvnHistoryProvider } private static class LocalLoader extends LogLoader { - private SVNInfo myInfo; + private Info myInfo; private LocalLoader(SvnVcs vcs, FilePath file, SVNRevision from, SVNRevision to, int limit, SVNRevision peg, boolean showMergeSources) { super(vcs, file, from, to, limit, peg, showMergeSources); @@ -419,7 +420,7 @@ public class SvnHistoryProvider private void loadBackwards(SVNURL svnurl) throws SVNException, VcsException { // this method is called when svnurl does not exist in latest repository revision - thus concrete old revision is used for "info" // command to get repository url - SVNInfo info = myVcs.getInfo(svnurl, myPeg, myPeg); + Info info = myVcs.getInfo(svnurl, myPeg, myPeg); final SVNURL rootURL = info != null ? info.getRepositoryRootURL() : null; final String root = rootURL != null ? rootURL.toString() : ""; String relativeUrl = myUrl; @@ -444,11 +445,11 @@ public class SvnHistoryProvider } private boolean existsNow(SVNURL svnurl) { - final SVNInfo info; + final Info info; try { info = myVcs.getInfo(svnurl, SVNRevision.HEAD, SVNRevision.HEAD); } - catch (SVNException e) { + catch (SvnBindException e) { return false; } return info != null && info.getURL() != null && info.getRevision().isValid(); @@ -470,7 +471,7 @@ public class SvnHistoryProvider return false; } - private static class MyLogEntryHandler implements ISVNLogEntryHandler { + private static class MyLogEntryHandler implements LogEntryConsumer { private final ProgressIndicator myIndicator; protected final SvnVcs myVcs; protected final SvnPathThroughHistoryCorrection myLastPathCorrector; @@ -503,10 +504,10 @@ public class SvnHistoryProvider myPegRevision = pegRevision; myUrl = url; myRepositoryRoot = repoRootURL; - myTracker = new SvnMergeSourceTracker(new ThrowableConsumer<Pair<SVNLogEntry, Integer>, SVNException>() { + myTracker = new SvnMergeSourceTracker(new ThrowableConsumer<Pair<LogEntry, Integer>, SVNException>() { @Override - public void consume(final Pair<SVNLogEntry, Integer> svnLogEntryIntegerPair) throws SVNException { - final SVNLogEntry logEntry = svnLogEntryIntegerPair.getFirst(); + public void consume(final Pair<LogEntry, Integer> svnLogEntryIntegerPair) throws SVNException { + final LogEntry logEntry = svnLogEntryIntegerPair.getFirst(); if (myIndicator != null) { if (myIndicator.isCanceled()) { @@ -514,12 +515,12 @@ public class SvnHistoryProvider } myIndicator.setText2(SvnBundle.message("progress.text2.revision.processed", logEntry.getRevision())); } - SVNLogEntryPath entryPath = null; + LogEntryPath entryPath = null; String copyPath = null; final int mergeLevel = svnLogEntryIntegerPair.getSecond(); if (! myLastPathCorrector.isRoot()) { - myLastPathCorrector.handleLogEntry(logEntry); + myLastPathCorrector.consume(logEntry); entryPath = myLastPathCorrector.getDirectlyMentioned(); copyPath = null; if (entryPath != null) { @@ -528,7 +529,7 @@ public class SvnHistoryProvider // if there are no path with exact match, check whether parent or child paths had changed // "entry path" is allowed to be null now; if it is null, last path would be taken for revision construction - // Separate SVNLogEntry is issued for each "merge source" revision. These "merge source" revisions are treated as child + // Separate LogEntry is issued for each "merge source" revision. These "merge source" revisions are treated as child // revisions of some other revision - this way we construct merge hierarchy. // mergeLevel >= 0 indicates that we are currently processing some "merge source" revision. This "merge source" revision // contains changes from some other branch - so checkForChildChanges() and checkForParentChanges() return "false". @@ -556,11 +557,11 @@ public class SvnHistoryProvider }); } - private boolean checkForParentChanges(SVNLogEntry logEntry) { + private boolean checkForParentChanges(LogEntry logEntry) { final String lastPathBefore = myLastPathCorrector.getBefore(); String path = SVNPathUtil.removeTail(lastPathBefore); while (path.length() > 0) { - final SVNLogEntryPath entryPath = logEntry.getChangedPaths().get(path); + final LogEntryPath entryPath = logEntry.getChangedPaths().get(path); // A & D are checked since we are not interested in parent folders property changes, only in structure changes // TODO: seems that R (replaced) should also be checked here if (entryPath != null && (entryPath.getType() == 'A' || entryPath.getType() == 'D')) { @@ -576,7 +577,7 @@ public class SvnHistoryProvider // TODO: this makes sense only for directories, but should always return true if something under the directory was changed in revision // TODO: as svn will provide child changes in history for directory - private boolean checkForChildChanges(SVNLogEntry logEntry) { + private boolean checkForChildChanges(LogEntry logEntry) { final String lastPathBefore = myLastPathCorrector.getBefore(); for (String key : logEntry.getChangedPaths().keySet()) { if (SVNPathUtil.isAncestor(lastPathBefore, key)) { @@ -587,7 +588,7 @@ public class SvnHistoryProvider } @Override - public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { + public void consume(LogEntry logEntry) throws SVNException { myTracker.consume(logEntry); } @@ -605,7 +606,7 @@ public class SvnHistoryProvider } } - protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath, SVNLogEntryPath entryPath) throws SVNException { + protected SvnFileRevision createRevision(final LogEntry logEntry, final String copyPath, LogEntryPath entryPath) throws SVNException { Date date = logEntry.getDate(); String author = logEntry.getAuthor(); String message = logEntry.getMessage(); @@ -628,7 +629,7 @@ public class SvnHistoryProvider } @Override - protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath, SVNLogEntryPath entryPath) + protected SvnFileRevision createRevision(final LogEntry logEntry, final String copyPath, LogEntryPath entryPath) throws SVNException { final SVNURL url = entryPath == null ? myRepositoryRoot.appendPath(myLastPathCorrector.getBefore(), false) : myRepositoryRoot.appendPath(entryPath.getPath(), true); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistorySession.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistorySession.java index 171b39cad623..f2f91bceec14 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistorySession.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistorySession.java @@ -20,7 +20,7 @@ import com.intellij.openapi.vcs.history.*; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.wc.SVNInfo; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -69,7 +69,7 @@ public class SvnHistorySession extends VcsAbstractHistorySession { } public static VcsRevisionNumber getCurrentCommittedRevision(final SvnVcs vcs, final File file) { - SVNInfo info = vcs.getInfo(file); + Info info = vcs.getInfo(file); return info != null ? new SvnRevisionNumber(info.getCommittedRevision()) : null; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnKitHistoryClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnKitHistoryClient.java index ca387bc9ca41..0aca8300e420 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnKitHistoryClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnKitHistoryClient.java @@ -8,6 +8,7 @@ import org.jetbrains.idea.svn.api.BaseSvnClient; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.ISVNLogEntryHandler; import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.wc.SVNLogClient; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -28,22 +29,38 @@ public class SvnKitHistoryClient extends BaseSvnClient implements HistoryClient boolean includeMergedRevisions, long limit, @Nullable String[] revisionProperties, - @Nullable ISVNLogEntryHandler handler) throws VcsException { + @Nullable LogEntryConsumer handler) throws VcsException { try { // TODO: a bug noticed when testing: we should pass "limit + 1" to get "limit" rows SVNLogClient client = myVcs.getSvnKitManager().createLogClient(); if (target.isFile()) { client.doLog(new File[]{target.getFile()}, startRevision, endRevision, target.getPegRevision(), stopOnCopy, discoverChangedPaths, - includeMergedRevisions, limit, revisionProperties, handler); + includeMergedRevisions, limit, revisionProperties, toHandler(handler)); } else { client.doLog(target.getURL(), ArrayUtil.EMPTY_STRING_ARRAY, target.getPegRevision(), startRevision, endRevision, stopOnCopy, - discoverChangedPaths, includeMergedRevisions, limit, revisionProperties, handler); + discoverChangedPaths, includeMergedRevisions, limit, revisionProperties, toHandler(handler)); } } catch (SVNException e) { throw new SvnBindException(e); } } + + @Nullable + private static ISVNLogEntryHandler toHandler(@Nullable final LogEntryConsumer handler) { + ISVNLogEntryHandler result = null; + + if (handler != null) { + result = new ISVNLogEntryHandler() { + @Override + public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { + handler.consume(LogEntry.create(logEntry)); + } + }; + } + + return result; + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLogUtil.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLogUtil.java index 7f4f25f023a9..878f38e6a748 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLogUtil.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLogUtil.java @@ -24,8 +24,6 @@ import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.ISVNLogEntryHandler; -import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -50,7 +48,7 @@ public class SvnLogUtil implements SvnLogLoader { final int maxCount, final boolean includingYoungest, final boolean includeOldest) throws VcsException { final List<CommittedChangeList> result = new ArrayList<CommittedChangeList>(); - ISVNLogEntryHandler handler = createLogHandler(fromIncluding, toIncluding, includingYoungest, includeOldest, result); + LogEntryConsumer handler = createLogHandler(fromIncluding, toIncluding, includingYoungest, includeOldest, result); SvnTarget target = SvnTarget.fromURL(myLocation.toSvnUrl()); myVcs.getFactory(target).createHistoryClient().doLog(target, fromIncluding, toIncluding, true, true, false, maxCount, null, handler); @@ -59,12 +57,13 @@ public class SvnLogUtil implements SvnLogLoader { } @NotNull - private ISVNLogEntryHandler createLogHandler(final SVNRevision fromIncluding, + private LogEntryConsumer createLogHandler(final SVNRevision fromIncluding, final SVNRevision toIncluding, final boolean includingYoungest, final boolean includeOldest, final List<CommittedChangeList> result) { - return new ISVNLogEntryHandler() { - public void handleLogEntry(SVNLogEntry logEntry) { + return new LogEntryConsumer() { + @Override + public void consume(LogEntry logEntry) { if (myProject.isDisposed()) throw new ProcessCanceledException(); final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator(); if (progress != null) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceDetails.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceDetails.java index f3ed60277dd5..be0722b6fc0c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceDetails.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceDetails.java @@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.MasterDetailsComponent; import com.intellij.openapi.ui.NamedConfigurable; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vcs.changes.committed.CommittedChangeListRenderer; import com.intellij.openapi.vcs.changes.ui.ChangeListViewerDialog; @@ -73,6 +74,8 @@ public class SvnMergeSourceDetails extends MasterDetailsComponent { final ContentManager contentManager = toolWindow.getContentManager(); final MyDialog dialog = new MyDialog(project, revision, file); + // TODO: Temporary memory leak fix - rewrite this part not to create dialog if only createCenterPanel(), but not show() is invoked + Disposer.register(project, dialog.getDisposable()); Content content = ContentFactory.SERVICE.getInstance().createContent(dialog.createCenterPanel(), SvnBundle.message("merge.source.details.title", (file == null) ? revision.getURL() : file.getName(), revision.getRevisionNumber().asString()), true); @@ -213,7 +216,10 @@ public class SvnMergeSourceDetails extends MasterDetailsComponent { if (list == null) { myPanel = new JPanel(); } else { - myPanel = new ChangeListViewerDialog(myProject, list).createCenterPanel(); + ChangeListViewerDialog dialog = new ChangeListViewerDialog(myProject, list); + // TODO: Temporary memory leak fix - rewrite this part not to create dialog if only createCenterPanel(), but not show() is invoked + Disposer.register(myProject, dialog.getDisposable()); + myPanel = dialog.createCenterPanel(); } } return myPanel; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceTracker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceTracker.java index 53f151876ec9..023d8489d795 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceTracker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceTracker.java @@ -18,24 +18,23 @@ package org.jetbrains.idea.svn.history; import com.intellij.openapi.util.Pair; import com.intellij.util.ThrowableConsumer; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNLogEntry; public class SvnMergeSourceTracker { private int myMergeLevel; // -1 - not merge source; 0 - direct merge source - private ThrowableConsumer<Pair<SVNLogEntry, Integer>, SVNException> myConsumer; + private ThrowableConsumer<Pair<LogEntry, Integer>, SVNException> myConsumer; - public SvnMergeSourceTracker(final ThrowableConsumer<Pair<SVNLogEntry, Integer>, SVNException> consumer) { + public SvnMergeSourceTracker(final ThrowableConsumer<Pair<LogEntry, Integer>, SVNException> consumer) { myConsumer = consumer; myMergeLevel = -1; } - public void consume(final SVNLogEntry logEntry) throws SVNException { + public void consume(final LogEntry logEntry) throws SVNException { if (logEntry.getRevision() < 0) { -- myMergeLevel; return; } - myConsumer.consume(new Pair<SVNLogEntry, Integer>(logEntry, myMergeLevel)); + myConsumer.consume(new Pair<LogEntry, Integer>(logEntry, myMergeLevel)); if (logEntry.hasChildren()) { ++ myMergeLevel; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnPathThroughHistoryCorrection.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnPathThroughHistoryCorrection.java index 8ecb8a3b1e90..bf6c08e74759 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnPathThroughHistoryCorrection.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnPathThroughHistoryCorrection.java @@ -17,10 +17,7 @@ package org.jetbrains.idea.svn.history; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.idea.svn.SvnUtil; -import org.tmatesoft.svn.core.ISVNLogEntryHandler; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNLogEntry; -import org.tmatesoft.svn.core.SVNLogEntryPath; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import java.util.Map; @@ -33,10 +30,10 @@ import java.util.Map; * * We consider here, that history is traversed "from now to past" */ -public class SvnPathThroughHistoryCorrection implements ISVNLogEntryHandler { +public class SvnPathThroughHistoryCorrection implements LogEntryConsumer { private String myBefore; private String myPath; - private SVNLogEntryPath myDirectlyMentioned; + private LogEntryPath myDirectlyMentioned; private boolean myRoot; public SvnPathThroughHistoryCorrection(String path) { @@ -46,14 +43,14 @@ public class SvnPathThroughHistoryCorrection implements ISVNLogEntryHandler { } @Override - public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { + public void consume(LogEntry logEntry) throws SVNException { if (myRoot) { return; } myBefore = myPath; myDirectlyMentioned = null; - final Map<String,SVNLogEntryPath> paths = logEntry.getChangedPaths(); - final SVNLogEntryPath entryPath = paths.get(myPath); + final Map<String,LogEntryPath> paths = logEntry.getChangedPaths(); + final LogEntryPath entryPath = paths.get(myPath); if (entryPath != null) { myDirectlyMentioned = entryPath; // exact match @@ -62,7 +59,7 @@ public class SvnPathThroughHistoryCorrection implements ISVNLogEntryHandler { return; } } - for (SVNLogEntryPath path : paths.values()) { + for (LogEntryPath path : paths.values()) { // "the origin path *from where* the item, ..." // TODO: this could incorrectly handle case when parent folder was replaced - see IDEA-103042 // TODO: or several parent folder renames occur IDEA-96825 @@ -89,7 +86,7 @@ public class SvnPathThroughHistoryCorrection implements ISVNLogEntryHandler { return myBefore; } - public SVNLogEntryPath getDirectlyMentioned() { + public LogEntryPath getDirectlyMentioned() { return myDirectlyMentioned; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRevisionsNavigationMediator.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRevisionsNavigationMediator.java index 7a11aee32c48..ca69ba7a58ec 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRevisionsNavigationMediator.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRevisionsNavigationMediator.java @@ -28,8 +28,8 @@ import com.intellij.openapi.vcs.changes.committed.CommittedChangesNavigation; import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.SVNInfo; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.wc.SVNRevision; import java.util.*; @@ -56,7 +56,7 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio myChunks = new LinkedList<List<Fragment>>(); final VcsException[] exception = new VcsException[1]; - final Ref<SVNInfo> infoRef = new Ref<SVNInfo>(); + final Ref<Info> infoRef = new Ref<Info>(); Runnable process = new Runnable() { @Override @@ -64,17 +64,14 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio try { infoRef.set(vcs.getInfo(location.toSvnUrl(), SVNRevision.HEAD)); } - catch (VcsException e) { + catch (SvnBindException e) { exception[0] = e; } - catch (SVNException e) { - exception[0] = new VcsException(e); - } } }; underProgress(exception, process); - SVNInfo info = infoRef.get(); + Info info = infoRef.get(); if (info == null || info.getRevision() == null || info.getRepositoryRootURL() == null) { throw new VcsException("Could not get head info for " + location); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/ignore/SvnPropertyService.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/ignore/SvnPropertyService.java index 2bd8627de196..8a9dbf760922 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/ignore/SvnPropertyService.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/ignore/SvnPropertyService.java @@ -23,7 +23,7 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnPropertyKeys; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.wc.SVNPropertyData; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -187,7 +187,7 @@ public class SvnPropertyService { String newValue = getNewPropertyValue(data, propertyValue); newValue = (newValue.trim().isEmpty()) ? null : newValue; myVcs.getFactory(folderDir).createPropertyClient() - .setProperty(folderDir, SvnPropertyKeys.SVN_IGNORE, SVNPropertyValue.create(newValue), SVNDepth.EMPTY, false); + .setProperty(folderDir, SvnPropertyKeys.SVN_IGNORE, SVNPropertyValue.create(newValue), Depth.EMPTY, false); if (myUseCommonExtension) { dirtyScopeManager.dirDirtyRecursively(folder); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/CmdInfoClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/CmdInfoClient.java index 475dd1a4f77d..91eb7ce42e3e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/CmdInfoClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/CmdInfoClient.java @@ -20,17 +20,16 @@ import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.util.Consumer; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.*; -import org.tmatesoft.svn.core.*; -import org.tmatesoft.svn.core.wc.ISVNInfoHandler; -import org.tmatesoft.svn.core.wc.SVNInfo; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import org.xml.sax.SAXException; @@ -41,7 +40,6 @@ import javax.xml.parsers.SAXParserFactory; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -55,48 +53,7 @@ public class CmdInfoClient extends BaseSvnClient implements InfoClient { private static final Logger LOG = Logger.getInstance(CmdInfoClient.class); - @Override - public void doInfo(File path, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) throws SVNException { - doInfo(path, SVNRevision.UNDEFINED, revision, recursive ? SVNDepth.INFINITY : SVNDepth.EMPTY, null, handler); - } - - @Override - public void doInfo(File path, SVNRevision pegRevision, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) - throws SVNException { - doInfo(path, pegRevision, revision, recursive ? SVNDepth.INFINITY : SVNDepth.EMPTY, null, handler); - } - - @Override - public void doInfo(File path, - SVNRevision pegRevision, - SVNRevision revision, - SVNDepth depth, - Collection changeLists, - final ISVNInfoHandler handler) throws SVNException { - File base = path.isDirectory() ? path : path.getParentFile(); - base = CommandUtil.correctUpToExistingParent(base); - if (base == null) { - // very unrealistic - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Can not find existing parent file")); - } - issueCommand(path, pegRevision, revision, depth, changeLists, handler, base); - } - - private void issueCommand(File path, SVNRevision pegRevision, - SVNRevision revision, - SVNDepth depth, - Collection changeLists, - final ISVNInfoHandler handler, File base) throws SVNException { - List<String> parameters = new ArrayList<String>(); - - fillParameters(path.getAbsolutePath(), pegRevision, revision, depth, parameters); - // TODO: Fix this check - update corresponding parameters in InfoClient - CommandUtil.putChangeLists(parameters, changeLists); - - parseResult(handler, base, execute(parameters, path)); - } - - private String execute(@NotNull List<String> parameters, @NotNull File path) throws SVNException { + private String execute(@NotNull List<String> parameters, @NotNull File path) throws SvnBindException { // workaround: separately capture command output - used in exception handling logic to overcome svn 1.8 issue (see below) final ProcessOutput output = new ProcessOutput(); LineCommandListener listener = new LineCommandAdapter() { @@ -113,51 +70,46 @@ public class CmdInfoClient extends BaseSvnClient implements InfoClient { return command.getOutput(); } - catch (VcsException e) { - final String text = e.getMessage(); - final boolean notEmpty = !StringUtil.isEmptyOrSpaces(text); - if (notEmpty && text.contains("W155010")) { + catch (SvnBindException e) { + final String text = StringUtil.notNullize(e.getMessage()); + if (text.contains("W155010")) { // if "svn info" is executed for several files at once, then this warning could be printed only for some files, but info for other // files should be parsed from output return output.getStdout(); } // not a working copy exception // "E155007: '' is not a working copy" - if (notEmpty && text.contains("is not a working copy")) { - if (StringUtil.isNotEmpty(output.getStdout())) { - // TODO: Seems not reproducible in 1.8.4 - // workaround: as in subversion 1.8 "svn info" on a working copy root outputs such error for parent folder, - // if there are files with conflicts. - // but the requested info is still in the output except root closing tag - return output.getStdout() + "</info>"; - } else { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.WC_NOT_WORKING_COPY, e), e); - } - // svn: E200009: Could not display info for all targets because some targets don't exist - } else if (notEmpty && text.contains("some targets don't exist")) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.ILLEGAL_TARGET, e), e); - } else if (notEmpty && text.contains(String.valueOf(SVNErrorCode.WC_UPGRADE_REQUIRED.getCode()))) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.WC_UPGRADE_REQUIRED, e), e); - } else if (notEmpty && - (text.contains("upgrade your Subversion client") || - text.contains(String.valueOf(SVNErrorCode.WC_UNSUPPORTED_FORMAT.getCode())))) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.WC_UNSUPPORTED_FORMAT, e), e); + if (text.contains("is not a working copy") && StringUtil.isNotEmpty(output.getStdout())) { + // TODO: Seems not reproducible in 1.8.4 + // workaround: as in subversion 1.8 "svn info" on a working copy root outputs such error for parent folder, + // if there are files with conflicts. + // but the requested info is still in the output except root closing tag + return output.getStdout() + "</info>"; } - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw e; } } - private static void parseResult(@NotNull final ISVNInfoHandler handler, @Nullable File base, @Nullable String result) throws SVNException { + @Nullable + private static Info parseResult(@Nullable File base, @Nullable String result) throws SvnBindException { + CollectInfoHandler handler = new CollectInfoHandler(); + + parseResult(handler, base, result); + + return handler.getInfo(); + } + + private static void parseResult(@NotNull final InfoConsumer handler, @Nullable File base, @Nullable String result) + throws SvnBindException { if (StringUtil.isEmptyOrSpaces(result)) { return; } - final SvnInfoHandler[] infoHandler = new SvnInfoHandler[1]; - infoHandler[0] = new SvnInfoHandler(base, new Consumer<SVNInfo>() { + final SvnInfoHandler infoHandler = new SvnInfoHandler(base, new Consumer<Info>() { @Override - public void consume(SVNInfo info) { + public void consume(Info info) { try { - handler.handleInfo(info); + handler.consume(info); } catch (SVNException e) { throw new SvnExceptionWrapper(e); @@ -165,87 +117,68 @@ public class CmdInfoClient extends BaseSvnClient implements InfoClient { } }); + parseResult(result, infoHandler); + } + + private static void parseResult(@NotNull String result, @NotNull SvnInfoHandler handler) throws SvnBindException { try { SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); - parser.parse(new ByteArrayInputStream(result.trim().getBytes(CharsetToolkit.UTF8_CHARSET)), infoHandler[0]); + parser.parse(new ByteArrayInputStream(result.trim().getBytes(CharsetToolkit.UTF8_CHARSET)), handler); } catch (SvnExceptionWrapper e) { LOG.info("info output " + result); - throw (SVNException) e.getCause(); + throw new SvnBindException(e.getCause()); } catch (IOException e) { LOG.info("info output " + result); - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } catch (ParserConfigurationException e) { LOG.info("info output " + result); - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } catch (SAXException e) { LOG.info("info output " + result); - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } } - private static void fillParameters(String path, SVNRevision pegRevision, SVNRevision revision, SVNDepth depth, List<String> parameters) { + @NotNull + private static List<String> buildParameters(@NotNull String path, + @Nullable SVNRevision pegRevision, + @Nullable SVNRevision revision, + @Nullable Depth depth) { + List<String> parameters = ContainerUtil.newArrayList(); + CommandUtil.put(parameters, depth); CommandUtil.put(parameters, revision); CommandUtil.put(parameters, path, pegRevision); parameters.add("--xml"); - } - @Override - public void doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) - throws SVNException { - doInfo(url, pegRevision, revision, recursive ? SVNDepth.INFINITY : SVNDepth.EMPTY, handler); + return parameters; } @Override - public void doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision, SVNDepth depth, ISVNInfoHandler handler) - throws SVNException { - String path = url.toDecodedString(); - List<String> parameters = new ArrayList<String>(); - - fillParameters(path, pegRevision, revision, depth, parameters); - CommandExecutor command; - try { - command = execute(myVcs, SvnTarget.fromURL(url), SvnCommandName.info, parameters, null); - } - catch (SvnBindException e) { - SVNErrorCode code = e.contains(SVNErrorCode.RA_ILLEGAL_URL) ? SVNErrorCode.RA_ILLEGAL_URL : SVNErrorCode.IO_ERROR; - - throw new SVNException(SVNErrorMessage.create(code, e), e); + public Info doInfo(File path, SVNRevision revision) throws SvnBindException { + File base = path.isDirectory() ? path : path.getParentFile(); + base = CommandUtil.correctUpToExistingParent(base); + if (base == null) { + // very unrealistic + throw new SvnBindException("Can not find existing parent file"); } - parseResult(handler, null, command.getOutput()); + return parseResult(base, execute(buildParameters(path.getAbsolutePath(), SVNRevision.UNDEFINED, revision, Depth.EMPTY), path)); } @Override - public SVNInfo doInfo(File path, SVNRevision revision) throws SVNException { - final SVNInfo[] infoArr = new SVNInfo[1]; - doInfo(path, SVNRevision.UNDEFINED, revision, SVNDepth.EMPTY, null, new ISVNInfoHandler() { - @Override - public void handleInfo(SVNInfo info) throws SVNException { - infoArr[0] = info; - } - }); - return infoArr[0]; - } + public Info doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision) throws SvnBindException { + CommandExecutor command = execute(myVcs, SvnTarget.fromURL(url), SvnCommandName.info, buildParameters(url.toDecodedString(), pegRevision, revision, Depth.EMPTY), null); - @Override - public SVNInfo doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision) throws SVNException { - final SVNInfo[] infoArr = new SVNInfo[1]; - doInfo(url, pegRevision, revision, SVNDepth.EMPTY, new ISVNInfoHandler() { - @Override - public void handleInfo(SVNInfo info) throws SVNException { - infoArr[0] = info; - } - }); - return infoArr[0]; + return parseResult(null, command.getOutput()); } @Override - public void doInfo(@NotNull Collection<File> paths, @Nullable ISVNInfoHandler handler) throws SVNException { + public void doInfo(@NotNull Collection<File> paths, @Nullable InfoConsumer handler) throws SvnBindException { File base = ContainerUtil.getFirstItem(paths); if (base != null) { @@ -265,4 +198,19 @@ public class CmdInfoClient extends BaseSvnClient implements InfoClient { } } } + + private static class CollectInfoHandler implements InfoConsumer { + + @Nullable private Info myInfo; + + @Override + public void consume(Info info) throws SVNException { + myInfo = info; + } + + @Nullable + public Info getInfo() { + return myInfo; + } + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/IdeaSVNInfo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/IdeaSVNInfo.java deleted file mode 100644 index 0e2905e73016..000000000000 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/IdeaSVNInfo.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.idea.svn.info; - -import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNLock; -import org.tmatesoft.svn.core.SVNNodeKind; -import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; -import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNTreeConflictDescription; - -import java.io.File; -import java.util.Date; - -/** - * Created by IntelliJ IDEA. - * User: Irina.Chernushina - * Date: 1/23/12 - * Time: 1:02 PM - */ -public class IdeaSVNInfo extends SVNInfo { - private final Date myCorrectCommittedDate; - private final Date myCorrectTextDate; - - public IdeaSVNInfo(@Nullable File file, - SVNURL url, - SVNURL rootURL, - long revision, - SVNNodeKind kind, - String uuid, - long committedRevision, - Date committedDate, - String author, - String schedule, - SVNURL copyFromURL, - long copyFromRevision, - Date textTime, - String propTime, - String checksum, - String conflictOld, - String conflictNew, - String conflictWorking, - String propRejectFile, - SVNLock lock, - SVNDepth depth, - String changelistName, - long wcSize, - SVNTreeConflictDescription treeConflict) { - super(file, url, rootURL, revision, kind, uuid, committedRevision, null, author, schedule, copyFromURL, copyFromRevision, - null, propTime, checksum, conflictOld, conflictNew, conflictWorking, propRejectFile, lock, depth, changelistName, wcSize, - treeConflict); - myCorrectCommittedDate = committedDate; - myCorrectTextDate = textTime; - } - - /** - * Gets the item's last commit date. This is the value of the item's - * {@link org.tmatesoft.svn.core.SVNProperty#COMMITTED_DATE} - * property. - * - * @return the item's last commit date - */ - @Override - public Date getCommittedDate() { - return myCorrectCommittedDate; - } - - /** - * Gets the value of the item's {@link org.tmatesoft.svn.core.SVNProperty#TEXT_TIME} - * property. It corresponds to the last commit time. - * - * @return the value of the item's text-time property - */ - @Override - public Date getTextTime() { - return myCorrectTextDate; - } - - public IdeaSVNInfo(String path, - SVNURL url, - SVNRevision revision, - SVNNodeKind kind, - String uuid, - SVNURL reposRootURL, - long comittedRevision, Date date, String author, SVNLock lock, SVNDepth depth, long size) { - super(path, url, revision, kind, uuid, reposRootURL, comittedRevision, date, author, lock, depth, size); - myCorrectCommittedDate = date; - myCorrectTextDate = null; - } -} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/Info.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/Info.java new file mode 100644 index 000000000000..96dbdbbcbc99 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/Info.java @@ -0,0 +1,267 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.info; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.BaseNodeDescription; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; +import org.jetbrains.idea.svn.lock.Lock; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.internal.util.SVNDate; +import org.tmatesoft.svn.core.wc.SVNInfo; +import org.tmatesoft.svn.core.wc.SVNRevision; + +import java.io.File; +import java.util.Date; + +/** + * @author Konstantin Kolosovsky. + */ +public class Info extends BaseNodeDescription { + + private final File myFile; + private final String myPath; + private final SVNURL myURL; + private final SVNRevision myRevision; + private final SVNURL myRepositoryRootURL; + private final String myRepositoryUUID; + private final SVNRevision myCommittedRevision; + private final Date myCommittedDate; + private final String myAuthor; + @Nullable private final Lock myLock; + private final boolean myIsRemote; + private final String mySchedule; + private final SVNURL myCopyFromURL; + private final SVNRevision myCopyFromRevision; + private final File myConflictOldFile; + private final File myConflictNewFile; + private final File myConflictWrkFile; + private final File myPropConflictFile; + private final Depth myDepth; + @Nullable private final TreeConflictDescription myTreeConflict; + + @NotNull + public static Info create(@NotNull SVNInfo info) { + Info result; + + if (info.isRemote()) { + result = new Info(info.getPath(), info.getURL(), info.getRevision(), NodeKind.from(info.getKind()), info.getRepositoryUUID(), + info.getRepositoryRootURL(), info.getCommittedRevision().getNumber(), info.getCommittedDate(), info.getAuthor(), + Lock.create(info.getLock()), Depth.from(info.getDepth())); + } + else { + result = + new Info(info.getFile(), info.getURL(), info.getRepositoryRootURL(), info.getRevision().getNumber(), NodeKind.from(info.getKind()), + info.getRepositoryUUID(), info.getCommittedRevision().getNumber(), toString(info.getCommittedDate()), info.getAuthor(), + info.getSchedule(), info.getCopyFromURL(), info.getCopyFromRevision().getNumber(), getPath(info.getConflictOldFile()), + getPath(info.getConflictNewFile()), getPath(info.getConflictWrkFile()), getPath(info.getPropConflictFile()), + Lock.create(info.getLock()), Depth.from(info.getDepth()), TreeConflictDescription.create(info.getTreeConflict())); + } + + return result; + } + + public Info(File file, + SVNURL url, + SVNURL rootURL, + long revision, + @NotNull NodeKind kind, + String uuid, + long committedRevision, + String committedDate, + String author, + String schedule, + SVNURL copyFromURL, + long copyFromRevision, + String conflictOld, + String conflictNew, + String conflictWorking, + String propRejectFile, + @Nullable Lock lock, + Depth depth, + @Nullable TreeConflictDescription treeConflict) { + super(kind); + myFile = file; + myURL = url; + myRevision = SVNRevision.create(revision); + myRepositoryUUID = uuid; + myRepositoryRootURL = rootURL; + + myCommittedRevision = SVNRevision.create(committedRevision); + myCommittedDate = committedDate != null ? SVNDate.parseDate(committedDate) : null; + myAuthor = author; + + mySchedule = schedule; + + myCopyFromURL = copyFromURL; + myCopyFromRevision = SVNRevision.create(copyFromRevision); + + myLock = lock; + myTreeConflict = treeConflict; + + myConflictOldFile = resolveConflictFile(file, conflictOld); + myConflictNewFile = resolveConflictFile(file, conflictNew); + myConflictWrkFile = resolveConflictFile(file, conflictWorking); + myPropConflictFile = resolveConflictFile(file, propRejectFile); + + myIsRemote = false; + myDepth = depth; + + myPath = null; + } + + public Info(String path, + SVNURL url, + SVNRevision revision, + @NotNull NodeKind kind, + String uuid, + SVNURL reposRootURL, + long committedRevision, + Date date, + String author, + @Nullable Lock lock, + Depth depth) { + super(kind); + myIsRemote = true; + myURL = url; + myRevision = revision; + myRepositoryRootURL = reposRootURL; + myRepositoryUUID = uuid; + + myCommittedDate = date; + myCommittedRevision = SVNRevision.create(committedRevision); + myAuthor = author; + + myLock = lock; + myPath = path; + myDepth = depth; + + myFile = null; + mySchedule = null; + myCopyFromURL = null; + myCopyFromRevision = null; + myConflictOldFile = null; + myConflictNewFile = null; + myConflictWrkFile = null; + myPropConflictFile = null; + myTreeConflict = null; + } + + public String getAuthor() { + return myAuthor; + } + + public Date getCommittedDate() { + return myCommittedDate; + } + + public SVNRevision getCommittedRevision() { + return myCommittedRevision; + } + + public File getConflictNewFile() { + return myConflictNewFile; + } + + public File getConflictOldFile() { + return myConflictOldFile; + } + + public File getConflictWrkFile() { + return myConflictWrkFile; + } + + @Nullable + public TreeConflictDescription getTreeConflict() { + return myTreeConflict; + } + + public SVNRevision getCopyFromRevision() { + return myCopyFromRevision; + } + + public SVNURL getCopyFromURL() { + return myCopyFromURL; + } + + public File getFile() { + return myFile; + } + + public boolean isRemote() { + return myIsRemote; + } + + @NotNull + public NodeKind getKind() { + return myKind; + } + + @Nullable + public Lock getLock() { + return myLock; + } + + public String getPath() { + return myPath; + } + + public File getPropConflictFile() { + return myPropConflictFile; + } + + public SVNURL getRepositoryRootURL() { + return myRepositoryRootURL; + } + + public String getRepositoryUUID() { + return myRepositoryUUID; + } + + public SVNRevision getRevision() { + return myRevision; + } + + public String getSchedule() { + return mySchedule; + } + + public SVNURL getURL() { + return myURL; + } + + public Depth getDepth() { + return myDepth; + } + + @Nullable + private static File resolveConflictFile(@Nullable File file, @Nullable String path) { + return file != null && path != null ? new File(file.getParentFile(), path) : null; + } + + @Nullable + private static String getPath(@Nullable File file) { + return file != null ? file.getPath() : null; + } + + @Nullable + private static String toString(@Nullable Date date) { + return date != null ? date.toString() : null; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoClient.java index f6582e603eda..56f87a040b17 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoClient.java @@ -18,11 +18,8 @@ package org.jetbrains.idea.svn.info; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNInfoHandler; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -36,15 +33,9 @@ import java.util.Collection; */ public interface InfoClient extends SvnClient { - void doInfo(File path, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) throws SVNException; - void doInfo(File path, SVNRevision pegRevision, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) throws SVNException; - void doInfo(File path, SVNRevision pegRevision, SVNRevision revision, SVNDepth depth, - Collection changeLists, ISVNInfoHandler handler) throws SVNException; - void doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) throws SVNException; - void doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision, SVNDepth depth, - ISVNInfoHandler handler) throws SVNException; - SVNInfo doInfo(File path, SVNRevision revision) throws SVNException; - SVNInfo doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision) throws SVNException; + Info doInfo(File path, SVNRevision revision) throws SvnBindException; - void doInfo(@NotNull Collection<File> paths, @Nullable ISVNInfoHandler handler) throws SVNException; + Info doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision) throws SvnBindException; + + void doInfo(@NotNull Collection<File> paths, @Nullable InfoConsumer handler) throws SvnBindException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoConsumer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoConsumer.java new file mode 100644 index 000000000000..317b2b6a5156 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoConsumer.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.info; + +import com.intellij.util.ThrowableConsumer; +import org.jetbrains.idea.svn.info.Info; +import org.tmatesoft.svn.core.SVNException; + +/** + * @author Konstantin Kolosovsky. + */ +public interface InfoConsumer extends ThrowableConsumer<Info, SVNException> { +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SVNLockWrapper.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SVNLockWrapper.java deleted file mode 100644 index f5752074da77..000000000000 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SVNLockWrapper.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.idea.svn.info; - -import org.tmatesoft.svn.core.SVNLock; - -import java.util.Date; - -/** - * Created with IntelliJ IDEA. - * User: Irina.Chernushina - * Date: 2/21/12 - * Time: 2:33 PM - */ -public class SVNLockWrapper { - private String myPath; - private String myID; - private String myOwner; - private String myComment; - private Date myCreationDate; - private Date myExpirationDate; - - public SVNLockWrapper(String path, String ID, String owner, String comment, Date creationDate, Date expirationDate) { - myPath = path; - myID = ID; - myOwner = owner; - myComment = comment; - myCreationDate = creationDate; - myExpirationDate = expirationDate; - } - - public SVNLockWrapper() { - } - - public SVNLock create() { - return new SVNLock(myPath, myID, myOwner, myComment, myCreationDate, myExpirationDate); - } - - public String getPath() { - return myPath; - } - - public void setPath(String path) { - myPath = path; - } - - public String getID() { - return myID; - } - - public void setID(String ID) { - myID = ID; - } - - public String getOwner() { - return myOwner; - } - - public void setOwner(String owner) { - myOwner = owner; - } - - public String getComment() { - return myComment; - } - - public void setComment(String comment) { - myComment = comment; - } - - public Date getCreationDate() { - return myCreationDate; - } - - public void setCreationDate(Date creationDate) { - myCreationDate = creationDate; - } - - public Date getExpirationDate() { - return myExpirationDate; - } - - public void setExpirationDate(Date expirationDate) { - myExpirationDate = expirationDate; - } -} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoHandler.java index e2e5fa910e38..969225eb69e3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoHandler.java @@ -21,12 +21,11 @@ import com.intellij.util.Consumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.lock.Lock; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNDate; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; @@ -42,14 +41,14 @@ import java.util.*; */ public class SvnInfoHandler extends DefaultHandler { @Nullable private final File myBase; - private final Consumer<SVNInfo> myInfoConsumer; - private Map<File, SVNInfo> myResultsMap; + private final Consumer<org.jetbrains.idea.svn.info.Info> myInfoConsumer; + private Map<File, org.jetbrains.idea.svn.info.Info> myResultsMap; private SvnInfoStructure myPending; private final Map<String, Getter<ElementHandlerBase>> myElementsMap; private final List<ElementHandlerBase> myParseStack; private final StringBuilder mySb; - public SvnInfoHandler(@Nullable File base, final Consumer<SVNInfo> infoConsumer) { + public SvnInfoHandler(@Nullable File base, final Consumer<org.jetbrains.idea.svn.info.Info> infoConsumer) { myBase = base; myInfoConsumer = infoConsumer; myPending = createPending(); @@ -57,12 +56,12 @@ public class SvnInfoHandler extends DefaultHandler { fillElements(); myParseStack = new ArrayList<ElementHandlerBase>(); myParseStack.add(new Fake()); - myResultsMap = new HashMap<File, SVNInfo>(); + myResultsMap = new HashMap<File, org.jetbrains.idea.svn.info.Info>(); mySb = new StringBuilder(); } private void switchPending() throws SAXException { - final SVNInfo info; + final org.jetbrains.idea.svn.info.Info info; try { info = myPending.convert(); } @@ -78,7 +77,7 @@ public class SvnInfoHandler extends DefaultHandler { private SvnInfoStructure createPending() { SvnInfoStructure pending = new SvnInfoStructure(); - pending.myDepth = SVNDepth.INFINITY; + pending.myDepth = org.jetbrains.idea.svn.api.Depth.INFINITY; return pending; } @@ -280,7 +279,7 @@ public class SvnInfoHandler extends DefaultHandler { myElementsMap.put("lock", new Getter<ElementHandlerBase>() { @Override public ElementHandlerBase get() { - return new Lock(); + return new LockElement(); } }); myElementsMap.put("token", new Getter<ElementHandlerBase>() { @@ -345,7 +344,7 @@ public class SvnInfoHandler extends DefaultHandler { }); } - public Map<File, SVNInfo> getResultsMap() { + public Map<File, org.jetbrains.idea.svn.info.Info> getResultsMap() { return myResultsMap; } @@ -514,8 +513,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - final SVNDate date = SVNDate.parseDate(s); - structure.myCommittedDate = date; + structure.myCommittedDate = s; } } @@ -600,8 +598,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - final SVNDate date = SVNDate.parseDate(s); - structure.myTextTime = date; + structure.myTextTime = s; } } @@ -616,7 +613,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - structure.myDepth = SVNDepth.fromString(s); + structure.myDepth = org.jetbrains.idea.svn.api.Depth.from(s); } } @@ -796,14 +793,14 @@ public class SvnInfoHandler extends DefaultHandler { } } - private static class Lock extends ElementHandlerBase { - private Lock() { + private static class LockElement extends ElementHandlerBase { + private LockElement() { super(new String[]{"token", "owner", "comment", "created"}, new String[]{}); } @Override protected void updateInfo(Attributes attributes, SvnInfoStructure structure) throws SAXException { - structure.myLockWrapper = new SVNLockWrapper(); + structure.myLockBuilder = new Lock.Builder(); } @Override @@ -822,7 +819,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - structure.myLockWrapper.setID(s); + structure.myLockBuilder.setToken(s); } } @@ -837,7 +834,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - structure.myLockWrapper.setOwner(s); + structure.myLockBuilder.setOwner(s); } } @@ -852,7 +849,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - structure.myLockWrapper.setComment(s); + structure.myLockBuilder.setComment(s); } } @@ -867,7 +864,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - structure.myLockWrapper.setCreationDate(SVNDate.parseDate(s)); + structure.myLockBuilder.setCreationDate(SVNDate.parseDate(s)); } } @@ -883,7 +880,7 @@ public class SvnInfoHandler extends DefaultHandler { protected void updateInfo(Attributes attributes, SvnInfoStructure structure) throws SAXException { final String kind = attributes.getValue("kind"); assertSAX(! StringUtil.isEmptyOrSpaces(kind)); - structure.myKind = SVNNodeKind.parseKind(kind); + structure.myKind = NodeKind.from(kind); if (myBase != null) { final String path = attributes.getValue("path"); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoStructure.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoStructure.java index 6e1b1db1efa2..42929885f364 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoStructure.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoStructure.java @@ -15,17 +15,18 @@ */ package org.jetbrains.idea.svn.info; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.conflict.ConflictAction; +import org.jetbrains.idea.svn.conflict.ConflictOperation; +import org.jetbrains.idea.svn.conflict.ConflictReason; +import org.jetbrains.idea.svn.lock.Lock; import org.tmatesoft.svn.core.*; -import org.tmatesoft.svn.core.internal.wc.SVNConflictVersion; -import org.tmatesoft.svn.core.wc.*; import org.xml.sax.SAXException; import java.io.File; import java.util.Date; -import java.util.Map; /** * Created with IntelliJ IDEA. @@ -35,46 +36,28 @@ import java.util.Map; */ public class SvnInfoStructure { - private static final Map<String, SVNConflictAction> ourConflictActions = ContainerUtil.newHashMap(); - private static final Map<String, SVNConflictReason> ourConflictReasons = ContainerUtil.newHashMap(); - - static { - ourConflictActions.put("add", SVNConflictAction.ADD); - ourConflictActions.put("edit", SVNConflictAction.EDIT); - ourConflictActions.put("delete", SVNConflictAction.DELETE); - ourConflictActions.put("replace", SVNConflictAction.REPLACE); - - ourConflictReasons.put("edit", SVNConflictReason.EDITED); - ourConflictReasons.put("obstruct", SVNConflictReason.OBSTRUCTED); - ourConflictReasons.put("delete", SVNConflictReason.DELETED); - ourConflictReasons.put("miss", SVNConflictReason.MISSING); - ourConflictReasons.put("unversion", SVNConflictReason.UNVERSIONED); - ourConflictReasons.put("add", SVNConflictReason.ADDED); - ourConflictReasons.put("replace", SVNConflictReason.REPLACED); - } - @Nullable public File myFile; public String relativeUrl; public SVNURL myUrl; public SVNURL myRootURL; public long myRevision; - public SVNNodeKind myKind; + public NodeKind myKind; public String myUuid; public long myCommittedRevision; - public Date myCommittedDate; + public String myCommittedDate; public String myAuthor; public String mySchedule; public SVNURL myCopyFromURL; public long myCopyFromRevision; - public Date myTextTime; + public String myTextTime; public String myPropTime; public String myChecksum; public String myConflictOld; public String myConflictNew; public String myConflictWorking; public String myPropRejectFile; - public SVNLockWrapper myLockWrapper; - public SVNDepth myDepth; + public Lock.Builder myLockBuilder; + public Depth myDepth; public String myChangelistName; public long myWcSize; public Date myCorrectCommittedDate; @@ -82,65 +65,37 @@ public class SvnInfoStructure { public TreeConflictDescription myTreeConflict; - public SVNInfo convert() throws SAXException, SVNException { - return new IdeaSVNInfo(myFile, myUrl, myRootURL, myRevision, myKind, myUuid, myCommittedRevision, myCommittedDate, myAuthor, mySchedule, - myCopyFromURL, myCopyFromRevision, myTextTime, myPropTime, myChecksum, myConflictOld, myConflictNew, myConflictWorking, - myPropRejectFile, getLock(), myDepth, myChangelistName, myWcSize, createTreeConflict()); + public Info convert() throws SAXException, SVNException { + return new Info(myFile, myUrl, myRootURL, myRevision, myKind, myUuid, myCommittedRevision, myCommittedDate, myAuthor, mySchedule, + myCopyFromURL, myCopyFromRevision, myConflictOld, myConflictNew, myConflictWorking, + myPropRejectFile, getLock(), myDepth, createTreeConflict()); } - private SVNLock getLock() { - SVNLock lock = null; - - if (myLockWrapper != null) { - myLockWrapper.setPath(relativeUrl); - lock = myLockWrapper.create(); - } - - return lock; + @Nullable + private Lock getLock() { + return myLockBuilder != null ? myLockBuilder.build() : null; } - private SVNTreeConflictDescription createTreeConflict() throws SAXException, SVNException { + private org.jetbrains.idea.svn.conflict.TreeConflictDescription createTreeConflict() throws SAXException, SVNException { if (myTreeConflict == null) { return null; } else { assert myFile != null; - final SVNConflictAction action = parseConflictAction(myTreeConflict.myAction); - final SVNConflictReason reason = parseConflictReason(myTreeConflict.myReason); - SVNOperation operation = SVNOperation.fromString(myTreeConflict.myOperation); - operation = operation == null ? SVNOperation.NONE : operation; - return new SVNTreeConflictDescription(myFile, myKind, action, reason, operation, - createVersion(myTreeConflict.mySourceLeft), - createVersion(myTreeConflict.mySourceRight)); + return new org.jetbrains.idea.svn.conflict.TreeConflictDescription(myFile, myKind, ConflictAction.from(myTreeConflict.myAction), + ConflictReason.from(myTreeConflict.myReason), + ConflictOperation.from(myTreeConflict.myOperation), + createVersion(myTreeConflict.mySourceLeft), + createVersion(myTreeConflict.mySourceRight)); } } - private SVNConflictAction parseConflictAction(@NotNull String actionName) { - SVNConflictAction action = SVNConflictAction.fromString(actionName); - action = action != null ? action : ourConflictActions.get(actionName); - - if (action == null) { - throw new IllegalArgumentException("Unknown conflict action " + actionName); - } - - return action; - } - - private SVNConflictReason parseConflictReason(@NotNull String reasonName) throws SAXException { - SVNConflictReason reason = SVNConflictReason.fromString(reasonName); - reason = reason != null ? reason : ourConflictReasons.get(reasonName); - - if (reason == null) { - throw new SAXException("Can not parse conflict reason: " + reasonName); - } - - return reason; - } - - private SVNConflictVersion createVersion(final ConflictVersion version) throws SVNException, SAXException { - return version == null ? null : new SVNConflictVersion(SVNURL.parseURIEncoded(version.myRepoUrl), version.myPathInRepo, - parseRevision(version.myRevision), SVNNodeKind.parseKind(version.myKind)); + private org.jetbrains.idea.svn.conflict.ConflictVersion createVersion(final ConflictVersion version) throws SVNException, SAXException { + return version == null + ? null + : new org.jetbrains.idea.svn.conflict.ConflictVersion(SVNURL.parseURIEncoded(version.myRepoUrl), version.myPathInRepo, + parseRevision(version.myRevision), NodeKind.from(version.myKind)); } private long parseRevision(final String revision) throws SAXException { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnKitInfoClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnKitInfoClient.java index 7f50e85cd2d7..3db2c647791a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnKitInfoClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnKitInfoClient.java @@ -18,12 +18,9 @@ package org.jetbrains.idea.svn.info; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.info.InfoClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNInfoHandler; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNWCClient; @@ -43,50 +40,27 @@ public class SvnKitInfoClient extends BaseSvnClient implements InfoClient { } @Override - public void doInfo(File path, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) throws SVNException { - getClient().doInfo(path, revision, recursive, handler); + public Info doInfo(File path, SVNRevision revision) throws SvnBindException { + try { + return Info.create(getClient().doInfo(path, revision)); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } @Override - public void doInfo(File path, SVNRevision pegRevision, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) - throws SVNException { - getClient().doInfo(path, pegRevision, revision, recursive, handler); + public Info doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision) throws SvnBindException { + try { + return Info.create(getClient().doInfo(url, pegRevision, revision)); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } @Override - public void doInfo(File path, - SVNRevision pegRevision, - SVNRevision revision, - SVNDepth depth, - Collection changeLists, - ISVNInfoHandler handler) throws SVNException { - getClient().doInfo(path, pegRevision, revision, depth, changeLists, handler); - } - - @Override - public void doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) - throws SVNException { - getClient().doInfo(url, pegRevision, revision, recursive, handler); - } - - @Override - public void doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision, SVNDepth depth, ISVNInfoHandler handler) - throws SVNException { - getClient().doInfo(url, pegRevision, revision, depth, handler); - } - - @Override - public SVNInfo doInfo(File path, SVNRevision revision) throws SVNException { - return getClient().doInfo(path, revision); - } - - @Override - public SVNInfo doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision) throws SVNException { - return getClient().doInfo(url, pegRevision, revision); - } - - @Override - public void doInfo(@NotNull Collection<File> paths, @Nullable ISVNInfoHandler handler) throws SVNException { + public void doInfo(@NotNull Collection<File> paths, @Nullable InfoConsumer handler) throws SvnBindException { throw new UnsupportedOperationException(); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/CmdMergeClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/CmdMergeClient.java index 63eb66d9b002..2f9d8ae5aac5 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/CmdMergeClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/CmdMergeClient.java @@ -4,10 +4,10 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.*; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.tmatesoft.svn.core.wc.SVNRevisionRange; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -23,8 +23,8 @@ public class CmdMergeClient extends BaseSvnClient implements MergeClient { public void merge(@NotNull SvnTarget source, @NotNull File destination, boolean dryRun, - @Nullable SVNDiffOptions diffOptions, - @Nullable final ISVNEventHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable final ProgressTracker handler) throws VcsException { assertUrl(source); List<String> parameters = new ArrayList<String>(); @@ -38,12 +38,12 @@ public class CmdMergeClient extends BaseSvnClient implements MergeClient { public void merge(@NotNull SvnTarget source, @NotNull SVNRevisionRange range, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean dryRun, boolean recordOnly, boolean force, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException { assertUrl(source); List<String> parameters = new ArrayList<String>(); @@ -60,13 +60,13 @@ public class CmdMergeClient extends BaseSvnClient implements MergeClient { public void merge(@NotNull SvnTarget source1, @NotNull SvnTarget source2, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean useAncestry, boolean dryRun, boolean recordOnly, boolean force, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException { assertUrl(source1); assertUrl(source2); @@ -82,12 +82,12 @@ public class CmdMergeClient extends BaseSvnClient implements MergeClient { private static void fillParameters(@NotNull List<String> parameters, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean dryRun, boolean recordOnly, boolean force, boolean reintegrate, - @Nullable SVNDiffOptions diffOptions) { + @Nullable DiffOptions diffOptions) { CommandUtil.put(parameters, destination); CommandUtil.put(parameters, diffOptions); CommandUtil.put(parameters, dryRun, "--dry-run"); @@ -102,7 +102,7 @@ public class CmdMergeClient extends BaseSvnClient implements MergeClient { CommandUtil.put(parameters, reintegrate, "--reintegrate"); } - private void run(File destination, ISVNEventHandler handler, List<String> parameters) throws VcsException { + private void run(File destination, ProgressTracker handler, List<String> parameters) throws VcsException { BaseUpdateCommandListener listener = new BaseUpdateCommandListener(CommandUtil.correctUpToExistingParent(destination), handler); execute(myVcs, SvnTarget.fromFile(destination), SvnCommandName.merge, parameters, listener); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/GroupMerger.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/GroupMerger.java index cb62668cbb25..73346ad4af66 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/GroupMerger.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/GroupMerger.java @@ -27,8 +27,8 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.update.UpdateEventHandler; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -131,7 +131,7 @@ public class GroupMerger implements IMerger { SvnTarget source = SvnTarget.fromURL(myCurrentBranchUrl); MergeClient client = myVcs.getFactory(myTarget).createMergeClient(); - client.merge(source, createRange(), myTarget, SVNDepth.INFINITY, mySvnConfig.isMergeDryRun(), myDryRun, true, + client.merge(source, createRange(), myTarget, Depth.INFINITY, mySvnConfig.isMergeDryRun(), myDryRun, true, mySvnConfig.getMergeOptions(), myHandler); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegrateEventHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegrateEventHandler.java index 75533d8801c3..d043c95f1f1d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegrateEventHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegrateEventHandler.java @@ -19,22 +19,22 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.vcs.update.FileGroup; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.status.StatusType; import org.jetbrains.idea.svn.update.UpdateEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; -import org.tmatesoft.svn.core.wc.SVNStatusType; public class IntegrateEventHandler extends UpdateEventHandler { public IntegrateEventHandler(final SvnVcs vcs, final ProgressIndicator progressIndicator) { super(vcs, progressIndicator, null); } - protected boolean handleInDescendants(final SVNEvent event) { - if ((event.getAction() == SVNEventAction.UPDATE_UPDATE) && (event.getContentsStatus() == SVNStatusType.UNCHANGED) && - (event.getPropertiesStatus() == SVNStatusType.UNKNOWN)) { + protected boolean handleInDescendants(final ProgressEvent event) { + if ((event.getAction() == EventAction.UPDATE_UPDATE) && (event.getContentsStatus() == StatusType.UNCHANGED) && + (event.getPropertiesStatus() == StatusType.UNKNOWN)) { myText2 = SvnBundle.message("progres.text2.updated", event.getFile().getName()); return true; - } else if (event.getAction() == SVNEventAction.DELETE) { + } else if (event.getAction() == EventAction.DELETE) { addFileToGroup(FileGroup.REMOVED_FROM_REPOSITORY_ID, event); myText2 = SvnBundle.message("progress.text2.deleted", event.getFile().getName()); return true; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegratedSelectedOptionsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegratedSelectedOptionsDialog.java index 3029f156a69c..3b2184c22484 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegratedSelectedOptionsDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegratedSelectedOptionsDialog.java @@ -32,8 +32,8 @@ import com.intellij.util.PlatformIcons; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import javax.swing.*; import javax.swing.event.ListSelectionEvent; @@ -248,7 +248,7 @@ public class IntegratedSelectedOptionsDialog extends DialogWrapper { @Nullable private static SVNURL realTargetUrl(final SvnVcs vcs, final WorkingCopyInfo info, final String targetBranchUrl) { - final SVNInfo svnInfo = vcs.getInfo(info.getLocalPath()); + final Info svnInfo = vcs.getInfo(info.getLocalPath()); final SVNURL svnurl = svnInfo != null ? svnInfo.getURL() : null; return (svnurl != null) && (svnurl.toString().startsWith(targetBranchUrl)) ? svnurl : null; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeCalculatorTask.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeCalculatorTask.java index 782bd789e00e..6e9f165798a0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeCalculatorTask.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeCalculatorTask.java @@ -33,16 +33,11 @@ import org.jetbrains.idea.svn.actions.ChangeListsMergerFactory; import org.jetbrains.idea.svn.dialogs.MergeContext; import org.jetbrains.idea.svn.dialogs.QuickMergeContentsVariants; import org.jetbrains.idea.svn.dialogs.SvnBranchPointsCalculator; -import org.jetbrains.idea.svn.history.SvnChangeList; -import org.jetbrains.idea.svn.history.SvnCommittedChangesProvider; -import org.jetbrains.idea.svn.history.SvnRepositoryLocation; -import org.jetbrains.idea.svn.history.TreeStructureNode; +import org.jetbrains.idea.svn.history.*; import org.jetbrains.idea.svn.mergeinfo.MergeChecker; import org.jetbrains.idea.svn.mergeinfo.OneShotMergeInfoHelper; import org.jetbrains.idea.svn.mergeinfo.SvnMergeInfoCache; import org.jetbrains.idea.svn.update.UpdateEventHandler; -import org.tmatesoft.svn.core.SVNLogEntry; -import org.tmatesoft.svn.core.SVNLogEntryPath; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; @@ -121,13 +116,13 @@ public class MergeCalculatorTask extends BaseMergeTask implements String relativeBranch = SVNPathUtil.getRelativePath(myMergeContext.getWcInfo().getRepositoryRoot(), myMergeContext.getSourceUrl()); relativeBranch = (relativeBranch.startsWith("/") ? relativeBranch : "/" + relativeBranch); - final LinkedList<Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>> list = - new LinkedList<Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>>(); + final LinkedList<Pair<SvnChangeList, LogHierarchyNode>> list = + new LinkedList<Pair<SvnChangeList, LogHierarchyNode>>(); try { committedChangesProvider.getCommittedChangesWithMergedRevisons(settings, new SvnRepositoryLocation(myMergeContext.getSourceUrl()), 0, - new PairConsumer<SvnChangeList, TreeStructureNode<SVNLogEntry>>() { + new PairConsumer<SvnChangeList, LogHierarchyNode>() { public void consume(SvnChangeList svnList, - TreeStructureNode<SVNLogEntry> tree) { + LogHierarchyNode tree) { indicator.checkCanceled(); if (sourceLatest >= svnList.getNumber()) return; list.add( @@ -144,7 +139,7 @@ public class MergeCalculatorTask extends BaseMergeTask implements indicator.setText("Checking merge information..."); // to do not go into file system while asking something on the net - for (Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>> pair : list) { + for (Pair<SvnChangeList, LogHierarchyNode> pair : list) { final SvnChangeList svnList = pair.getFirst(); final SvnMergeInfoCache.MergeCheckResult checkResult = myMergeChecker.checkList(svnList); indicator.setText2("Processing revision " + svnList.getNumber()); @@ -204,7 +199,7 @@ public class MergeCalculatorTask extends BaseMergeTask implements // true if errors found static boolean checkListForPaths(String relativeLocal, - String relativeBranch, Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>> pair) { + String relativeBranch, Pair<SvnChangeList, LogHierarchyNode> pair) { // TODO: Such filtering logic is not clear enough so far (and probably not correct for all cases - for instance when we perform merge // TODO: from branch1 to branch2 and have revision which contain merge changes from branch3 to branch1. // TODO: In this case paths of child log entries will not contain neither urls from branch1 nor from branch2 - and checkEntry() method @@ -212,9 +207,9 @@ public class MergeCalculatorTask extends BaseMergeTask implements // TODO: Why do we check entries recursively - we have a revision - set of changes in the "merge from" branch? Why do we need to check // TODO: where they came from - we want avoid some circular merges or what? Does subversion itself perform such checks or not? - final List<TreeStructureNode<SVNLogEntry>> children = pair.getSecond().getChildren(); + final List<LogHierarchyNode> children = pair.getSecond().getChildren(); boolean localChange = false; - for (TreeStructureNode<SVNLogEntry> child : children) { + for (LogHierarchyNode child : children) { if (checkForSubtree(child, relativeLocal, relativeBranch)) { localChange = true; break; @@ -228,13 +223,13 @@ public class MergeCalculatorTask extends BaseMergeTask implements } // true if errors found - private static boolean checkForSubtree(final TreeStructureNode<SVNLogEntry> tree, + private static boolean checkForSubtree(final LogHierarchyNode tree, String relativeBranch, final String localURL) { - final LinkedList<TreeStructureNode<SVNLogEntry>> queue = new LinkedList<TreeStructureNode<SVNLogEntry>>(); + final LinkedList<LogHierarchyNode> queue = new LinkedList<LogHierarchyNode>(); queue.addLast(tree); while (!queue.isEmpty()) { - final TreeStructureNode<SVNLogEntry> element = queue.removeFirst(); + final LogHierarchyNode element = queue.removeFirst(); ProgressManager.checkCanceled(); if (checkForEntry(element.getMe(), localURL, relativeBranch)) return true; @@ -248,11 +243,11 @@ public class MergeCalculatorTask extends BaseMergeTask implements // or if no changed paths in current branch, checks if at least one path in "merge from" branch // NOTE: this fails for "merge-source" log entries from other branches - when all changed paths are from some // third branch - this logic treats such log entry as local. - private static boolean checkForEntry(final SVNLogEntry entry, final String localURL, String relativeBranch) { + private static boolean checkForEntry(final LogEntry entry, final String localURL, String relativeBranch) { boolean atLeastOneUnderBranch = false; final Map map = entry.getChangedPaths(); for (Object o : map.values()) { - final SVNLogEntryPath path = (SVNLogEntryPath)o; + final LogEntryPath path = (LogEntryPath)o; if (SVNPathUtil.isAncestor(localURL, path.getPath())) { return true; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeClient.java index 94e4c9cece38..d32ea2951cd0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeClient.java @@ -3,10 +3,10 @@ package org.jetbrains.idea.svn.integrate; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.tmatesoft.svn.core.wc.SVNRevisionRange; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -20,27 +20,27 @@ public interface MergeClient extends SvnClient { void merge(@NotNull SvnTarget source, @NotNull File destination, boolean dryRun, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException; void merge(@NotNull SvnTarget source, @NotNull SVNRevisionRange range, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean dryRun, boolean recordOnly, boolean force, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException; void merge(@NotNull SvnTarget source1, @NotNull SvnTarget source2, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean useAncestry, boolean dryRun, boolean recordOnly, boolean force, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/Merger.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/Merger.java index 8f534b90bb27..07e0c5bbb737 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/Merger.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/Merger.java @@ -28,8 +28,9 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.update.UpdateEventHandler; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.*; @@ -44,7 +45,7 @@ import java.util.List; public class Merger implements IMerger { protected final List<CommittedChangeList> myChangeLists; protected final File myTarget; - @Nullable private final ISVNEventHandler myHandler; + @Nullable private final ProgressTracker myHandler; protected int myCount; private final ProgressIndicator myProgressIndicator; protected CommittedChangeList myLatestProcessed; @@ -128,7 +129,7 @@ public class Merger implements IMerger { SvnTarget source = SvnTarget.fromURL(myCurrentBranchUrl); MergeClient client = myVcs.getFactory(myTarget).createMergeClient(); - client.merge(source, createRange(), myTarget, SVNDepth.INFINITY, mySvnConfig.isMergeDryRun(), isRecordOnly(), true, + client.merge(source, createRange(), myTarget, Depth.INFINITY, mySvnConfig.isMergeDryRun(), isRecordOnly(), true, mySvnConfig.getMergeOptions(), myHandler); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/PointMerger.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/PointMerger.java index 1a58a3c80b68..aabf015f97ee 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/PointMerger.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/PointMerger.java @@ -22,11 +22,11 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.copy.CopyMoveClient; import org.jetbrains.idea.svn.delete.DeleteClient; import org.jetbrains.idea.svn.history.SvnRepositoryContentRevision; import org.jetbrains.idea.svn.update.UpdateEventHandler; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; @@ -87,7 +87,7 @@ public class PointMerger extends Merger { SvnTarget source1 = SvnTarget.fromURL(SVNURL.parseURIEncoded(beforeUrl), ((SvnRevisionNumber)before.getRevisionNumber()).getRevision()); SvnTarget source2 = SvnTarget.fromURL(SVNURL.parseURIEncoded(afterUrl), ((SvnRevisionNumber) after.getRevisionNumber()).getRevision()); - client.merge(source1, source2, afterPath, SVNDepth.FILES, true, mySvnConfig.isMergeDryRun(), false, false, mySvnConfig.getMergeOptions(), + client.merge(source1, source2, afterPath, Depth.FILES, true, mySvnConfig.isMergeDryRun(), false, false, mySvnConfig.getMergeOptions(), myHandler); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnIntegrateChangesTask.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnIntegrateChangesTask.java index b4e544ba1e3d..5dd6f24b10ba 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnIntegrateChangesTask.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnIntegrateChangesTask.java @@ -36,11 +36,11 @@ import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnChangeProvider; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.jetbrains.idea.svn.update.UpdateEventHandler; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.util.ArrayList; @@ -267,8 +267,8 @@ public class SvnIntegrateChangesTask extends Task.Backgroundable { private void initMergeTarget() { final File mergeInfoHolder = myMerger.getMergeInfoHolder(); if (mergeInfoHolder != null) { - final SVNStatus svnStatus = SvnUtil.getStatus(myVcs, mergeInfoHolder); - if ((svnStatus != null) && (SVNStatusType.STATUS_MODIFIED.equals(svnStatus.getPropertiesStatus()))) { + final Status svnStatus = SvnUtil.getStatus(myVcs, mergeInfoHolder); + if ((svnStatus != null) && (StatusType.STATUS_MODIFIED.equals(svnStatus.getPropertiesStatus()))) { myMergeTarget = FilePathImpl.create(mergeInfoHolder, mergeInfoHolder.isDirectory()); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnKitMergeClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnKitMergeClient.java index e3635ff8827b..51cbc7c10409 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnKitMergeClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnKitMergeClient.java @@ -4,11 +4,11 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNDiffClient; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; import org.tmatesoft.svn.core.wc.SVNRevisionRange; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -23,8 +23,8 @@ public class SvnKitMergeClient extends BaseSvnClient implements MergeClient { public void merge(@NotNull SvnTarget source, @NotNull File destination, boolean dryRun, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException { assertUrl(source); try { @@ -39,17 +39,17 @@ public class SvnKitMergeClient extends BaseSvnClient implements MergeClient { public void merge(@NotNull SvnTarget source, @NotNull SVNRevisionRange range, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean dryRun, boolean recordOnly, boolean force, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException { assertUrl(source); try { createClient(diffOptions, handler).doMerge(source.getURL(), source.getPegRevision(), Collections.singletonList(range), destination, - depth, true, force, dryRun, recordOnly); + toDepth(depth), true, force, dryRun, recordOnly); } catch (SVNException e) { throw new VcsException(e); @@ -60,19 +60,19 @@ public class SvnKitMergeClient extends BaseSvnClient implements MergeClient { public void merge(@NotNull SvnTarget source1, @NotNull SvnTarget source2, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean useAncestry, boolean dryRun, boolean recordOnly, boolean force, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException { assertUrl(source1); assertUrl(source2); try { createClient(diffOptions, handler).doMerge(source1.getURL(), source1.getPegRevision(), source2.getURL(), source2.getPegRevision(), - destination, depth, useAncestry, force, dryRun, recordOnly); + destination, toDepth(depth), useAncestry, force, dryRun, recordOnly); } catch (SVNException e) { throw new VcsException(e); @@ -80,11 +80,11 @@ public class SvnKitMergeClient extends BaseSvnClient implements MergeClient { } @NotNull - private SVNDiffClient createClient(@Nullable SVNDiffOptions diffOptions, @Nullable ISVNEventHandler handler) { + private SVNDiffClient createClient(@Nullable DiffOptions diffOptions, @Nullable ProgressTracker handler) { SVNDiffClient client = myVcs.getSvnKitManager().createDiffClient(); - client.setMergeOptions(diffOptions); - client.setEventHandler(handler); + client.setMergeOptions(toDiffOptions(diffOptions)); + client.setEventHandler(toEventHandler(handler)); return client; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/CmdLockClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/CmdLockClient.java index abc4b5b794c2..551431dd7f16 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/CmdLockClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/CmdLockClient.java @@ -5,15 +5,14 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; import org.tmatesoft.svn.core.SVNErrorMessage; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -26,22 +25,22 @@ import java.util.List; public class CmdLockClient extends BaseSvnClient implements LockClient { @Override - public void lock(@NotNull File file, boolean force, @NotNull String message, @Nullable ISVNEventHandler handler) throws VcsException { + public void lock(@NotNull File file, boolean force, @NotNull String message, @Nullable ProgressTracker handler) throws VcsException { List<String> parameters = prepareParameters(file, force); parameters.add("--message"); parameters.add(message); CommandExecutor command = execute(myVcs, SvnTarget.fromFile(file), SvnCommandName.lock, parameters, null); - handleCommandCompletion(command, file, SVNEventAction.LOCKED, SVNEventAction.LOCK_FAILED, handler); + handleCommandCompletion(command, file, EventAction.LOCKED, EventAction.LOCK_FAILED, handler); } @Override - public void unlock(@NotNull File file, boolean force, @Nullable ISVNEventHandler handler) throws VcsException { + public void unlock(@NotNull File file, boolean force, @Nullable ProgressTracker handler) throws VcsException { List<String> parameters = prepareParameters(file, force); CommandExecutor command = execute(myVcs, SvnTarget.fromFile(file), SvnCommandName.unlock, parameters, null); - handleCommandCompletion(command, file, SVNEventAction.UNLOCKED, SVNEventAction.UNLOCK_FAILED, handler); + handleCommandCompletion(command, file, EventAction.UNLOCKED, EventAction.UNLOCK_FAILED, handler); } private static List<String> prepareParameters(@NotNull File file, boolean force) { @@ -55,9 +54,9 @@ public class CmdLockClient extends BaseSvnClient implements LockClient { private static void handleCommandCompletion(@NotNull CommandExecutor command, @NotNull File file, - @NotNull SVNEventAction success, - @NotNull SVNEventAction failure, - @Nullable ISVNEventHandler handler) throws VcsException { + @NotNull EventAction success, + @NotNull EventAction failure, + @Nullable ProgressTracker handler) throws VcsException { // just warning appears in output when can not lock/unlock file for some reason (like, that file is already locked) SVNErrorMessage error = SvnUtil.parseWarning(command.getErrorOutput()); @@ -70,17 +69,16 @@ public class CmdLockClient extends BaseSvnClient implements LockClient { } private static void invokeHandler(@NotNull File file, - @NotNull SVNEventAction action, - @Nullable ISVNEventHandler handler, + @NotNull EventAction action, + @Nullable ProgressTracker handler, @Nullable SVNErrorMessage error) throws SVNException { if (handler != null) { - handler.handleEvent(createEvent(file, action, error), 1); + handler.consume(createEvent(file, action, error)); } } - private static SVNEvent createEvent(@NotNull File file, @NotNull SVNEventAction action, @Nullable SVNErrorMessage error) { - return new SVNEvent(file, file.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE, null, -1, null, null, null, null, action, action, - error, null, null, null, null); + private static ProgressEvent createEvent(@NotNull File file, @NotNull EventAction action, @Nullable SVNErrorMessage error) { + return new ProgressEvent(file, -1, null, null, action, error, null); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/Lock.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/Lock.java new file mode 100644 index 000000000000..60598a91aeda --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/Lock.java @@ -0,0 +1,128 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.lock; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.tmatesoft.svn.core.SVNLock; + +import javax.xml.bind.annotation.*; +import java.util.Date; + +/** + * TODO: Probably unify with LogicalLock class + * + * @author Konstantin Kolosovsky. + */ +public class Lock { + + private final String myOwner; + private final String myComment; + private final Date myCreationDate; + @Nullable private final Date myExpirationDate; + + @Nullable + public static Lock create(@Nullable SVNLock lock) { + Lock result = null; + + if (lock != null) { + result = new Lock.Builder().setOwner(lock.getOwner()).setComment(lock.getComment()).setCreationDate(lock.getCreationDate()) + .setExpirationDate(lock.getExpirationDate()).build(); + } + + return result; + } + + public Lock(@NotNull Lock.Builder builder) { + myOwner = builder.owner; + myComment = builder.comment; + myCreationDate = builder.created; + myExpirationDate = builder.expires; + } + + public String getComment() { + return myComment; + } + + public Date getCreationDate() { + return myCreationDate; + } + + @Nullable + public Date getExpirationDate() { + return myExpirationDate; + } + + public String getOwner() { + return myOwner; + } + + @XmlAccessorType(XmlAccessType.NONE) + @XmlType(name = "lock") + @XmlRootElement(name = "lock") + public static class Builder { + + @XmlElement(name = "token") + private String token; + + @XmlElement(name = "owner") + private String owner; + + @XmlElement(name = "comment") + private String comment; + + @XmlElement(name = "created") + private Date created; + + @XmlElement(name = "expires") + @Nullable private Date expires; + + @NotNull + public Builder setToken(String token) { + this.token = token; + return this; + } + + @NotNull + public Builder setOwner(String owner) { + this.owner = owner; + return this; + } + + @NotNull + public Builder setComment(String comment) { + this.comment = comment; + return this; + } + + @NotNull + public Builder setCreationDate(Date creationDate) { + this.created = creationDate; + return this; + } + + @NotNull + public Builder setExpirationDate(@Nullable Date expirationDate) { + this.expires = expirationDate; + return this; + } + + @NotNull + public Lock build() { + return new Lock(this); + } + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/LockClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/LockClient.java index f36891f294b3..4a64a4e88de3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/LockClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/LockClient.java @@ -3,8 +3,8 @@ package org.jetbrains.idea.svn.lock; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import java.io.File; @@ -16,9 +16,9 @@ public interface LockClient extends SvnClient { void lock(@NotNull File file, boolean force, @NotNull String message, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable ProgressTracker handler) throws VcsException; void unlock(@NotNull File file, boolean force, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/SvnKitLockClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/SvnKitLockClient.java index d11aec262b09..2db2650aab04 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/SvnKitLockClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/SvnKitLockClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -17,7 +17,7 @@ import java.io.File; public class SvnKitLockClient extends BaseSvnClient implements LockClient { @Override - public void lock(@NotNull File file, boolean force, @NotNull String message, @Nullable ISVNEventHandler handler) throws VcsException { + public void lock(@NotNull File file, boolean force, @NotNull String message, @Nullable ProgressTracker handler) throws VcsException { try { getClient(handler).doLock(new File[]{file}, force, message); } @@ -27,7 +27,7 @@ public class SvnKitLockClient extends BaseSvnClient implements LockClient { } @Override - public void unlock(@NotNull File file, boolean force, @Nullable ISVNEventHandler handler) throws VcsException { + public void unlock(@NotNull File file, boolean force, @Nullable ProgressTracker handler) throws VcsException { try { getClient(handler).doUnlock(new File[]{file}, force); } @@ -37,10 +37,10 @@ public class SvnKitLockClient extends BaseSvnClient implements LockClient { } @NotNull - private SVNWCClient getClient(@Nullable ISVNEventHandler handler) { + private SVNWCClient getClient(@Nullable ProgressTracker handler) { SVNWCClient client = myVcs.getSvnKitManager().createWCClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); return client; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/BranchInfo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/BranchInfo.java index ead9b7ddc587..62638291b485 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/BranchInfo.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/BranchInfo.java @@ -21,10 +21,10 @@ import com.intellij.openapi.vcs.VcsException; import com.intellij.util.containers.MultiMap; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.history.SvnChangeList; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.util.SVNMergeInfoUtil; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNPropertyData; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -123,7 +123,7 @@ public class BranchInfo { } private SvnMergeInfoCache.MergeCheckResult checkAlive(final SvnChangeList list, final String branchPath) { - final SVNInfo info = getInfo(new File(branchPath)); + final Info info = getInfo(new File(branchPath)); if (info == null || info.getURL() == null || (! SVNPathUtil.isAncestor(myBranchUrl, info.getURL().toString()))) { return SvnMergeInfoCache.MergeCheckResult.NOT_MERGED; } @@ -179,7 +179,7 @@ public class BranchInfo { // no paths in local copy return SvnMergeInfoCache.MergeCheckResult.NOT_EXISTS; } - final SVNInfo svnInfo = getInfo(new File(branchRootPath)); + final Info svnInfo = getInfo(new File(branchRootPath)); if (svnInfo == null || svnInfo.getRevision() == null || svnInfo.getURL() == null) { return SvnMergeInfoCache.MergeCheckResult.NOT_MERGED; } @@ -238,7 +238,7 @@ public class BranchInfo { return processMergeinfoProperty(keyString, revisionAsked, mergeinfoProperty.getValue(), trunkUrl, false); } - private SVNInfo getInfo(final File pathFile) { + private Info getInfo(final File pathFile) { return myVcs.getInfo(pathFile); } @@ -255,7 +255,7 @@ public class BranchInfo { } } - final SVNInfo svnInfo = getInfo(pathFile); + final Info svnInfo = getInfo(pathFile); if (svnInfo == null || svnInfo.getRevision() == null || svnInfo.getURL() == null) { LOG.info("Svninfo for " + pathFile + " is null or not full."); return SvnMergeInfoCache.MergeCheckResult.NOT_MERGED; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/OneRecursiveShotMergeInfoWorker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/OneRecursiveShotMergeInfoWorker.java index bd2c41537091..0ea95c99c4d4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/OneRecursiveShotMergeInfoWorker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/OneRecursiveShotMergeInfoWorker.java @@ -21,6 +21,7 @@ import com.intellij.openapi.vcs.AreaMap; import com.intellij.openapi.vcs.VcsException; import com.intellij.util.PairProcessor; import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.dialogs.MergeContext; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.util.SVNMergeInfoUtil; @@ -61,7 +62,7 @@ public class OneRecursiveShotMergeInfoWorker implements MergeInfoWorker { } public void prepare() throws VcsException { - final SVNDepth depth = myMergeContext.getVcs().getSvnConfiguration().isCheckNestedForQuickMerge() ? SVNDepth.INFINITY : SVNDepth.EMPTY; + final Depth depth = Depth.allOrEmpty(myMergeContext.getVcs().getSvnConfiguration().isCheckNestedForQuickMerge()); ISVNPropertyHandler handler = new ISVNPropertyHandler() { public void handleProperty(File path, SVNPropertyData property) throws SVNException { final String key = keyFromFile(path); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/CmdPropertyClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/CmdPropertyClient.java index 60ab43c3baba..e855abe1ec2e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/CmdPropertyClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/CmdPropertyClient.java @@ -5,12 +5,13 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.ISVNPropertyHandler; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNPropertyData; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -63,7 +64,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { public void getProperty(@NotNull SvnTarget target, @NotNull String property, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException { List<String> parameters = new ArrayList<String>(); @@ -77,7 +78,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { @Override public void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException { List<String> parameters = new ArrayList<String>(); fillListParameters(target, revision, depth, parameters, true); @@ -90,7 +91,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { public void setProperty(@NotNull File file, @NotNull String property, @Nullable SVNPropertyValue value, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean force) throws VcsException { runSetProperty(SvnTarget.fromFile(file), property, null, depth, value, force); } @@ -101,7 +102,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { currentProperties.putAll(properties); for (String propertyName : currentProperties.nameSet()) { - setProperty(file, propertyName, currentProperties.getSVNPropertyValue(propertyName), SVNDepth.EMPTY, true); + setProperty(file, propertyName, currentProperties.getSVNPropertyValue(propertyName), Depth.EMPTY, true); } } @@ -109,7 +110,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { private SVNProperties collectPropertiesToDelete(@NotNull File file) throws VcsException { final SVNProperties result = new SVNProperties(); - list(SvnTarget.fromFile(file), null, SVNDepth.EMPTY, new ISVNPropertyHandler() { + list(SvnTarget.fromFile(file), null, Depth.EMPTY, new ISVNPropertyHandler() { @Override public void handleProperty(File path, SVNPropertyData property) throws SVNException { // null indicates property will be deleted @@ -140,7 +141,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { private void runSetProperty(@NotNull SvnTarget target, @NotNull String property, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable SVNPropertyValue value, boolean force) throws VcsException { List<String> parameters = new ArrayList<String>(); @@ -169,7 +170,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { private void fillListParameters(@NotNull SvnTarget target, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @NotNull List<String> parameters, boolean verbose) { CommandUtil.put(parameters, target); @@ -266,7 +267,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { // base should be resolved manually - could not set revision to BASE to get revision property if (SVNRevision.BASE.equals(revision)) { - SVNInfo info = myVcs.getInfo(path, SVNRevision.BASE); + Info info = myVcs.getInfo(path, SVNRevision.BASE); result = info != null ? info.getRevision().getNumber() : -1; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/PropertyClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/PropertyClient.java index b44f7ea12e75..1b61d59c0e20 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/PropertyClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/PropertyClient.java @@ -5,8 +5,8 @@ import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.util.LineSeparator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNProperties; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions; @@ -38,18 +38,18 @@ public interface PropertyClient extends SvnClient { void getProperty(@NotNull SvnTarget target, @NotNull String property, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException; void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException; void setProperty(@NotNull File file, @NotNull String property, @Nullable SVNPropertyValue value, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean force) throws VcsException; void setProperties(@NotNull File file, @NotNull SVNProperties properties) throws VcsException; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/SvnKitPropertyClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/SvnKitPropertyClient.java index 64343927be11..4ad3f10afccc 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/SvnKitPropertyClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/SvnKitPropertyClient.java @@ -4,6 +4,7 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.*; @@ -50,7 +51,7 @@ public class SvnKitPropertyClient extends BaseSvnClient implements PropertyClien public void getProperty(@NotNull SvnTarget target, @NotNull String property, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException { runGetProperty(target, property, revision, depth, handler); } @@ -58,7 +59,7 @@ public class SvnKitPropertyClient extends BaseSvnClient implements PropertyClien @Override public void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException { runGetProperty(target, null, revision, depth, handler); } @@ -67,10 +68,10 @@ public class SvnKitPropertyClient extends BaseSvnClient implements PropertyClien public void setProperty(@NotNull File file, @NotNull String property, @Nullable SVNPropertyValue value, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean force) throws VcsException { try { - createClient().doSetProperty(file, property, value, force, depth, null, null); + createClient().doSetProperty(file, property, value, force, toDepth(depth), null, null); } catch (SVNException e) { throw new SvnBindException(e); @@ -114,15 +115,15 @@ public class SvnKitPropertyClient extends BaseSvnClient implements PropertyClien private void runGetProperty(@NotNull SvnTarget target, @Nullable String property, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException { SVNWCClient client = createClient(); try { if (target.isURL()) { - client.doGetProperty(target.getURL(), property, target.getPegRevision(), revision, depth, handler); + client.doGetProperty(target.getURL(), property, target.getPegRevision(), revision, toDepth(depth), handler); } else { - client.doGetProperty(target.getFile(), property, target.getPegRevision(), revision, depth, handler, null); + client.doGetProperty(target.getFile(), property, target.getPegRevision(), revision, toDepth(depth), handler, null); } } catch (SVNException e) { throw new VcsException(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/CmdRevertClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/CmdRevertClient.java index aef5ae942687..a57e24b525d7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/CmdRevertClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/CmdRevertClient.java @@ -4,15 +4,11 @@ import com.intellij.openapi.vcs.VcsException; import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.api.FileStatusResultParser; +import org.jetbrains.idea.svn.api.*; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -32,7 +28,7 @@ public class CmdRevertClient extends BaseSvnClient implements RevertClient { private static final Pattern CHANGED_PATH = Pattern.compile(STATUS + PATH + OPTIONAL_COMMENT); @Override - public void revert(@NotNull File[] paths, @Nullable SVNDepth depth, @Nullable ISVNEventHandler handler) throws VcsException { + public void revert(@NotNull File[] paths, @Nullable Depth depth, @Nullable ProgressTracker handler) throws VcsException { if (paths.length > 0) { List<String> parameters = prepareParameters(paths, depth); @@ -46,7 +42,7 @@ public class CmdRevertClient extends BaseSvnClient implements RevertClient { } } - private static List<String> prepareParameters(File[] paths, SVNDepth depth) { + private static List<String> prepareParameters(File[] paths, Depth depth) { ArrayList<String> parameters = new ArrayList<String>(); CommandUtil.put(parameters, paths); @@ -55,9 +51,9 @@ public class CmdRevertClient extends BaseSvnClient implements RevertClient { return parameters; } - private static class RevertStatusConvertor implements Convertor<Matcher, SVNEvent> { + private static class RevertStatusConvertor implements Convertor<Matcher, ProgressEvent> { - public SVNEvent convert(@NotNull Matcher matcher) { + public ProgressEvent convert(@NotNull Matcher matcher) { String statusMessage = matcher.group(1); String path = matcher.group(2); @@ -65,17 +61,17 @@ public class CmdRevertClient extends BaseSvnClient implements RevertClient { } @Nullable - public static SVNEventAction createAction(@NotNull String code) { - SVNEventAction result = null; + public static EventAction createAction(@NotNull String code) { + EventAction result = null; if ("Reverted".equals(code)) { - result = SVNEventAction.REVERT; + result = EventAction.REVERT; } else if ("Failed to revert".equals(code)) { - result = SVNEventAction.FAILED_REVERT; + result = EventAction.FAILED_REVERT; } else if ("Skipped".equals(code)) { - result = SVNEventAction.SKIP; + result = EventAction.SKIP; } return result; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/RevertClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/RevertClient.java index 053de373bc0a..5f0d26bb09aa 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/RevertClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/RevertClient.java @@ -3,9 +3,9 @@ package org.jetbrains.idea.svn.revert; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import java.io.File; @@ -14,5 +14,5 @@ import java.io.File; */ public interface RevertClient extends SvnClient { - void revert(@NotNull File[] paths, @Nullable SVNDepth depth, @Nullable ISVNEventHandler handler) throws VcsException; + void revert(@NotNull File[] paths, @Nullable Depth depth, @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/SvnKitRevertClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/SvnKitRevertClient.java index ea88ebcc7c32..06593f472106 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/SvnKitRevertClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/SvnKitRevertClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -17,12 +17,12 @@ import java.io.File; public class SvnKitRevertClient extends BaseSvnClient implements RevertClient { @Override - public void revert(@NotNull File[] paths, @Nullable SVNDepth depth, @Nullable ISVNEventHandler handler) throws VcsException { + public void revert(@NotNull File[] paths, @Nullable Depth depth, @Nullable ProgressTracker handler) throws VcsException { SVNWCClient client = myVcs.getSvnKitManager().createWCClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); try { - client.doRevert(paths, depth, null); + client.doRevert(paths, toDepth(depth), null); } catch (SVNException e) { throw new VcsException(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/rollback/SvnRollbackEnvironment.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/rollback/SvnRollbackEnvironment.java index 01c86eb1054b..237d05bd5f7a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/rollback/SvnRollbackEnvironment.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/rollback/SvnRollbackEnvironment.java @@ -28,6 +28,12 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.*; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -75,15 +81,15 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { checker.gather(changes); exceptions.addAll(checker.getExceptions()); - ISVNEventHandler revertHandler = new ISVNEventHandler() { - public void handleEvent(SVNEvent event, double progress) { - if (event.getAction() == SVNEventAction.REVERT) { + ProgressTracker revertHandler = new ProgressTracker() { + public void consume(ProgressEvent event) { + if (event.getAction() == EventAction.REVERT) { final File file = event.getFile(); if (file != null) { listener.accept(file); } } - if (event.getAction() == SVNEventAction.FAILED_REVERT) { + if (event.getAction() == EventAction.FAILED_REVERT) { exceptions.add(new VcsException("Revert failed")); } } @@ -150,7 +156,7 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { final File source = entry.getKey(); final ThroughRenameInfo info = entry.getValue(); if (info.isVersioned()) { - mySvnVcs.getFactory(source).createPropertyClient().list(SvnTarget.fromFile(source), SVNRevision.WORKING, SVNDepth.EMPTY, handler); + mySvnVcs.getFactory(source).createPropertyClient().list(SvnTarget.fromFile(source), SVNRevision.WORKING, Depth.EMPTY, handler); } if (source.isDirectory()) { if (! FileUtil.filesEqual(info.getTo(), info.getFirstTo())) { @@ -225,8 +231,8 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { catch (IOException e) { exceptions.add(new VcsException(e)); } - catch (SVNException e) { - exceptions.add(new VcsException(e)); + catch (VcsException e) { + exceptions.add(e); } } } @@ -248,10 +254,10 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { private static class Reverter { @NotNull private final SvnVcs myVcs; - private ISVNEventHandler myHandler; + private ProgressTracker myHandler; private final List<VcsException> myExceptions; - private Reverter(@NotNull SvnVcs vcs, ISVNEventHandler handler, List<VcsException> exceptions) { + private Reverter(@NotNull SvnVcs vcs, ProgressTracker handler, List<VcsException> exceptions) { myVcs = vcs; myHandler = handler; myExceptions = exceptions; @@ -261,7 +267,7 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { if (files.length == 0) return; try { // Files passed here are split into groups by root and working copy format - thus we could determine factory based on first file - myVcs.getFactory(files[0]).createRevertClient().revert(files, recursive ? SVNDepth.INFINITY : SVNDepth.EMPTY, myHandler); + myVcs.getFactory(files[0]).createRevertClient().revert(files, Depth.allOrEmpty(recursive), myHandler); } catch (VcsException e) { processRevertError(e); @@ -298,9 +304,9 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { } private void revertFileOrDir(File file) throws SVNException, VcsException { - SVNInfo info = mySvnVcs.getInfo(file); + Info info = mySvnVcs.getInfo(file); if (info != null) { - if (info.getKind() == SVNNodeKind.FILE) { + if (info.isFile()) { doRevert(file, false); } else { if (SVNProperty.SCHEDULE_ADD.equals(info.getSchedule())) { @@ -321,17 +327,17 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { } private void doRevert(@NotNull File path, boolean recursive) throws VcsException { - mySvnVcs.getFactory(path).createRevertClient().revert(new File[]{path}, SVNDepth.fromRecurse(recursive), null); + mySvnVcs.getFactory(path).createRevertClient().revert(new File[]{path}, Depth.allOrFiles(recursive), null); } - private boolean is17OrGreaterCopy(final File file, final SVNInfo info) throws VcsException { + private boolean is17OrGreaterCopy(final File file, final Info info) throws VcsException { final RootsToWorkingCopies copies = mySvnVcs.getRootsToWorkingCopies(); WorkingCopy copy = copies.getMatchingCopy(info.getURL()); if (copy == null) { WorkingCopyFormat format = mySvnVcs.getWorkingCopyFormat(file); - return !WorkingCopyFormat.UNKNOWN.equals(format) && format.isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN); + return format.isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN); } else { return copy.is17Copy(); } @@ -614,6 +620,9 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { catch (SVNException e) { myExceptions.add(new VcsException(e)); } + catch (SvnBindException e) { + myExceptions.add(e); + } } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/CmdStatusClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/CmdStatusClient.java index 235f5d1ecddc..4030c83005ea 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/CmdStatusClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/CmdStatusClient.java @@ -18,18 +18,18 @@ package org.jetbrains.idea.svn.status; import com.intellij.openapi.util.Getter; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.commandLine.CommandExecutor; -import org.jetbrains.idea.svn.commandLine.CommandUtil; -import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.jetbrains.idea.svn.commandLine.SvnExceptionWrapper; -import org.tmatesoft.svn.core.*; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.*; +import org.jetbrains.idea.svn.info.Info; +import org.tmatesoft.svn.core.SVNErrorCode; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import org.tmatesoft.svn.core.wc.*; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -52,75 +52,38 @@ import java.util.*; public class CmdStatusClient extends BaseSvnClient implements StatusClient { @Override - public long doStatus(File path, boolean recursive, boolean remote, boolean reportAll, boolean includeIgnored, ISVNStatusHandler handler) - throws SVNException { - return doStatus(path, recursive, remote, reportAll, includeIgnored, false, handler); - } - - @Override - public long doStatus(File path, - boolean recursive, - boolean remote, - boolean reportAll, - boolean includeIgnored, - boolean collectParentExternals, - ISVNStatusHandler handler) throws SVNException { - return doStatus(path, SVNRevision.UNDEFINED, recursive, remote, reportAll, includeIgnored, collectParentExternals, handler); - } - - @Override - public long doStatus(File path, - SVNRevision revision, - boolean recursive, - boolean remote, - boolean reportAll, - boolean includeIgnored, - boolean collectParentExternals, - ISVNStatusHandler handler) throws SVNException { - return doStatus(path, revision, recursive ? SVNDepth.INFINITY : SVNDepth.EMPTY, remote, reportAll, includeIgnored, - collectParentExternals, handler, null); - } - - @Override public long doStatus(final File path, final SVNRevision revision, - final SVNDepth depth, + final Depth depth, boolean remote, boolean reportAll, boolean includeIgnored, boolean collectParentExternals, - final ISVNStatusHandler handler, - final Collection changeLists) throws SVNException { + final StatusConsumer handler, + final Collection changeLists) throws SvnBindException { File base = path.isDirectory() ? path : path.getParentFile(); base = CommandUtil.correctUpToExistingParent(base); - final SVNInfo infoBase = myFactory.createInfoClient().doInfo(base, revision); + final Info infoBase = myFactory.createInfoClient().doInfo(base, revision); List<String> parameters = new ArrayList<String>(); putParameters(parameters, path, depth, remote, reportAll, includeIgnored, changeLists); - CommandExecutor command; - try { - command = execute(myVcs, SvnTarget.fromFile(path), SvnCommandName.st, parameters, null); - } - catch (VcsException e) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); - } + CommandExecutor command = execute(myVcs, SvnTarget.fromFile(path), SvnCommandName.st, parameters, null); parseResult(path, revision, handler, base, infoBase, command); return 0; } private void parseResult(final File path, SVNRevision revision, - ISVNStatusHandler handler, + StatusConsumer handler, File base, - SVNInfo infoBase, - CommandExecutor command) throws SVNException { + Info infoBase, + CommandExecutor command) throws SvnBindException { String result = command.getOutput(); if (StringUtil.isEmptyOrSpaces(result)) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.FS_GENERAL, "Status request returned nothing for command: " + - command.getCommandText())); + throw new SvnBindException("Status request returned nothing for command: " + command.getCommandText()); } try { @@ -130,8 +93,7 @@ public class CmdStatusClient extends BaseSvnClient implements StatusClient { parser.parse(new ByteArrayInputStream(result.trim().getBytes(CharsetToolkit.UTF8_CHARSET)), svnHandl[0]); if (!svnHandl[0].isAnythingReported()) { if (!SvnUtil.isSvnVersioned(myVcs, path)) { - throw new SVNException( - SVNErrorMessage.create(SVNErrorCode.WC_NOT_DIRECTORY, "Command - " + command.getCommandText() + ". Result - " + result)); + throw new SvnBindException(SVNErrorCode.WC_NOT_DIRECTORY, "Command - " + command.getCommandText() + ". Result - " + result); } else { // return status indicating "NORMAL" state // typical output would be like @@ -142,38 +104,42 @@ public class CmdStatusClient extends BaseSvnClient implements StatusClient { PortableStatus status = new PortableStatus(); status.setPath(path.getAbsolutePath()); - status.setContentsStatus(SVNStatusType.STATUS_NORMAL); - status.setInfoGetter(new Getter<SVNInfo>() { + status.setContentsStatus(StatusType.STATUS_NORMAL); + status.setInfoGetter(new Getter<Info>() { @Override - public SVNInfo get() { + public Info get() { return createInfoGetter(null).convert(path); } }); - handler.handleStatus(status); + try { + handler.consume(status); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } } } catch (SvnExceptionWrapper e) { - throw (SVNException) e.getCause(); + throw new SvnBindException(e.getCause()); } catch (IOException e) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } catch (ParserConfigurationException e) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } catch (SAXException e) { // status parsing errors are logged separately as sometimes there are parsing errors connected to terminal output handling. // these errors primarily occur when status output is rather large. // and status output could be large, for instance, when working copy is locked (seems that each file is listed in status output). command.logCommand(); - - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } } private static void putParameters(@NotNull List<String> parameters, @NotNull File path, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean remote, boolean reportAll, boolean includeIgnored, @@ -189,33 +155,33 @@ public class CmdStatusClient extends BaseSvnClient implements StatusClient { } public SvnStatusHandler createStatusHandler(final SVNRevision revision, - final ISVNStatusHandler handler, + final StatusConsumer handler, final File base, - final SVNInfo infoBase, final SvnStatusHandler[] svnHandl) { + final Info infoBase, final SvnStatusHandler[] svnHandl) { final SvnStatusHandler.ExternalDataCallback callback = createStatusCallback(handler, base, infoBase, svnHandl); return new SvnStatusHandler(callback, base, createInfoGetter(revision)); } - private Convertor<File, SVNInfo> createInfoGetter(final SVNRevision revision) { - return new Convertor<File, SVNInfo>() { + private Convertor<File, Info> createInfoGetter(final SVNRevision revision) { + return new Convertor<File, Info>() { @Override - public SVNInfo convert(File o) { + public Info convert(File o) { try { return myFactory.createInfoClient().doInfo(o, revision); } - catch (SVNException e) { + catch (SvnBindException e) { throw new SvnExceptionWrapper(e); } } }; } - public static SvnStatusHandler.ExternalDataCallback createStatusCallback(final ISVNStatusHandler handler, + public static SvnStatusHandler.ExternalDataCallback createStatusCallback(final StatusConsumer handler, final File base, - final SVNInfo infoBase, + final Info infoBase, final SvnStatusHandler[] svnHandl) { - final Map<File, SVNInfo> externalsMap = new HashMap<File, SVNInfo>(); + final Map<File, Info> externalsMap = new HashMap<File, Info>(); final String[] changelistName = new String[1]; return new SvnStatusHandler.ExternalDataCallback() { @@ -225,7 +191,7 @@ public class CmdStatusClient extends BaseSvnClient implements StatusClient { pending.setChangelistName(changelistName[0]); try { //if (infoBase != null) { - SVNInfo baseInfo = infoBase; + Info baseInfo = infoBase; File baseFile = base; final File pendingFile = new File(pending.getPath()); if (! externalsMap.isEmpty()) { @@ -250,10 +216,10 @@ public class CmdStatusClient extends BaseSvnClient implements StatusClient { } pending.setURL(SVNURL.parseURIEncoded(append)); } - if (SVNStatusType.STATUS_EXTERNAL.equals(pending.getNodeStatus())) { + if (StatusType.STATUS_EXTERNAL.equals(pending.getNodeStatus())) { externalsMap.put(pending.getFile(), pending.getInfo()); } - handler.handleStatus(pending); + handler.consume(pending); } catch (SVNException e) { throw new SvnExceptionWrapper(e); @@ -268,16 +234,11 @@ public class CmdStatusClient extends BaseSvnClient implements StatusClient { } @Override - public SVNStatus doStatus(File path, boolean remote) throws SVNException { - return doStatus(path, remote, false); - } - - @Override - public SVNStatus doStatus(File path, boolean remote, boolean collectParentExternals) throws SVNException { - final SVNStatus[] svnStatus = new SVNStatus[1]; - doStatus(path, SVNRevision.UNDEFINED, SVNDepth.EMPTY, remote, false, false, collectParentExternals, new ISVNStatusHandler() { + public Status doStatus(File path, boolean remote) throws SvnBindException { + final Status[] svnStatus = new Status[1]; + doStatus(path, SVNRevision.UNDEFINED, Depth.EMPTY, remote, false, false, false, new StatusConsumer() { @Override - public void handleStatus(SVNStatus status) throws SVNException { + public void consume(Status status) throws SVNException { svnStatus[0] = status; } }, null); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/PortableStatus.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/PortableStatus.java index e78c0cd57316..4ed2d78f29ab 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/PortableStatus.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/PortableStatus.java @@ -15,10 +15,13 @@ */ package org.jetbrains.idea.svn.status; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Getter; -import org.tmatesoft.svn.core.SVNLock; -import org.tmatesoft.svn.core.SVNNodeKind; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.lock.Lock; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.*; @@ -27,18 +30,18 @@ import java.util.Date; import java.util.Map; /** + * TODO: Merge PortableStatus and Status to single class. + * * Created by IntelliJ IDEA. * User: Irina.Chernushina * Date: 1/24/12 * Time: 12:29 PM */ -public class PortableStatus extends SVNStatus { - - private static final Logger LOG = Logger.getInstance(PortableStatus.class); +public class PortableStatus extends Status { private boolean myConflicted; - private Getter<SVNInfo> myInfoGetter; - private SVNInfo myInfo; + private Getter<Info> myInfoGetter; + private Info myInfo; private String myPath; private boolean myFileExists; @@ -81,42 +84,42 @@ public class PortableStatus extends SVNStatus { */ public PortableStatus(SVNURL url, File file, - SVNNodeKind kind, + @NotNull NodeKind kind, SVNRevision revision, SVNRevision committedRevision, Date committedDate, String author, - SVNStatusType contentsStatus, - SVNStatusType propertiesStatus, - SVNStatusType remoteContentsStatus, - SVNStatusType remotePropertiesStatus, + StatusType contentsStatus, + StatusType propertiesStatus, + StatusType remoteContentsStatus, + StatusType remotePropertiesStatus, boolean isLocked, boolean isCopied, boolean isSwitched, boolean isFileExternal, - SVNLock remoteLock, - SVNLock localLock, + @Nullable Lock remoteLock, + @Nullable Lock localLock, Map entryProperties, String changelistName, int wcFormatVersion, boolean isConflicted, - Getter<SVNInfo> infoGetter) { - super(url, file, kind, revision, committedRevision, committedDate, author, contentsStatus, propertiesStatus, remoteContentsStatus, - remotePropertiesStatus, isLocked, isCopied, isSwitched, isFileExternal, null, null, null, null, null, null, remoteLock, - localLock, entryProperties, changelistName, wcFormatVersion, null); + Getter<Info> infoGetter) { + super(url, file, kind, revision, committedRevision, contentsStatus, propertiesStatus, remoteContentsStatus, + remotePropertiesStatus, isLocked, isCopied, isSwitched, null, remoteLock, + localLock, changelistName, null); myConflicted = isConflicted; - myInfoGetter = infoGetter == null ? new Getter<SVNInfo>() { + myInfoGetter = infoGetter == null ? new Getter<Info>() { @Override - public SVNInfo get() { + public Info get() { return null; } } : infoGetter; } public PortableStatus() { - myInfoGetter = new Getter<SVNInfo>() { + myInfoGetter = new Getter<Info>() { @Override - public SVNInfo get() { + public Info get() { return null; } }; @@ -124,22 +127,12 @@ public class PortableStatus extends SVNStatus { } @Override - public int getWorkingCopyFormat() { - LOG.error("Do not use working copy format detection through status"); - return 0; - } - - @Override public void setIsConflicted(boolean isConflicted) { myConflicted = isConflicted; super.setIsConflicted(isConflicted); } - public void setConflicted(boolean conflicted) { - myConflicted = conflicted; - } - - public void setInfoGetter(Getter<SVNInfo> infoGetter) { + public void setInfoGetter(Getter<Info> infoGetter) { myInfoGetter = infoGetter; } @@ -148,10 +141,10 @@ public class PortableStatus extends SVNStatus { return myConflicted; } - private SVNInfo initInfo() { + private Info initInfo() { if (myInfo == null) { - final SVNStatusType contentsStatus = getContentsStatus(); - if (contentsStatus == null || SVNStatusType.UNKNOWN.equals(contentsStatus)) { + final StatusType contentsStatus = getContentsStatus(); + if (contentsStatus == null || StatusType.UNKNOWN.equals(contentsStatus)) { return null; } myInfo = myInfoGetter.get(); @@ -159,14 +152,15 @@ public class PortableStatus extends SVNStatus { return myInfo; } - public SVNInfo getInfo() { + public Info getInfo() { return initInfo(); } @Override - public SVNNodeKind getKind() { + @NotNull + public NodeKind getKind() { if (myFileExists) return super.getKind(); - final SVNInfo info = initInfo(); + final Info info = initInfo(); if (info != null) { return info.getKind(); } @@ -174,68 +168,6 @@ public class PortableStatus extends SVNStatus { } /** - * Gets the temporary file that contains all latest changes from the - * repository which led to a conflict with local changes. This file is at - * the HEAD revision. - * - * @return an autogenerated temporary file just as it is in the latest - * revision in the repository - */ - @Override - public File getConflictNewFile() { - if (! isConflicted()) return null; - final SVNInfo info = initInfo(); - return info == null ? null : info.getConflictNewFile(); - } - - /** - * Gets the temporary BASE revision file of that working file that is - * currently in conflict with changes received from the repository. This - * file does not contain the latest user's modifications, only 'pristine' - * contents. - * - * @return an autogenerated temporary file just as the conflicting file was - * before any modifications to it - */ - @Override - public File getConflictOldFile() { - if (! isConflicted()) return null; - final SVNInfo info = initInfo(); - return info == null ? null : info.getConflictOldFile(); - } - - /** - * Gets the temporary <i>'.mine'</i> file with all current local changes to - * the original file. That is if the file item is in conflict with changes - * that came during an update this temporary file is created to get the - * snapshot of the user's file with only the user's local modifications and - * nothing more. - * - * @return an autogenerated temporary file with only the user's - * modifications - */ - @Override - public File getConflictWrkFile() { - if (! isConflicted()) return null; - final SVNInfo info = initInfo(); - return info == null ? null : info.getConflictWrkFile(); - } - - /** - * Gets the <i>'.prej'</i> file containing details on properties conflicts. - * If the item's properties are in conflict with those that came during an - * update this file will contain a conflict description. - * - * @return the properties conflicts file - */ - @Override - public File getPropRejectFile() { - if (! isConflicted()) return null; - final SVNInfo info = initInfo(); - return info == null ? null : info.getPropConflictFile(); - } - - /** * Gets the URL (repository location) of the ancestor from which the item * was copied. That is when the item is added with history. * @@ -244,7 +176,7 @@ public class PortableStatus extends SVNStatus { @Override public String getCopyFromURL() { if (! isCopied()) return null; - final SVNInfo info = initInfo(); + final Info info = initInfo(); if (info == null) return null; SVNURL url = initInfo().getCopyFromURL(); return url == null ? null : url.toString(); @@ -255,7 +187,7 @@ public class PortableStatus extends SVNStatus { SVNURL url = super.getURL(); if (url == null) { - SVNInfo info = initInfo(); + Info info = initInfo(); url = info != null ? info.getURL() : url; } @@ -267,7 +199,7 @@ public class PortableStatus extends SVNStatus { SVNURL url = super.getRepositoryRootURL(); if (url == null) { - SVNInfo info = initInfo(); + Info info = initInfo(); url = info != null ? info.getRepositoryRootURL() : url; } @@ -279,7 +211,7 @@ public class PortableStatus extends SVNStatus { File file = super.getFile(); if (file == null) { - SVNInfo info = initInfo(); + Info info = initInfo(); file = info != null ? info.getFile() : file; } @@ -291,28 +223,15 @@ public class PortableStatus extends SVNStatus { final SVNRevision revision = super.getRevision(); if (revision != null && revision.isValid()) return revision; - final SVNStatusType status = getContentsStatus(); - if (SVNStatusType.STATUS_NONE.equals(status) || SVNStatusType.STATUS_UNVERSIONED.equals(status) || - SVNStatusType.STATUS_ADDED.equals(status)) return revision; + final StatusType status = getContentsStatus(); + if (StatusType.STATUS_NONE.equals(status) || StatusType.STATUS_UNVERSIONED.equals(status) || + StatusType.STATUS_ADDED.equals(status)) return revision; - final SVNInfo info = initInfo(); + final Info info = initInfo(); return info == null ? revision : info.getRevision(); } /** - * Gets the revision of the item's ancestor from which the item was copied - * (the item is added with history). - * - * @return the ancestor's revision - */ - @Override - public SVNRevision getCopyFromRevision() { - if (! isCopied()) return null; - final SVNInfo info = initInfo(); - return info == null ? null : info.getCopyFromRevision(); - } - - /** * Returns a tree conflict description. * * @return tree conflict description; <code>null</code> if no conflict @@ -320,9 +239,10 @@ public class PortableStatus extends SVNStatus { * @since 1.3 */ @Override - public SVNTreeConflictDescription getTreeConflict() { + @Nullable + public TreeConflictDescription getTreeConflict() { if (! isConflicted()) return null; - final SVNInfo info = initInfo(); + final Info info = initInfo(); return info == null ? null : info.getTreeConflict(); } @@ -334,7 +254,7 @@ public class PortableStatus extends SVNStatus { return myPath; } - public void setKind(boolean exists, SVNNodeKind kind) { + public void setKind(boolean exists, @NotNull NodeKind kind) { myFileExists = exists; setKind(kind); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/Status.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/Status.java new file mode 100644 index 000000000000..7fc81510076f --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/Status.java @@ -0,0 +1,313 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.status; + +import com.intellij.openapi.util.Condition; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; +import org.jetbrains.idea.svn.lock.Lock; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.wc.SVNRevision; +import org.tmatesoft.svn.core.wc.SVNStatus; + +import java.io.File; + +/** + * TODO: Could also inherit BaseNodeDescription when myKind becomes final. + * + * @author Konstantin Kolosovsky. + */ +public class Status { + private SVNURL myURL; + private File myFile; + private @NotNull NodeKind myKind; + private SVNRevision myRevision; + private SVNRevision myCommittedRevision; + private StatusType myContentsStatus; + private StatusType myPropertiesStatus; + private StatusType myRemoteContentsStatus; + private StatusType myRemoteNodeStatus; + private StatusType myRemotePropertiesStatus; + private boolean myIsLocked; + private boolean myIsCopied; + private boolean myIsSwitched; + private String myCopyFromURL; + @Nullable private Lock myRemoteLock; + @Nullable private Lock myLocalLock; + private SVNRevision myRemoteRevision; + private String myChangelistName; + @Nullable private TreeConflictDescription myTreeConflict; + private boolean myIsConflicted; + + private StatusType myNodeStatus; + private SVNURL myRepositoryRootURL; + + @Nullable + public static Status create(@Nullable SVNStatus status) { + Status result = null; + + if (status != null) { + result = + new Status(status.getURL(), status.getFile(), NodeKind.from(status.getKind()), status.getRevision(), status.getCommittedRevision(), + StatusType.from(status.getContentsStatus()), StatusType.from(status.getPropertiesStatus()), + StatusType.from(status.getRemoteContentsStatus()), StatusType.from(status.getRemotePropertiesStatus()), + status.isLocked(), status.isCopied(), status.isSwitched(), status.getCopyFromURL(), Lock.create(status.getRemoteLock()), + Lock.create(status.getLocalLock()), status.getChangelistName(), + TreeConflictDescription.create(status.getTreeConflict())); + result.setIsConflicted(status.isConflicted()); + result.setNodeStatus(StatusType.from(status.getNodeStatus())); + result.setRemoteNodeStatus(StatusType.from(status.getRemoteNodeStatus())); + result.setRemoteRevision(status.getRemoteRevision()); + result.setRepositoryRootURL(status.getRepositoryRootURL()); + } + + return result; + } + + public Status(SVNURL url, + File file, + @NotNull NodeKind kind, + SVNRevision revision, + SVNRevision committedRevision, + StatusType contentsStatus, + StatusType propertiesStatus, + StatusType remoteContentsStatus, + StatusType remotePropertiesStatus, + boolean isLocked, + boolean isCopied, + boolean isSwitched, + String copyFromURL, + @Nullable Lock remoteLock, + @Nullable Lock localLock, + String changelistName, + @Nullable TreeConflictDescription treeConflict) { + myURL = url; + myFile = file; + myKind = kind; + myRevision = revision == null ? SVNRevision.UNDEFINED : revision; + myCommittedRevision = committedRevision == null ? SVNRevision.UNDEFINED : committedRevision; + myContentsStatus = contentsStatus == null ? StatusType.STATUS_NONE : contentsStatus; + myPropertiesStatus = propertiesStatus == null ? StatusType.STATUS_NONE : propertiesStatus; + myRemoteContentsStatus = remoteContentsStatus == null ? StatusType.STATUS_NONE : remoteContentsStatus; + myRemotePropertiesStatus = remotePropertiesStatus == null ? StatusType.STATUS_NONE : remotePropertiesStatus; + myRemoteNodeStatus = StatusType.STATUS_NONE; + myIsLocked = isLocked; + myIsCopied = isCopied; + myIsSwitched = isSwitched; + myCopyFromURL = copyFromURL; + myRemoteLock = remoteLock; + myLocalLock = localLock; + myChangelistName = changelistName; + myTreeConflict = treeConflict; + myRemoteRevision = SVNRevision.UNDEFINED; + } + + public Status() { + setRevision(SVNRevision.UNDEFINED); + myRemoteRevision = SVNRevision.UNDEFINED; + } + + public SVNURL getURL() { + return myURL; + } + + public File getFile() { + return myFile; + } + + @NotNull + public NodeKind getKind() { + return myKind; + } + + public SVNRevision getRevision() { + return myRevision; + } + + public SVNRevision getCommittedRevision() { + return myCommittedRevision; + } + + public StatusType getContentsStatus() { + return myContentsStatus; + } + + public StatusType getPropertiesStatus() { + return myPropertiesStatus; + } + + public StatusType getRemoteContentsStatus() { + return myRemoteContentsStatus; + } + + public StatusType getRemotePropertiesStatus() { + return myRemotePropertiesStatus; + } + + public boolean is(@NotNull StatusType type) { + return type.equals(getNodeStatus()) || type.equals(getContentsStatus()); + } + + public boolean is(@NotNull StatusType... types) { + return ContainerUtil.or(types, new Condition<StatusType>() { + @Override + public boolean value(StatusType type) { + return is(type); + } + }); + } + + public boolean isLocked() { + return myIsLocked; + } + + public boolean isCopied() { + return myIsCopied; + } + + public boolean isSwitched() { + return myIsSwitched; + } + + public String getCopyFromURL() { + return myCopyFromURL; + } + + @Nullable + public Lock getRemoteLock() { + return myRemoteLock; + } + + @Nullable + public Lock getLocalLock() { + return myLocalLock; + } + + public SVNRevision getRemoteRevision() { + return myRemoteRevision; + } + + public String getChangelistName() { + return myChangelistName; + } + + @Nullable + public TreeConflictDescription getTreeConflict() { + return myTreeConflict; + } + + public boolean isConflicted() { + return myIsConflicted; + } + + public StatusType getRemoteNodeStatus() { + return myRemoteNodeStatus; + } + + public StatusType getNodeStatus() { + if (myNodeStatus == null) { + return myContentsStatus; + } + return myNodeStatus; + } + + public SVNURL getRepositoryRootURL() { + return myRepositoryRootURL; + } + + public void setURL(SVNURL uRL) { + myURL = uRL; + } + + public void setFile(File file) { + myFile = file; + } + + public void setKind(@NotNull NodeKind kind) { + myKind = kind; + } + + public void setRevision(SVNRevision revision) { + myRevision = revision; + } + + public void setCommittedRevision(SVNRevision committedRevision) { + myCommittedRevision = committedRevision; + } + + public void setContentsStatus(StatusType statusType) { + myContentsStatus = statusType; + } + + public void setPropertiesStatus(StatusType propertiesStatus) { + myPropertiesStatus = propertiesStatus; + } + + public void setRemoteContentsStatus(StatusType remoteContentsStatus) { + myRemoteContentsStatus = remoteContentsStatus; + } + + public void setRemotePropertiesStatus(StatusType remotePropertiesStatus) { + myRemotePropertiesStatus = remotePropertiesStatus; + } + + public void setIsLocked(boolean isLocked) { + myIsLocked = isLocked; + } + + public void setIsCopied(boolean isCopied) { + myIsCopied = isCopied; + } + + public void setIsSwitched(boolean isSwitched) { + myIsSwitched = isSwitched; + } + + public void setRemoteLock(@Nullable Lock remoteLock) { + myRemoteLock = remoteLock; + } + + public void setLocalLock(@Nullable Lock localLock) { + myLocalLock = localLock; + } + + public void setChangelistName(String changelistName) { + myChangelistName = changelistName; + } + + public void setIsConflicted(boolean isConflicted) { + myIsConflicted = isConflicted; + } + + public void setRemoteNodeStatus(StatusType remoteNodeStatus) { + myRemoteNodeStatus = remoteNodeStatus; + } + + public void setNodeStatus(StatusType nodeStatus) { + myNodeStatus = nodeStatus; + } + + public void setRepositoryRootURL(SVNURL repositoryRootURL) { + myRepositoryRootURL = repositoryRootURL; + } + + public void setRemoteRevision(SVNRevision remoteRevision) { + myRemoteRevision = remoteRevision; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusClient.java index 4b43e6c51211..9bbf74b62084 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusClient.java @@ -15,12 +15,11 @@ */ package org.jetbrains.idea.svn.status; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNStatusHandler; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatus; import java.io.File; import java.util.Collection; @@ -32,13 +31,20 @@ import java.util.Collection; * Time: 9:46 AM */ public interface StatusClient extends SvnClient { - long doStatus(File path, boolean recursive, boolean remote, boolean reportAll, - boolean includeIgnored, ISVNStatusHandler handler) throws SVNException; - long doStatus(File path, boolean recursive, boolean remote, boolean reportAll, boolean includeIgnored, boolean collectParentExternals, ISVNStatusHandler handler) throws SVNException; - long doStatus(File path, SVNRevision revision, boolean recursive, boolean remote, boolean reportAll, boolean includeIgnored, boolean collectParentExternals, ISVNStatusHandler handler) throws SVNException; - long doStatus(File path, SVNRevision revision, SVNDepth depth, boolean remote, boolean reportAll, - boolean includeIgnored, boolean collectParentExternals, ISVNStatusHandler handler, - Collection changeLists) throws SVNException; - SVNStatus doStatus( File path, boolean remote) throws SVNException; - SVNStatus doStatus(File path, boolean remote, boolean collectParentExternals) throws SVNException; + + /** + * TODO: Return value is never used by other code + */ + long doStatus(File path, + SVNRevision revision, + Depth depth, + boolean remote, + boolean reportAll, + boolean includeIgnored, + boolean collectParentExternals, + StatusConsumer handler, + Collection changeLists) throws SvnBindException; + + @Nullable + Status doStatus(File path, boolean remote) throws SvnBindException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusConsumer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusConsumer.java new file mode 100644 index 000000000000..ca82bdc85f13 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusConsumer.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.status; + +import com.intellij.util.ThrowableConsumer; +import org.tmatesoft.svn.core.SVNException; + +/** + * @author Konstantin Kolosovsky. + */ +public interface StatusConsumer extends ThrowableConsumer<Status, SVNException> { +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusType.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusType.java new file mode 100644 index 000000000000..ff1c3a8a342c --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusType.java @@ -0,0 +1,110 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.status; + +import com.intellij.util.ObjectUtils; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.tmatesoft.svn.core.wc.SVNStatusType; + +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +public enum StatusType { + + // currently used to represent some not used status types from SVNKit + UNUSED("unused"), + + INAPPLICABLE("inapplicable"), + UNKNOWN("unknown"), + UNCHANGED("unchanged"), + MISSING("missing"), + OBSTRUCTED("obstructed"), + CHANGED("changed"), + MERGED("merged"), + CONFLICTED("conflicted"), + + STATUS_NONE("none"), + STATUS_NORMAL("normal", ' '), + STATUS_MODIFIED("modified", 'M'), + STATUS_ADDED("added", 'A'), + STATUS_DELETED("deleted", 'D'), + STATUS_UNVERSIONED("unversioned", '?'), + STATUS_MISSING("missing", '!'), + STATUS_REPLACED("replaced", 'R'), + STATUS_CONFLICTED("conflicted", 'C'), + STATUS_OBSTRUCTED("obstructed", '~'), + STATUS_IGNORED("ignored", 'I'), + // directory is incomplete - checkout or update was interrupted + STATUS_INCOMPLETE("incomplete", '!'), + STATUS_EXTERNAL("external", 'X'); + + private static final String STATUS_PREFIX = "STATUS_"; + + @NotNull private static final Map<String, StatusType> ourOtherStatusTypes = ContainerUtil.newHashMap(); + @NotNull private static final Map<String, StatusType> ourStatusTypesForStatusOperation = ContainerUtil.newHashMap(); + + static { + for (StatusType action : StatusType.values()) { + register(action); + } + } + + private String myName; + private char myCode; + + StatusType(String name) { + this(name, ' '); + } + + StatusType(String name, char code) { + myName = name; + myCode = code; + } + + public char getCode() { + return myCode; + } + + public String toString() { + return myName; + } + + private static void register(@NotNull StatusType action) { + (action.name().startsWith(STATUS_PREFIX) ? ourStatusTypesForStatusOperation : ourOtherStatusTypes).put(action.myName, action); + } + + @NotNull + public static StatusType from(@NotNull SVNStatusType type) { + StatusType result = ourOtherStatusTypes.get(type.toString()); + + // CONFLICTED, OBSTRUCTED, MISSING status types have corresponding STATUS_* analogs with same names - so additional check added when + // converting from SVNKit values + if (type != SVNStatusType.CONFLICTED && type != SVNStatusType.OBSTRUCTED && type != SVNStatusType.MISSING) { + result = ObjectUtils.chooseNotNull(ourStatusTypesForStatusOperation.get(type.toString()), result); + } + + return ObjectUtils.notNull(result, UNUSED); + } + + @Nullable + public static StatusType forStatusOperation(@NotNull String statusName) { + return ourStatusTypesForStatusOperation.get(statusName); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnKitStatusClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnKitStatusClient.java index 4fc337ba1c0a..3f33435c678d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnKitStatusClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnKitStatusClient.java @@ -18,8 +18,9 @@ package org.jetbrains.idea.svn.status; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.status.StatusClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.*; @@ -36,68 +37,50 @@ public class SvnKitStatusClient extends BaseSvnClient implements StatusClient { private SVNStatusClient myStatusClient; @Nullable private final ISVNStatusFileProvider myProvider; - @Nullable private final ISVNEventHandler myHandler; + @Nullable private final ProgressTracker myHandler; public SvnKitStatusClient() { this(null, null); } - public SvnKitStatusClient(@Nullable ISVNStatusFileProvider provider, @Nullable ISVNEventHandler handler) { + public SvnKitStatusClient(@Nullable ISVNStatusFileProvider provider, @Nullable ProgressTracker handler) { myProvider = provider; myHandler = handler; } @Override - public long doStatus(File path, boolean recursive, boolean remote, boolean reportAll, boolean includeIgnored, ISVNStatusHandler handler) - throws SVNException { - return getStatusClient().doStatus(path, recursive, remote, reportAll, includeIgnored, handler); - } - - @Override - public long doStatus(File path, - boolean recursive, - boolean remote, - boolean reportAll, - boolean includeIgnored, - boolean collectParentExternals, - ISVNStatusHandler handler) throws SVNException { - return getStatusClient().doStatus(path, recursive, remote, reportAll, includeIgnored, collectParentExternals, handler); - } - - @Override public long doStatus(File path, SVNRevision revision, - boolean recursive, + Depth depth, boolean remote, boolean reportAll, boolean includeIgnored, boolean collectParentExternals, - ISVNStatusHandler handler) throws SVNException { - return getStatusClient().doStatus(path, revision, recursive, remote, reportAll, includeIgnored, collectParentExternals, handler); - } - - @Override - public long doStatus(File path, - SVNRevision revision, - SVNDepth depth, - boolean remote, - boolean reportAll, - boolean includeIgnored, - boolean collectParentExternals, - ISVNStatusHandler handler, - Collection changeLists) throws SVNException { - return getStatusClient() - .doStatus(path, revision, depth, remote, reportAll, includeIgnored, collectParentExternals, handler, changeLists); - } - - @Override - public SVNStatus doStatus(File path, boolean remote) throws SVNException { - return getStatusClient().doStatus(path, remote); + final StatusConsumer handler, + Collection changeLists) throws SvnBindException { + try { + return getStatusClient() + .doStatus(path, revision, toDepth(depth), remote, reportAll, includeIgnored, collectParentExternals, new ISVNStatusHandler() { + @Override + public void handleStatus(SVNStatus status) throws SVNException { + handler.consume(Status.create(status)); + } + }, changeLists); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } @Override - public SVNStatus doStatus(File path, boolean remote, boolean collectParentExternals) throws SVNException { - return getStatusClient().doStatus(path, remote, collectParentExternals); + @Nullable + public Status doStatus(File path, boolean remote) throws SvnBindException { + try { + return Status.create(getStatusClient().doStatus(path, remote)); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } @NotNull @@ -111,7 +94,7 @@ public class SvnKitStatusClient extends BaseSvnClient implements StatusClient { if (myStatusClient == null) { myStatusClient = myVcs.getSvnKitManager().createStatusClient(); myStatusClient.setFilesProvider(myProvider); - myStatusClient.setEventHandler(myHandler); + myStatusClient.setEventHandler(toEventHandler(myHandler)); } return myStatusClient; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnStatusHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnStatusHandler.java index 642914a558ce..e0f97585f527 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnStatusHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnStatusHandler.java @@ -18,18 +18,16 @@ package org.jetbrains.idea.svn.status; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Getter; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.Convertor; import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; -import org.jetbrains.idea.svn.info.SVNLockWrapper; -import org.tmatesoft.svn.core.SVNNodeKind; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.lock.Lock; import org.tmatesoft.svn.core.internal.util.SVNDate; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatusType; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; @@ -47,29 +45,9 @@ public class SvnStatusHandler extends DefaultHandler { private static final Logger LOG = Logger.getInstance(SvnStatusHandler.class); - public static final Map<String, SVNStatusType> ourStatusTypes = ContainerUtil.newHashMap(); - - static { - // TODO: Check STATUS_MERGED as it is marked deprecated - put(SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_CONFLICTED, SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_EXTERNAL, - SVNStatusType.STATUS_IGNORED, SVNStatusType.STATUS_INCOMPLETE, SVNStatusType.STATUS_MERGED, SVNStatusType.STATUS_MISSING, - SVNStatusType.STATUS_MODIFIED, SVNStatusType.STATUS_NONE, SVNStatusType.STATUS_NORMAL, SVNStatusType.STATUS_OBSTRUCTED, - SVNStatusType.STATUS_REPLACED, SVNStatusType.STATUS_UNVERSIONED); - } - - private static void put(@NotNull SVNStatusType... statusTypes) { - for (SVNStatusType statusType : statusTypes) { - put(statusType); - } - } - - private static void put(@NotNull SVNStatusType statusType) { - ourStatusTypes.put(statusType.toString(), statusType); - } - @Nullable - public static SVNStatusType getStatus(@NotNull String code) { - SVNStatusType result = ourStatusTypes.get(code); + public static StatusType getStatus(@NotNull String code) { + StatusType result = StatusType.forStatusOperation(code); if (result == null) { LOG.info("Unknown status type " + code); @@ -83,7 +61,7 @@ public class SvnStatusHandler extends DefaultHandler { private MultiMap<String, PortableStatus> myCurrentListChanges; private PortableStatus myPending; private boolean myInRemoteStatus; - private SVNLockWrapper myLockWrapper; + private Lock.Builder myLockBuilder; private final List<ElementHandlerBase> myParseStack; private final Map<String, Getter<ElementHandlerBase>> myElementsMap; @@ -92,7 +70,7 @@ public class SvnStatusHandler extends DefaultHandler { private final StringBuilder mySb; private boolean myAnythingReported; - public SvnStatusHandler(final ExternalDataCallback dataCallback, File base, final Convertor<File, SVNInfo> infoGetter) { + public SvnStatusHandler(final ExternalDataCallback dataCallback, File base, final Convertor<File, Info> infoGetter) { myBase = base; myParseStack = new ArrayList<ElementHandlerBase>(); myParseStack.add(new Fake()); @@ -104,17 +82,17 @@ public class SvnStatusHandler extends DefaultHandler { myDataCallback = new DataCallback() { @Override public void startLock() { - myLockWrapper = new SVNLockWrapper(); + myLockBuilder = new Lock.Builder(); } @Override public void endLock() { if (myInRemoteStatus) { - myPending.setRemoteLock(myLockWrapper.create()); + myPending.setRemoteLock(myLockBuilder.build()); } else { - myPending.setLocalLock(myLockWrapper.create()); + myPending.setLocalLock(myLockBuilder.build()); } - myLockWrapper = null; + myLockBuilder = null; } @Override @@ -143,17 +121,17 @@ public class SvnStatusHandler extends DefaultHandler { myDataCallback = new DataCallback() { @Override public void startLock() { - myLockWrapper = new SVNLockWrapper(); + myLockBuilder = new Lock.Builder(); } @Override public void endLock() { if (myInRemoteStatus) { - myPending.setRemoteLock(myLockWrapper.create()); + myPending.setRemoteLock(myLockBuilder.build()); } else { - myPending.setLocalLock(myLockWrapper.create()); + myPending.setLocalLock(myLockBuilder.build()); } - myLockWrapper = null; + myLockBuilder = null; } @Override @@ -191,12 +169,12 @@ public class SvnStatusHandler extends DefaultHandler { return myAnythingReported; } - private void newPending(final Convertor<File, SVNInfo> infoGetter) { + private void newPending(final Convertor<File, Info> infoGetter) { final PortableStatus status = new PortableStatus(); myPending = status; - status.setInfoGetter(new Getter<SVNInfo>() { + status.setInfoGetter(new Getter<Info>() { @Override - public SVNInfo get() { + public Info get() { return infoGetter.convert(status.getFile()); } }); @@ -224,7 +202,7 @@ public class SvnStatusHandler extends DefaultHandler { myElementsMap.put("lock", new Getter<ElementHandlerBase>() { @Override public ElementHandlerBase get() { - return new Lock(); + return new LockElement(); } }); @@ -319,7 +297,7 @@ public class SvnStatusHandler extends DefaultHandler { assertSAX(! myParseStack.isEmpty()); ElementHandlerBase current = myParseStack.get(myParseStack.size() - 1); if (mySb.length() > 0) { - current.characters(mySb.toString().trim(), myPending, myLockWrapper); + current.characters(mySb.toString().trim(), myPending, myLockBuilder); mySb.setLength(0); } @@ -329,7 +307,7 @@ public class SvnStatusHandler extends DefaultHandler { assertSAX(myElementsMap.containsKey(qName)); final ElementHandlerBase newChild = myElementsMap.get(qName).get(); newChild.preAttributesEffect(myDataCallback); - newChild.updateStatus(attributes, myPending, myLockWrapper); + newChild.updateStatus(attributes, myPending, myLockBuilder); newChild.preEffect(myDataCallback); myParseStack.add(newChild); return; @@ -365,13 +343,13 @@ public class SvnStatusHandler extends DefaultHandler { } } - private static SVNStatusType parseContentsStatus(Attributes attributes) throws SAXException { + private static StatusType parseContentsStatus(Attributes attributes) throws SAXException { final String item = attributes.getValue("item"); assertSAX(item != null); return getStatus(item); } - private static SVNStatusType parsePropertiesStatus(Attributes attributes) throws SAXException { + private static StatusType parsePropertiesStatus(Attributes attributes) throws SAXException { final String props = attributes.getValue("props"); assertSAX(props != null); return getStatus(props); @@ -383,7 +361,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -395,7 +373,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -405,7 +383,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -417,8 +395,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { - pending.setCommittedDate(SVNDate.parseDate(s)); + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -428,7 +405,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -440,8 +417,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { - pending.setAuthor(s); + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -456,7 +432,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { final String revision = attributes.getValue("revision"); if (!StringUtil.isEmpty(revision)) { status.setCommittedRevision(SVNRevision.create(Long.valueOf(revision))); @@ -472,7 +448,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -508,7 +484,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -520,7 +496,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { final SVNDate date = SVNDate.parseDate(s); lock.setCreationDate(date); } @@ -532,7 +508,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -544,7 +520,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { lock.setComment(s); } } @@ -555,7 +531,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -567,7 +543,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { lock.setOwner(s); } } @@ -578,7 +554,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -590,19 +566,18 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { - lock.setID(s); + public void characters(String s, PortableStatus pending, Lock.Builder lock) { + lock.setToken(s); } } - private static class Lock extends ElementHandlerBase { - private Lock() { + private static class LockElement extends ElementHandlerBase { + private LockElement() { super(new String[]{"token", "owner", "comment", "created"}, new String[]{}); } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { - lock.setPath(status.getPath()); + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -620,7 +595,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -630,11 +605,11 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { - final SVNStatusType propertiesStatus = parsePropertiesStatus(attributes); + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { + final StatusType propertiesStatus = parsePropertiesStatus(attributes); status.setRemotePropertiesStatus(propertiesStatus); - final SVNStatusType contentsStatus = parseContentsStatus(attributes); + final StatusType contentsStatus = parseContentsStatus(attributes); status.setRemoteContentsStatus(contentsStatus); } @@ -653,7 +628,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -675,13 +650,13 @@ public class SvnStatusHandler extends DefaultHandler { revision="120">*/ @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { - final SVNStatusType propertiesStatus = parsePropertiesStatus(attributes); + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { + final StatusType propertiesStatus = parsePropertiesStatus(attributes); status.setPropertiesStatus(propertiesStatus); - final SVNStatusType contentsStatus = parseContentsStatus(attributes); + final StatusType contentsStatus = parseContentsStatus(attributes); status.setContentsStatus(contentsStatus); - if (SVNStatusType.STATUS_CONFLICTED.equals(propertiesStatus) || SVNStatusType.STATUS_CONFLICTED.equals(contentsStatus)) { + if (StatusType.STATUS_CONFLICTED.equals(propertiesStatus) || StatusType.STATUS_CONFLICTED.equals(contentsStatus)) { status.setIsConflicted(true); } @@ -724,7 +699,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -737,14 +712,14 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { final String path = attributes.getValue("path"); assertSAX(path != null); final File file = SvnUtil.resolvePath(myBase, path); status.setFile(file); final boolean exists = file.exists(); if (exists) { - status.setKind(exists, file.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE); + status.setKind(exists, NodeKind.from(file.isDirectory())); } else { // this is a hack. This is done so because of strange svn native client output: /* @@ -779,15 +754,15 @@ c:\TestProjects\sortedProjects\Subversion\local\withExt82420\mod4>dir and no "mod4" under */ - final SVNStatusType ns = status.getNodeStatus(); - if (myBase.getName().equals(path) && ! SVNStatusType.MISSING.equals(ns) && - ! SVNStatusType.STATUS_DELETED.equals(ns) ) { - status.setKind(true, SVNNodeKind.DIR); + final StatusType ns = status.getNodeStatus(); + if (myBase.getName().equals(path) && ! StatusType.MISSING.equals(ns) && + ! StatusType.STATUS_DELETED.equals(ns) ) { + status.setKind(true, NodeKind.DIR); status.setFile(myBase); status.setPath(""); return; } - status.setKind(exists, SVNNodeKind.UNKNOWN); + status.setKind(exists, NodeKind.UNKNOWN); } status.setPath(path); } @@ -802,7 +777,7 @@ and no "mod4" under } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -814,7 +789,7 @@ and no "mod4" under } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { final String name = attributes.getValue("name"); assertSAX(! StringUtil.isEmptyOrSpaces(name)); myName = name; @@ -830,7 +805,7 @@ and no "mod4" under } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -840,7 +815,7 @@ and no "mod4" under } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) { } @Override @@ -852,7 +827,7 @@ and no "mod4" under } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -862,7 +837,7 @@ and no "mod4" under } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -874,7 +849,7 @@ and no "mod4" under } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -884,7 +859,7 @@ and no "mod4" under } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) { } @Override @@ -896,7 +871,7 @@ and no "mod4" under } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -909,7 +884,7 @@ and no "mod4" under myAwaitedChildrenMultiple = new HashSet<String>(Arrays.asList(awaitedChildrenMultiple)); } - protected abstract void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException; + protected abstract void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException; public abstract void postEffect(final DataCallback callback); public abstract void preEffect(final DataCallback callback); @@ -920,7 +895,7 @@ and no "mod4" under return myAwaitedChildren.remove(qName); } - public abstract void characters(String s, PortableStatus pending, SVNLockWrapper lock); + public abstract void characters(String s, PortableStatus pending, Lock.Builder lock); public void preAttributesEffect(DataCallback callback) {} } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/svnkit/SvnKitProgressCanceller.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/svnkit/SvnKitProgressCanceller.java new file mode 100644 index 000000000000..6bb370674ba2 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/svnkit/SvnKitProgressCanceller.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.svnkit; + +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import org.tmatesoft.svn.core.ISVNCanceller; +import org.tmatesoft.svn.core.SVNCancelException; + +/** + * @author Konstantin Kolosovsky. + */ +public class SvnKitProgressCanceller implements ISVNCanceller { + + public void checkCancelled() throws SVNCancelException { + final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); + if (indicator != null && indicator.isCanceled()) { + throw new SVNCancelException(); + } + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/MergeFromTheirsResolver.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/MergeFromTheirsResolver.java index 762f4449b897..b655cdca170c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/MergeFromTheirsResolver.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/MergeFromTheirsResolver.java @@ -52,12 +52,11 @@ import com.intellij.util.continuation.TaskDescriptor; import com.intellij.util.continuation.Where; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.*; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; import org.jetbrains.idea.svn.history.SvnChangeList; import org.jetbrains.idea.svn.history.SvnRepositoryLocation; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNTreeConflictDescription; import java.io.File; import java.io.IOException; @@ -71,7 +70,7 @@ import java.util.*; */ public class MergeFromTheirsResolver { private final SvnVcs myVcs; - private final SVNTreeConflictDescription myDescription; + private final TreeConflictDescription myDescription; private final Change myChange; private final FilePath myOldFilePath; private final FilePath myNewFilePath; @@ -86,7 +85,7 @@ public class MergeFromTheirsResolver { private List<TextFilePatch> myTextPatches; private VirtualFile myBaseForPatch; - public MergeFromTheirsResolver(SvnVcs vcs, SVNTreeConflictDescription description, Change change, SvnRevisionNumber revision) { + public MergeFromTheirsResolver(SvnVcs vcs, TreeConflictDescription description, Change change, SvnRevisionNumber revision) { myVcs = vcs; myDescription = description; myChange = change; @@ -126,11 +125,7 @@ public class MergeFromTheirsResolver { }); final List<TaskDescriptor> tasks = new SmartList<TaskDescriptor>(); - if (SVNNodeKind.DIR.equals(myDescription.getNodeKind())) { - tasks.add(new PreloadChangesContentsForDir()); - } else { - tasks.add(new PreloadChangesContentsForFile()); - } + tasks.add(myDescription.isDirectory() ? new PreloadChangesContentsForDir() : new PreloadChangesContentsForFile()); tasks.add(new ConvertTextPaths()); tasks.add(new PatchCreator()); tasks.add(new SelectPatchesInApplyPatchDialog()); @@ -290,7 +285,7 @@ public class MergeFromTheirsResolver { // TODO: is used. Command line also does not support automatic directory creation. // TODO: Need to check additionally if there are cases when directory does not exist and add corresponding code. myVcs.getFactory(myOldFilePath.getIOFile()).createAddClient() - .add(myOldFilePath.getIOFile(), SVNDepth.EMPTY, true, false, true, null); + .add(myOldFilePath.getIOFile(), Depth.EMPTY, true, false, true, null); } catch (VcsException e) { context.handleException(e, true); @@ -564,7 +559,7 @@ public class MergeFromTheirsResolver { } } - private List<CommittedChangeList> loadSvnChangeListsForPatch(SVNTreeConflictDescription description) throws VcsException { + private List<CommittedChangeList> loadSvnChangeListsForPatch(TreeConflictDescription description) throws VcsException { long max = description.getSourceRightVersion().getPegRevision(); long min = description.getSourceLeftVersion().getPegRevision(); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/SvnTreeConflictResolver.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/SvnTreeConflictResolver.java index c637ce243981..584666c7e86a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/SvnTreeConflictResolver.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/SvnTreeConflictResolver.java @@ -27,8 +27,13 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; +import org.jetbrains.idea.svn.status.Status; import org.jetbrains.idea.svn.status.StatusClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.status.StatusConsumer; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.*; @@ -57,7 +62,7 @@ public class SvnTreeConflictResolver { myDirtyScopeManager = VcsDirtyScopeManager.getInstance(myVcs.getProject()); } - public void resolveSelectTheirsFull(SVNTreeConflictDescription d) throws VcsException { + public void resolveSelectTheirsFull(TreeConflictDescription d) throws VcsException { final LocalHistory localHistory = LocalHistory.getInstance(); localHistory.putSystemLabel(myVcs.getProject(), "Before accepting theirs for " + TreeConflictRefreshablePanel.filePath(myPath)); try { @@ -84,74 +89,64 @@ public class SvnTreeConflictResolver { private void revertAdditional() throws VcsException { if (myRevertPath == null) return; final File ioFile = myRevertPath.getIOFile(); - try { - final SVNStatus status = myVcs.getFactory(ioFile).createStatusClient().doStatus(ioFile, false); - myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, SVNDepth.INFINITY, null); - if (SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus())) { - FileUtil.delete(ioFile); - } - } - catch (SVNException e) { - throw new VcsException(e); + final Status status = myVcs.getFactory(ioFile).createStatusClient().doStatus(ioFile, false); + myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, Depth.INFINITY, null); + if (StatusType.STATUS_ADDED.equals(status.getNodeStatus())) { + FileUtil.delete(ioFile); } pathDirty(myRevertPath); } - public void resolveSelectMineFull(SVNTreeConflictDescription d) throws VcsException { + public void resolveSelectMineFull(TreeConflictDescription d) throws VcsException { final File ioFile = myPath.getIOFile(); - myVcs.getFactory(ioFile).createConflictClient().resolve(ioFile, SVNDepth.INFINITY, true, true, true); + myVcs.getFactory(ioFile).createConflictClient().resolve(ioFile, Depth.INFINITY, true, true, true); pathDirty(myPath); } private void updatetoTheirsFull() throws VcsException { - try { - final File ioFile = myPath.getIOFile(); - SVNStatus status = myVcs.getFactory(ioFile).createStatusClient().doStatus(ioFile, false); - if (myCommittedRevision == null) { - myCommittedRevision = new SvnRevisionNumber(status.getCommittedRevision()); - } - if (status == null || SVNStatusType.STATUS_UNVERSIONED.equals(status.getNodeStatus())) { - myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, SVNDepth.INFINITY, null); - updateIoFile(ioFile, SVNRevision.HEAD); - return; - } else if (SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus())) { - myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, SVNDepth.INFINITY, null); - updateIoFile(ioFile, SVNRevision.HEAD); - FileUtil.delete(ioFile); - return; - } else { - final Set<File> usedToBeAdded = new HashSet<File>(); - if (myPath.isDirectory()) { - StatusClient statusClient = myVcs.getFactory(ioFile).createStatusClient(); - statusClient.doStatus(ioFile, SVNRevision.UNDEFINED, SVNDepth.INFINITY, false, false, false, false, - new ISVNStatusHandler() { - @Override - public void handleStatus(SVNStatus status) throws SVNException { - if (status != null && SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus())) { - usedToBeAdded.add(status.getFile()); - } + final File ioFile = myPath.getIOFile(); + Status status = myVcs.getFactory(ioFile).createStatusClient().doStatus(ioFile, false); + if (myCommittedRevision == null) { + myCommittedRevision = new SvnRevisionNumber(status.getCommittedRevision()); + } + if (status == null || StatusType.STATUS_UNVERSIONED.equals(status.getNodeStatus())) { + myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, Depth.INFINITY, null); + updateIoFile(ioFile, SVNRevision.HEAD); + return; + } else if (StatusType.STATUS_ADDED.equals(status.getNodeStatus())) { + myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, Depth.INFINITY, null); + updateIoFile(ioFile, SVNRevision.HEAD); + FileUtil.delete(ioFile); + return; + } else { + final Set<File> usedToBeAdded = new HashSet<File>(); + if (myPath.isDirectory()) { + StatusClient statusClient = myVcs.getFactory(ioFile).createStatusClient(); + statusClient.doStatus(ioFile, SVNRevision.UNDEFINED, Depth.INFINITY, false, false, false, false, + new StatusConsumer() { + @Override + public void consume(Status status) throws SVNException { + if (status != null && StatusType.STATUS_ADDED.equals(status.getNodeStatus())) { + usedToBeAdded.add(status.getFile()); } - }, null); - } - myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, SVNDepth.INFINITY, null); - for (File wasAdded : usedToBeAdded) { - FileUtil.delete(wasAdded); - } - updateIoFile(ioFile, SVNRevision.HEAD); + } + }, null); } - } - catch (SVNException e1) { - throw new VcsException(e1); + myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, Depth.INFINITY, null); + for (File wasAdded : usedToBeAdded) { + FileUtil.delete(wasAdded); + } + updateIoFile(ioFile, SVNRevision.HEAD); } } - private void updateIoFile(@NotNull File ioFile, @NotNull final SVNRevision revision) throws SVNException { + private void updateIoFile(@NotNull File ioFile, @NotNull final SVNRevision revision) throws SvnBindException { if (! ioFile.exists()) { File parent = ioFile.getParentFile(); - myVcs.getFactory(parent).createUpdateClient().doUpdate(parent, revision, SVNDepth.INFINITY, true, false); + myVcs.getFactory(parent).createUpdateClient().doUpdate(parent, revision, Depth.INFINITY, true, false); } else { - myVcs.getFactory(ioFile).createUpdateClient().doUpdate(ioFile, revision, SVNDepth.INFINITY, false, false); + myVcs.getFactory(ioFile).createUpdateClient().doUpdate(ioFile, revision, Depth.INFINITY, false, false); } } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/TreeConflictRefreshablePanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/TreeConflictRefreshablePanel.java index da0b1e7f590b..9a68d63527ae 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/TreeConflictRefreshablePanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/TreeConflictRefreshablePanel.java @@ -43,16 +43,14 @@ import gnu.trove.TLongArrayList; import org.jetbrains.idea.svn.ConflictedSvnChange; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.conflict.ConflictAction; +import org.jetbrains.idea.svn.conflict.ConflictReason; +import org.jetbrains.idea.svn.conflict.ConflictVersion; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; import org.jetbrains.idea.svn.history.SvnHistoryProvider; import org.jetbrains.idea.svn.history.SvnHistorySession; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; -import org.tmatesoft.svn.core.internal.wc.SVNConflictVersion; -import org.tmatesoft.svn.core.internal.wc.SVNTreeConflictUtil; -import org.tmatesoft.svn.core.wc.SVNConflictAction; -import org.tmatesoft.svn.core.wc.SVNConflictReason; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNTreeConflictDescription; import javax.swing.*; import java.awt.*; @@ -96,7 +94,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { return true; } - private static boolean descriptionsEqual(SVNTreeConflictDescription d1, SVNTreeConflictDescription d2) { + private static boolean descriptionsEqual(TreeConflictDescription d1, TreeConflictDescription d2) { if (d1.isPropertyConflict() != d2.isPropertyConflict()) return false; if (d1.isTextConflict() != d2.isTextConflict()) return false; if (d1.isTreeConflict() != d2.isTreeConflict()) return false; @@ -111,7 +109,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { return true; } - private static boolean compareConflictVersion(SVNConflictVersion v1, SVNConflictVersion v2) { + private static boolean compareConflictVersion(ConflictVersion v1, ConflictVersion v2) { if (v1 == null && v2 == null) return true; if (v1 == null || v2 == null) return false; if (! v1.getKind().equals(v2.getKind())) return false; @@ -131,7 +129,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { processDescription(myChange.getAfterDescription())); } - private BeforeAfter<ConflictSidePresentation> processDescription(SVNTreeConflictDescription description) throws VcsException { + private BeforeAfter<ConflictSidePresentation> processDescription(TreeConflictDescription description) throws VcsException { if (description == null) return null; if (myChange.getBeforeRevision() != null) { myCommittedRevision = (SvnRevisionNumber)SvnHistorySession.getCurrentCommittedRevision(myVcs, @@ -180,12 +178,12 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { return new BeforeAfter<ConflictSidePresentation>(leftSide, rightSide); } - private static boolean isDifferentURLs(SVNTreeConflictDescription description) { + private static boolean isDifferentURLs(TreeConflictDescription description) { return description.getSourceLeftVersion() != null && description.getSourceRightVersion() != null && ! Comparing.equal(description.getSourceLeftVersion().getPath(), description.getSourceRightVersion().getPath()); } - private ConflictSidePresentation createSide(SVNConflictVersion version, final SVNRevision untilThisOther, final boolean isLeft) throws VcsException { + private ConflictSidePresentation createSide(ConflictVersion version, final SVNRevision untilThisOther, final boolean isLeft) throws VcsException { if (version == null) return EmptyConflictSide.getInstance(); if (myChange.getBeforeRevision() != null && myCommittedRevision != null) { SvnRevisionNumber number = myCommittedRevision; @@ -226,12 +224,12 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { return wrapper; } - private void appendDescription(SVNTreeConflictDescription description, + private void appendDescription(TreeConflictDescription description, JPanel main, GridBagConstraints gb, BeforeAfter<ConflictSidePresentation> ba, boolean directory) { if (description == null) return; - JLabel descriptionLbl = new JLabel(SVNTreeConflictUtil.getHumanReadableConflictDescription(description)); + JLabel descriptionLbl = new JLabel(description.toPresentableString()); descriptionLbl.setForeground(Color.red); main.add(descriptionLbl, gb); ++ gb.gridy; @@ -243,7 +241,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { addSide(main, gb, ba.getAfter(), description.getSourceRightVersion(), "Right", directory); } - private void addResolveButtons(SVNTreeConflictDescription description, JPanel main, GridBagConstraints gb) { + private void addResolveButtons(TreeConflictDescription description, JPanel main, GridBagConstraints gb) { final FlowLayout flowLayout = new FlowLayout(FlowLayout.LEFT, 5, 5); JPanel wrapper = new JPanel(flowLayout); final JButton both = new JButton("Both"); @@ -266,7 +264,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { ++ gb.gridy; } - private ActionListener createRight(final SVNTreeConflictDescription description) { + private ActionListener createRight(final TreeConflictDescription description) { return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -276,11 +274,11 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { FileDocumentManager.getInstance().saveAllDocuments(); final Paths paths = getPaths(description); ProgressManager.getInstance().run( - new VcsBackgroundTask<SVNTreeConflictDescription>(myVcs.getProject(), "Accepting theirs for: " + filePath(paths.myMainPath), + new VcsBackgroundTask<TreeConflictDescription>(myVcs.getProject(), "Accepting theirs for: " + filePath(paths.myMainPath), BackgroundFromStartOption.getInstance(), Collections.singletonList(description), true) { @Override - protected void process(SVNTreeConflictDescription d) throws VcsException { + protected void process(TreeConflictDescription d) throws VcsException { new SvnTreeConflictResolver(myVcs, paths.myMainPath, myCommittedRevision, paths.myAdditionalPath).resolveSelectTheirsFull(d); } @@ -296,11 +294,11 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { }; } - private Paths getPaths(final SVNTreeConflictDescription description) { - FilePath mainPath = new FilePathImpl(description.getPath(), SVNNodeKind.DIR.equals(description.getNodeKind())); + private Paths getPaths(final TreeConflictDescription description) { + FilePath mainPath; FilePath additionalPath = null; if (myChange.isMoved() || myChange.isRenamed()) { - if (SVNConflictAction.ADD.equals(description.getConflictAction())) { + if (ConflictAction.ADD.equals(description.getConflictAction())) { mainPath = myChange.getAfterRevision().getFile(); additionalPath = myChange.getBeforeRevision().getFile(); } else { @@ -323,7 +321,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { } } - private ActionListener createLeft(final SVNTreeConflictDescription description) { + private ActionListener createLeft(final TreeConflictDescription description) { return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -333,11 +331,11 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { FileDocumentManager.getInstance().saveAllDocuments(); final Paths paths = getPaths(description); ProgressManager.getInstance().run( - new VcsBackgroundTask<SVNTreeConflictDescription>(myVcs.getProject(), "Accepting yours for: " + filePath(paths.myMainPath), + new VcsBackgroundTask<TreeConflictDescription>(myVcs.getProject(), "Accepting yours for: " + filePath(paths.myMainPath), BackgroundFromStartOption.getInstance(), Collections.singletonList(description), true) { @Override - protected void process(SVNTreeConflictDescription d) throws VcsException { + protected void process(TreeConflictDescription d) throws VcsException { new SvnTreeConflictResolver(myVcs, paths.myMainPath, myCommittedRevision, paths.myAdditionalPath).resolveSelectMineFull(d); } @@ -353,22 +351,22 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { }; } - private ActionListener createMerge(final SVNTreeConflictDescription description) { + private ActionListener createMerge(final TreeConflictDescription description) { if (isDifferentURLs(description)) { return null; } // my edit, theirs move or delete - if (SVNConflictAction.EDIT.equals(description.getConflictAction()) && description.getSourceLeftVersion() != null && - SVNConflictReason.DELETED.equals(description.getConflictReason()) && (myChange.isMoved() || myChange.isRenamed()) && + if (ConflictAction.EDIT.equals(description.getConflictAction()) && description.getSourceLeftVersion() != null && + ConflictReason.DELETED.equals(description.getConflictReason()) && (myChange.isMoved() || myChange.isRenamed()) && myCommittedRevision != null) { - if (myPath.isDirectory() == SVNNodeKind.DIR.equals(description.getSourceRightVersion().getKind())) { + if (myPath.isDirectory() == description.getSourceRightVersion().isDirectory()) { return createMergeTheirsForFile(description); } } return null; } - private ActionListener createMergeTheirsForFile(final SVNTreeConflictDescription description) { + private ActionListener createMergeTheirsForFile(final TreeConflictDescription description) { return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -381,7 +379,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { return newFilePath.getName() + " (" + newFilePath.getParentPath().getPath() + ")"; } - private static ActionListener createBoth(SVNTreeConflictDescription description) { + private static ActionListener createBoth(TreeConflictDescription description) { return null; } @@ -397,10 +395,10 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { private void addSide(JPanel main, GridBagConstraints gb, ConflictSidePresentation before, - SVNConflictVersion leftVersion, final String name, boolean directory) { + ConflictVersion leftVersion, final String name, boolean directory) { final String leftPresentation = leftVersion == null ? name + ": (" + (directory ? "directory" : "file") + (myChange.getBeforeRevision() == null ? ") added" : ") unversioned") : - name + ": " + FileUtil.toSystemIndependentName(SVNTreeConflictUtil.getHumanReadableConflictVersion(leftVersion)); + name + ": " + FileUtil.toSystemIndependentName(ConflictVersion.toPresentableString(leftVersion)); gb.insets.top = 10; main.add(new JLabel(leftPresentation), gb); ++ gb.gridy; @@ -454,9 +452,9 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { private abstract static class AbstractConflictSide<T> implements ConflictSidePresentation, Convertor<T, VcsRevisionNumber> { protected final Project myProject; - protected final SVNConflictVersion myVersion; + protected final ConflictVersion myVersion; - private AbstractConflictSide(Project project, SVNConflictVersion version) { + private AbstractConflictSide(Project project, ConflictVersion version) { myProject = project; myVersion = version; } @@ -472,13 +470,13 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { private FileHistoryPanelImpl myFileHistoryPanel; private TLongArrayList myListToReportLoaded; - private HistoryConflictSide(SvnVcs vcs, SVNConflictVersion version, final SVNRevision peg) throws VcsException { + private HistoryConflictSide(SvnVcs vcs, ConflictVersion version, final SVNRevision peg) throws VcsException { super(vcs.getProject(), version); myVcs = vcs; myPeg = peg; try { myPath = FilePathImpl.createNonLocal( - version.getRepositoryRoot().appendPath(FileUtil.toSystemIndependentName(version.getPath()), true).toString(), SVNNodeKind.DIR.equals(version.getKind())); + version.getRepositoryRoot().appendPath(FileUtil.toSystemIndependentName(version.getPath()), true).toString(), version.isDirectory()); } catch (SVNException e) { throw new VcsException(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractSvnUpdatePanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractSvnUpdatePanel.java index 0cea23ea3988..c57d043b33d2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractSvnUpdatePanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractSvnUpdatePanel.java @@ -23,8 +23,8 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.DepthCombo; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import javax.swing.*; import java.awt.*; @@ -106,7 +106,7 @@ public abstract class AbstractSvnUpdatePanel { @Nullable private SVNURL getUrlFor(@NotNull final FilePath root) { - final SVNInfo info = myVCS.getInfo(root.getIOFile()); + final Info info = myVCS.getInfo(root.getIOFile()); return info != null ? info.getURL() : null; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractUpdateIntegrateCrawler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractUpdateIntegrateCrawler.java index 47b15802287b..991c2fe1e7b2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractUpdateIntegrateCrawler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractUpdateIntegrateCrawler.java @@ -22,9 +22,7 @@ import com.intellij.openapi.vcs.update.UpdatedFiles; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.SvnWCRootCrawler; -import org.tmatesoft.svn.core.SVNErrorCode; -import org.tmatesoft.svn.core.SVNErrorMessage; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import java.io.File; import java.util.Collection; @@ -58,13 +56,9 @@ public abstract class AbstractUpdateIntegrateCrawler implements SvnWCRootCrawler long rev = doUpdate(root); if (rev < 0 && !isMerge()) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.UNKNOWN, SvnBundle.message("exception.text.root.was.not.properly.updated", root))); + throw new SvnBindException(SvnBundle.message("exception.text.root.was.not.properly.updated", root)); } } - catch (SVNException e) { - LOG.info(e); - myExceptions.add(new VcsException(e)); - } catch (VcsException e) { LOG.info(e); myExceptions.add(e); @@ -73,7 +67,7 @@ public abstract class AbstractUpdateIntegrateCrawler implements SvnWCRootCrawler protected abstract void showProgressMessage(ProgressIndicator progress, File root); - protected abstract long doUpdate(File root) throws SVNException, VcsException; + protected abstract long doUpdate(File root) throws VcsException; protected abstract boolean isMerge(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AutoSvnUpdater.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AutoSvnUpdater.java index 925d13c7242f..4bb3dbea9a18 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AutoSvnUpdater.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AutoSvnUpdater.java @@ -29,7 +29,7 @@ import com.intellij.openapi.wm.WindowManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.wc.SVNRevision; import javax.swing.*; @@ -66,7 +66,7 @@ public class AutoSvnUpdater extends AbstractCommonUpdateAction { final SvnConfiguration configuration17 = SvnConfiguration.getInstance(myProject); configuration17.setForceUpdate(false); configuration17.setUpdateLockOnDemand(false); - configuration17.setUpdateDepth(SVNDepth.INFINITY); + configuration17.setUpdateDepth(Depth.INFINITY); final SvnVcs vcs = SvnVcs.getInstance(myProject); for (FilePath root : myRoots) { configureUpdateRootInfo(root, configuration17.getUpdateRootInfo(root.getIOFile(), vcs)); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/CmdUpdateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/CmdUpdateClient.java index 051be8945b3e..61b0592af085 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/CmdUpdateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/CmdUpdateClient.java @@ -16,16 +16,17 @@ package org.jetbrains.idea.svn.update; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; import org.jetbrains.idea.svn.commandLine.BaseUpdateCommandListener; import org.jetbrains.idea.svn.commandLine.CommandUtil; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.commandLine.SvnCommandName; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -47,46 +48,24 @@ public class CmdUpdateClient extends SvnKitUpdateClient { private static final Pattern ourExceptionPattern = Pattern.compile("svn: E(\\d{6}): .+"); private static final String ourAuthenticationRealm = "Authentication realm:"; - @Override - public long[] doUpdate(final File[] paths, final SVNRevision revision, final SVNDepth depth, final boolean allowUnversionedObstructions, - final boolean depthIsSticky, final boolean makeParents) throws SVNException { - // since one revision is passed -> I assume same repository here - checkWorkingCopy(paths[0]); - - final List<String> parameters = new ArrayList<String>(); - - fillParameters(parameters, revision, depth, depthIsSticky, allowUnversionedObstructions); - CommandUtil.put(parameters, makeParents, "--parents"); - CommandUtil.put(parameters, myIgnoreExternals, "--ignore-externals"); - CommandUtil.put(parameters, paths); - - return run(paths, parameters, SvnCommandName.up); - } - - private void checkWorkingCopy(@NotNull File path) throws SVNException { - final SVNInfo info = myFactory.createInfoClient().doInfo(path, SVNRevision.UNDEFINED); + private void checkWorkingCopy(@NotNull File path) throws SvnBindException { + final Info info = myFactory.createInfoClient().doInfo(path, SVNRevision.UNDEFINED); if (info == null || info.getURL() == null) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.WC_NOT_WORKING_COPY, path.getPath())); + throw new SvnBindException(SVNErrorCode.WC_NOT_WORKING_COPY, path.getPath()); } } - private long[] run(@NotNull File[] paths, @NotNull List<String> parameters, @NotNull SvnCommandName command) throws SVNException { - File base = paths[0]; - base = base.isDirectory() ? base : base.getParentFile(); + private long[] run(@NotNull File path, @NotNull List<String> parameters, @NotNull SvnCommandName command) throws SvnBindException { + File base = path.isDirectory() ? path : path.getParentFile(); final AtomicReference<long[]> updatedToRevision = new AtomicReference<long[]>(); updatedToRevision.set(new long[0]); - final BaseUpdateCommandListener listener = createCommandListener(paths, updatedToRevision, base); - try { - execute(myVcs, SvnTarget.fromFile(base), command, parameters, listener); - } - catch (VcsException e) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e)); - } + final BaseUpdateCommandListener listener = createCommandListener(new File[]{path}, updatedToRevision, base); + execute(myVcs, SvnTarget.fromFile(base), command, parameters, listener); - listener.throwIfException(); + listener.throwWrappedIfException(); return updatedToRevision.get(); } @@ -98,8 +77,8 @@ public class CmdUpdateClient extends SvnKitUpdateClient { final long[] myRevisions = new long[paths.length]; @Override - protected void beforeHandler(@NotNull SVNEvent event) { - if (SVNEventAction.UPDATE_COMPLETED.equals(event.getAction())) { + protected void beforeHandler(@NotNull ProgressEvent event) { + if (EventAction.UPDATE_COMPLETED.equals(event.getAction())) { final long eventRevision = event.getRevision(); for (int i = 0; i < paths.length; i++) { final File path = paths[i]; @@ -121,7 +100,7 @@ public class CmdUpdateClient extends SvnKitUpdateClient { private static void fillParameters(@NotNull List<String> parameters, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean depthIsSticky, boolean allowUnversionedObstructions) { @@ -155,9 +134,17 @@ public class CmdUpdateClient extends SvnKitUpdateClient { } @Override - public long doUpdate(File path, SVNRevision revision, SVNDepth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) - throws SVNException { - final long[] longs = doUpdate(new File[]{path}, revision, depth, allowUnversionedObstructions, depthIsSticky, false); + public long doUpdate(File path, SVNRevision revision, Depth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) + throws SvnBindException { + checkWorkingCopy(path); + + final List<String> parameters = new ArrayList<String>(); + + fillParameters(parameters, revision, depth, depthIsSticky, allowUnversionedObstructions); + CommandUtil.put(parameters, myIgnoreExternals, "--ignore-externals"); + CommandUtil.put(parameters, path); + + final long[] longs = run(path, parameters, SvnCommandName.up); return longs[0]; } @@ -166,9 +153,9 @@ public class CmdUpdateClient extends SvnKitUpdateClient { SVNURL url, SVNRevision pegRevision, SVNRevision revision, - SVNDepth depth, + Depth depth, boolean allowUnversionedObstructions, - boolean depthIsSticky) throws SVNException { + boolean depthIsSticky) throws SvnBindException { checkWorkingCopy(path); List<String> parameters = new ArrayList<String>(); @@ -178,7 +165,7 @@ public class CmdUpdateClient extends SvnKitUpdateClient { fillParameters(parameters, revision, depth, depthIsSticky, allowUnversionedObstructions); parameters.add("--ignore-ancestry"); - long[] revisions = run(new File[]{path}, parameters, SvnCommandName.switchCopy); + long[] revisions = run(path, parameters, SvnCommandName.switchCopy); return revisions != null && revisions.length > 0 ? revisions[0] : -1; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/MergeRootInfo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/MergeRootInfo.java index 872ee8f81573..6bc2af02415c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/MergeRootInfo.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/MergeRootInfo.java @@ -16,9 +16,9 @@ package org.jetbrains.idea.svn.update; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -33,7 +33,7 @@ public class MergeRootInfo { myRevision1 = SVNRevision.HEAD; myRevision2 = SVNRevision.HEAD; - SVNInfo info = vcs.getInfo(file); + Info info = vcs.getInfo(file); myUrl1 = info != null && info.getURL() != null ? info.getURL().toString() : ""; myUrl2 = myUrl1; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnKitUpdateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnKitUpdateClient.java index be9923d1b07b..eaf6578b1587 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnKitUpdateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnKitUpdateClient.java @@ -18,10 +18,11 @@ package org.jetbrains.idea.svn.update; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNUpdateClient; @@ -35,24 +36,19 @@ import java.io.File; */ public class SvnKitUpdateClient extends BaseSvnClient implements UpdateClient { - @Nullable protected ISVNEventHandler myDispatcher; + @Nullable protected ProgressTracker myDispatcher; protected boolean myIgnoreExternals; protected boolean myLocksOnDemand; @Override - public long[] doUpdate(File[] paths, - SVNRevision revision, - SVNDepth depth, - boolean allowUnversionedObstructions, - boolean depthIsSticky, - boolean makeParents) throws SVNException { - return getClient().doUpdate(paths, revision, depth, allowUnversionedObstructions, depthIsSticky, makeParents); - } - - @Override - public long doUpdate(File path, SVNRevision revision, SVNDepth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) - throws SVNException { - return getClient().doUpdate(path, revision, depth, allowUnversionedObstructions, depthIsSticky); + public long doUpdate(File path, SVNRevision revision, Depth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) + throws SvnBindException { + try { + return getClient().doUpdate(path, revision, toDepth(depth), allowUnversionedObstructions, depthIsSticky); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } @Override @@ -60,9 +56,14 @@ public class SvnKitUpdateClient extends BaseSvnClient implements UpdateClient { SVNURL url, SVNRevision pegRevision, SVNRevision revision, - SVNDepth depth, - boolean allowUnversionedObstructions, boolean depthIsSticky) throws SVNException { - return getClient().doSwitch(path, url, pegRevision, revision, depth, allowUnversionedObstructions, depthIsSticky); + Depth depth, + boolean allowUnversionedObstructions, boolean depthIsSticky) throws SvnBindException { + try { + return getClient().doSwitch(path, url, pegRevision, revision, toDepth(depth), allowUnversionedObstructions, depthIsSticky); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } @Override @@ -71,7 +72,7 @@ public class SvnKitUpdateClient extends BaseSvnClient implements UpdateClient { } @Override - public void setEventHandler(ISVNEventHandler dispatcher) { + public void setEventHandler(ProgressTracker dispatcher) { myDispatcher = dispatcher; } @@ -84,7 +85,7 @@ public class SvnKitUpdateClient extends BaseSvnClient implements UpdateClient { private SVNUpdateClient getClient() { SVNUpdateClient client = myVcs.getSvnKitManager().createUpdateClient(); - client.setEventHandler(myDispatcher); + client.setEventHandler(toEventHandler(myDispatcher)); client.setIgnoreExternals(myIgnoreExternals); client.setUpdateLocksOnDemand(myLocksOnDemand); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdateEnvironment.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdateEnvironment.java index e4d25c385375..554b2c29bc48 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdateEnvironment.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdateEnvironment.java @@ -24,9 +24,9 @@ import com.intellij.openapi.vcs.update.UpdatedFiles; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -70,7 +70,7 @@ public class SvnUpdateEnvironment extends AbstractSvnUpdateIntegrateEnvironment progress.setText(SvnBundle.message("progress.text.updating", root.getAbsolutePath())); } - protected long doUpdate(final File root) throws SVNException { + protected long doUpdate(final File root) throws SvnBindException { final long rev; final SvnConfiguration configuration = SvnConfiguration.getInstance(myVcs.getProject()); @@ -113,7 +113,7 @@ public class SvnUpdateEnvironment extends AbstractSvnUpdateIntegrateEnvironment @Nullable private static SVNURL getSourceUrl(final SvnVcs vcs, final File root) { - final SVNInfo svnInfo = vcs.getInfo(root); + final Info svnInfo = vcs.getInfo(root); return svnInfo != null ? svnInfo.getURL() : null; } @@ -140,7 +140,7 @@ public class SvnUpdateEnvironment extends AbstractSvnUpdateIntegrateEnvironment } } } - catch (SVNException e) { + catch (SvnBindException e) { Messages.showErrorDialog(myVcs.getProject(), e.getMessage(), SvnBundle.message("switch.target.problem.title")); return false; }*/ @@ -148,7 +148,7 @@ public class SvnUpdateEnvironment extends AbstractSvnUpdateIntegrateEnvironment return true; } - private SVNRevision correctRevision(@NotNull UpdateRootInfo value) throws SVNException { + private SVNRevision correctRevision(@NotNull UpdateRootInfo value) throws SvnBindException { if (SVNRevision.HEAD.equals(value.getRevision())) { // find acual revision to update to (a bug if just say head in switch) value.setRevision(SvnUtil.getHeadRevision(myVcs, value.getUrl())); @@ -157,9 +157,9 @@ public class SvnUpdateEnvironment extends AbstractSvnUpdateIntegrateEnvironment } // false - do not do update - private boolean checkAncestry(final File sourceFile, final SVNURL targetUrl, final SVNRevision targetRevision) throws SVNException { - final SVNInfo sourceSvnInfo = myVcs.getInfo(sourceFile); - final SVNInfo targetSvnInfo = myVcs.getInfo(targetUrl, targetRevision); + private boolean checkAncestry(final File sourceFile, final SVNURL targetUrl, final SVNRevision targetRevision) throws SvnBindException { + final Info sourceSvnInfo = myVcs.getInfo(sourceFile); + final Info targetSvnInfo = myVcs.getInfo(targetUrl, targetRevision); if (sourceSvnInfo == null || targetSvnInfo == null) { // cannot check diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateClient.java index b68829e28940..7155400df04e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateClient.java @@ -15,11 +15,11 @@ */ package org.jetbrains.idea.svn.update; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -32,14 +32,19 @@ import java.io.File; */ public interface UpdateClient extends SvnClient { - long[] doUpdate(File[] paths, SVNRevision revision, SVNDepth depth, boolean allowUnversionedObstructions, boolean depthIsSticky, boolean makeParents) throws SVNException; - - long doUpdate(File path, SVNRevision revision, SVNDepth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) throws SVNException; + long doUpdate(File path, SVNRevision revision, Depth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) + throws SvnBindException; void setUpdateLocksOnDemand(boolean locksOnDemand); - long doSwitch(File path, SVNURL url, SVNRevision pegRevision, SVNRevision revision, SVNDepth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) throws SVNException; + long doSwitch(File path, + SVNURL url, + SVNRevision pegRevision, + SVNRevision revision, + Depth depth, + boolean allowUnversionedObstructions, + boolean depthIsSticky) throws SvnBindException; - void setEventHandler(ISVNEventHandler dispatcher); + void setEventHandler(ProgressTracker dispatcher); void setIgnoreExternals(boolean ignoreExternals); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateEventHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateEventHandler.java index cea4edbcc7cd..fc552dbd1655 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateEventHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateEventHandler.java @@ -25,6 +25,10 @@ import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnFileUrlMapping; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNCancelException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.wc.SVNErrorManager; @@ -38,7 +42,7 @@ import java.util.Map; /** * @author lesya */ -public class UpdateEventHandler implements ISVNEventHandler { +public class UpdateEventHandler implements ProgressTracker { private ProgressIndicator myProgressIndicator; private UpdatedFiles myUpdatedFiles; private int myExternalsCount; @@ -66,7 +70,7 @@ public class UpdateEventHandler implements ISVNEventHandler { myUpdatedFiles = updatedFiles; } - public void handleEvent(final SVNEvent event, double progress) { + public void consume(final ProgressEvent event) { if (event == null || event.getFile() == null) { return; } @@ -81,7 +85,7 @@ public class UpdateEventHandler implements ISVNEventHandler { return; } - if (event.getAction() == SVNEventAction.TREE_CONFLICT) { + if (event.getAction() == EventAction.TREE_CONFLICT) { myText2 = SvnBundle.message("progress.text2.treeconflicted", displayPath); updateProgressIndicator(); myUpdatedFiles.registerGroup(createFileGroup(VcsBundle.message("update.group.name.merged.with.tree.conflicts"), @@ -89,10 +93,10 @@ public class UpdateEventHandler implements ISVNEventHandler { addFileToGroup(FileGroup.MERGED_WITH_TREE_CONFLICT, event); } - if (event.getAction() == SVNEventAction.UPDATE_ADD || - event.getAction() == SVNEventAction.ADD) { + if (event.getAction() == EventAction.UPDATE_ADD || + event.getAction() == EventAction.ADD) { myText2 = SvnBundle.message("progress.text2.added", displayPath); - if (event.getContentsStatus() == SVNStatusType.CONFLICTED || event.getPropertiesStatus() == SVNStatusType.CONFLICTED) { + if (event.getContentsStatus() == StatusType.CONFLICTED || event.getPropertiesStatus() == StatusType.CONFLICTED) { addFileToGroup(FileGroup.MERGED_WITH_CONFLICT_ID, event); myText2 = SvnBundle.message("progress.text2.conflicted", displayPath); } else if (myUpdatedFiles.getGroupById(FileGroup.REMOVED_FROM_REPOSITORY_ID).getFiles().contains(path)) { @@ -106,38 +110,38 @@ public class UpdateEventHandler implements ISVNEventHandler { addFileToGroup(FileGroup.CREATED_ID, event); } } - else if (event.getAction() == SVNEventAction.UPDATE_NONE) { + else if (event.getAction() == EventAction.UPDATE_NONE) { // skip it return; } - else if (event.getAction() == SVNEventAction.UPDATE_DELETE) { + else if (event.getAction() == EventAction.UPDATE_DELETE) { myText2 = SvnBundle.message("progress.text2.deleted", displayPath); addFileToGroup(FileGroup.REMOVED_FROM_REPOSITORY_ID, event); } - else if (event.getAction() == SVNEventAction.UPDATE_UPDATE) { + else if (event.getAction() == EventAction.UPDATE_UPDATE) { possiblySwitched(event); - if (event.getContentsStatus() == SVNStatusType.CONFLICTED || event.getPropertiesStatus() == SVNStatusType.CONFLICTED) { - if (event.getContentsStatus() == SVNStatusType.CONFLICTED) { + if (event.getContentsStatus() == StatusType.CONFLICTED || event.getPropertiesStatus() == StatusType.CONFLICTED) { + if (event.getContentsStatus() == StatusType.CONFLICTED) { addFileToGroup(FileGroup.MERGED_WITH_CONFLICT_ID, event); } - if (event.getPropertiesStatus() == SVNStatusType.CONFLICTED) { + if (event.getPropertiesStatus() == StatusType.CONFLICTED) { addFileToGroup(FileGroup.MERGED_WITH_PROPERTY_CONFLICT_ID, event); } myText2 = SvnBundle.message("progress.text2.conflicted", displayPath); } - else if (event.getContentsStatus() == SVNStatusType.MERGED || event.getPropertiesStatus() == SVNStatusType.MERGED) { + else if (event.getContentsStatus() == StatusType.MERGED || event.getPropertiesStatus() == StatusType.MERGED) { myText2 = SvnBundle.message("progres.text2.merged", displayPath); addFileToGroup(FileGroup.MERGED_ID, event); } - else if (event.getContentsStatus() == SVNStatusType.CHANGED || event.getPropertiesStatus() == SVNStatusType.CHANGED) { + else if (event.getContentsStatus() == StatusType.CHANGED || event.getPropertiesStatus() == StatusType.CHANGED) { myText2 = SvnBundle.message("progres.text2.updated", displayPath); addFileToGroup(FileGroup.UPDATED_ID, event); } - else if (event.getContentsStatus() == SVNStatusType.UNCHANGED && - (event.getPropertiesStatus() == SVNStatusType.UNCHANGED || event.getPropertiesStatus() == SVNStatusType.UNKNOWN)) { + else if (event.getContentsStatus() == StatusType.UNCHANGED && + (event.getPropertiesStatus() == StatusType.UNCHANGED || event.getPropertiesStatus() == StatusType.UNKNOWN)) { myText2 = SvnBundle.message("progres.text2.updated", displayPath); - } else if (SVNStatusType.INAPPLICABLE.equals(event.getContentsStatus()) && - (event.getPropertiesStatus() == SVNStatusType.UNCHANGED || event.getPropertiesStatus() == SVNStatusType.UNKNOWN)) { + } else if (StatusType.INAPPLICABLE.equals(event.getContentsStatus()) && + (event.getPropertiesStatus() == StatusType.UNCHANGED || event.getPropertiesStatus() == StatusType.UNKNOWN)) { myText2 = SvnBundle.message("progres.text2.updated", displayPath); } else { @@ -145,7 +149,7 @@ public class UpdateEventHandler implements ISVNEventHandler { addFileToGroup(FileGroup.UNKNOWN_ID, event); } } - else if (event.getAction() == SVNEventAction.UPDATE_EXTERNAL) { + else if (event.getAction() == EventAction.UPDATE_EXTERNAL) { if (mySequentialUpdatesContext != null) { mySequentialUpdatesContext.registerExternalRootBeingUpdated(event.getFile()); } @@ -158,11 +162,11 @@ public class UpdateEventHandler implements ISVNEventHandler { addFileToGroup(AbstractSvnUpdateIntegrateEnvironment.EXTERNAL_ID, event); myText = SvnBundle.message("progress.text.updating.external.location", event.getFile().getAbsolutePath()); } - else if (event.getAction() == SVNEventAction.RESTORE) { + else if (event.getAction() == EventAction.RESTORE) { myText2 = SvnBundle.message("progress.text2.restored.file", displayPath); addFileToGroup(FileGroup.RESTORED_ID, event); } - else if (event.getAction() == SVNEventAction.UPDATE_COMPLETED && event.getRevision() >= 0) { + else if (event.getAction() == EventAction.UPDATE_COMPLETED && event.getRevision() >= 0) { possiblySwitched(event); myExternalsCount--; myText2 = SvnBundle.message("progres.text2.updated.to.revision", event.getRevision()); @@ -171,7 +175,7 @@ public class UpdateEventHandler implements ISVNEventHandler { StatusBar.Info.set(SvnBundle.message("status.text.updated.to.revision", event.getRevision()), myVCS.getProject()); } } - else if (event.getAction() == SVNEventAction.SKIP) { + else if (event.getAction() == EventAction.SKIP) { myText2 = SvnBundle.message("progress.text2.skipped.file", displayPath); addFileToGroup(FileGroup.SKIPPED_ID, event); } @@ -179,7 +183,7 @@ public class UpdateEventHandler implements ISVNEventHandler { updateProgressIndicator(); } - private void possiblySwitched(SVNEvent event) { + private void possiblySwitched(ProgressEvent event) { final File file = event.getFile(); if (file == null) return; final SVNURL wasUrl = myUrlToCheckForSwitch.get(file); @@ -189,7 +193,7 @@ public class UpdateEventHandler implements ISVNEventHandler { } } - private boolean itemSwitched(final SVNEvent event) { + private boolean itemSwitched(final ProgressEvent event) { final File file = event.getFile(); final SvnFileUrlMapping urlMapping = myVCS.getSvnFileUrlMapping(); final SVNURL currentUrl = urlMapping.getUrlForFile(file); @@ -207,11 +211,11 @@ public class UpdateEventHandler implements ISVNEventHandler { } } - protected boolean handleInDescendants(final SVNEvent event) { + protected boolean handleInDescendants(final ProgressEvent event) { return false; } - protected void addFileToGroup(final String id, final SVNEvent event) { + protected void addFileToGroup(final String id, final ProgressEvent event) { final FileGroup fileGroup = myUpdatedFiles.getGroupById(id); final String path = event.getFile().getAbsolutePath(); fileGroup.add(path, SvnVcs.getKey(), new SvnRevisionNumber(SVNRevision.create(event.getRevision()))); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateRootInfo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateRootInfo.java index b2a318b39da8..c858f78890f4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateRootInfo.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateRootInfo.java @@ -16,9 +16,9 @@ package org.jetbrains.idea.svn.update; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -31,7 +31,7 @@ public class UpdateRootInfo { public UpdateRootInfo(File file, SvnVcs vcs) { myRevision = SVNRevision.HEAD; - SVNInfo info = vcs.getInfo(file); + Info info = vcs.getInfo(file); myUrl = info != null && info.getURL() != null ? info.getURL().toString() : ""; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/CmdUpgradeClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/CmdUpgradeClient.java index 3a4e6eb6ce92..f27615423904 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/CmdUpgradeClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/CmdUpgradeClient.java @@ -7,14 +7,10 @@ import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.WorkingCopyFormat; -import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.api.FileStatusResultParser; +import org.jetbrains.idea.svn.api.*; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.LineCommandAdapter; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -34,11 +30,11 @@ public class CmdUpgradeClient extends BaseSvnClient implements UpgradeClient { private static final Pattern CHANGED_PATH = Pattern.compile(STATUS + PATH); @Override - public void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ISVNEventHandler handler) throws VcsException { + public void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ProgressTracker handler) throws VcsException { validateFormat(format, getSupportedFormats()); // fake event indicating upgrade start - callHandler(handler, createEvent(path, SVNEventAction.UPDATE_COMPLETED)); + callHandler(handler, createEvent(path, EventAction.UPDATE_COMPLETED)); List<String> parameters = new ArrayList<String>(); @@ -64,9 +60,9 @@ public class CmdUpgradeClient extends BaseSvnClient implements UpgradeClient { return result; } - private static class UpgradeStatusConvertor implements Convertor<Matcher, SVNEvent> { + private static class UpgradeStatusConvertor implements Convertor<Matcher, ProgressEvent> { - public SVNEvent convert(@NotNull Matcher matcher) { + public ProgressEvent convert(@NotNull Matcher matcher) { String statusMessage = matcher.group(1); String path = matcher.group(2); @@ -74,11 +70,11 @@ public class CmdUpgradeClient extends BaseSvnClient implements UpgradeClient { } @Nullable - public static SVNEventAction createAction(@NotNull String code) { - SVNEventAction result = null; + public static EventAction createAction(@NotNull String code) { + EventAction result = null; if ("Upgraded".equals(code)) { - result = SVNEventAction.UPGRADED_PATH; + result = EventAction.UPGRADED_PATH; } return result; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/SvnKitUpgradeClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/SvnKitUpgradeClient.java index 66b5f71b4911..f583ad2c8eda 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/SvnKitUpgradeClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/SvnKitUpgradeClient.java @@ -5,11 +5,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.checkout.SvnKitCheckoutClient; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEventAction; import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -21,12 +21,12 @@ import java.util.List; public class SvnKitUpgradeClient extends BaseSvnClient implements UpgradeClient { @Override - public void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ISVNEventHandler handler) throws VcsException { + public void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ProgressTracker handler) throws VcsException { validateFormat(format, getSupportedFormats()); SVNWCClient client = myVcs.getSvnKitManager().createWCClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); try { cleanupIfNecessary(path, format, client, handler); upgrade(path, format, client, handler); @@ -44,11 +44,11 @@ public class SvnKitUpgradeClient extends BaseSvnClient implements UpgradeClient private static void cleanupIfNecessary(@NotNull File path, @NotNull WorkingCopyFormat format, @NotNull SVNWCClient client, - @Nullable ISVNEventHandler handler) throws SVNException, VcsException { + @Nullable ProgressTracker handler) throws SVNException, VcsException { // cleanup is executed only for SVNKit as it could handle both 1.6 and 1.7 formats if (WorkingCopyFormat.ONE_DOT_SEVEN.equals(format)) { // fake event indicating cleanup start - callHandler(handler, createEvent(path, SVNEventAction.UPDATE_STARTED)); + callHandler(handler, createEvent(path, EventAction.UPDATE_STARTED)); client.doCleanup(path); } } @@ -56,9 +56,9 @@ public class SvnKitUpgradeClient extends BaseSvnClient implements UpgradeClient private static void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @NotNull SVNWCClient client, - @Nullable ISVNEventHandler handler) throws SVNException, VcsException { + @Nullable ProgressTracker handler) throws SVNException, VcsException { // fake event indicating upgrade start - callHandler(handler, createEvent(path, SVNEventAction.UPDATE_COMPLETED)); + callHandler(handler, createEvent(path, EventAction.UPDATE_COMPLETED)); client.doSetWCFormat(path, format.getFormat()); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/UpgradeClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/UpgradeClient.java index 2d22acf08c45..22d916f158fd 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/UpgradeClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/UpgradeClient.java @@ -4,8 +4,8 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.WorkingCopyFormat; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import java.io.File; import java.util.List; @@ -15,7 +15,7 @@ import java.util.List; */ public interface UpgradeClient extends SvnClient { - void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ISVNEventHandler handler) throws VcsException; + void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ProgressTracker handler) throws VcsException; List<WorkingCopyFormat> getSupportedFormats() throws VcsException; } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/ConflictCreator.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/ConflictCreator.java index 635484fd2112..cca76e17f234 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/ConflictCreator.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/ConflictCreator.java @@ -26,8 +26,8 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Processor; import com.intellij.util.containers.Convertor; import junit.framework.Assert; -import org.tmatesoft.svn.core.wc.SVNInfo; -import org.tmatesoft.svn.core.wc.SVNStatusType; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.status.StatusType; import java.io.File; import java.io.IOException; @@ -100,7 +100,7 @@ public class ConflictCreator { String subPath = ""; for (String part : parts) { final String path = subPath + part; - SVNInfo info = vcs.getInfo(new File(myTheirsDir.getPath(), path)); + Info info = vcs.getInfo(new File(myTheirsDir.getPath(), path)); if (info == null || info.getURL() == null) { myClientRunner.add(myTheirsDir, path); } @@ -161,15 +161,15 @@ public class ConflictCreator { final File target = new File(root.getPath(), fileData.myRelativePath); // we dont apply properties changes fow now - if (SVNStatusType.STATUS_MISSING.equals(fileData.myNodeStatus)) { + if (StatusType.STATUS_MISSING.equals(fileData.myNodeStatus)) { // delete existing only from fs FileUtil.delete(target); return; - } else if (SVNStatusType.STATUS_UNVERSIONED.equals(fileData.myNodeStatus)) { + } else if (StatusType.STATUS_UNVERSIONED.equals(fileData.myNodeStatus)) { // create new unversioned createFile(root, fileData, target); return; - } else if (SVNStatusType.STATUS_ADDED.equals(fileData.myNodeStatus)) { + } else if (StatusType.STATUS_ADDED.equals(fileData.myNodeStatus)) { if (fileData.myCopyFrom != null) { myClientRunner.copy(root, fileData.myCopyFrom, fileData.myRelativePath); return; @@ -177,11 +177,11 @@ public class ConflictCreator { createFile(root, fileData, target); myClientRunner.add(root, fileData.myRelativePath); return; - } else if (SVNStatusType.STATUS_DELETED.equals(fileData.myNodeStatus)) { + } else if (StatusType.STATUS_DELETED.equals(fileData.myNodeStatus)) { myClientRunner.delete(root, fileData.myRelativePath); return; - } else if (SVNStatusType.STATUS_NORMAL.equals(fileData.myNodeStatus)) { - if (SVNStatusType.STATUS_MODIFIED.equals(fileData.myContentsStatus)) { + } else if (StatusType.STATUS_NORMAL.equals(fileData.myNodeStatus)) { + if (StatusType.STATUS_MODIFIED.equals(fileData.myContentsStatus)) { createFile(root, fileData, target); return; } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCachingRevisionsTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCachingRevisionsTest.java index ee9e2cd46496..d3a9bc552224 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCachingRevisionsTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCachingRevisionsTest.java @@ -8,7 +8,6 @@ import com.intellij.openapi.vcs.changes.committed.ChangesBunch; import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList; import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase; import org.jetbrains.idea.svn.history.*; -import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -36,8 +35,10 @@ public class SvnCachingRevisionsTest extends CodeInsightFixtureTestCase { } private SvnChangeList createList(final long revision) { - return new SvnChangeList(null, myLocation, - new SVNLogEntry(Collections.emptyMap(), revision, AUTHOR, new Date(System.currentTimeMillis()), ""), ROOT.toDecodedString()); + LogEntry entry = + new LogEntry.Builder().setRevision(revision).setAuthor(AUTHOR).setDate(new Date(System.currentTimeMillis())).setMessage("").build(); + + return new SvnChangeList(null, myLocation, entry, ROOT.toDecodedString()); } private class MockSvnLogLoader implements SvnLogLoader { diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnMergeInfoTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnMergeInfoTest.java index 1ed14dce6704..b6d83ad9ed2d 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnMergeInfoTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnMergeInfoTest.java @@ -24,20 +24,20 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.dialogs.MergeContext; import org.jetbrains.idea.svn.dialogs.WCInfo; import org.jetbrains.idea.svn.history.SvnChangeList; import org.jetbrains.idea.svn.history.SvnRepositoryLocation; +import org.jetbrains.idea.svn.info.Info; import org.jetbrains.idea.svn.mergeinfo.BranchInfo; import org.jetbrains.idea.svn.mergeinfo.OneShotMergeInfoHelper; import org.jetbrains.idea.svn.mergeinfo.SvnMergeInfoCache; import org.junit.Assert; import org.junit.Test; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNPropertyData; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNWCClient; @@ -86,7 +86,7 @@ public class SvnMergeInfoTest extends Svn17TestCase { VirtualFile vcsRoot = LocalFileSystem.getInstance().findFileByIoFile(myBranchVcsRoot); Node node = new Node(vcsRoot, SVNURL.parseURIEncoded(myBranchUrl), SVNURL.parseURIEncoded(myRepoUrl)); RootUrlInfo root = new RootUrlInfo(node, WorkingCopyFormat.ONE_DOT_SIX, vcsRoot, null); - myWCInfo = new WCInfo(root, true, SVNDepth.INFINITY); + myWCInfo = new WCInfo(root, true, Depth.INFINITY); myMergeContext = new MergeContext(SvnVcs.getInstance(myProject), myTrunkUrl, myWCInfo, SVNPathUtil.tail(myTrunkUrl), vcsRoot); myOneShotMergeInfoHelper = new OneShotMergeInfoHelper(myMergeContext); @@ -255,7 +255,7 @@ public class SvnMergeInfoTest extends Svn17TestCase { assertMergeInfo(myBranchVcsRoot, "/trunk:3"); - final SVNInfo f1info = myVcs.getInfo(new File(myBranchVcsRoot, "folder/f1.txt")); + final Info f1info = myVcs.getInfo(new File(myBranchVcsRoot, "folder/f1.txt")); assert f1info.getRevision().getNumber() == 2; final List<SvnChangeList> changeListList = getTrunkChangeLists(); diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeClientAuthTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeClientAuthTest.java index 99f7b0cda790..a0dfa979ea74 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeClientAuthTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeClientAuthTest.java @@ -30,6 +30,7 @@ import com.intellij.util.Processor; import com.intellij.util.containers.Convertor; import junit.framework.Assert; import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.auth.SvnAuthenticationManager; import org.jetbrains.idea.svn.auth.SvnAuthenticationNotifier; import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider; @@ -544,7 +545,7 @@ public class SvnNativeClientAuthTest extends Svn17TestCase { root.deleteOnExit(); Assert.assertTrue(root.exists()); SvnCheckoutProvider - .checkout(myProject, root, url, SVNRevision.HEAD, SVNDepth.INFINITY, false, new CheckoutProvider.Listener() { + .checkout(myProject, root, url, SVNRevision.HEAD, Depth.INFINITY, false, new CheckoutProvider.Listener() { @Override public void directoryCheckedOut(File directory, VcsKey vcs) { } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnParseCommandLineParseTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnParseCommandLineParseTest.java index ec78b9fd5f55..6e0ee960b64a 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnParseCommandLineParseTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnParseCommandLineParseTest.java @@ -24,19 +24,15 @@ import com.intellij.util.containers.Convertor; import com.intellij.util.containers.MultiMap; import junit.framework.Assert; import junit.framework.TestCase; -import org.jetbrains.idea.svn.status.CmdStatusClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.status.*; import org.jetbrains.idea.svn.info.SvnInfoHandler; -import org.jetbrains.idea.svn.status.SvnStatusHandler; -import org.jetbrains.idea.svn.info.IdeaSVNInfo; -import org.jetbrains.idea.svn.status.PortableStatus; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNStatusHandler; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatus; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; @@ -84,10 +80,10 @@ public class SvnParseCommandLineParseTest extends TestCase { "</entry>\n" + "</info>"; - final SVNInfo[] info = new SVNInfo[1]; - final SvnInfoHandler handler = new SvnInfoHandler(new File("C:/base/"), new Consumer<SVNInfo>() { + final Info[] info = new Info[1]; + final SvnInfoHandler handler = new SvnInfoHandler(new File("C:/base/"), new Consumer<Info>() { @Override - public void consume(SVNInfo info1) { + public void consume(Info info1) { info[0] = info1; } }); @@ -574,9 +570,9 @@ public class SvnParseCommandLineParseTest extends TestCase { @Override public void switchChangeList(String newList) { } - }, new File(basePath), new Convertor<File, SVNInfo>() { + }, new File(basePath), new Convertor<File, Info>() { @Override - public SVNInfo convert(File o) { + public Info convert(File o) { try { o.getCanonicalFile(); } @@ -616,9 +612,9 @@ public class SvnParseCommandLineParseTest extends TestCase { return StringUtil.replace(s, "C:/", LINUX_ROOT); } - private IdeaSVNInfo createStubInfo(final String basePath, final String baseUrl) throws SVNException { - return new IdeaSVNInfo(basePath, SVNURL.parseURIEncoded(baseUrl), SVNRevision.HEAD, SVNNodeKind.FILE, "", - SVNURL.parseURIEncoded("http://a.b.c"), 1, new Date(), "me", null, SVNDepth.EMPTY, 1); + private Info createStubInfo(final String basePath, final String baseUrl) throws SVNException { + return new Info(basePath, SVNURL.parseURIEncoded(baseUrl), SVNRevision.HEAD, NodeKind.FILE, "", + SVNURL.parseURIEncoded("http://a.b.c"), 1, new Date(), "me", null, Depth.EMPTY); } public void testStatusInExternalMove() throws Exception { @@ -671,9 +667,9 @@ public class SvnParseCommandLineParseTest extends TestCase { final String basePath = "C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main"; final SvnStatusHandler[] handler = new SvnStatusHandler[1]; final File baseFile = new File(basePath); - final SvnStatusHandler.ExternalDataCallback callback = CmdStatusClient.createStatusCallback(new ISVNStatusHandler() { + final SvnStatusHandler.ExternalDataCallback callback = CmdStatusClient.createStatusCallback(new StatusConsumer() { @Override - public void handleStatus(SVNStatus status) throws SVNException { + public void consume(Status status) throws SVNException { System.out.println(status.getURL()); if (new File( "C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\MacMessagesParser.java") @@ -686,9 +682,9 @@ public class SvnParseCommandLineParseTest extends TestCase { } } }, baseFile, createStubInfo(basePath, "http://mainurl/"), handler); - handler[0] = new SvnStatusHandler(callback, baseFile, new Convertor<File, SVNInfo>() { + handler[0] = new SvnStatusHandler(callback, baseFile, new Convertor<File, Info>() { @Override - public SVNInfo convert(File o) { + public Info convert(File o) { try { if (new File("C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave").equals(o)) { return createStubInfo(o.getPath(), "http://external"); @@ -756,9 +752,9 @@ public class SvnParseCommandLineParseTest extends TestCase { @Override public void switchChangeList(String newList) { } - }, new File(basePath), new Convertor<File, SVNInfo>() { + }, new File(basePath), new Convertor<File, Info>() { @Override - public SVNInfo convert(File o) { + public Info convert(File o) { try { o.getCanonicalFile(); } @@ -846,9 +842,9 @@ public class SvnParseCommandLineParseTest extends TestCase { public void switchChangeList(String newList) { clName[0] = newList; } - }, new File(basePath), new Convertor<File, SVNInfo>() { + }, new File(basePath), new Convertor<File, Info>() { @Override - public SVNInfo convert(File o) { + public Info convert(File o) { try { o.getCanonicalFile(); } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnProtocolsTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnProtocolsTest.java index 358f3722d7b5..af17c9aa2190 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnProtocolsTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnProtocolsTest.java @@ -35,6 +35,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Processor; import com.intellij.util.containers.Convertor; import junit.framework.Assert; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.auth.SvnAuthenticationManager; import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider; import org.junit.Before; @@ -222,7 +223,7 @@ public class SvnProtocolsTest extends Svn17TestCase { root.deleteOnExit(); Assert.assertTrue(root.exists()); SvnCheckoutProvider - .checkout(myProject, root, url, SVNRevision.HEAD, SVNDepth.INFINITY, false, new CheckoutProvider.Listener() { + .checkout(myProject, root, url, SVNRevision.HEAD, Depth.INFINITY, false, new CheckoutProvider.Listener() { @Override public void directoryCheckedOut(File directory, VcsKey vcs) { } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java index 071da76aee78..03d3875b37b2 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java @@ -26,12 +26,12 @@ import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Processor; import junit.framework.Assert; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.jetbrains.idea.svn.treeConflict.SvnTreeConflictResolver; import org.junit.Before; import org.junit.Test; -import org.tmatesoft.svn.core.wc.SVNInfo; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.io.IOException; @@ -162,43 +162,43 @@ public class SvnResolveTreeAcceptVariantsTest extends Svn17TestCase { } private void checkStatusesAfterMineFullResolve(TreeConflictData.Data data, File conflictIoFile) { - SVNStatus conflStatus = SvnUtil.getStatus(myVcs, conflictIoFile); + Status conflStatus = SvnUtil.getStatus(myVcs, conflictIoFile); Assert.assertTrue(createTestFailedComment(data, conflictIoFile.getPath()) + " tree conflict resolved", conflStatus.getTreeConflict() == null); Collection<TreeConflictData.FileData> leftFiles = data.getLeftFiles(); for (TreeConflictData.FileData file : leftFiles) { File exFile = new File(myWorkingCopyDir.getPath(), file.myRelativePath); - final SVNStatus status = SvnUtil.getStatus(myVcs, exFile); + final Status status = SvnUtil.getStatus(myVcs, exFile); boolean theirsExists = new File(myTheirs.getPath(), file.myRelativePath).exists(); - if (SVNStatusType.STATUS_UNVERSIONED.equals(file.myNodeStatus)) { + if (StatusType.STATUS_UNVERSIONED.equals(file.myNodeStatus)) { Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (file exists)", exFile.exists()); if (theirsExists) { // should be deleted - Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (unversioned)", status == null || SVNStatusType.STATUS_DELETED.equals(status.getNodeStatus())); + Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (unversioned)", status == null || StatusType.STATUS_DELETED.equals(status.getNodeStatus())); } else { // unversioned - Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (unversioned)", status == null || SVNStatusType.STATUS_UNVERSIONED.equals(status.getNodeStatus())); + Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (unversioned)", status == null || StatusType.STATUS_UNVERSIONED.equals(status.getNodeStatus())); } - } else if (SVNStatusType.STATUS_DELETED.equals(file.myNodeStatus)) { + } else if (StatusType.STATUS_DELETED.equals(file.myNodeStatus)) { Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (deleted status)", status != null && file.myNodeStatus.equals(status.getNodeStatus())); - } else if (SVNStatusType.STATUS_ADDED.equals(file.myNodeStatus)) { + } else if (StatusType.STATUS_ADDED.equals(file.myNodeStatus)) { Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (file exists)", exFile.exists()); if (theirsExists) { - Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (added status)", status != null && SVNStatusType.STATUS_REPLACED.equals(status.getNodeStatus())); + Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (added status)", status != null && StatusType.STATUS_REPLACED.equals(status.getNodeStatus())); } else { - Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (added status)", status != null && SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus())); + Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (added status)", status != null && StatusType.STATUS_ADDED.equals(status.getNodeStatus())); } } else { - if (SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus())) { + if (StatusType.STATUS_ADDED.equals(status.getNodeStatus())) { // in theirs -> deleted Assert.assertFalse(createTestFailedComment(data, file.myRelativePath) + " check deleted in theirs", theirsExists); } else { if (theirsExists) { - Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (normal node status)", status != null && SVNStatusType.STATUS_REPLACED.equals(status.getNodeStatus())); + Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (normal node status)", status != null && StatusType.STATUS_REPLACED.equals(status.getNodeStatus())); } else { Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (normal node status)", status != null && - (SVNStatusType.STATUS_NORMAL.equals(status.getNodeStatus()) || SVNStatusType.STATUS_MODIFIED.equals(status.getNodeStatus()))); + (StatusType.STATUS_NORMAL.equals(status.getNodeStatus()) || StatusType.STATUS_MODIFIED.equals(status.getNodeStatus()))); } } Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (modified text status)", status != null && file.myContentsStatus.equals(status.getContentsStatus())); @@ -271,8 +271,8 @@ public class SvnResolveTreeAcceptVariantsTest extends Svn17TestCase { exists); } final File theirsFile = new File(file.getPath()); - SVNInfo theirsInfo = myVcs.getInfo(theirsFile); - SVNInfo thisInfo = myVcs.getInfo(workingFile); + Info theirsInfo = myVcs.getInfo(theirsFile); + Info thisInfo = myVcs.getInfo(workingFile); if (theirsInfo != null) { Assert.assertEquals("Check failed for test: " + getTestName(data) + " and file: " + relative + " in: " + myWorkingCopyDir.getPath() + ", theirs: " + theirsInfo.getRevision().getNumber() + ", mine: " + thisInfo.getRevision().getNumber(), diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnTreeConflictDataTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnTreeConflictDataTest.java index a38d851fbe8e..00172495348c 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnTreeConflictDataTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnTreeConflictDataTest.java @@ -23,18 +23,15 @@ import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import junit.framework.Assert; +import org.jetbrains.idea.svn.conflict.ConflictAction; +import org.jetbrains.idea.svn.conflict.ConflictOperation; +import org.jetbrains.idea.svn.conflict.ConflictVersion; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; import org.junit.Before; import org.junit.Test; -import org.tmatesoft.svn.core.SVNNodeKind; -import org.tmatesoft.svn.core.internal.wc.SVNConflictVersion; -import org.tmatesoft.svn.core.wc.SVNConflictAction; -import org.tmatesoft.svn.core.wc.SVNOperation; -import org.tmatesoft.svn.core.wc.SVNTreeConflictDescription; import java.io.File; -import static com.intellij.util.TimeoutUtil.sleep; - /** * @author Irina.Chernushina * @since 2.05.2012 @@ -71,20 +68,20 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); Assert.assertNull(beforeDescription.getSourceLeftVersion()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } @Test @@ -99,22 +96,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.DELETE, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.DELETE, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.FILE, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isFile()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.NONE, version.getKind()); + Assert.assertTrue(version.isNone()); } private String createConflict(final TreeConflictData.Data data) throws Exception { @@ -138,22 +135,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.EDIT, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.EDIT, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.FILE, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isFile()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } @Test @@ -168,22 +165,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.DELETE, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.DELETE, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.FILE, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isFile()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.NONE, version.getKind()); + Assert.assertTrue(version.isNone()); } @Test @@ -198,21 +195,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); + } @Test @@ -229,22 +227,23 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.EDIT, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.EDIT, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.FILE, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isFile()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); + } @Test @@ -261,22 +260,23 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - //Assert.assertEquals(SVNNodeKind.FILE, leftVersion.getKind()); + //Assert.assertEquals(NodeKind.FILE, leftVersion.getKind()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); + } //---------------------------------- dirs -------------------------------------------------------- @@ -292,21 +292,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } // not a conflict in Subversion 1.7.7. "mine" file becomes added @@ -322,22 +322,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.DELETE, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.DELETE, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.DIR, leftVersion.getKind()); + Assert.assertEquals(NodeKind.DIR, leftVersion.getKind()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.NONE, version.getKind()); + Assert.assertEquals(NodeKind.NONE, version.getKind()); }*/ @Test @@ -350,22 +350,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { final Change change = changeListManager.getChange(new FilePathImpl(new File(myWorkingCopyDir.getPath(), conflictFile), true)); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.EDIT, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.EDIT, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.DIR, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isDirectory()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -380,22 +380,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.DELETE, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.DELETE, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.DIR, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isDirectory()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.NONE, version.getKind()); + Assert.assertTrue(version.isNone()); } @Test @@ -410,21 +410,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -437,22 +437,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { final Change change = changeListManager.getChange(new FilePathImpl(new File(myWorkingCopyDir.getPath(), conflictFile), true)); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.EDIT, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.EDIT, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.DIR, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isDirectory()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -465,22 +465,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { final Change change = changeListManager.getChange(new FilePathImpl(new File(myWorkingCopyDir.getPath(), conflictFile), true)); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - //Assert.assertEquals(SVNNodeKind.DIR, leftVersion.getKind()); + //Assert.assertEquals(NodeKind.DIR, leftVersion.getKind()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } //--------------------------------- @Test @@ -498,21 +498,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -530,21 +530,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -562,21 +562,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -594,21 +594,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -626,21 +626,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } //****************************************** // dir -> file (mine, theirs) @@ -659,21 +659,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } @Test @@ -691,21 +691,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } @Test @@ -723,21 +723,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } @Test @@ -755,21 +755,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } @Test @@ -787,21 +787,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } private void createSubTree() throws Exception { diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/TreeConflictData.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/TreeConflictData.java index 2114e0e0b82b..178253bf58bf 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/TreeConflictData.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/TreeConflictData.java @@ -15,7 +15,7 @@ */ package org.jetbrains.idea.svn; -import org.tmatesoft.svn.core.wc.SVNStatusType; +import org.jetbrains.idea.svn.status.StatusType; import java.util.ArrayList; import java.util.Arrays; @@ -51,8 +51,8 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "added.txt", new FileData[]{new FileData("added.txt", "unversioned text", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "added.txt", new FileData[]{new FileData("added.txt", "unversioned text", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_EDIT_THEIRS_DELETE = new Data("Index: root/source/s1.txt\n" + @@ -62,8 +62,8 @@ public interface TreeConflictData { "@@ -1,1 +0,0 @@\n" + "-123\n" + "\\ No newline at end of file\n", "root/source/s1.txt", - new FileData[] {new FileData("root/source/s1.txt", "1*2*3", SVNStatusType.STATUS_NORMAL, - SVNStatusType.STATUS_MODIFIED, SVNStatusType.STATUS_NORMAL, false)}); + new FileData[] {new FileData("root/source/s1.txt", "1*2*3", StatusType.STATUS_NORMAL, + StatusType.STATUS_MODIFIED, StatusType.STATUS_NORMAL, false)}); Data MINE_DELETE_THEIRS_EDIT = new Data("Index: root/source/s1.txt\n" + "===================================================================\n" + "--- root/source/s1.txt\t(revision 358)\n" + @@ -73,24 +73,24 @@ public interface TreeConflictData { "\\ No newline at end of file\n" + "+1*2*3\n" + "\\ No newline at end of file\n", "root/source/s1.txt", - new FileData[] {new FileData("root/source/s1.txt", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, false)}); + new FileData[] {new FileData("root/source/s1.txt", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, false)}); Data MINE_EDIT_THEIRS_MOVE = new Data("Index: root/source/s1.txt\n" + "===================================================================\n" + "--- root/source/s1.txt\t(revision 358)\n" + "+++ root/source/s1renamed.txt\t(revision )\n" + "@@ -1,0 +1,0 @@\n", "root/source/s1.txt", - new FileData[] {new FileData("root/source/s1.txt", "1*2*3", SVNStatusType.STATUS_NORMAL, - SVNStatusType.STATUS_MODIFIED, SVNStatusType.STATUS_NORMAL, false)}); + new FileData[] {new FileData("root/source/s1.txt", "1*2*3", StatusType.STATUS_NORMAL, + StatusType.STATUS_MODIFIED, StatusType.STATUS_NORMAL, false)}); Data MINE_UNV_THEIRS_MOVE = new Data("Index: root/source/s1.txt\n" + "===================================================================\n" + "--- root/source/s1.txt\t(revision 358)\n" + "+++ root/source/s1renamed.txt\t(revision )\n" + "@@ -1,0 +1,0 @@\n", "root/source/s1renamed.txt", - new FileData[] {new FileData("root/source/s1renamed.txt", "1*2*3", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + new FileData[] {new FileData("root/source/s1renamed.txt", "1*2*3", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_MOVE_THEIRS_EDIT = new Data("Index: root/source/s1.txt\n" + "===================================================================\n" + @@ -102,10 +102,10 @@ public interface TreeConflictData { "+1*2*3\n" + // conflict would be marked by svn on s1.txt, but here we put s1moved.txt, for change list manager to find the change "\\ No newline at end of file\n", "root/source/s1moved.txt", - new FileData[] {new FileData("root/source/s1moved.txt", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_ADDED, false, "root/source/s1.txt"), - new FileData("root/source/s1.txt", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, false)}); + new FileData[] {new FileData("root/source/s1moved.txt", null, StatusType.STATUS_ADDED, + StatusType.STATUS_ADDED, StatusType.STATUS_ADDED, false, "root/source/s1.txt"), + new FileData("root/source/s1.txt", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, false)}); Data MINE_MOVE_THEIRS_ADD = new Data("Index: root/source/s1moved.txt\n" + "===================================================================\n" + "--- root/source/s1moved.txt\t(revision )\n" + @@ -114,10 +114,10 @@ public interface TreeConflictData { "+added text\n" + "\\ No newline at end of file\n", "root/source/s1moved.txt", - new FileData[] {new FileData("root/source/s1moved.txt", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_ADDED, false, "root/source/s1.txt"), - new FileData("root/source/s1.txt", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, false)}) { + new FileData[] {new FileData("root/source/s1moved.txt", null, StatusType.STATUS_ADDED, + StatusType.STATUS_ADDED, StatusType.STATUS_ADDED, false, "root/source/s1.txt"), + new FileData("root/source/s1.txt", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, false)}) { @Override protected void afterInit() { setExcludeFromToTheirsCheck("root\\source\\s1.txt"); @@ -133,11 +133,11 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir", new FileData[]{new FileData("addedDir", null, SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "addedDir", new FileData[]{new FileData("addedDir", null, StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, true), - new FileData("addedDir/unv.txt", "unversioned", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + new FileData("addedDir/unv.txt", "unversioned", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_EDIT_THEIRS_DELETE = new Data("Index: root/source/s1.txt\n" + @@ -154,8 +154,8 @@ public interface TreeConflictData { "@@ -1,1 +0,0 @@\n" + "-abc\n" + "\\ No newline at end of file\n", "root/source", - new FileData[] {new FileData("root/source/s1.txt", "1*2*3", SVNStatusType.STATUS_NORMAL, - SVNStatusType.STATUS_MODIFIED, SVNStatusType.STATUS_NORMAL, false)}); + new FileData[] {new FileData("root/source/s1.txt", "1*2*3", StatusType.STATUS_NORMAL, + StatusType.STATUS_MODIFIED, StatusType.STATUS_NORMAL, false)}); Data MINE_DELETE_THEIRS_EDIT = new Data("Index: root/source/s1.txt\n" + "===================================================================\n" + "--- root/source/s1.txt\t(revision 358)\n" + @@ -165,8 +165,8 @@ public interface TreeConflictData { "\\ No newline at end of file\n" + "+1*2*3\n" + "\\ No newline at end of file\n", "root/source", - new FileData[] {new FileData("root/source", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, true)}); + new FileData[] {new FileData("root/source", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, true)}); Data MINE_EDIT_THEIRS_MOVE = new Data( "Index: root/source/s1.txt\n" + @@ -180,8 +180,8 @@ public interface TreeConflictData { "+++ root/source1/s2.txt\t(revision )\n" + "@@ -1,0 +1,0 @@\n", "root/source", - new FileData[] {new FileData("root/source/s1.txt", "1*2*3", SVNStatusType.STATUS_NORMAL, - SVNStatusType.STATUS_MODIFIED, SVNStatusType.STATUS_NORMAL, false)}); + new FileData[] {new FileData("root/source/s1.txt", "1*2*3", StatusType.STATUS_NORMAL, + StatusType.STATUS_MODIFIED, StatusType.STATUS_NORMAL, false)}); Data MINE_UNV_THEIRS_MOVE = new Data( "Index: root/source/s1.txt\n" + @@ -194,11 +194,11 @@ public interface TreeConflictData { "--- root/source/s2.txt\t(revision 358)\n" + "+++ root/source1/s2.txt\t(revision )\n" + "@@ -1,0 +1,0 @@\n", "root/source1", - new FileData[] {new FileData("root/source1", null, SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + new FileData[] {new FileData("root/source1", null, StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, true), - new FileData("root/source1/unv.txt", "unversioned", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + new FileData("root/source1/unv.txt", "unversioned", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_MOVE_THEIRS_EDIT = new Data("Index: root/source/s1.txt\n" + @@ -211,10 +211,10 @@ public interface TreeConflictData { "+1*2*3\n" + "\\ No newline at end of file\n", "root/source", new FileData[] { - new FileData("root/sourceNew", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_ADDED, true, "root/source"), - new FileData("root/source", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, true)}); + new FileData("root/sourceNew", null, StatusType.STATUS_ADDED, + StatusType.STATUS_ADDED, StatusType.STATUS_ADDED, true, "root/source"), + new FileData("root/source", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, true)}); Data MINE_MOVE_THEIRS_ADD = new Data("Index: root/sourceNew/added.txt\n" + "===================================================================\n" + "--- root/sourceNew/added.txt\t(revision )\n" + @@ -223,10 +223,10 @@ public interface TreeConflictData { "+added text\n" + "\\ No newline at end of file\n", "root/sourceNew", new FileData[] { - new FileData("root/sourceNew", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_ADDED, true, "root/source"), - new FileData("root/source", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, true)}) { + new FileData("root/sourceNew", null, StatusType.STATUS_ADDED, + StatusType.STATUS_ADDED, StatusType.STATUS_ADDED, true, "root/source"), + new FileData("root/source", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, true)}) { @Override protected void afterInit() { setExcludeFromToTheirsCheck("root\\source", "root\\source\\s1.txt", "root\\source\\s2.txt"); @@ -243,8 +243,8 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir", new FileData[]{new FileData("addedDir", "unversioned", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "addedDir", new FileData[]{new FileData("addedDir", "unversioned", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_ADD_THEIRS_ADD = new Data("Index: addedDir/added.txt\n" + @@ -254,8 +254,8 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir", new FileData[]{new FileData("addedDir", "unversioned", SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "addedDir", new FileData[]{new FileData("addedDir", "unversioned", StatusType.STATUS_ADDED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_UNV_THEIRS_MOVE = new Data( "Index: root/source/s1.txt\n" + @@ -268,8 +268,8 @@ public interface TreeConflictData { "--- root/source/s2.txt\t(revision 358)\n" + "+++ root/source1/s2.txt\t(revision )\n" + "@@ -1,0 +1,0 @@\n", - "root/source1", new FileData[]{new FileData("root/source1", "unversioned", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "root/source1", new FileData[]{new FileData("root/source1", "unversioned", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_ADD_THEIRS_MOVE = new Data( "Index: root/source/s1.txt\n" + @@ -282,8 +282,8 @@ public interface TreeConflictData { "--- root/source/s2.txt\t(revision 358)\n" + "+++ root/source1/s2.txt\t(revision )\n" + "@@ -1,0 +1,0 @@\n", - "root/source1", new FileData[]{new FileData("root/source1", "unversioned", SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "root/source1", new FileData[]{new FileData("root/source1", "unversioned", StatusType.STATUS_ADDED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_MOVE_THEIRS_ADD = new Data("Index: addedDir/added.txt\n" + "===================================================================\n" + @@ -292,11 +292,11 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir", new FileData[]{new FileData("addedDir", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_ADDED, + "addedDir", new FileData[]{new FileData("addedDir", null, StatusType.STATUS_ADDED, + StatusType.STATUS_ADDED, StatusType.STATUS_ADDED, false, "root/source/s1.txt"), - new FileData("root/source/s1.txt", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, + new FileData("root/source/s1.txt", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, false, null)}) { @Override protected void afterInit() { @@ -314,11 +314,11 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir.txt", new FileData[]{new FileData("addedDir.txt", null, SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "addedDir.txt", new FileData[]{new FileData("addedDir.txt", null, StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, true), - new FileData("addedDir.txt/unv.txt", "unversioned", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + new FileData("addedDir.txt/unv.txt", "unversioned", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_ADD_THEIRS_ADD = new Data("Index: addedDir.txt\n" + @@ -328,11 +328,11 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir.txt", new FileData[]{new FileData("addedDir.txt", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "addedDir.txt", new FileData[]{new FileData("addedDir.txt", null, StatusType.STATUS_ADDED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, true), - new FileData("addedDir.txt/unv.txt", "unversioned", SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + new FileData("addedDir.txt/unv.txt", "unversioned", StatusType.STATUS_ADDED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_UNV_THEIRS_MOVE = new Data( "Index: root/source/s1.txt\n" + @@ -342,12 +342,12 @@ public interface TreeConflictData { "@@ -1,0 +1,0 @@\n" + "\\ No newline at end of file\n", "root/source/s1renamed.txt", new FileData[]{new FileData("root/source/s1renamed.txt", null, - SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, true), new FileData("root/source/s1renamed.txt/file.txt", "unversioned", - SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_ADD_THEIRS_MOVE = new Data( "Index: root/source/s1.txt\n" + @@ -357,12 +357,12 @@ public interface TreeConflictData { "@@ -1,0 +1,0 @@\n" + "\\ No newline at end of file\n", "root/source/s1renamed.txt", new FileData[]{new FileData("root/source/s1renamed.txt", null, - SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + StatusType.STATUS_ADDED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, true), new FileData("root/source/s1renamed.txt/file.txt", "unversioned", - SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + StatusType.STATUS_ADDED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_MOVE_THEIRS_ADD = new Data("Index: addedDir.txt\n" + @@ -372,10 +372,10 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir.txt", new FileData[]{new FileData("addedDir.txt", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_ADDED, true, "root/source"), - new FileData("root/source", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, true)}) { + "addedDir.txt", new FileData[]{new FileData("addedDir.txt", null, StatusType.STATUS_ADDED, + StatusType.STATUS_ADDED, StatusType.STATUS_ADDED, true, "root/source"), + new FileData("root/source", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, true)}) { @Override protected void afterInit() { setExcludeFromToTheirsCheck("root\\source", "root\\source\\s1.txt", "root\\source\\s2.txt"); @@ -424,26 +424,26 @@ public interface TreeConflictData { public final String myRelativePath; public final String myContents; public final String myCopyFrom; - public final SVNStatusType myNodeStatus; - public final SVNStatusType myContentsStatus; + public final StatusType myNodeStatus; + public final StatusType myContentsStatus; // not used for now - public final SVNStatusType myPropertiesStatus; + public final StatusType myPropertiesStatus; public boolean myIsDir; public FileData(String relativePath, String contents, - SVNStatusType nodeStatus, - SVNStatusType contentsStatus, - SVNStatusType propertiesStatus, + StatusType nodeStatus, + StatusType contentsStatus, + StatusType propertiesStatus, boolean isDir) { this(relativePath, contents, nodeStatus, contentsStatus, propertiesStatus, isDir, null); } public FileData(String relativePath, String contents, - SVNStatusType nodeStatus, - SVNStatusType contentsStatus, - SVNStatusType propertiesStatus, + StatusType nodeStatus, + StatusType contentsStatus, + StatusType propertiesStatus, boolean isDir, final String copyFrom) { myRelativePath = relativePath; myContents = contents; diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCachingRevisionsTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCachingRevisionsTest.java index 749ee38c9336..c5f7b9d4757e 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCachingRevisionsTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCachingRevisionsTest.java @@ -10,7 +10,6 @@ import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase; import org.jetbrains.idea.svn.SvnApplicationSettings; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.history.*; -import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -38,8 +37,9 @@ public class SvnCachingRevisionsTest extends CodeInsightFixtureTestCase { } private SvnChangeList createList(final long revision) { - return new SvnChangeList(null, myLocation, - new SVNLogEntry(Collections.emptyMap(), revision, AUTHOR, new Date(System.currentTimeMillis()), ""), ROOT.toDecodedString()); + LogEntry entry = + new LogEntry.Builder().setRevision(revision).setAuthor(AUTHOR).setDate(new Date(System.currentTimeMillis())).setMessage("").build(); + return new SvnChangeList(null, myLocation, entry, ROOT.toDecodedString()); } private class MockSvnLogLoader implements SvnLogLoader { diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnMergeInfoTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnMergeInfoTest.java index cab82d7fc929..028b8c5c631a 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnMergeInfoTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnMergeInfoTest.java @@ -25,6 +25,7 @@ import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.idea.svn.*; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.dialogs.MergeContext; import org.jetbrains.idea.svn.dialogs.WCInfo; import org.jetbrains.idea.svn.history.SvnChangeList; @@ -34,7 +35,6 @@ import org.jetbrains.idea.svn.mergeinfo.OneShotMergeInfoHelper; import org.jetbrains.idea.svn.mergeinfo.SvnMergeInfoCache; import org.junit.Assert; import org.junit.Test; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNPropertyData; @@ -65,7 +65,7 @@ public class SvnMergeInfoTest extends Svn16TestCase { VirtualFile vcsRoot = LocalFileSystem.getInstance().findFileByIoFile(myBranchVcsRoot); Node node = new Node(vcsRoot, SVNURL.parseURIEncoded(myRepoUrl + "/branch"), SVNURL.parseURIEncoded(myRepoUrl)); RootUrlInfo root = new RootUrlInfo(node, WorkingCopyFormat.ONE_DOT_SIX, vcsRoot, null); - myWCInfo = new WCInfo(root, true, SVNDepth.INFINITY); + myWCInfo = new WCInfo(root, true, Depth.INFINITY); myMergeContext = new MergeContext(SvnVcs.getInstance(myProject), myRepoUrl + "/trunk", myWCInfo, "trunk", vcsRoot); myOneShotMergeInfoHelper = new OneShotMergeInfoHelper(myMergeContext); |