Package org.tmatesoft.svn.core.io

Examples of org.tmatesoft.svn.core.io.SVNRepository


            wcAccess.close();
        }
    }

    protected Map getMergeInfo(SVNURL url, SVNRevision pegRevision, SVNURL repositoryRoot[]) throws SVNException {
        SVNRepository repository = null;
        try {
            repository = createRepository(url, null, null, true);
            long revisionNum = getRevisionNumber(pegRevision, repository, null);
            SVNURL reposRoot = repository.getRepositoryRoot(true);
            if (repositoryRoot != null && repositoryRoot.length > 0) {
                repositoryRoot[0] = reposRoot;
            }
            String relPath = getPathRelativeToRoot(null, url, reposRoot, null, null);
            return getReposMergeInfo(repository, relPath, revisionNum,
                    SVNMergeInfoInheritance.INHERITED, false);
        } finally {
            if (repository != null) {
                repository.closeSession();
            }
        }
    }
View Full Code Here


                SVNErrorManager.error(err, SVNLogType.WC);
            }
       
            SVNURL wcReposRoot = getReposRoot(targetWCPath, null, SVNRevision.WORKING, adminArea, myWCAccess);
            List mergeSources = null;
            SVNRepository repository = null;
            SVNURL sourceReposRoot = null;
            try {
              repository = createRepository(url, null, null, true);
              sourceReposRoot = repository.getRepositoryRoot(true);
              mergeSources = normalizeMergeSources(srcPath, url, sourceReposRoot, pegRevision, rangesToMerge,
                  repository);
            } finally {
              repository.closeSession();
            }
           
            doMerge(mergeSources, targetWCPath, targetEntry, adminArea, true, true,
                wcReposRoot.equals(sourceReposRoot), ignoreAncestry, force, dryRun, recordOnly, depth);
           
View Full Code Here

            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_BAD_REVISION,
                    "Not all required revisions are specified");           
            SVNErrorManager.error(err, SVNLogType.DEFAULT);
        }
       
        SVNRepository repository1 = null;
        SVNRepository repository2 = null;
        myWCAccess = createWCAccess();
        targetWCPath = targetWCPath.getAbsoluteFile();
        try {
            SVNAdminArea adminArea = myWCAccess.probeOpen(targetWCPath, !dryRun, SVNWCAccess.INFINITE_DEPTH);

            SVNEntry entry = myWCAccess.getVersionedEntry(targetWCPath, false);
            SVNURL wcReposRoot = getReposRoot(targetWCPath, null, SVNRevision.WORKING, adminArea, myWCAccess);
               
            long[] latestRev = new long[1];
            latestRev[0] = SVNRepository.INVALID_REVISION;

            repository1 = createRepository(url1, null, null, false);
            SVNURL sourceReposRoot = repository1.getRepositoryRoot(true);
            long rev1 = getRevisionNumber(revision1, latestRev, repository1, null);

            repository2 = createRepository(url2, null, null, false);
            long rev2 = getRevisionNumber(revision2, latestRev, repository2, null);
           
            boolean sameRepos = sourceReposRoot.equals(wcReposRoot);
            String youngestCommonPath = null;
            long youngestCommonRevision = SVNRepository.INVALID_REVISION;
            if (!ignoreAncestry) {
              SVNLocationEntry youngestLocation = getYoungestCommonAncestor(null, url1, rev1, null, url2,
                  rev2);
              youngestCommonPath = youngestLocation.getPath();
              youngestCommonRevision = youngestLocation.getRevision();
            }

            boolean related = false;
            boolean ancestral = false;
            List mergeSources = null;
            if (youngestCommonPath != null && SVNRevision.isValidRevisionNumber(youngestCommonRevision)) {
              SVNRevisionRange range = null;
              List ranges = new LinkedList();
              related = true;
              SVNURL youngestCommonURL = sourceReposRoot.appendPath(youngestCommonPath, false);

              if (youngestCommonURL.equals(url2) && youngestCommonRevision == rev2) {
                ancestral = true;
                SVNRevision sRev = SVNRevision.create(rev1);
                SVNRevision eRev = SVNRevision.create(youngestCommonRevision);
                range = new SVNRevisionRange(sRev, eRev);
                ranges.add(range);
                mergeSources = normalizeMergeSources(null, url1, sourceReposRoot, sRev,
                    ranges, repository1);
              } else if (youngestCommonURL.equals(url1) && youngestCommonRevision == rev1) {
                ancestral = true;
                SVNRevision sRev = SVNRevision.create(youngestCommonRevision);
                SVNRevision eRev = SVNRevision.create(rev2);
                range = new SVNRevisionRange(sRev, eRev);
                ranges.add(range);
                mergeSources = normalizeMergeSources(null, url2, sourceReposRoot, eRev,
                    ranges, repository2);
              } else {
                mergeCousinsAndSupplementMergeInfo(targetWCPath, entry, adminArea, repository1, url1,
                    rev1, url2, rev2, youngestCommonRevision, sourceReposRoot, wcReposRoot, depth,
                    ignoreAncestry, force, recordOnly, dryRun);
                return;
              }
            } else {
                MergeSource mergeSrc = new MergeSource();
                mergeSrc.myURL1 = url1;
                mergeSrc.myURL2 = url2;
                mergeSrc.myRevision1 = rev1;
                mergeSrc.myRevision2 = rev2;
                mergeSources = new LinkedList();
                mergeSources.add(mergeSrc);
            }

        repository1.closeSession();
        repository2.closeSession();
           
        doMerge(mergeSources, targetWCPath, entry, adminArea, ancestral, related, sameRepos,
            ignoreAncestry, force, dryRun, recordOnly, depth);
        } finally {
          if (repository1 != null) {
            repository1.closeSession();
          }
          if (repository2 != null) {
            repository2.closeSession();
          }
          try {
                myWCAccess.close();
            } catch (SVNException svne) {
                //
View Full Code Here

                        "''{0}'' has no URL", srcPath);
                SVNErrorManager.error(err, SVNLogType.WC);
            }
       
            SVNURL wcReposRoot = getReposRoot(targetWCPath, null, SVNRevision.WORKING, adminArea, myWCAccess);
            SVNRepository repository = null;
            SVNURL sourceReposRoot = null;
            try {
                repository = createRepository(wcReposRoot, null, null, true);
                sourceReposRoot = repository.getRepositoryRoot(true);
                if (!wcReposRoot.equals(sourceReposRoot)) {
                    Object source = srcPath;
                    if (source == null) {
                        source = srcURL;
                    }
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_UNRELATED_RESOURCES,
                            "''{0}'' must be from the same repository as ''{1}''", new Object[] { source, 
                            targetWCPath });
                    SVNErrorManager.error(err, SVNLogType.WC);
                }
               
                ensureWCReflectsRepositorySubTree(targetWCPath);
                long[] rev1 = { targetEntry.getRevision() };
                String sourceReposRelPath = getPathRelativeToRoot(null, url2, null, null, repository);
                String targetReposRelPath = getPathRelativeToRoot(targetWCPath, null, wcReposRoot, null,
                        repository);
               
                SubTreeMergeInfoHandler handler = new SubTreeMergeInfoHandler(targetWCPath, wcReposRoot);
                myWCAccess.walkEntries(targetWCPath, handler, true, SVNDepth.INFINITY);
               
                long rev2 = getRevisionNumber(pegRevision, repository, srcPath);
                SVNURL[] url1 = { null };
               
                Map unmergedToSourceMergeInfoCatalog = calculateLeftHandSide(url1, rev1, targetReposRelPath,
                        handler.getSubTreesWithMergeInfoPaths(), rev1[0], sourceReposRelPath, sourceReposRoot, rev2, repository);
               
                SVNLocationEntry youngestCommonAncestor = getYoungestCommonAncestor(null, url2, rev2, null, url1[0],
                        rev1[0]);
               
                String youngestAncestorPath = youngestCommonAncestor.getPath();
                long youngestAncestorRevision = youngestCommonAncestor.getRevision();
                if (!(youngestAncestorPath != null && SVNRevision.isValidRevisionNumber(youngestAncestorRevision))) {
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_NOT_READY_TO_MERGE,
                            "''{0}@{1}'' must be ancestrally related to ''{2}@{3}''",
                            new Object[] { url1[0], new Long(rev1[0]), url2, new Long(rev2)});
                    SVNErrorManager.error(err, SVNLogType.WC);
                }
               
                if (rev1[0] > youngestAncestorRevision) {
                    try {
                        ensureAllMissingRangesArePhantoms(repository, unmergedToSourceMergeInfoCatalog);
                    } catch (SVNException svne) {
                        if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.CLIENT_NOT_READY_TO_MERGE) {
                            String srcMergeInfoCatalogString = SVNMergeInfoUtil.formatMergeInfoCatalogToString(unmergedToSourceMergeInfoCatalog,
                                    "  ", "    Missing ranges: ");
                            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_NOT_READY_TO_MERGE,
                                    "Reintegrate can only be used if revisions {0} through {1} were " +
                                    "previously merged from {2} to the reintegrate source, but this is not the case:\n{3}", new Object[] {
                                    String.valueOf(youngestAncestorRevision + 1), String.valueOf(rev2), targetEntry.getURL(),
                                    srcMergeInfoCatalogString });
                            SVNErrorManager.error(err, SVNLogType.WC);
                        }
                        throw svne;
                    }
                }

                mergeCousinsAndSupplementMergeInfo(targetWCPath, targetEntry, adminArea, repository, url1[0],
                        rev1[0], url2, rev2, youngestAncestorRevision, sourceReposRoot, wcReposRoot,
                        SVNDepth.INFINITY, false, false, false, dryRun);

            } finally {
                repository.closeSession();
            }
           
        } finally {
            myWCAccess.close();
        }
