Package org.tmatesoft.svn.core.io

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

@version 1.3 @author TMate Software Ltd. @since 1.2 @see ISVNReporterBaton @see Examples

         * will create directories and files accordingly.
         *
         * As we've reported 'emtpy working copy', server will only send 'addDir/addFile' instructions
         * and will never ask our editor implementation to modify a file or directory properties.
         */
        ISVNEditor exportEditor = new ExportEditor(exportDir);

        /*
         * Now ask SVNKit to perform generic 'update' operation using our reporter and editor.
         *
         * We are passing:
View Full Code Here


                SVNErrorManager.error(err, SVNLogType.DEFAULT);
            }
        }
        commitMessage = SVNCommitUtil.validateCommitMessage(commitMessage);
        SVNPropertiesManager.validateRevisionProperties(revisionProperties);
        ISVNEditor commitEditor = repos.getCommitEditor(commitMessage, null, false, revisionProperties, null);
        ISVNCommitPathHandler deleter = new ISVNCommitPathHandler() {
            public boolean handleCommitPath(String commitPath, ISVNEditor commitEditor) throws SVNException {
                commitEditor.deleteEntry(commitPath, -1);
                return false;
            }
        };
        SVNCommitInfo info;
        try {
            SVNCommitUtil.driveCommitEditor(deleter, paths, commitEditor, -1);
            info = commitEditor.closeEdit();
        } catch (SVNException e) {
            try {
                commitEditor.abortEdit();
            } catch (SVNException inner) {
                //
            }
            throw e;
        }
View Full Code Here

        }
        paths = decodedPaths;
        SVNRepository repos = createRepository(rootURL, null, null, true);
        commitMessage = SVNCommitUtil.validateCommitMessage(commitMessage);
        SVNPropertiesManager.validateRevisionProperties(revisionProperties);
        ISVNEditor commitEditor = repos.getCommitEditor(commitMessage, null, false, revisionProperties, null);
        ISVNCommitPathHandler creater = new ISVNCommitPathHandler() {
            public boolean handleCommitPath(String commitPath, ISVNEditor commitEditor) throws SVNException {
                SVNPathUtil.checkPathIsValid(commitPath);
                commitEditor.addDir(commitPath, null, -1);
                return true;
            }
        };
        SVNCommitInfo info;
        try {
            SVNCommitUtil.driveCommitEditor(creater, paths, commitEditor, -1);
            info = commitEditor.closeEdit();
        } catch (SVNException e) {
            try {
                commitEditor.abortEdit();
            } catch (SVNException inner) {
                //
            }
            throw e;
        }
View Full Code Here

        if (commitMessage == null) {
            return SVNCommitInfo.NULL;
        }
        commitMessage = SVNCommitUtil.validateCommitMessage(commitMessage);
        SVNPropertiesManager.validateRevisionProperties(revisionProperties);
        ISVNEditor commitEditor = repos.getCommitEditor(commitMessage, null, false, revisionProperties,
                new SVNImportMediator());
        String filePath = "";
        if (srcKind != SVNFileType.DIRECTORY) {
            filePath = (String) newPaths.remove(0);
            for (int i = 0; i < newPaths.size(); i++) {
                String newDir = (String) newPaths.get(i);
                filePath = newDir + "/" + filePath;
            }
        }
        Collection ignores = useGlobalIgnores ? SVNStatusEditor.getGlobalIgnores(getOptions()) : null;
        checkCancelled();
        boolean changed = false;
        SVNCommitInfo info = null;
        try {
            commitEditor.openRoot(-1);
            String newDirPath = null;
            for (int i = newPaths.size() - 1; i >= 0; i--) {
                newDirPath = newDirPath == null ? (String) newPaths.get(i) : SVNPathUtil.append(newDirPath, (String) newPaths.get(i));
                commitEditor.addDir(newDirPath, null, -1);
            }
            changed = newPaths.size() > 0;
            SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
            if (srcKind == SVNFileType.DIRECTORY) {
                changed |= importDir(deltaGenerator, path, newDirPath, useGlobalIgnores,
                        ignoreUnknownNodeTypes, depth, commitEditor);
            } else if (srcKind == SVNFileType.FILE || srcKind == SVNFileType.SYMLINK) {
                if (!useGlobalIgnores || !SVNStatusEditor.isIgnored(ignores, path, "/" + path.getName())) {
                    changed |= importFile(deltaGenerator, path, srcKind, filePath, commitEditor);
                }
            } else if (srcKind == SVNFileType.NONE || srcKind == SVNFileType.UNKNOWN) {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.NODE_UNKNOWN_KIND,
                        "''{0}'' does not exist", path);
                SVNErrorManager.error(err, SVNLogType.WC);
            }
           
            if (!changed) {
                try {
                    commitEditor.abortEdit();
                } catch (SVNException e) {}
                return SVNCommitInfo.NULL;
            }
            for (int i = 0; i < newPaths.size(); i++) {
                commitEditor.closeDir();
            }
            info = commitEditor.closeEdit();
        } finally {
            if (!changed || info == null) {
                try {
                    commitEditor.abortEdit();
                } catch (SVNException e) {
                    //
                }
            }
        }
View Full Code Here

            return new SVNCommitInfo[0];
        }

        Collection tmpFiles = null;
        SVNCommitInfo info = null;
        ISVNEditor commitEditor = null;

        Collection infos = new ArrayList();
        boolean needsSleepForTimeStamp = false;
        for (int p = 0; p < commitPackets.length; p++) {
            SVNCommitPacket commitPacket = commitPackets[p].removeSkippedItems();
            if (commitPacket.getCommitItems().length == 0) {
                continue;
            }
            try {
                commitMessage = getCommitHandler().getCommitMessage(commitMessage, commitPacket.getCommitItems());               
                if (commitMessage == null) {
                    infos.add(SVNCommitInfo.NULL);
                    continue;
                }
                commitMessage = SVNCommitUtil.validateCommitMessage(commitMessage);
                Map commitables = new TreeMap();
                SVNURL baseURL = SVNCommitUtil.translateCommitables(commitPacket.getCommitItems(), commitables);
                Map lockTokens = SVNCommitUtil.translateLockTokens(commitPacket.getLockTokens(), baseURL.toString());
                //TODO: we should pass wcAccess and path to check uuids
                SVNCommitItem firstItem = commitPacket.getCommitItems()[0];
                SVNRepository repository = createRepository(baseURL, firstItem.getFile(),
                        firstItem.getWCAccess(), true);
                SVNCommitMediator mediator = new SVNCommitMediator(commitables);
               
                tmpFiles = mediator.getTmpFiles();
                String repositoryRoot = repository.getRepositoryRoot(true).getPath();
                SVNPropertiesManager.validateRevisionProperties(revisionProperties);
                commitEditor = repository.getCommitEditor(commitMessage, lockTokens, keepLocks, revisionProperties, mediator);
                // commit.
                // set event handler for each wc access.
                for (int i = 0; i < commitPacket.getCommitItems().length; i++) {
                    commitPacket.getCommitItems()[i].getWCAccess().setEventHandler(getEventDispatcher());
                }
                info = SVNCommitter.commit(mediator.getTmpFiles(), commitables, repositoryRoot, commitEditor);
                // update wc.
                Collection processedItems = new SVNHashSet();
                Collection explicitCommitPaths = new SVNHashSet();
                for (Iterator urls = commitables.keySet().iterator(); urls.hasNext();) {
                    String url = (String) urls.next();
                    SVNCommitItem item = (SVNCommitItem) commitables.get(url);
                    explicitCommitPaths.add(item.getPath());
                }
                for (Iterator urls = commitables.keySet().iterator(); urls.hasNext();) {
                    String url = (String) urls.next();
                    SVNCommitItem item = (SVNCommitItem) commitables.get(url);
                    SVNWCAccess wcAccess = item.getWCAccess();
                    String path = item.getPath();
                    SVNAdminArea dir = null;
                    String target = null;

                    try {
                        if (item.getKind() == SVNNodeKind.DIR) {
                            target = "";
                            dir = wcAccess.retrieve(item.getFile());
                        } else {
                            target = SVNPathUtil.tail(path);
                            dir = wcAccess.retrieve(item.getFile().getParentFile());
                        }
                    } catch (SVNException e) {
                        if (e.getErrorMessage().getErrorCode() == SVNErrorCode.WC_NOT_LOCKED) {
                            dir = null;
                        }
                    }
                    if (dir == null) {
                        if (hasProcessedParents(processedItems, path)) {
                            processedItems.add(path);
                            continue;
                        }
                        if (item.isDeleted() && item.getKind() == SVNNodeKind.DIR) {
                            File parentPath = "".equals(path) ? null : item.getFile().getParentFile();
                            String nameInParent = "".equals(path) ? null : SVNPathUtil.tail(path);
                            if (parentPath != null) {
                                SVNAdminArea parentDir = wcAccess.retrieve(parentPath);
                                if (parentDir != null) {
                                    SVNEntry entryInParent = parentDir.getEntry(nameInParent, true);
                                    if (entryInParent != null) {
                                        Map attributes = new SVNHashMap();
                                        attributes.put(SVNProperty.SCHEDULE, null);
                                        attributes.put(SVNProperty.DELETED, Boolean.TRUE.toString());
                                        parentDir.modifyEntry(nameInParent, attributes, true, true);
                                    }
                                }
                            }
                            processedItems.add(path);
                            continue;
                        }
                    }
                    SVNEntry entry = dir.getEntry(target, true);
                    if (entry == null && hasProcessedParents(processedItems, path)) {
                        processedItems.add(path);
                        continue;
                    }
                    boolean recurse = false;
                    if (item.isAdded() && item.getCopyFromURL() != null && item.getKind() == SVNNodeKind.DIR) {
                        recurse = true;
                    }
                    boolean removeLock = !keepLocks && item.isLocked();
                    // update entry in dir.
                    SVNProperties wcPropChanges = mediator.getWCProperties(item);
                    dir.commit(target, info, wcPropChanges, removeLock, recurse, !keepChangelist, explicitCommitPaths, getCommitParameters());
                    processedItems.add(path);
                }
                needsSleepForTimeStamp = true;
                // commit completed, include revision number.
                dispatchEvent(SVNEventFactory.createSVNEvent(null, SVNNodeKind.NONE, null, info.getNewRevision(), SVNEventAction.COMMIT_COMPLETED, null, null, null), ISVNEventHandler.UNKNOWN);
            } catch (SVNException e) {
                if (e instanceof SVNCancelException) {
                    throw e;
                }
                SVNErrorMessage err = e.getErrorMessage().wrap("Commit failed (details follow):");
                infos.add(new SVNCommitInfo(-1, null, null, err));
                dispatchEvent(SVNEventFactory.createErrorEvent(err, SVNEventAction.COMMIT_COMPLETED), ISVNEventHandler.UNKNOWN);
                continue;
            } finally {
                if (info == null && commitEditor != null) {
                    try {
                        commitEditor.abortEdit();
                    } catch (SVNException e) {
                        //
                    }
                }
                if (tmpFiles != null) {
View Full Code Here

     */
    public static SVNCommitInfo createRepositoryTree(File reposRoot) throws SVNException {
        SVNURL reposURL = SVNURL.fromFile(reposRoot);
        SVNRepository repos = SVNRepositoryFactory.create(reposURL);
       
        ISVNEditor commitEditor = repos.getCommitEditor("initializing the repository with a greek tree",
                null, false, null, null);

        SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
       
        commitEditor.openRoot(SVNRepository.INVALID_REVISION);

        //add /iota file
        commitEditor.addFile(IOTA, null, SVNRepository.INVALID_REVISION);
        commitEditor.applyTextDelta(IOTA, null);
        String fileText = (String) ourGreekTreeFiles.get(IOTA);
        String checksum = deltaGenerator.sendDelta(IOTA, new ByteArrayInputStream(fileText.getBytes()),
                commitEditor, true);
        commitEditor.closeFile(IOTA, checksum);
       
        //add /A directory
        commitEditor.addDir("A", null, SVNRepository.INVALID_REVISION);
       
        //add /A/mu file
        String muPath = "A/" + MU;
        commitEditor.addFile(muPath, null, SVNRepository.INVALID_REVISION);
        commitEditor.applyTextDelta(muPath, null);
        fileText = (String) ourGreekTreeFiles.get(MU);
        checksum = deltaGenerator.sendDelta(muPath, new ByteArrayInputStream(fileText.getBytes()), commitEditor,
                true);
        commitEditor.closeFile(muPath, checksum);
       
        commitEditor.addDir("A/B", null, SVNRepository.INVALID_REVISION);
       
        //add /A/B/lambda file
        String lambdaPath = "A/B/" + LAMBDA;
        commitEditor.addFile(lambdaPath, null, SVNRepository.INVALID_REVISION);
        commitEditor.applyTextDelta(lambdaPath, null);
        fileText = (String) ourGreekTreeFiles.get(LAMBDA);
        checksum = deltaGenerator.sendDelta(lambdaPath, new ByteArrayInputStream(fileText.getBytes()), commitEditor,
                true);
        commitEditor.closeFile(lambdaPath, checksum);
       
        commitEditor.addDir("A/B/E", null, SVNRepository.INVALID_REVISION);

        //add /A/B/E/alpha file
        String alphaPath = "A/B/E/" + ALPHA;
        commitEditor.addFile(alphaPath, null, SVNRepository.INVALID_REVISION);
        commitEditor.applyTextDelta(alphaPath, null);
        fileText = (String) ourGreekTreeFiles.get(ALPHA);
        checksum = deltaGenerator.sendDelta(alphaPath, new ByteArrayInputStream(fileText.getBytes()), commitEditor,
                true);
        commitEditor.closeFile(alphaPath, checksum);
       
        //add /A/B/E/beta file
        String betaPath = "A/B/E/" + BETA;
        commitEditor.addFile(betaPath, null, SVNRepository.INVALID_REVISION);
        commitEditor.applyTextDelta(betaPath, null);
        fileText = (String) ourGreekTreeFiles.get(BETA);
        checksum = deltaGenerator.sendDelta(betaPath, new ByteArrayInputStream(fileText.getBytes()), commitEditor,
                true);
        commitEditor.closeFile(betaPath, checksum);
       
        //close /A/B/E
        commitEditor.closeDir();
       
        //add /A/B/F
        commitEditor.addDir("A/B/F", null, SVNRepository.INVALID_REVISION);
       
        //close /A/B/F
        commitEditor.closeDir();
       
        //close /A/B
        commitEditor.closeDir();

        //add /A/C
        commitEditor.addDir("A/C", null, SVNRepository.INVALID_REVISION);
       
        //close /A/C
        commitEditor.closeDir();

        //add /A/D
        commitEditor.addDir("A/D", null, SVNRepository.INVALID_REVISION);
       
        //add /A/D/gamma file
        String gammaPath = "A/D/" + GAMMA;
        commitEditor.addFile(gammaPath, null, SVNRepository.INVALID_REVISION);
        commitEditor.applyTextDelta(gammaPath, null);
        fileText = (String) ourGreekTreeFiles.get(GAMMA);
        checksum = deltaGenerator.sendDelta(gammaPath, new ByteArrayInputStream(fileText.getBytes()), commitEditor,
                true);
        commitEditor.closeFile(gammaPath, checksum);
       
        //add /A/D/G
        commitEditor.addDir("A/D/G", null, SVNRepository.INVALID_REVISION);
       
        //add /A/D/G/pi file
        String piPath = "A/D/G/" + PI;
        commitEditor.addFile(piPath, null, SVNRepository.INVALID_REVISION);
        commitEditor.applyTextDelta(piPath, null);
        fileText = (String) ourGreekTreeFiles.get(PI);
        checksum = deltaGenerator.sendDelta(piPath, new ByteArrayInputStream(fileText.getBytes()), commitEditor,
                true);
        //close /A/D/G/pi file
        commitEditor.closeFile(piPath, checksum);

        //add /A/D/G/rho file
        String rhoPath = "A/D/G/" + RHO;
        commitEditor.addFile(rhoPath, null, SVNRepository.INVALID_REVISION);
        commitEditor.applyTextDelta(rhoPath, null);
        fileText = (String) ourGreekTreeFiles.get(RHO);
        checksum = deltaGenerator.sendDelta(rhoPath, new ByteArrayInputStream(fileText.getBytes()), commitEditor,
                true);
        //close /A/D/G/rho file
        commitEditor.closeFile(rhoPath, checksum);

        //add /A/D/G/tau file
        String tauPath = "A/D/G/" + TAU;
        commitEditor.addFile(tauPath, null, SVNRepository.INVALID_REVISION);
        commitEditor.applyTextDelta(tauPath, null);
        fileText = (String) ourGreekTreeFiles.get(TAU);
        checksum = deltaGenerator.sendDelta(tauPath, new ByteArrayInputStream(fileText.getBytes()), commitEditor,
                true);
        //close /A/D/G/tau file
        commitEditor.closeFile(tauPath, checksum);
       
        //close /A/D/G
        commitEditor.closeDir();

        //add /A/D/H
        commitEditor.addDir("A/D/H", null, SVNRepository.INVALID_REVISION);

        //add /A/D/H/chi file
        String chiPath = "A/D/H/" + CHI;
        commitEditor.addFile(chiPath, null, SVNRepository.INVALID_REVISION);
        commitEditor.applyTextDelta(chiPath, null);
        fileText = (String) ourGreekTreeFiles.get(CHI);
        checksum = deltaGenerator.sendDelta(chiPath, new ByteArrayInputStream(fileText.getBytes()), commitEditor,
                true);
        //close /A/D/H/chi file
        commitEditor.closeFile(chiPath, checksum);

        //add /A/D/H/omega file
        String omegaPath = "A/D/H/" + OMEGA;
        commitEditor.addFile(omegaPath, null, SVNRepository.INVALID_REVISION);
        commitEditor.applyTextDelta(omegaPath, null);
        fileText = (String) ourGreekTreeFiles.get(OMEGA);
        checksum = deltaGenerator.sendDelta(omegaPath, new ByteArrayInputStream(fileText.getBytes()), commitEditor,
                true);
        //close /A/D/H/omega file
        commitEditor.closeFile(omegaPath, checksum);

        //add /A/D/H/psi file
        String psiPath = "A/D/H/" + PSI;
        commitEditor.addFile(psiPath, null, SVNRepository.INVALID_REVISION);
        commitEditor.applyTextDelta(psiPath, null);
        fileText = (String) ourGreekTreeFiles.get(PSI);
        checksum = deltaGenerator.sendDelta(psiPath, new ByteArrayInputStream(fileText.getBytes()), commitEditor,
                true);
        //close /A/D/H/psi file
        commitEditor.closeFile(psiPath, checksum);

        //close /A/D/H
        commitEditor.closeDir();
       
        //close /A/D
        commitEditor.closeDir();
       
        //close /A
        commitEditor.closeDir();
        //close the root of the edit - / (repository root) in our case
        commitEditor.closeDir();
       
        return commitEditor.closeEdit();
    }
