Package org.tmatesoft.svn.core

Examples of org.tmatesoft.svn.core.SVNMergeRangeList$RangeComparator2


      if (!honorMergeInfo || myIsRecordOnly) {
          for (ListIterator childrenIter = childrenWithMergeInfo.listIterator(); childrenIter.hasNext();) {
                MergePath child = (MergePath) childrenIter.next();
                SVNMergeRange range = new SVNMergeRange(revision1, revision2, inheritable);
                child.myRemainingRanges = new SVNMergeRangeList(range);
          }       
          return;
      }

      int index = 0;
      for (ListIterator childrenIter = childrenWithMergeInfo.listIterator(); childrenIter.hasNext();) {
            MergePath child = (MergePath) childrenIter.next();
            if (child == null || child.myIsAbsent) {
                index++;
                continue;
            }
           
            String childRelativePath = null;
            if (myTarget.equals(child.myPath)) {
                childRelativePath = "";
            } else {
                childRelativePath = SVNPathUtil.getRelativePath(myTarget.getAbsolutePath(),
                    child.myPath.getAbsolutePath());
            }
            MergePath parent = null;
            SVNURL childURL1 = url1.appendPath(childRelativePath, false);
            SVNURL childURL2 = url2.appendPath(childRelativePath, false);
            SVNEntry childEntry = myWCAccess.getVersionedEntry(child.myPath, false);
           
            boolean indirect[] = { false };
            Map mergeInfo[] = getFullMergeInfo(childEntry, indirect, SVNMergeInfoInheritance.INHERITED,
                repository, child.myPath, Math.max(revision1, revision2), Math.min(revision1, revision2));
            child.myPreMergeMergeInfo = mergeInfo[0];
            child.myImplicitMergeInfo = mergeInfo[1];
            child.myIsIndirectMergeInfo = indirect[0];

            if (index == 0) {
                long[] rangePoints = SVNMergeInfoUtil.getRangeEndPoints(child.myImplicitMergeInfo);
                long youngestRev = rangePoints[0];
                long oldestRev = rangePoints[1];
               
                for (Iterator mergeInfoIter = child.myImplicitMergeInfo.keySet().iterator(); mergeInfoIter.hasNext();) {
                    String sourcePath = (String) mergeInfoIter.next();
                    SVNMergeRangeList sourceRangeList = (SVNMergeRangeList) child.myImplicitMergeInfo.get(sourcePath);
                    SVNMergeRange[] srcRanges = sourceRangeList.getRanges();
                    SVNMergeRange range = srcRanges[srcRanges.length - 1];
                    youngestRev = range.getEndRevision();
                   
                    SVNMergeRangeList rev1rev2RangeList = new SVNMergeRangeList(new SVNMergeRange(oldestRev, youngestRev, true));
                    SVNMergeRangeList result = sourceRangeList.merge(rev1rev2RangeList);
                    sourceRangeList.setRanges(result.getRanges());
                }
            }
           
            if (index > 0) {
                Object[] childrenWithMergeInfoArray = childrenWithMergeInfo.toArray();
                int parentIndex = findNearestAncestor(childrenWithMergeInfoArray, false, child.myPath);
                if (parentIndex >= 0 && parentIndex < childrenWithMergeInfoArray.length) {
                    parent = (MergePath) childrenWithMergeInfoArray[parentIndex];
                }               
            }
            calculateRemainingRanges(parent, child, sourceRootURL, childURL1, revision1,
                childURL2, revision2, child.myPreMergeMergeInfo, child.myImplicitMergeInfo,
                index > 0, childEntry, repository);
            index++;
      }
        
      if (childrenWithMergeInfo.size() > 1) {
        MergePath child = (MergePath) childrenWithMergeInfo.get(0);
        if (child.myRemainingRanges.isEmpty()) {
          SVNMergeRange dummyRange = new SVNMergeRange(revision2, revision2, inheritable);
          child.myRemainingRanges = new SVNMergeRangeList(dummyRange);
                myIsTargetHasDummyMergeRange = true;
        }
      }
    }
