All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.jarch.svn.SwitchSvn Maven / Gradle / Ivy

There is a newer version: 24.8.0
Show newest version
package br.com.jarch.svn;

import org.tmatesoft.svn.core.SVNDepth;
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.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNUpdateClient;

import java.io.File;
import java.net.URL;
import java.util.List;

class SwitchSvn extends BaseSvn {

    public SwitchSvn(List log, String login, String senha) {
        super(log, login, senha);
    }

    public void switchSvn(URL urlRepositorio, File pastaTrabalho) throws Exception {
        if (!existeRepositorio(urlRepositorio)) {
            throw new Exception("Repositório " + urlRepositorio + " NÃO Localizado ");
        }

        if (!pastaTrabalho.exists()) {
            throw new Exception("Pasta trabalho " + pastaTrabalho.getAbsolutePath() + " NÃO Localizado ");
        }

        logUtil.formatBegin(log, "SWITCH");
        logUtil.formatMiddle(log, "FOLDER: " + pastaTrabalho.getAbsolutePath() + " URL: " + urlRepositorio);

        SVNUpdateClient updateClient = getUpdateClient();

        updateClient.setEventHandler(new ISVNEventHandler() {
            @Override
            public void checkCancelled() {
            }

            @Override
            public void handleEvent(SVNEvent svnEvent, double arg1) {
                String mensagem = "SWITCH: " + svnEvent.getFile().getPath();
                logUtil.formatMiddle(log, mensagem);
            }
        });

        long numeroRevisao = updateClient.doSwitch(pastaTrabalho, SVNURL.parseURIEncoded(urlRepositorio.toString()),
                SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.INFINITY, false, false);

        logUtil.formatMiddle(log, "REVISÃO(ÕES) " + numeroRevisao);

        logUtil.formatEnd(log, "SWITCH");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy