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

br.com.jarch.svn.UpdateSvn 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.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 UpdateSvn extends BaseSvn {

    private static final long serialVersionUID = 1196865122154368792L;

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

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

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

        SVNUpdateClient updateClient = getUpdateClient();

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

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

        updateClient.setIgnoreExternals(false);

        logUtil.formatBegin(log, "UPDATE");

        long numeroRevisao = updateClient.doUpdate(pastaTrabalho, SVNRevision.HEAD, SVNDepth.INFINITY, true, true);

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

        logUtil.formatBegin(log, "FIM");

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy