Package org.tmatesoft.svn.core.wc

Examples of org.tmatesoft.svn.core.wc.SVNClientManager


   * @param revision revision of the file
   * @return found {@link FileEntry}, null if not found
   */
  public FileEntry findOne(User user, String path, SVNRevision revision) {
    final FileEntry script = new FileEntry();
    SVNClientManager svnClientManager = null;
    ByteArrayOutputStream outputStream = null;
    try {
      svnClientManager = getSVNClientManager();

      SVNURL userRepoUrl = SVNURL.fromFile(getUserRepoDirectory(user));
      if (userRepoUrl == null) {
        return null;
      }
      SVNRepository repo = svnClientManager.createRepository(userRepoUrl, true);
      SVNNodeKind nodeKind = repo.checkPath(path, -1);
      if (nodeKind == SVNNodeKind.NONE) {
        return null;
      }
      outputStream = new ByteArrayOutputStream();
View Full Code Here


   * @param fileEntry fileEntry to be saved
   * @param encoding  file encoding with which fileEntry is saved. It is meaningful
   *                  only FileEntry is editable.
   */
  public void save(User user, FileEntry fileEntry, String encoding) {
    SVNClientManager svnClientManager = null;
    ISVNEditor editor = null;
    String checksum = null;
    InputStream bais = null;
    try {
      svnClientManager = getSVNClientManager();
      SVNRepository repo = svnClientManager.createRepository(SVNURL.fromFile(getUserRepoDirectory(user)), true);
      SVNDirEntry dirEntry = repo.info(fileEntry.getPath(), -1);

      // Add base paths
      String fullPath = "";
      // Check.. first
View Full Code Here

   *
   * @param user  user
   * @param paths paths of file entries.
   */
  public void delete(User user, List<String> paths) {
    SVNClientManager svnClientManager = null;
    ISVNEditor editor = null;
    try {
      svnClientManager = getSVNClientManager();
      SVNRepository repo = svnClientManager.createRepository(SVNURL.fromFile(getUserRepoDirectory(user)), true);

      editor = repo.getCommitEditor("delete", null, true, null);
      editor.openRoot(-1);
      for (String each : paths) {
        editor.deleteEntry(each, -1);
View Full Code Here

   * @param user user
   * @param path path in user repo
   * @return true if exists.
   */
  public boolean hasOne(User user, String path) {
    SVNClientManager svnClientManager = null;
    try {
      svnClientManager = getSVNClientManager();
      SVNURL userRepoUrl = SVNURL.fromFile(getUserRepoDirectory(user));
      SVNRepository repo = svnClientManager.createRepository(userRepoUrl, true);
      SVNNodeKind nodeKind = repo.checkPath(path, -1);
      return (nodeKind != SVNNodeKind.NONE);
    } catch (Exception e) {
      LOG.error("Error while fetching files from SVN", e);
      throw processException("Error while checking file existence from SVN", e);
View Full Code Here

   * @param user      user
   * @param path      path of {@link FileEntry}
   * @param toPathDir file dir path to write.
   */
  public void writeContentTo(User user, String path, File toPathDir) {
    SVNClientManager svnClientManager = null;
    FileOutputStream fileOutputStream = null;
    try {
      svnClientManager = getSVNClientManager();

      SVNURL userRepoUrl = SVNURL.fromFile(getUserRepoDirectory(user));
      SVNRepository repo = svnClientManager.createRepository(userRepoUrl, true);
      SVNNodeKind nodeKind = repo.checkPath(path, -1);
      // If it's DIR, it does not work.
      if (nodeKind == SVNNodeKind.NONE || nodeKind == SVNNodeKind.DIR) {
        throw processException("It's not possible to write directory. nodeKind is " + nodeKind);
      }
View Full Code Here

    workDir.mkdirs();
        File baseDirectory = workDir;
        File reposRoot = new File(baseDirectory, "tempRepository");
        File wcRoot = new File(workDir, "working_copy");
       
        SVNClientManager clientManager = SVNClientManager.newInstance();       
        SVNAdminClient adminClient = clientManager.getAdminClient();
        SVNDiffClient diffClient = clientManager.getDiffClient();    
        DefaultSVNOptions options = (DefaultSVNOptions) diffClient.getOptions();
        options.setConflictHandler(new ConflictResolverHandler());
        SVNCommitClient commitClient = clientManager.getCommitClient();
       
        boolean fileRepo = true;
       
        String url = "svn://192.168.56.101/project6";
        final SVNURL reposURL = (fileRepo? SVNURL.fromFile(reposRoot) : SVNURL.parseURIEncoded(url)),
      demoURL = reposURL.appendPath("demo", false);       
        if (fileRepo)
          adminClient.doCreateRepository(reposRoot, null, true, true, false, false);
        else
        {
          SubversionSubmitter.setUpSVNKit();
          //SVNRepository repository = SVNRepositoryFactory.create(reposURL);
          ISVNAuthenticationManager m = SVNWCUtil.createDefaultAuthenticationManager("harry", "secret");
         //repository.setAuthenticationManager(m);
         clientManager.setAuthenticationManager(m);
        }
        logger.info("Repo URL = "+ reposURL);
        repos =  SVNRepositoryFactory.create(reposURL);
       
        SVNCommitInfo info;       
        String msg;

        msg = "Import of oldDMO tree";
        info = clientManager.getCommitClient( ).doImport( oldDemoTree , demoURL , msg , true);
        logger.info("Imported oldDemo tree: "+ info);
        //final long revOldDemo = info.getNewRevision();
           
        msg= "Copy demo to custom";
        SVNCopyClient copyClient = clientManager.getCopyClient();
        SVNURL customURL = reposURL.appendPath("custom", true);
        SVNCopySource copySource = new SVNCopySource(SVNRevision.UNDEFINED, SVNRevision.HEAD, demoURL);
        info = copyClient.doCopy(new SVNCopySource[] { copySource }, customURL, false, false, true,
                msg, null);
        final long revAfterCopyToCustom = info.getNewRevision();
        logger.info(msg + ": " + info);
               
        File  demoDir = new File(wcRoot, "demo"),
          customDir = new File(wcRoot, "custom");
       
        SVNUpdateClient updateClient = clientManager.getUpdateClient();
        updateClient.doCheckout(reposURL, wcRoot, SVNRevision.UNDEFINED, SVNRevision.HEAD, SVNDepth.INFINITY,
                false);
        logger.info("Checked out working copy to " + wcRoot);
       
        overwriteTree(newDemoTree, demoDir);
/*       
        for (File f: dirsCreated)
          clientManager.getWCClient( ).doAdd( f, false , false , false , false );
        for (File f: filesCreated)
          clientManager.getWCClient( ).doAdd( f, false , false , false , false );
*/
        msg = "Commit of newDMO (in demo tree)";
        info = commitClient.doCommit(new File[] { wcRoot }, false, msg, null, null, false,
                              false, SVNDepth.INFINITY);       
        //final long revNewDMO = info.getNewRevision();
/*
        diffClient.doDiffStatus(reposURL, SVNRevision.create(revOldDemo), reposURL, SVNRevision.create(revNewDMO),
            true, true, new ISVNDiffStatusHandler() {       
          public void handleDiffStatus(SVNDiffStatus arg0) throws SVNException {
            if (arg0.getURL().toString().endsWith(".pcode"))
            {
              logger.info("Diff in NewDMO-OldDMO: " + arg0.getURL());

               logger.info("path = " + arg0.getPath());
                  SVNProperties properties = SVNProperties.wrap(new HashMap());
                  if (repos.checkPath("/" + arg0.getPath(), revOldDemo) == SVNNodeKind.FILE
                      && repos.checkPath("/" + arg0.getPath(), revNewDMO) == SVNNodeKind.FILE)
                  {
                deltaOldDMONewDMO.add(arg0.getURL());
                    repos.getFile( "/" + arg0.getPath(), revOldDemo, properties, null);
                    String oldCheckSum = properties.getStringValue(SVNProperty.CHECKSUM);
                    repos.getFile("/" +arg0.getPath(), revNewDMO, properties, null);
                    String newCheckSum = properties.getStringValue(SVNProperty.CHECKSUM);
                    logger.info("Checksums: " + oldCheckSum + " " + newCheckSum);
                  }
            }
          }
        });
*/
        logger.info(msg + ":" + info);

        dirsCreated.clear(); filesCreated.clear();
        overwriteTree(oldDevTree, customDir);
/*
        msg = "Commit of old DEV";
        info = commitClient.doCommit(new File[] { wcRoot }, false, msg, null, null, false,
                              false, SVNDepth.INFINITY);         
        logger.info(msg + ":" + info);
        long revOldDEV = info.getNewRevision();
        diffClient.doDiffStatus(reposURL, SVNRevision.create(revNewDMO), reposURL, SVNRevision.create(revOldDEV),
            true, true, new ISVNDiffStatusHandler() {       
          public void handleDiffStatus(SVNDiffStatus arg0) throws SVNException {
            if (arg0.getURL().toString().endsWith(".pcode"))
            {
              logger.fine("Diff in DEV-oldDMO: " + arg0.getURL());
              deltaOldDMODev.add(arg0.getURL());
            }
          }
        });
*/
        updateClient = clientManager.getUpdateClient();
        updateClient.doCheckout(reposURL, wcRoot, SVNRevision.UNDEFINED, SVNRevision.HEAD, SVNDepth.INFINITY,
                false);
        logger.info("Checked out working copy to " + wcRoot);       
       
        File targetOfMerge = (mergeToDMO? demoDir: customDir);
View Full Code Here

    private String getPatch(long revA, long revB) throws SVNException {
        // Prepare required arguments.
        SVNURL svnURL = SVNURL.fromFile(new File(getRepoPrefix() + ownerName + "/" + projectName));

        // Get diffClient.
        SVNClientManager clientManager = SVNClientManager.newInstance();
        SVNDiffClient diffClient = clientManager.getDiffClient();

        // Using diffClient, write the changes by commitId into
        // byteArrayOutputStream, as unified format.
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        diffClient.doDiff(svnURL, null, SVNRevision.create(revA), SVNRevision.create(revB),
View Full Code Here

  private List<Commit> fetchCommits(final Key project, String url,
      String username, String password) {
    try {
      final List<Commit> ret = new ArrayList<Commit>();
      SVNURL svnUrl = SVNURL.parseURIDecoded(url);
      SVNClientManager clientManager = SVNClientManager.newInstance(
          new DefaultSVNOptions(), username, password);
      SVNLogClient logClient = clientManager.getLogClient();
      logClient.doLog(svnUrl, new String[] { "." }, SVNRevision.HEAD,
          SVNRevision.HEAD, SVNRevision.create(0), true, true, 10,
          new ISVNLogEntryHandler() {
            @Override
            public void handleLogEntry(SVNLogEntry logEntry)
                throws SVNException {
              ret.add(new Commit(project, logEntry));
            }
          });
      clientManager.dispose();
      return ret;
    } catch (SVNException e) {
      log.error("Unable to refresh data from svn: {} {}", e.getClass()
          .getSimpleName(), e.getMessage());
    }
View Full Code Here

public class SVNPostCommit implements RepositoryPostCommit {
  private static Logger logger = Logger.getLogger("SVNPostCommit");
 
  public void postCommitHook(String path, String repositoryURL) {
    File dstPath = new File(path);
    SVNClientManager cm = SVNClientManager.newInstance();
    SVNUpdateClient uc = cm.getUpdateClient();
    try {
      uc.doUpdate(dstPath, SVNRevision.HEAD,SVNDepth.INFINITY,true, true);
    } catch (SVNException e) {
      logger.throwing("SVNPostCommit", "postCommitHook", e);
      logger.warning(e.getLocalizedMessage());
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.wc.SVNClientManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.