View Full Code Here

  }

  public boolean update(SVNRevision toRevision) throws SVNException {
    ISVNReporterBaton reporterBaton = new ExportReporterBaton(toRevision.getNumber());

    ISVNEditor exportEditor;

    try {
      exportEditor = new ExportEditor(collection);

      repository.update(toRevision.getNumber(), null, true, reporterBaton,
View Full Code Here

                                                                getDiffGenerator(),
                                                                reverse ? -1 : revNumber, reverse ? revNumber : -1, result);
            SVNDiffEditor editor = new SVNDiffEditor(wcAccess, info, callback, useAncestry, reverse /* reverse */,
                    revision2 == SVNRevision.BASE || revision2 == SVNRevision.COMMITTED /* compare to base */,
                    depth, changeLists);
            ISVNEditor filterEditor = SVNAmbientDepthFilterEditor.wrap(editor, info, false);
            boolean serverSupportsDepth = repository.hasCapability(SVNCapability.DEPTH);
            SVNReporter reporter = new SVNReporter(info, info.getAnchor().getFile(info.getTargetName()),
                    false, !serverSupportsDepth, depth, false, false, true, getDebugLog());
           
            // this should be rev2.
View Full Code Here

            repository.setLocation(sourceURL, false);
            String[] preservedExts = getOptions().getPreservedConflictFileExtensions();
            ISVNUpdateEditor editor = wcAccess.createUpdateEditor(info, url.toString(),
                    allowUnversionedObstructions, depthIsSticky, depth, preservedExts, null, false);

            ISVNEditor filterEditor = SVNAmbientDepthFilterEditor.wrap(editor, info, depthIsSticky);
           
            String target = "".equals(info.getTargetName()) ? null : info.getTargetName();
            repository.update(url, revNumber, target, depth, reporter, SVNCancellableEditor.newInstance(filterEditor, this, getDebugLog()));

            long targetRevision = editor.getTargetRevision();
View Full Code Here

            };
           
            ISVNUpdateEditor editor = wcAccess.createUpdateEditor(adminInfo, null, allowUnversionedObstructions,
                    depthIsSticky, depth, preservedExts, fileFetcher, isUpdateLocksOnDemand());

            ISVNEditor filterEditor = SVNAmbientDepthFilterEditor.wrap(editor, adminInfo, depthIsSticky);

            try {
                repos.update(revNumber, target, depth, sendCopyFrom, reporter, SVNCancellableEditor.newInstance(filterEditor, this, getDebugLog()));
            } finally {
                if (repos2[0] != null) {
View Full Code Here

TOP

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

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.