View Full Code Here


        if (honorMergeInfo) {
            if (myIsTargetHasDummyMergeRange) {
                targetStart = revision2;
            } else if (childrenWithMergeInfo != null && !childrenWithMergeInfo.isEmpty()) {
                MergePath targetMergePath = (MergePath) childrenWithMergeInfo.get(0);
                SVNMergeRangeList remainingRanges = targetMergePath.myRemainingRanges;
                if (remainingRanges != null && !remainingRanges.isEmpty()) {
                    SVNMergeRange[] ranges = remainingRanges.getRanges();
                    SVNMergeRange range = ranges[0];
                    if ((!isRollBack && range.getStartRevision() > revision2) ||
                            (isRollBack && range.getStartRevision() < revision2)) {
                        targetStart = revision2;
                    } else {
                        targetStart = range.getStartRevision();
                    }
                }
            }
        }

        editor = getMergeReportEditor(defaultStart, revision2, adminArea, depth, mergeCallback, editor);

        SVNURL oldURL = ensureSessionURL(myRepository2, url1);
        try {
            final SVNDepth reportDepth = depth;
            final long reportStart = targetStart;
            final String targetPath = targetWCPath.getAbsolutePath().replace(File.separatorChar, '/');

          myRepository1.diff(url2, revision2, revision2, null, myIsIgnoreAncestry, depth, true,
                    new ISVNReporterBaton() {
                        public void report(ISVNReporter reporter) throws SVNException {
                           
                            reporter.setPath("", null, reportStart, reportDepth, false);

                            if (honorMergeInfo && childrenWithMergeInfo != null) {
                              for (int i = 1; i < childrenWithMergeInfo.size(); i++) {
                                   MergePath childMergePath = (MergePath) childrenWithMergeInfo.get(i);
                                   MergePath parent = null;
                                   if (childMergePath == null || childMergePath.myIsAbsent) {
                                       continue;
                                   }
                                   Object[] childrenWithMergeInfoArray = childrenWithMergeInfo.toArray();
                                   int parentIndex = findNearestAncestor(childrenWithMergeInfoArray, false, childMergePath.myPath);
                                   if (parentIndex >= 0 && parentIndex < childrenWithMergeInfoArray.length) {
                                       parent = (MergePath) childrenWithMergeInfoArray[parentIndex];
                                   }
                                   String parentPath = parent.myPath.getAbsolutePath().replace(File.separatorChar, '/');
                                   boolean nearestParentIsTarget = parentPath.equals(targetPath);
                                  
                                   SVNMergeRange range = null;
                                   if (childMergePath.myRemainingRanges != null &&
                                           !childMergePath.myRemainingRanges.isEmpty()) {
                                       SVNMergeRangeList remainingRangesList = childMergePath.myRemainingRanges;
                                       SVNMergeRange[] remainingRanges = remainingRangesList.getRanges();
                                       range = remainingRanges[0];
                                      
                                       if ((!isRollBack && range.getStartRevision() > revision2) ||
                                               (isRollBack && range.getStartRevision() < revision2)) {
                                           continue;
View Full Code Here

                SVNStatus status = SVNStatusUtil.getStatus(skippedPath, myWCAccess);
                if (status.getContentsStatus() == SVNStatusType.STATUS_NONE ||
                    status.getContentsStatus() == SVNStatusType.STATUS_UNVERSIONED) {
                  continue;
                }
                merges.put(skippedPath, new SVNMergeRangeList(new SVNMergeRange[0]));
            }
        }
       
        if (depth != SVNDepth.INFINITY && myMergedPaths != null) {
            for (Iterator mergedPathsIter = myMergedPaths.iterator(); mergedPathsIter.hasNext();) {
                File mergedPath = (File) mergedPathsIter.next();
                SVNMergeRangeList childRangeList = null;
                SVNEntry childEntry = myWCAccess.getVersionedEntry(mergedPath, false);
                if ((childEntry.isDirectory() && mergedPath.equals(myTarget) && depth == SVNDepth.IMMEDIATES) ||
                        (childEntry.isFile() && depth == SVNDepth.FILES)) {
                    childRangeList = rangeList.dup();
                    SVNMergeRange[] childMergeRanges = childRangeList.getRanges();
                    for (int i = 0; i < childRangeList.getSize(); i++) {
                        childMergeRanges[i].setInheritable(true);
                    }
                    merges.put(mergedPath, childRangeList);
                }
            }
View Full Code Here

       
        for (Iterator mergesEntries = merges.entrySet().iterator(); mergesEntries.hasNext();) {
           
            Map.Entry pathToRangeList = (Map.Entry) mergesEntries.next();
            File path = (File) pathToRangeList.getKey();
            SVNMergeRangeList ranges = (SVNMergeRangeList) pathToRangeList.getValue();
            Map mergeInfo = null;
            try {
                // TODO this is a hack: assert that path is not missing if it is directory.
                SVNEntry pathEntry = entry.getAdminArea().getWCAccess().getEntry(path, false);
                if (pathEntry != null && pathEntry.isDirectory()) {
                    pathEntry.getAdminArea().getWCAccess().retrieve(path);
                }
              mergeInfo = SVNPropertiesManager.parseMergeInfo(path, entry, false)
            } catch (SVNException svne) {
              if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.WC_NOT_LOCKED) {
                continue;
              }
              throw svne;
            }
           
            if (mergeInfo == null && ranges.isEmpty()) {
                mergeInfo = getWCMergeInfo(path, entry, null,
                        SVNMergeInfoInheritance.NEAREST_ANCESTOR, true, new boolean[1]);
            }
           
            if (mergeInfo == null) {
                mergeInfo = new TreeMap();
            }
           
            String parent = targetPath.getAbsolutePath();
            parent = parent.replace(File.separatorChar, '/');
            String child = path.getAbsolutePath();
            child = child.replace(File.separatorChar, '/');
            String reposPath = null;
            if (parent.length() < child.length()) {
                String childRelPath = child.substring(parent.length());
                if (childRelPath.startsWith("/")) {
                    childRelPath = childRelPath.substring(1);
                }
                reposPath = SVNPathUtil.getAbsolutePath(SVNPathUtil.append(parentReposPath, childRelPath));
            } else {
                reposPath = parentReposPath;
            }
           
            SVNMergeRangeList rangeList = (SVNMergeRangeList) mergeInfo.get(reposPath);
            if (rangeList == null) {
                rangeList = new SVNMergeRangeList(new SVNMergeRange[0]);
            }
           
            if (isRollBack) {
                ranges = ranges.dup();
                ranges = ranges.reverse();
                rangeList = rangeList.diff(ranges, false);
            } else {
                rangeList = rangeList.merge(ranges);
            }
           
            mergeInfo.put(reposPath, rangeList);
            //TODO: I do not understand this:) how mergeInfo can be ever empty here????
            if (isRollBack && mergeInfo.isEmpty()) {
View Full Code Here

        filterMergedRevisions(child, mergeInfoPath,
                targetMergeInfo, implicitMergeInfo, revision1, revision2);
       
        if (isSubtree) {
            SVNMergeRangeList[] rangeListDiff = SVNMergeInfoUtil.diffMergeRangeLists(child.myRemainingRanges, parent.myRemainingRanges, true);
            SVNMergeRangeList deletedRangeList = rangeListDiff[0];
            SVNMergeRangeList addedRangeList = rangeListDiff[1];
            if (!deletedRangeList.isEmpty() || !addedRangeList.isEmpty()) {
                adjustDeletedSubTreeRanges(child, parent, revision1, revision2, primaryURL, repository);
            }
        }

        if ((child.myRemainingRanges == null || child.myRemainingRanges.isEmpty()) &&
View Full Code Here

                    if (isRollback) {
                        child.myRemainingRanges = child.myRemainingRanges.reverse();
                        parent.myRemainingRanges = parent.myRemainingRanges.reverse();
                    }
                   
                    SVNMergeRangeList existingRangeList = new SVNMergeRangeList(new SVNMergeRange(olderRev, primaryURLDeletedRevision - 1, true));
                    child.myRemainingRanges = child.myRemainingRanges.intersect(existingRangeList, false);
                   
                    SVNMergeRangeList deletedRangeList = new SVNMergeRangeList(new SVNMergeRange(primaryURLDeletedRevision - 1, pegRev, true));
                    deletedRangeList = parent.myRemainingRanges.intersect(deletedRangeList, false);
                    child.myRemainingRanges = child.myRemainingRanges.merge(deletedRangeList);
                   
                    if (isRollback) {
                        child.myRemainingRanges = child.myRemainingRanges.reverse();
                        parent.myRemainingRanges = parent.myRemainingRanges.reverse();
                    }
                }
            } else {
                throw e;           
            }
        }
       
        if (locationSegments != null && !locationSegments.isEmpty()) {
            SVNLocationSegment segment = (SVNLocationSegment) locationSegments.get(locationSegments.size() - 1);
            if (segment.getStartRevision() == olderRev) {
                return;
            }
            if (isRollback) {
                child.myRemainingRanges = child.myRemainingRanges.reverse();
                parent.myRemainingRanges = parent.myRemainingRanges.reverse();
            }
           
            SVNMergeRangeList existingRangeList = new SVNMergeRangeList(new SVNMergeRange(segment.getStartRevision(), pegRev, true));
            child.myRemainingRanges = child.myRemainingRanges.intersect(existingRangeList, false);
            SVNMergeRangeList nonExistentRangeList = new SVNMergeRangeList(new SVNMergeRange(olderRev, segment.getStartRevision(), true));
            nonExistentRangeList = parent.myRemainingRanges.intersect(nonExistentRangeList, false);
            child.myRemainingRanges = child.myRemainingRanges.merge(nonExistentRangeList);

            if (isRollback) {
                child.myRemainingRanges = child.myRemainingRanges.reverse();
View Full Code Here

    }

    private void filterMergedRevisions(MergePath child, String mergeInfoPath, Map targetMergeInfo, Map implicitMergeInfo,
            long rev1, long rev2) throws SVNException {
        Map mergeInfo = implicitMergeInfo;
        SVNMergeRangeList targetRangeList = null;
       
        if (rev1 > rev2) {
            if (targetMergeInfo != null) {
                mergeInfo = SVNMergeInfoUtil.dupMergeInfo(implicitMergeInfo, null);
                SVNMergeInfoUtil.mergeMergeInfos(mergeInfo, targetMergeInfo);
            }
            targetRangeList = (SVNMergeRangeList) mergeInfo.get(mergeInfoPath);
            if (targetRangeList != null) {
                SVNMergeRangeList requestedMergeRangeList = new SVNMergeRangeList(new SVNMergeRange(rev1, rev2, true));
                requestedMergeRangeList = requestedMergeRangeList.reverse();
                child.myRemainingRanges = targetRangeList.intersect(requestedMergeRangeList, false);
                child.myRemainingRanges = child.myRemainingRanges.reverse();
            } else {
                child.myRemainingRanges = new SVNMergeRangeList(new SVNMergeRange[0]);
            }
        } else {
            if (getOptions().isAllowAllForwardMergesFromSelf()) {
                if (targetMergeInfo != null) {
                    targetRangeList = (SVNMergeRangeList) targetMergeInfo.get(mergeInfoPath);
                }
            } else {
                if (targetMergeInfo != null) {
                    mergeInfo = SVNMergeInfoUtil.dupMergeInfo(implicitMergeInfo, null);
                    mergeInfo = SVNMergeInfoUtil.mergeMergeInfos(mergeInfo, targetMergeInfo);
                }
                targetRangeList = (SVNMergeRangeList) mergeInfo.get(mergeInfoPath);
            }
            if (targetRangeList != null) {
                SVNMergeRangeList requestedRangeList = new SVNMergeRangeList(new SVNMergeRange(rev1, rev2, true));
                child.myRemainingRanges = requestedRangeList.diff(targetRangeList, false);
            } else {
                child.myRemainingRanges = new SVNMergeRangeList(new SVNMergeRange(rev1, rev2, true));
            }
        }
    }
View Full Code Here

        }
       
        public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
            checkCancelled();
            SVNMergeRange range = new SVNMergeRange(logEntry.getRevision() - 1, logEntry.getRevision(), true);
            SVNMergeRangeList thisRangeList = new SVNMergeRangeList(range);
            SVNMergeRangeList intersection = thisRangeList.intersect(myRangeList, true);
            if (intersection == null || intersection.isEmpty()) {
                return;
            }
           
            if (intersection.getSize() != 1) {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN,
                        "assertion failure in SVNMergeDriver.LogHandlerFilter.handleLogEntry: intersection list " +
                        "size is {0}", new Integer(intersection.getSize()));
                SVNErrorManager.error(err, SVNLogType.DEFAULT);
            }
            if (myRealHandler != null) {
                myRealHandler.handleLogEntry(logEntry);
            }
View Full Code Here

        if (map == null) {
            getLog().warn("There is NO mergeinfo property, please try manually merge first.");
            return;
        }

        SVNMergeRangeList value = map.get(SVNURL.parseURIDecoded(trunk));

        long start = 1;
        if (value != null) {
            start = value.getRanges()[value.getRanges().length - 1].getEndRevision();
        } else {
            SVNLogEntryHandler handler = new SVNLogEntryHandler();
            manager.getLogClient().doLog(status.getURL(), new String[] { "." }, SVNRevision.UNDEFINED,
                    SVNRevision.create(1), /* start, defaults to peg */
                    SVNRevision.HEAD, /* end, defaults to 0 */
 
View Full Code Here

   
    private Map appendToMergedFroms(Map mergeInfo, String pathComponent) {
        Map result = new TreeMap();
        for (Iterator pathsIter = mergeInfo.keySet().iterator(); pathsIter.hasNext();) {
            String path = (String) pathsIter.next();
            SVNMergeRangeList rangeList = (SVNMergeRangeList) mergeInfo.get(path);
            result.put(SVNPathUtil.append(path, pathComponent), rangeList.dup());
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.SVNMergeRangeList$RangeComparator2

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.