Package org.evolizer.versioncontrol.svn.model.entities

Examples of org.evolizer.versioncontrol.svn.model.entities.SVNRevision


        List<Revision> revisions =
                fPersistenceProvider.query("FROM SVNRevision as f WHERE f.file.path LIKE '" + fromPath
                        + "%' ORDER BY f.file.path", Revision.class);
        HashMap<String, SVNRevision> m = new HashMap<String, SVNRevision>();
        for (Revision rev : revisions) {
            SVNRevision r = (SVNRevision) rev;
            SVNRevision found = m.get(r.getFile().getPath());
            if (found == null) {
                if (Long.parseLong(r.getNumber()) <= copyRevision) {
                    m.put(r.getFile().getPath(), r);
                }
            } else if (Long.parseLong(r.getNumber()) <= copyRevision
                    && Long.parseLong(r.getNumber()) > Long.parseLong(found.getNumber())) {
                m.put(r.getFile().getPath(), r);
            }
        }
        for (String key : m.keySet()) {
            SVNRevision oldRevision = m.get(key);
            String oldRevisionFileName = oldRevision.getFile().getPath();
            String newRevisionFileName = oldRevisionFileName.replaceFirst(fromPath, toPath);
            if (oldRevision.getState() == null) {
                // I create the new SVNRevision which will have as a revision number the one of the branch/release
                // creation
                SVNRevision newRevision = new SVNRevision(revisionNum + "");
                ModificationReport report = this.createModificationReport(creationTime, commitMessage, author);
                newRevision.setReport(report);

                // I also need to create a new File, as it is actually done by the SVN
                // It's the same of the old one, but with a different path
                SVNVersionedFile newFile = (SVNVersionedFile) createFile(newRevisionFileName);
                newRevision.setChangeSet(changeSet);
                changeSet.addRevision(newRevision); // Transaction -> SVNRevision
                newFile.addRevision(newRevision); // File -> SVNRevision
                newRevision.setFile(newFile); // SVNRevision -> File
                // Keep track of a new file ancestor
                newRevision.setAncestor(oldRevision);
                // I check whether I'm connecting the new SVNRevision to a Branch or to a Release
                if ((branch != null) && (release == null)) {
                    // Now I add the newly created file version to the Branch and viceversa
                    branch.addRevision(newRevision); // Branch -> SVNRevision
                    LOGGER.debug(NLS.bind(MapperMessages.SVNModelMapper_addedRevisionToBranch, new String[]{
                            newRevision.getFile().getPath(),
                            newRevision.getNumber(),
                            branch.getName(),
                            oldRevision.getFile().getPath(),
                            oldRevision.getNumber()}));
                } else if ((branch == null) && (release != null)) {
                    // I add the newly created file version to the Release and viceversa
                    release.addReleaseRevision(newRevision);

                    LOGGER.debug(NLS.bind(MapperMessages.SVNModelMapper_addedRevisionToRelease, new String[]{
                            newRevision.getFile().getPath(),
                            newRevision.getNumber(),
                            release.getName(),
                            oldRevision.getFile().getPath(),
                            oldRevision.getNumber()}));
                }
            }
View Full Code Here


            String copyPath,
            boolean deleted,
            String contents,
            String branchName) throws SVNImporterException {

        SVNRevision newRevision = new SVNRevision(number + "");
        SVNRevision oldRevision = (SVNRevision) file.getLatestRevision();
       
        LOGGER.debug(NLS.bind(MapperMessages.SVNModelMapper_createdRevision, file.getPath(), number));
        // Check if I'm actually modifying a revision that I was already created handling the same transaction.
        if (oldRevision != null && oldRevision.getNumber().compareTo(number + "") == 0) {
            newRevision = oldRevision;
            oldRevision = (SVNRevision) oldRevision.getPreviousRevision();
        } else {
            // Transaction -> SVNRevision
            changeSet.addRevision(newRevision);
            if (oldRevision != null) {
                // Older SVNRevision -> New one
                oldRevision.setNextRevision(newRevision);
                // New SVNRevision -> Old one
                newRevision.setPreviousRevision(oldRevision);
            }
            // File -> SVNRevision
            file.addRevision(newRevision);
View Full Code Here

         * SVNRevisions is a list order by number of SVNRevision (from the earliest to the oldest).
         * So I'll go from the last element down. So, when a SVNRevision that has a SVNRevision
         * number smaller or equal to the wanted SVNRevision number if found, it's for sure the closest.
         */
        for (int i = f.getRevisions().size() - 1; i >= 0; i--) {
            SVNRevision revision = (SVNRevision) f.getRevisions().get(i);
            if (Long.parseLong(revision.getNumber()) <= revNum) {
                return revision;
            }
        }
        return null;
    }
View Full Code Here

     * @param currSVNRevision
     *            The revision number of that File.
     * @return The previous revision number.
     */
    public String getPreviousRevision(String changedPath, long currSVNRevision) {
        SVNRevision revision = null;
        long currRevision = currSVNRevision;
        while (revision == null && currRevision >= 0) {
            revision =
                    fPersistenceProvider.uniqueResult("FROM SVNRevision as f WHERE f.file.path='" + changedPath
                            + "' AND f.number = '" + (--currRevision) + "' ORDER BY(f.number) DESC", SVNRevision.class);
        }
        if ((revision != null)) {
            return revision.getNumber();
        } else {
            return "-1";
        }
    }
View Full Code Here

     *            The Release to modify.
     * @see org.evolizer.model.resources.entities.fs.File
     * @see org.evolizer.versioncontrol.svn.model.entities.SVNRelease
     */
    private void removeRevisionFromRelease(SVNVersionedFile file, SVNRelease release) {
        SVNRevision toRemove = (SVNRevision) file.getLatestRevision();
        release.removeReleaseRevision(toRemove);
        toRemove.getReleases().remove(release); // SVNRevision ->Release
        toRemove.getChangeSet().getInvolvedRevisions().remove(toRemove);
        LOGGER.debug(NLS.bind(MapperMessages.SVNModelMapper_removedRevisionFromRelease, new String[]{
                file.getPath(),
                file.getLatestRevision().getNumber(),
                release.getName()}));
    }
View Full Code Here

     */
    private void removeRevisionFromBranch(SVNVersionedFile file, Branch branch) {
        // Straight forward. A Branch has always a reference to just the latest SVNRevision of
        // all the files it is made of.
        // So I'll just get the latest SVNRevision of the File and remove the references.
        SVNRevision toRemove = (SVNRevision) file.getLatestRevision();
        branch.getRevisions().remove(toRemove); // Release -> SVNRevision
        toRemove.getChangeSet().getInvolvedRevisions().remove(toRemove);
        LOGGER.debug(NLS.bind(MapperMessages.SVNModelMapper_removedRevisionFromBranch, new String[]{
                file.getPath(),
                file.getLatestRevision().getNumber(),
                branch.getName()}));
    }
View Full Code Here

         * In fact in an update there could be files and sub directories that don't exist
         * in the directory that is being updated. In that case, I need to create them.
         */
        if (toUpdate != null) {
            // that file actually exists
            SVNRevision revision = getClosestRevision(toCopy, replacementRevisionNum);
            if (revision != null) {
                ((SVNRevision) toUpdate.getLatestRevision()).setAncestor(revision);
            }
        } else {
            // That file does not exist yet
            toUpdate = (SVNVersionedFile) createFile(path);
            toUpdate.setCopiedFrom(toCopy);
            toCopy.setCopiedTo(toUpdate);
            SVNRevision revision = getClosestRevision(toCopy, replacementRevisionNum);
            ModificationReport report = this.createModificationReport(date, message, author);

            SVNRevision newRevision = new SVNRevision("" + currentRevisionNum);
            // Usual SVNRevision initialization
            changeSet.addRevision(newRevision); // Transaction -> SVNRevision
            newRevision.setChangeSet(changeSet); // SVNRevision -> Transaction
            newRevision.setAncestor(revision);
            toUpdate.addRevision(newRevision); // File -> SVNRevision
            newRevision.setFile(toUpdate); // SVNRevision -> File
            newRevision.setReport(report); // SVNRevision -> ModificationReport
            if (release != null) {
                release.addReleaseRevision(newRevision); // Release -> SVNRevision
                LOGGER.debug(NLS.bind(MapperMessages.SVNModelMapper_addedFileToRelease, new String[]{
                        toUpdate.getPath(),
                        toUpdate.getLatestRevision().getNumber(),
View Full Code Here

        if (dir != null) {
            recurseDelete(fDirectories.get(rel.getUrl()));
        }
        for (Revision tmp : rel.getReleaseRevisions()) {
            fFiles.remove(tmp.getFile().getPath());
            SVNRevision f = ((SVNRevision) tmp).getAncestor();
            if (f != null) {
                rel.addRevision(f);
                // I check that the file version doesn't refer to a deleted file
                if (f.getState() == null) {
                    while (f != null) {
                        f.addRelease(rel);
                        f = (SVNRevision) f.getPreviousRevision();
                    }
                }
            } else {
                rel.addRevision(tmp);
            }
View Full Code Here

TOP

Related Classes of org.evolizer.versioncontrol.svn.model.entities.SVNRevision

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.