Package org.exist.versioning.svn.internal.wc.admin

Examples of org.exist.versioning.svn.internal.wc.admin.SVNAdminArea


    }

    public SVNStatusType directoryDeleted(final String path, boolean[] isTreeConflicted) throws SVNException {
        setIsConflicted(isTreeConflicted, false);
        final File mergedFile = getFile(path);
        final SVNAdminArea dir = retrieve(mergedFile.getParentFile(), true);
        if (dir == null) {
            return SVNStatusType.MISSING;
        }

        SVNEntry entry = getWCAccess().getEntry(mergedFile, true);
View Full Code Here


    public SVNStatusType[] fileChanged(String path, File file1, File file2, long revision1, long revision2, String mimeType1,
            String mimeType2, SVNProperties originalProperties, SVNProperties diff, boolean[] isTreeConflicted) throws SVNException {
        setIsConflicted(isTreeConflicted, false);
        boolean needsMerge = true;
        File mergedFile = getFile(path);
        SVNAdminArea dir = retrieve(mergedFile.getParentFile(), myIsDryRun);
        if (dir == null) {
            return new SVNStatusType[] {SVNStatusType.MISSING, SVNStatusType.MISSING};
        }
       
        SVNStatusType[] result = new SVNStatusType[] {SVNStatusType.UNCHANGED, SVNStatusType.UNCHANGED};
        SVNEntry entry = getWCAccess().getEntry(mergedFile, false);
        SVNFileType fileType = null;
        if (entry != null) {
            fileType = SVNFileType.getType(mergedFile);
        }
       
        if (entry == null || (fileType != SVNFileType.FILE && fileType != SVNFileType.SYMLINK)) {
            return new SVNStatusType[] {SVNStatusType.MISSING, SVNStatusType.MISSING};
        }
       
        if (diff != null && !diff.isEmpty()) {
            result[1] = propertiesChanged(path, originalProperties, diff, null);
        }
       
        String name = mergedFile.getName();
        if (file1 != null) {
            boolean textModified = dir.hasTextModifications(name, false);
            if (!textModified &&
                    (SVNProperty.isBinaryMimeType(mimeType1) || SVNProperty.isBinaryMimeType(mimeType2))) {
                boolean same = SVNFileUtil.compareFiles(!myIsAddNecessitatedMerge ? file1 : file2, mergedFile, null);
                if (same) {
                    if (!myIsDryRun && !myIsAddNecessitatedMerge) {
                        SVNFileUtil.rename(file2, mergedFile);
                    }
                    result[0] = SVNStatusType.CHANGED;
                    needsMerge = false;
                }
            }
           
            if (needsMerge) {
                String localLabel = ".working";
                String baseLabel = ".merge-left.r" + revision1;
                String latestLabel = ".merge-right.r" + revision2;
                SVNStatusType mergeResult = dir.mergeText(name, file1, file2, null, localLabel,
                        baseLabel, latestLabel, diff, myIsDryRun, myDiffOptions, null);

                dir.runLogs();
                if (mergeResult == SVNStatusType.CONFLICTED || mergeResult == SVNStatusType.CONFLICTED_UNRESOLVED) {
                    result[0] = mergeResult;
                } else if (textModified && mergeResult != SVNStatusType.UNCHANGED) {
                    result[0] = SVNStatusType.MERGED;
                } else if (mergeResult == SVNStatusType.MERGED) {
View Full Code Here

            }
            SVNPropertyValue propValue = diff.getSVNPropertyValue(propName);
            newProps.put(propName, propValue);
        }
        File mergedFile = getFile(path);
        SVNAdminArea dir = retrieve(mergedFile.getParentFile(), true);
        if (dir == null) {
            if (myIsDryRun && myAddedPath != null && SVNPathUtil.isAncestor(myAddedPath, path)) {
                result[0] = SVNStatusType.CHANGED;
                if (!newProps.isEmpty()) {
                    result[1] = SVNStatusType.CHANGED;
View Full Code Here

    public SVNStatusType fileDeleted(String path, File file1, File file2, String mimeType1, String mimeType2, SVNProperties originalProperties,
            boolean[] isTreeConflicted) throws SVNException {
        setIsConflicted(isTreeConflicted, false);
        File mergedFile = getFile(path);
        SVNAdminArea dir = retrieve(mergedFile.getParentFile(), true);
        if (dir == null) {
            return SVNStatusType.MISSING;
        }
        SVNFileType fileType = SVNFileType.getType(mergedFile);
        if (fileType == SVNFileType.FILE || fileType == SVNFileType.SYMLINK) {
View Full Code Here

    protected void delete(File path, boolean force, boolean dryRun) throws SVNException {
        if (!force) {
            SVNWCManager.canDelete(path, getWCAccess().getOptions(), getWCAccess());
        }
        SVNAdminArea root = getWCAccess().retrieve(path.getParentFile());
        if (!dryRun) {
            SVNWCManager.delete(getWCAccess(), root, path, true, false);
        }
    }
View Full Code Here

            event = SVNEventFactory.createSVNEvent(file, item.getKind(), null, SVNRepository.INVALID_REVISION, SVNEventAction.COMMIT_REPLACED, null, null, null);
          event.setPreviousRevision(rev);
        } else if (item.isAdded()) {
            String mimeType = null;
            if (item.getKind() == SVNNodeKind.FILE && file != null) {
                SVNAdminArea dir = item.getWCAccess().retrieve(file.getParentFile());
                mimeType = dir.getProperties(file.getName()).getStringPropertyValue(SVNProperty.MIME_TYPE);
            }
            event = SVNEventFactory.createSVNEvent(file, item.getKind(), mimeType, SVNRepository.INVALID_REVISION, SVNEventAction.COMMIT_ADDED, null, null, null);
          event.setPreviousRevision(item.getCopyFromRevision() != null ? item.getCopyFromRevision().getNumber() : -1);
          event.setPreviousURL(item.getCopyFromURL());
        } else if (item.isDeleted()) {
View Full Code Here

            wcAccess.checkCancelled();

            SVNEvent event = SVNEventFactory.createSVNEvent(new Resource(wcAccess.getAnchor(), item.getPath()),SVNNodeKind.FILE, null, SVNRepository.INVALID_REVISION, SVNEventAction.COMMIT_DELTA_SENT, null, null, null);
            wcAccess.handleEvent(event, ISVNEventHandler.UNKNOWN);

            SVNAdminArea dir = wcAccess.retrieve(item.getFile().getParentFile());
            String name = SVNPathUtil.tail(item.getPath());
            SVNEntry entry = dir.getEntry(name, false);

            File tmpFile = dir.getBaseFile(name, true);
            myTmpFiles.add(tmpFile);

            String expectedChecksum = null;
            String checksum = null;
            String newChecksum = null;

            SVNChecksumInputStream baseChecksummedIS = null;
            InputStream sourceIS = null;
            InputStream targetIS = null;
            OutputStream tmpBaseStream = null;
            File baseFile = dir.getBaseFile(name, false);
            SVNErrorMessage error = null;
            boolean useChecksummedStream = false;
            boolean openSrcStream = false;
            if (!item.isAdded()) {
                openSrcStream = true;
                expectedChecksum = entry.getChecksum();
                if (expectedChecksum != null) {
                    useChecksummedStream = true;
                } else {
                    expectedChecksum = SVNFileUtil.computeChecksum(baseFile);
                }
            } else {
                sourceIS = SVNFileUtil.DUMMY_IN;
            }
 
            editor.applyTextDelta(path, expectedChecksum);
            if (myDeltaGenerator == null) {
                myDeltaGenerator = new SVNDeltaGenerator();
            }

            try {
                sourceIS = openSrcStream ? SVNFileUtil.openFileForReading(baseFile, SVNLogType.WC) : sourceIS;
                if (useChecksummedStream) {
                    baseChecksummedIS = new SVNChecksumInputStream(sourceIS, SVNChecksumInputStream.MD5_ALGORITHM);
                    sourceIS = baseChecksummedIS;
                }
                   
                targetIS = SVNTranslator.getTranslatedStream(dir, name, true, false);
                tmpBaseStream = SVNFileUtil.openFileForWriting(tmpFile);
                CopyingStream localStream = new CopyingStream(tmpBaseStream, targetIS);
                newChecksum = myDeltaGenerator.sendDelta(path, sourceIS, 0, localStream, editor, true);
            } catch (SVNException svne) {
                error = svne.getErrorMessage().wrap("While preparing ''{0}'' for commit", dir.getFile(name));
            } finally {
                SVNFileUtil.closeFile(sourceIS);
                SVNFileUtil.closeFile(targetIS);
                SVNFileUtil.closeFile(tmpBaseStream);
            }

            if (baseChecksummedIS != null) {
                checksum = baseChecksummedIS.getDigest();
            }
           
            if (expectedChecksum != null && checksum != null && !expectedChecksum.equals(checksum)) {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_CORRUPT_TEXT_BASE,
                        "Checksum mismatch for ''{0}''; expected: ''{1}'', actual: ''{2}''",
                        new Object[] { dir.getFile(name), expectedChecksum, checksum });
                SVNErrorManager.error(err, SVNLogType.WC);
            }

            if (error != null) {
                SVNErrorManager.error(error, SVNLogType.WC);
View Full Code Here

            editor.closeFile(path, newChecksum);
        }
    }

    private void sendPropertiesDelta(String commitPath, SVNCommitItem item, ISVNEditor editor) throws SVNException {
        SVNAdminArea dir;
        String name;
        SVNWCAccess wcAccess = item.getWCAccess();
        if (item.getKind() == SVNNodeKind.DIR) {
            dir = wcAccess.retrieve(item.getFile());
            name = "";
        } else {
            dir = wcAccess.retrieve(item.getFile().getParentFile());
            name = SVNPathUtil.tail(item.getPath());
        }
       
        if (!dir.hasPropModifications(name)) {
            return;
        }
        SVNEntry entry = dir.getEntry(name, false);
        boolean replaced = false;
        if (entry != null) {
            replaced = entry.isScheduledForReplacement();
        }
        SVNVersionedProperties props = dir.getProperties(name);
        SVNVersionedProperties baseProps = replaced ? null : dir.getBaseProperties(name);
        SVNProperties diff = replaced ? props.asMap() : baseProps.compareTo(props).asMap();
        if (diff != null && !diff.isEmpty()) {
            File tmpPropsFile = dir.getPropertiesFile(name, true);
            SVNWCProperties tmpProps = new SVNWCProperties(tmpPropsFile, null);
            for(Iterator propNames = props.getPropertyNames(null).iterator(); propNames.hasNext();) {
                String propName = (String) propNames.next();
                SVNPropertyValue propValue = props.getPropertyValue(propName);
                tmpProps.setPropertyValue(propName, propValue);
View Full Code Here

            // that were not explicitly added but are explicitly copied. ufff.
            if (depth != SVNDepth.INFINITY && force) {
                SVNAdminArea[] lockedDirs = baseAccess.getAdminAreas();
                for (int i = 0; i < lockedDirs.length; i++) {
                    statusClient.checkCancelled();
                    SVNAdminArea dir = lockedDirs[i];
                    if (dir == null) {
                        // could be null for missing, but known dir.
                        continue;
                    }
                    SVNEntry rootEntry = baseAccess.getEntry(dir.getRoot(), true);
                    if (rootEntry.getCopyFromURL() != null) {
                        File dirRoot = dir.getRoot();
                        boolean keep = false;
                        for (int j = 0; j < paths.length; j++) {
                            if (dirRoot.equals(paths[j])) {
                                keep = true;
                                break;
                            }
                        }
                        if (!keep) {
                            baseAccess.closeAdminArea(dir.getRoot());
                        }
                    }
                }
            }
        } catch (SVNException e) {
View Full Code Here

            String target = targets.hasNext() ? (String) targets.next() : "";
            baseAccess.checkCancelled();
            // get entry for target
            File targetFile = new Resource(baseAccess.getAnchor(), target);
            String parentPath = SVNPathUtil.removeTail(target);
            SVNAdminArea dir = baseAccess.probeRetrieve(targetFile);
            SVNEntry entry = null;
            try {
                entry = baseAccess.getVersionedEntry(targetFile, false);
            } catch (SVNException e) {
                if (e.getErrorMessage() != null &&
                        e.getErrorMessage().getErrorCode() == SVNErrorCode.ENTRY_NOT_FOUND) {
                    SVNTreeConflictDescription tc = baseAccess.getTreeConflict(targetFile);
                    if (tc != null) {
                        SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_FOUND_CONFLICT, "Aborting commit: ''{0}'' remains in conflict", targetFile);
                        SVNErrorManager.error(err, SVNLogType.WC);
                    }                   
                }
                throw e;               
            }
            String url = null;
            if (entry.getURL() == null) {
                // it could be missing directory.
                if (!entry.isThisDir() && entry.getName() != null &&
                        entry.isDirectory() && !(entry.isScheduledForAddition() || entry.isScheduledForReplacement()) && SVNFileType.getType(targetFile) == SVNFileType.NONE) {
                    File parentDir = targetFile.getParentFile();
                    if (parentDir != null) {
                        SVNEntry parentEntry = baseAccess.getEntry(parentDir, false);
                        if (parentEntry != null) {
                            url = SVNPathUtil.append(parentEntry.getURL(), SVNEncodingUtil.uriEncode(entry.getName()));
                        }
                    }
                }
                if (url == null) {
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_CORRUPT, "Entry for ''{0}'' has no URL", targetFile);
                    SVNErrorManager.error(err, SVNLogType.WC);
                }
            } else {
                url = entry.getURL();
            }
            SVNEntry parentEntry = null;
            if (entry.isScheduledForAddition() || entry.isScheduledForReplacement()) {
                // get parent (for file or dir-> get ""), otherwise open parent
                // dir and get "".
                try {
                    baseAccess.retrieve(targetFile.getParentFile());
                } catch (SVNException e) {
                    if (e.getErrorMessage().getErrorCode() == SVNErrorCode.WC_NOT_LOCKED) {
                        baseAccess.open(targetFile.getParentFile(), true, 0);
                    } else {
                        throw e;
                    }
                }
                parentEntry = baseAccess.getEntry(targetFile.getParentFile(), false);
                if (parentEntry == null) {
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_CORRUPT,
                            "''{0}'' is scheduled for addition within unversioned parent", targetFile);
                    SVNErrorManager.error(err, SVNLogType.WC);
                } else if (parentEntry.isScheduledForAddition() || parentEntry.isScheduledForReplacement()) {
                    danglers.add(targetFile.getParentFile());
                }
            }
            SVNDepth forcedDepth = depth;
            if (entry.isCopied() && entry.getSchedule() == null) {
                // if commit is forced => we could collect this entry, assuming
                // that its parent is already included into commit
                // it will be later removed from commit anyway.
                if (!force) {
                    SVNErrorMessage err =  SVNErrorMessage.create(SVNErrorCode.ILLEGAL_TARGET,
                            "Entry for ''{0}''"
                                    + " is marked as 'copied' but is not itself scheduled\n"
                                    + "for addition.  Perhaps you're committing a target that is\n"
                                    + "inside an unversioned (or not-yet-versioned) directory?", targetFile);
                    SVNErrorManager.error(err, SVNLogType.WC);
                } else {
                    // just do not process this item as in case of recursive
                    // commit.
                    continue;
                }
            } else if (entry.isCopied() && entry.isScheduledForAddition()) {
                if (force) {
                    isRecursionForced = depth != SVNDepth.INFINITY;
                    forcedDepth = SVNDepth.INFINITY;
                }
            } else if (entry.isScheduledForDeletion() && force && depth != SVNDepth.INFINITY) {
                // if parent is also deleted -> skip this entry
                File parentFile = targetFile.getParentFile();
                parentEntry = baseAccess.getEntry(parentFile, false);
                if (parentEntry == null) {
                    try {
                        baseAccess.retrieve(parentFile);
                    } catch (SVNException e) {
                        if (e.getErrorMessage().getErrorCode() == SVNErrorCode.WC_NOT_LOCKED) {
                            baseAccess.open(parentFile, true, 0);
                        } else {
                            throw e;
                        }
                    }
                    parentEntry = baseAccess.getEntry(parentFile, false);
                }
                if (parentEntry != null && parentEntry.isScheduledForDeletion() && paths.contains(parentPath)) {
                    continue;
                }
                // this recursion is not considered as "forced", all children should be
                // deleted anyway.
                forcedDepth = SVNDepth.INFINITY;
            }
           
            // check ancestors for tc.
            File ancestorPath = dir.getRoot();
           
            SVNWCAccess localAccess = SVNWCAccess.newInstance(null);
            localAccess.open(ancestorPath, false, 0);
            try {
                while (true) {
                    boolean isRoot = localAccess.isWCRoot(ancestorPath);
                    if (isRoot) {
                        break;
                    }
                    File pPath = ancestorPath.getParentFile();
                    localAccess.open(pPath, false, 0);
                    if (localAccess.hasTreeConflict(ancestorPath)) {
                        SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_FOUND_CONFLICT,
                                "Aborting commit: ''{0}'' remains in tree-conflict", ancestorPath);
                        SVNErrorManager.error(err, SVNLogType.WC);
                    }
                    ancestorPath = pPath;
                }
            } finally {
                localAccess.close();
            }
//            String relativePath = entry.getKind() == SVNNodeKind.DIR ? target : SVNPathUtil.removeTail(target);
            harvestCommitables(commitables, dir, targetFile, parentEntry, entry, url, null, false, false,
                    justLocked, lockTokens, forcedDepth, isRecursionForced, changelists, params, null);
        } while (targets.hasNext());

        for (Iterator ds = danglers.iterator(); ds.hasNext();) {
            baseAccess.checkCancelled();
            File file = (File) ds.next();
            if (!commitables.containsKey(file)) {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ILLEGAL_TARGET,
                        "''{0}'' is not under version control\n"
                        + "and is not part of the commit, \n"
                        + "yet its child is part of the commit", file);
                SVNErrorManager.error(err, SVNLogType.WC);
            }
        }
       
        // filter out file externals that were not explicitly specified.
        filterOutFileExternals(paths, commitables, baseAccess);
       
        if (isRecursionForced) {
            // if commit is non-recursive and forced and there are elements included into commit
            // that not only 'copied' but also has local mods (modified or deleted), remove those items?
            // or not?
            for (Iterator items = commitables.values().iterator(); items.hasNext();) {
                baseAccess.checkCancelled();
                SVNCommitItem item = (SVNCommitItem) items.next();
                if (item.isDeleted()) {
                    // to detect deleted copied items.
                    File file = item.getFile();
                    if (item.getKind() == SVNNodeKind.DIR) {
                        if (!file.exists()) {
                            continue;
                        }
                    } else {
                        String name = SVNPathUtil.tail(item.getPath());
                        SVNAdminArea dir = baseAccess.retrieve(item.getFile().getParentFile());
                        if (!dir.getBaseFile(name, false).exists()) {
                            continue;
                        }
                    }
                }
                if (item.isContentsModified() || item.isDeleted() || item.isPropertiesModified()) {
View Full Code Here

TOP

Related Classes of org.exist.versioning.svn.internal.wc.admin.SVNAdminArea

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.