Package org.tmatesoft.svn.core.internal.wc.admin

Examples of org.tmatesoft.svn.core.internal.wc.admin.SVNVersionedProperties


        }
        return info;
    }
   
    private File detranslateFile(SVNAdminArea dir, String name) throws SVNException {
        SVNVersionedProperties properties = dir.getProperties(name);
        String keywords = properties.getPropertyValue(SVNProperty.KEYWORDS);
        String eolStyle = properties.getPropertyValue(SVNProperty.EOL_STYLE);
        boolean special = properties.getPropertyValue(SVNProperty.SPECIAL) != null;
        if (keywords == null && eolStyle == null && (!special || SVNFileUtil.isWindows)) {
            return dir.getFile(name);
        }
        byte[] eol = SVNTranslator.getEOL(eolStyle);
        File tmpFile = createTempFile();
View Full Code Here


                } else {
                    // area could only be path itself or child file in it.
                    if ((base && entry.isScheduledForAddition()) || (!base && entry.isScheduledForDeletion())) {
                        return;
                    }
                    SVNVersionedProperties properties = base ? area.getBaseProperties(entry.getName()) : area.getProperties(entry.getName());
                    if (propName != null) {
                        String propValue = properties.getPropertyValue(propName);
                        if (propValue != null) {
                            handler.handleProperty(path, new SVNPropertyData(propName, propValue));
                        }
                    } else {
                        Map allProps = properties.asMap();
                        for(Iterator names = allProps.keySet().iterator(); names.hasNext();) {
                            String name = (String) names.next();
                            String val = (String) allProps.get(name);
                            handler.handleProperty(area.getFile(entry.getName()), new SVNPropertyData(name, val));
                        }
View Full Code Here

   
    private boolean revert(SVNAdminArea dir, String name, SVNEntry entry, boolean useCommitTime) throws SVNException {
        SVNLog log = dir.getLog();
        boolean reverted = false;
        boolean revertBase = false;
        SVNVersionedProperties baseProperties = null;
        Map command = new HashMap();
       
        if (entry.isScheduledForReplacement()) {
            String propRevertPath = SVNAdminUtil.getPropRevertPath(name, entry.getKind(), false);
            File propRevertFile = dir.getFile(propRevertPath);
            revertBase = true;
            if (!propRevertFile.isFile()) {
                propRevertPath = SVNAdminUtil.getPropBasePath(name, entry.getKind(), false);
                revertBase = false;
            }
            if (dir.getFile(propRevertPath).isFile()) {
                baseProperties = revertBase ? dir.getRevertProperties(name) : dir.getBaseProperties(name);
                if (revertBase) {
                    command.put(SVNLog.NAME_ATTR, propRevertPath);
                    log.addCommand(SVNLog.DELETE, command, false);
                    command.clear();
                }
                reverted = true;
            }
        }
        boolean reinstallWorkingFile = false;
        if (baseProperties == null) {
            if (dir.hasPropModifications(name)) {
                baseProperties = dir.getBaseProperties(name);
                SVNVersionedProperties propDiff = dir.getProperties(name).compareTo(baseProperties);
                Collection propNames = propDiff.getPropertyNames(null);
                reinstallWorkingFile = propNames.contains(SVNProperty.EXECUTABLE) ||
                                propNames.contains(SVNProperty.KEYWORDS) ||
                                propNames.contains(SVNProperty.EOL_STYLE) ||
                                propNames.contains(SVNProperty.SPECIAL) ||
                                propNames.contains(SVNProperty.NEEDS_LOCK);
            }
        }
        if (baseProperties != null) {
            // save base props both to base and working.
            Map newProperties = baseProperties.asMap();
            SVNVersionedProperties originalBaseProperties = dir.getBaseProperties(name);
            SVNVersionedProperties workProperties = dir.getProperties(name);
            if (revertBase) {
                originalBaseProperties.removeAll();
            }
            workProperties.removeAll();
            for(Iterator names = newProperties.keySet().iterator(); names.hasNext();) {
                String propName = (String) names.next();
                if (revertBase) {
                    originalBaseProperties.setPropertyValue(propName, (String) newProperties.get(propName));
                }
                workProperties.setPropertyValue(propName, (String) newProperties.get(propName));
            }
            dir.saveVersionedProperties(log, false);
            reverted = true;
        }
        Map newEntryProperties = new HashMap();
View Full Code Here

                        entry.setLockToken(lock.getID());
                        entry.setLockComment(lock.getComment());
                        entry.setLockOwner(lock.getOwner());
                        entry.setLockCreationDate(SVNTimeUtil.formatDate(lock.getCreationDate()));
                        // get properties and values.
                        SVNVersionedProperties props = dir.getProperties(entry.getName());
                       
                        if (props.getPropertyValue(SVNProperty.NEEDS_LOCK) != null) {
                            SVNFileUtil.setReadonly(dir.getFile(entry.getName()), false);
                        }
                        SVNFileUtil.setExecutable(dir.getFile(entry.getName()), props.getPropertyValue(SVNProperty.EXECUTABLE) != null);
                        dir.saveEntries(false);
                        handleEvent(SVNEventFactory.createLockEvent(dir, entry.getName(), SVNEventAction.LOCKED, lock, null),
                                ISVNEventHandler.UNKNOWN);
                    } else {
                        handleEvent(SVNEventFactory.createLockEvent(dir, lockInfo.myFile.getName(), SVNEventAction.LOCK_FAILED, lock, error),
View Full Code Here

                        entry.setLockToken(null);
                        entry.setLockComment(null);
                        entry.setLockOwner(null);
                        entry.setLockCreationDate(null);
                       
                        SVNVersionedProperties props = dir.getProperties(entry.getName());
                       
                        if (props.getPropertyValue(SVNProperty.NEEDS_LOCK) != null) {
                            SVNFileUtil.setReadonly(dir.getFile(entry.getName()), true);
                        }
                        dir.saveEntries(false);
                        action = SVNEventAction.UNLOCKED;
                    }
View Full Code Here

                continue;
            }
            if ((base && entry.isScheduledForAddition()) || (!base && entry.isScheduledForDeletion())) {
                continue;
            }
            SVNVersionedProperties properties = base ? area.getBaseProperties(entry.getName()) : area.getProperties(entry.getName());
            if (propName != null) {
                String propVal = properties.getPropertyValue(propName);
                if (propVal != null) {
                    handler.handleProperty(area.getFile(entry.getName()), new SVNPropertyData(propName, propVal));
                }
            } else {
                Map allProps = properties.asMap();
                for(Iterator names = allProps.keySet().iterator(); names.hasNext();) {
                    String name = (String) names.next();
                    String val = (String) allProps.get(name);
                    handler.handleProperty(area.getFile(entry.getName()), new SVNPropertyData(name, val));
                }
View Full Code Here

                                new Object[] {propName, wcFile});
                        SVNErrorManager.error(err);
                    }
                    return;
                }
                SVNVersionedProperties props = anchor.getProperties(name);
                if (SVNProperty.EXECUTABLE.equals(propName)) {
                    SVNFileUtil.setExecutable(wcFile, propValue != null);
                }
                if (!force && SVNProperty.EOL_STYLE.equals(propName) && propValue != null) {
                    if (SVNProperty.isBinaryMimeType(props.getPropertyValue(SVNProperty.MIME_TYPE))) {
                        if (!recursive) {
                            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ILLEGAL_TARGET, "File ''{0}'' has binary mime type property", wcFile);
                            SVNErrorManager.error(err);
                        }
                        return;
                    }
                    if (!SVNTranslator.checkNewLines(wcFile)) {
                        SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ILLEGAL_TARGET, "File ''{0}'' has incosistent newlines", wcFile);
                        SVNErrorManager.error(err);
                    }
                }
                String oldValue = props.getPropertyValue(propName);
                boolean modified = oldValue == null ? propValue != null : !oldValue.equals(propValue);
                props.setPropertyValue(propName, propValue);

                if (SVNProperty.EOL_STYLE.equals(propName) || SVNProperty.KEYWORDS.equals(propName)) {
                    entry.setTextTime(null);
                } else if (SVNProperty.NEEDS_LOCK.equals(propName) && propValue == null) {
                    SVNFileUtil.setReadonly(wcFile, false);
                }
                if (modified && handler != null) {
                    handler.handleProperty(anchor.getFile(name), new SVNPropertyData(propName, propValue));
                }
            }
            SVNLog log = anchor.getLog();
            anchor.saveVersionedProperties(log, true);
            anchor.saveEntries(false);
            log.save();
            anchor.runLogs();
            return;
        }
        SVNVersionedProperties props = anchor.getProperties(name);
        if ((SVNProperty.KEYWORDS.equals(propName)
                || SVNProperty.EOL_STYLE.equals(propName)
                || SVNProperty.MIME_TYPE.equals(propName)
                || SVNProperty.EXECUTABLE.equals(propName)) && propValue != null) {
            if (!recursive) {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ILLEGAL_TARGET, "Cannot set ''{0}'' on a directory (''{1}'')",
                        new Object[] {propName, anchor.getRoot()});
                SVNErrorManager.error(err);
            }
        } else {
            String oldValue = props.getPropertyValue(propName);
            boolean modified = oldValue == null ? propValue != null : !oldValue.equals(propValue);
            props.setPropertyValue(propName, propValue);
            SVNLog log = anchor.getLog();
            anchor.saveVersionedProperties(log, true);
            log.save();
            anchor.runLogs();
            if (modified && handler != null) {
View Full Code Here

   
    private void doGetLocalFileContents(File path, OutputStream dst, SVNRevision revision, boolean expandKeywords) throws SVNException {
        SVNWCAccess wcAccess = createWCAccess();
        InputStream input = null;
        boolean hasMods = false;
        SVNVersionedProperties properties = null;

        try {
            SVNAdminArea area = wcAccess.open(path.getParentFile(), false, 0);
            SVNEntry entry = wcAccess.getEntry(path, false);
            if (entry == null) {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNVERSIONED_RESOURCE, "''{0}'' is not under version control or doesn''t exist", path, SVNErrorMessage.TYPE_WARNING);
                SVNErrorManager.error(err);
            } else if (entry.getKind() != SVNNodeKind.FILE) {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNVERSIONED_RESOURCE, "''{0}'' refers to a directory", path, SVNErrorMessage.TYPE_WARNING);
                SVNErrorManager.error(err);
            }
            String name = path.getName();
            if (revision != SVNRevision.WORKING) {
                // get base version and base props.
                input = area.getBaseFileForReading(name, false);
                properties = area.getBaseProperties(name);
            } else {
                // get working version and working props.
                input = SVNFileUtil.openFileForReading(area.getFile(path.getName()));
                hasMods = area.hasPropModifications(name) || area.hasTextModifications(name, true);
                properties = area.getProperties(name);
            }
            String eolStyle = properties.getPropertyValue(SVNProperty.EOL_STYLE);
            String keywords = properties.getPropertyValue(SVNProperty.KEYWORDS);
            boolean special = properties.getPropertyValue(SVNProperty.SPECIAL) != null;
            byte[] eols = null;
            Map keywordsMap = null;
            String time = null;

            if (eolStyle != null) {
View Full Code Here

                    String srcURL = srcEntry.getURL();
                    String srcCFURL = srcEntry.getCopyFromURL();
                    long srcRevision = srcEntry.getRevision();
                    long srcCFRevision = srcEntry.getCopyFromRevision();
                    // copy props!
                    SVNVersionedProperties srcProps = srcParentArea.getProperties(src.getName());
                    SVNVersionedProperties dstProps = dstParentArea.getProperties(dst.getName());
                    srcProps.copyTo(dstProps);
                    File srcBaseFile = srcParentArea.getBaseFile(src.getName(), false);
                    File dstBaseFile = dstParentArea.getBaseFile(dst.getName(), false);
                    if (srcBaseFile.isFile()) {
                        SVNFileUtil.copy(srcBaseFile, dstBaseFile, false, false);
                    }
                   
                    if (srcEntry.isScheduledForAddition() && srcEntry.isCopied()) {
                        dstEntry.scheduleForAddition();
                        dstEntry.setCopyFromRevision(srcCFRevision);
                        dstEntry.setCopyFromURL(srcCFURL);
                        dstEntry.setKind(SVNNodeKind.FILE);
                        dstEntry.setRevision(srcRevision);
                        dstEntry.setCopied(true);
                    } else if (!srcEntry.isCopied()
                            && !srcEntry.isScheduledForAddition()) {
                        dstEntry.setCopied(true);
                        dstEntry.scheduleForAddition();
                        dstEntry.setKind(SVNNodeKind.FILE);
                        dstEntry.setCopyFromRevision(srcRevision);
                        dstEntry.setCopyFromURL(srcURL);
                    } else {
                        dstEntry.scheduleForAddition();
                        dstEntry.setKind(SVNNodeKind.FILE);
                        if (!dstEntry.isScheduledForReplacement()) {
                            dstEntry.setRevision(0);
                        }
                    }
                   
                    SVNLog log = dstParentArea.getLog();
                    dstParentArea.saveEntries(false);
                    dstParentArea.saveVersionedProperties(log, true);
                    log.save();
                    dstParentArea.runLogs();
                } else if (srcEntry.isDirectory()) {
                    SVNAdminArea srcArea = wcAccess.open(src, false, 0);
                    srcEntry = srcArea.getEntry(srcArea.getThisDirName(), false);
                    if (dstEntry == null) {
                        dstEntry = dstParentArea.addEntry(dst.getName());
                    }
                    SVNAdminArea dstArea = wcAccess.open(dst, true, SVNWCAccess.INFINITE_DEPTH);
                   
                    SVNVersionedProperties srcProps = srcArea.getProperties(srcArea.getThisDirName());
                    SVNVersionedProperties dstProps = dstArea.getProperties(dstArea.getThisDirName());
                   
                    SVNEntry dstParentEntry = dstParentArea.getEntry(dstParentArea.getThisDirName(), false);
                    String srcURL = srcEntry.getURL();
                    String srcCFURL = srcEntry.getCopyFromURL();
                    String dstURL = dstParentEntry.getURL();
View Full Code Here

                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ENTRY_EXISTS, "''{0}'' is already under version control", dst);
                SVNErrorManager.error(err);               
            }
           
            SVNAdminArea srcArea = srcAccess.probeOpen(src, false, 0);
            SVNVersionedProperties srcProps = srcArea.getProperties(src.getName());
            SVNVersionedProperties dstProps = dstArea.getProperties(dst.getName());

            srcProps.copyTo(dstProps);

            dstEntry = dstArea.addEntry(dst.getName());
            dstEntry.setCopyFromURL(cfURL);
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.internal.wc.admin.SVNVersionedProperties

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.