Search in sources :

Example 16 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.

the class LatestExistentSearcher method existsInRevision.

private boolean existsInRevision(@NotNull SVNURL url, long revisionNumber) throws SvnBindException {
    SVNRevision revision = SVNRevision.create(revisionNumber);
    Info info = null;
    try {
        info = myVcs.getInfo(url, revision, revision);
    } catch (SvnBindException e) {
        // throw error if not "does not exist" error code
        if (!e.contains(SVNErrorCode.RA_ILLEGAL_URL)) {
            throw e;
        }
    }
    return info != null;
}
Also used : SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) RootUrlInfo(org.jetbrains.idea.svn.RootUrlInfo) Info(org.jetbrains.idea.svn.info.Info)

Example 17 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.

the class BranchInfo method checkPathGoingUp.

@NotNull
private SvnMergeInfoCache.MergeCheckResult checkPathGoingUp(final long revisionAsked, final long targetRevision, @NotNull String branchRootPath, @NotNull String path, final String trunkUrl, final boolean self) throws VcsException, SVNException {
    SvnMergeInfoCache.MergeCheckResult result;
    final File pathFile = new File(path);
    // check whether we locally have path
    if (targetRevision == -1 && !pathFile.exists()) {
        result = goUp(revisionAsked, targetRevision, branchRootPath, path, trunkUrl);
    } else {
        final Info svnInfo = myVcs.getInfo(pathFile);
        if (svnInfo == null || svnInfo.getURL() == null) {
            LOG.info("Svninfo for " + pathFile + " is null or not full.");
            result = SvnMergeInfoCache.MergeCheckResult.NOT_MERGED;
        } else {
            final long actualRevision = svnInfo.getRevision().getNumber();
            final long targetRevisionCorrected = (targetRevision == -1) ? actualRevision : targetRevision;
            // here we know local URL and revision
            // check existing info
            final String keyString = path + "@" + targetRevisionCorrected;
            final Set<Long> selfInfo = self ? myNonInheritablePathMergedMap.get(keyString) : null;
            final Set<Long> mergeInfo = myPathMergedMap.get(keyString);
            if (mergeInfo != null || selfInfo != null) {
                boolean merged = mergeInfo != null && mergeInfo.contains(revisionAsked) || selfInfo != null && selfInfo.contains(revisionAsked);
                // take from self or first parent with info; do not go further
                result = SvnMergeInfoCache.MergeCheckResult.getInstance(merged);
            } else {
                if (actualRevision != targetRevisionCorrected) {
                    myMixedRevisionsFound = true;
                }
                SvnTarget target;
                SVNRevision revision;
                if (actualRevision == targetRevisionCorrected) {
                    // look in WC
                    target = SvnTarget.fromFile(pathFile, SVNRevision.WORKING);
                    revision = SVNRevision.WORKING;
                } else {
                    // in repo
                    target = SvnTarget.fromURL(svnInfo.getURL());
                    revision = SVNRevision.create(targetRevisionCorrected);
                }
                PropertyValue mergeinfoProperty = myVcs.getFactory(target).createPropertyClient().getProperty(target, SvnPropertyKeys.MERGE_INFO, false, revision);
                result = mergeinfoProperty == null ? goUp(revisionAsked, targetRevisionCorrected, branchRootPath, path, trunkUrl) : processMergeinfoProperty(keyString, revisionAsked, mergeinfoProperty, trunkUrl, self);
            }
        }
    }
    return result;
}
Also used : SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue) Info(org.jetbrains.idea.svn.info.Info) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 18 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.

the class CreateBranchOrTagAction method perform.