View Full Code Here

                String mimeType2;
                String mimeType1;
                SVNStatusType[] mergeResult;
               
                SVNRepository repos1 = myRepository1;
                SVNRepository repos2 = myRepository2;
                if (honorMergeInfo && !url1.equals(url2)) {
                    if (!isRollBack && nextRange.getStartRevision() != revision1) {
                        repos1 = repos2;
                    } else if (isRollBack && nextRange.getEndRevision() != revision2) {
                        repos2 = repos1;
View Full Code Here

        driveMergeReportEditor(targetWCPath, url1, revision1, url2, revision2, null, isRollBack,
            depth, adminArea, mergeCallback, null);
        return;
      }
     
      SVNRepository repository = isRollBack ? myRepository1 : myRepository2;
      SVNURL sourceRootURL = repository.getRepositoryRoot(true);
      String mergeInfoPath = getPathRelativeToRoot(null, primaryURL, sourceRootURL, null, null);
      myChildrenWithMergeInfo = getMergeInfoPaths(myChildrenWithMergeInfo, mergeInfoPath, parentEntry,
          sourceRootURL, revision1, revision2, honorMergeInfo, repository, depth);

      MergePath targetMergePath = (MergePath) myChildrenWithMergeInfo.get(0);
View Full Code Here

      if (!destPath.exists()) {
        destPath.createNewFile();
      }

      // remove the base project path
      SVNRepository repo = managerPool.getSvnRepository(project);
      filePath = removeBasePath(filePath, repo);

      repo.checkoutFiles(revision, new String[] { filePath }, new ISVNFileCheckoutTarget() {

        public void filePropertyChanged(String arg0, String arg1, SVNPropertyValue arg2)
            throws SVNException {}

        public OutputStream getOutputStream(String path) throws SVNException {
View Full Code Here

  }

  private void initRepository(String url, String username, String password) throws SvnException {
    try {
      // 1# instantiate a new object of type SVNRepository
      SVNRepository repo = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url));
      ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(
          username, password);
      repo.setAuthenticationManager(authManager);

      // 2# add the repository to the pool, for later use
      repositories.put(url, repo);

    }
View Full Code Here

public class SvnUtils {
   
    public static SVNRepository getRepository(String url, String username, String password) {
        DAVRepositoryFactory.setup();
        SVNRepositoryFactoryImpl.setup();
        SVNRepository repository = null;
        SVNNodeKind nodeKind = null;
        try {
            repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url));
            ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(username, password);
            repository.setAuthenticationManager(authManager);
            nodeKind = repository.checkPath("", -1);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if (nodeKind == SVNNodeKind.NONE) {
            throw new RuntimeException("There is no entry at '" + url + "'.");
View Full Code Here

            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_PROPERTY_NAME,
                    "Property ''{0}'' is an entry property", propName);
            SVNErrorManager.error(err, SVNLogType.WC);
        }        
        long[] pegRev = new long[]{-1};
        SVNRepository repos = createRepository(url, null, null, pegRevision, revision, pegRev);
        revision = pegRev[0] < 0 ? revision : SVNRevision.create(pegRev[0]);
        doGetRemoteProperty(url, "", repos, propName, revision, depth, handler);
    }
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.io.SVNRepository

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.