@Override
protected void perform(@NotNull SvnVcs vcs, @NotNull VirtualFile file, @NotNull DataContext context) throws VcsException {
    CreateBranchOrTagDialog dialog = new CreateBranchOrTagDialog(vcs.getProject(), true, virtualToIoFile(file));
    if (dialog.showAndGet()) {
        String dstURL = dialog.getToURL();
        SVNRevision revision = dialog.getRevision();
        String comment = dialog.getComment();
        Ref<Exception> exception = new Ref<>();
        boolean isSrcFile = dialog.isCopyFromWorkingCopy();
        File srcFile = new File(dialog.getCopyFromPath());
        SVNURL srcUrl;
        SVNURL dstSvnUrl;
        SVNURL parentUrl;
        try {
            srcUrl = SVNURL.parseURIEncoded(dialog.getCopyFromUrl());
            dstSvnUrl = SVNURL.parseURIEncoded(dstURL);
            parentUrl = dstSvnUrl.removePathTail();
        } catch (SVNException e) {
            throw new SvnBindException(e);
        }
        if (!dirExists(vcs, parentUrl)) {
            int rc = Messages.showYesNoDialog(vcs.getProject(), "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 = () -> {
            try {
                ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
                CommitEventHandler handler = null;
                if (progress != null) {
                    progress.setText(SvnBundle.message("progress.text.copy.to", dstURL));
                    handler = new IdeaCommitHandler(progress);
                }
                SvnTarget source = isSrcFile ? SvnTarget.fromFile(srcFile, revision) : SvnTarget.fromURL(srcUrl, revision);
                long newRevision = vcs.getFactory(source).createCopyMoveClient().copy(source, SvnTarget.fromURL(dstSvnUrl), revision, true, false, comment, handler);
                updateStatusBar(newRevision, vcs.getProject());
            } catch (Exception e) {
                exception.set(e);
            }
        };
        ProgressManager.getInstance().runProcessWithProgressSynchronously(copyCommand, SvnBundle.message("progress.title.copy"), false, vcs.getProject());
        if (!exception.isNull()) {
            throw new VcsException(exception.get());
        }
        if (dialog.isCopyFromWorkingCopy() && dialog.isSwitchOnCreate()) {
            SingleRootSwitcher switcher = new SingleRootSwitcher(vcs.getProject(), VcsUtil.getFilePath(srcFile, srcFile.isDirectory()), dstSvnUrl);
            AutoSvnUpdater.run(switcher, SvnBundle.message("action.name.switch"));
        }
    }
}
Also used : IdeaCommitHandler(org.jetbrains.idea.svn.checkin.IdeaCommitHandler) SVNURL(org.tmatesoft.svn.core.SVNURL) CommitEventHandler(org.jetbrains.idea.svn.checkin.CommitEventHandler) SVNException(org.tmatesoft.svn.core.SVNException) SingleRootSwitcher(org.jetbrains.idea.svn.update.SingleRootSwitcher) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) VcsException(com.intellij.openapi.vcs.VcsException) SVNException(org.tmatesoft.svn.core.SVNException) Ref(com.intellij.openapi.util.Ref) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) VcsException(com.intellij.openapi.vcs.VcsException) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File)

Example 19 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision in project sling by apache.

the class SvnChangeLogFinder method getChanges.

public List<String> getChanges(String first, String second) throws SVNException {
    SVNURL svnUrl = SVNURL.parseURIEncoded(SLING_SVN_REPO_BASE);
    List<String> changes = new ArrayList<>();
    SVNClientManager manager = SVNClientManager.newInstance();
    SVNRepository repo = manager.getRepositoryPool().createRepository(svnUrl, true);
    SVNRevision from = SVNRevision.create(getRevision(first, repo));
    SVNRevision to = SVNRevision.create(getRevision(second, repo));
    repo.log(new String[] { "tags/" + second }, from.getNumber(), to.getNumber(), false, false, (e) -> changes.add(e.getMessage()));
    return changes;
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) ArrayList(java.util.ArrayList) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) SVNClientManager(org.tmatesoft.svn.core.wc.SVNClientManager)

Aggregations

SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)19 VcsException (com.intellij.openapi.vcs.VcsException)7 Info (org.jetbrains.idea.svn.info.Info)7 SVNURL (org.tmatesoft.svn.core.SVNURL)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)4 Ref (com.intellij.openapi.util.Ref)4 File (java.io.File)4 NotNull (org.jetbrains.annotations.NotNull)4 Nullable (org.jetbrains.annotations.Nullable)4 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)4 SvnTarget (org.tmatesoft.svn.core.wc2.SvnTarget)4 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 FilePath (com.intellij.openapi.vcs.FilePath)3 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)3 List (java.util.List)2 SVNException (org.tmatesoft.svn.core.SVNException)2 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 Application (com.intellij.openapi.application.Application)1