Package org.tmatesoft.svn.core

Examples of org.tmatesoft.svn.core.SVNMergeRange


            RangeListPath rangeListPath = new RangeListPath();
            rangeListPath.myPath = path;
            rangeListPath.myRangeList = changes.dup();
            SVNMergeRange[] rangesArray = rangeListPath.myRangeList.getRanges();
            for (int i = 0; i < rangesArray.length; i++) {
                SVNMergeRange range = rangesArray[i];
                range.setStartRevision(range.getStartRevision() + 1);
            }
            rangeListPaths.add(rangeListPath);
        }
       
        LinkedList combinedList = new LinkedList();
        Comparator rangeListPathsComparator = new Comparator() {
            public int compare(Object arg1, Object arg2) {
                RangeListPath rangeListPath1 = (RangeListPath) arg1;
                RangeListPath rangeListPath2 = (RangeListPath) arg2;
                SVNMergeRange[] ranges1 = rangeListPath1.myRangeList.getRanges();
                SVNMergeRange[] ranges2 = rangeListPath2.myRangeList.getRanges();
                SVNMergeRange range1 = ranges1[0];
                SVNMergeRange range2 = ranges2[0];
                if (range1.getStartRevision() < range2.getStartRevision()) {
                    return -1;
                }
                if (range1.getStartRevision() > range2.getStartRevision()) {
                    return 1;
                }
                if (range1.getEndRevision() < range2.getEndRevision()) {
                    return -1;
                }
                if (range1.getEndRevision() > range2.getEndRevision()) {
                    return 1;
                }
                return 0;
            }
        };
       
        while (rangeListPaths.size() > 1) {
            Collections.sort(rangeListPaths, rangeListPathsComparator);
            RangeListPath rangeListPath = (RangeListPath) rangeListPaths.get(0);
            RangeListPath firstRLP = rangeListPath;
            long youngest = rangeListPath.myRangeList.getRanges()[0].getStartRevision();
            long nextYoungest = youngest;
            int numRevs = 1;
            for (; nextYoungest == youngest; numRevs++) {
                if (numRevs == rangeListPaths.size()) {
                    numRevs++;
                    break;
                }
                rangeListPath = (RangeListPath) rangeListPaths.get(numRevs);
                nextYoungest = rangeListPath.myRangeList.getRanges()[0].getStartRevision();
            }
            numRevs--;
            long youngestEnd = firstRLP.myRangeList.getRanges()[0].getEndRevision();
            long tail = nextYoungest - 1;
            if (nextYoungest == youngest || youngestEnd < nextYoungest) {
                tail = youngestEnd;
            }

            PathListRange pathListRange = new PathListRange();
            pathListRange.myRange = new SVNMergeRange(youngest, tail, false);
            List paths = new LinkedList();
            for (int i = 0; i < numRevs; i++) {
                RangeListPath rp = (RangeListPath) rangeListPaths.get(i);
                paths.add(rp.myPath);
            }
            pathListRange.myPaths = (String[]) paths.toArray(new String[paths.size()]);
       
            combinedList.add(pathListRange);
           
            for (int i = 0; i < numRevs; i++) {
                RangeListPath rp = (RangeListPath) rangeListPaths.get(i);
                SVNMergeRange range = rp.myRangeList.getRanges()[0];
                range.setStartRevision(tail + 1);
                if (range.getStartRevision() > range.getEndRevision()) {
                    if (rp.myRangeList.getSize() == 1) {
                        rangeListPaths.remove(0);
                        i--;
                        numRevs--;
                    } else {
View Full Code Here


                for (Iterator mergeInfoIter = mergedMergeInfo.keySet().iterator(); mergeInfoIter.hasNext();) {
                    String path = (String) mergeInfoIter.next();
                    SVNMergeRangeList rangeList = (SVNMergeRangeList) mergedMergeInfo.get(path);
                    SVNMergeRange[] ranges = rangeList.getRanges();
                    for (int j = 0; j < ranges.length; j++) {
                        SVNMergeRange range = ranges[j];
                        FSRevisionRoot root = myFSFS.createRevisionRoot(range.getEndRevision());
                        SVNNodeKind kind = root.checkNodeKind(path);
                        if (kind != SVNNodeKind.FILE) {
                            continue;
                        }
                       
                        newPathRevisions = findInterestingRevisions(newPathRevisions, path,
                                range.getStartRevision(), range.getEndRevision(), true, true, duplicatePathRevs);
                    }
                }
            }
            mergedPathRevisions.addAll(newPathRevisions);
            oldPathRevisions = newPathRevisions;
View Full Code Here

                if (newNearestAncestorIndex != myCurrentAncestorIndex) {
                    MergePath child = (MergePath) childrenWithMergeInfoArray[newNearestAncestorIndex];
                    myCurrentAncestorIndex = newNearestAncestorIndex;
                    if (!child.myIsAbsent && !child.myRemainingRanges.isEmpty() &&
                            !(newNearestAncestorIndex == 0 && myIsTargetHasDummyMergeRange)) {
                        SVNMergeRange ranges[] = child.myRemainingRanges.getRanges();
                        SVNEvent mergeBeginEvent = SVNEventFactory.createSVNEvent(child.myPath,
                                SVNNodeKind.UNKNOWN, null, SVNRepository.INVALID_REVISION,
                                myIsSameRepository ? SVNEventAction.MERGE_BEGIN : SVNEventAction.FOREIGN_MERGE_BEGIN, null, null, ranges[0]);
                        super.handleEvent(mergeBeginEvent, ISVNEventHandler.UNKNOWN);
                    }
View Full Code Here

        }
       
        SVNMergeRange[] listRanges = rangeList.getRanges();
        Arrays.sort(listRanges);
       
        SVNMergeRange youngestRange = listRanges[listRanges.length - 1];
        SVNRevision youngestRev = SVNRevision.create(youngestRange.getEndRevision());
        SVNMergeRange oldestRange = listRanges[0];
        SVNRevision oldestRev = SVNRevision.create(oldestRange.getStartRevision());
           
        LogHandlerFilter filterHandler = new LogHandlerFilter(handler, rangeList);
        SVNLogClient logClient = getLogClient();
        logClient.doLog(reposRootURL, paths, youngestRev, oldestRev, youngestRev, false, discoverChangedPaths,
                false, 0, revProps, filterHandler);
View Full Code Here

        boolean[] indirect = { false };
        Map targetMergeInfo = null;
        Map implicitMergeInfo = null;
        String mergeInfoPath = null;
        SVNMergeRangeList remainingRangeList = null;
        SVNMergeRange conflictedRange = null;
       
        myWCAccess.probeTry(targetWCPath, true, SVNWCAccess.INFINITE_DEPTH);
        SVNEntry entry = myWCAccess.getVersionedEntry(targetWCPath, false);
       
        SVNMergeRange range = new SVNMergeRange(revision1, revision2, true);
        if (honorMergeInfo) {
            MergePath mergeTarget = new MergePath();
            SVNURL sourceRootURL = myRepository1.getRepositoryRoot(true);
            mergeInfoPath = getPathRelativeToRoot(null, primaryURL, sourceRootURL, null, null);
           
            myRepository1.setLocation(entry.getSVNURL(), false);
            Map[] fullMergeInfo = getFullMergeInfo(entry, indirect, SVNMergeInfoInheritance.INHERITED,
                    myRepository1, targetWCPath, Math.max(revision1, revision2), Math.min(revision1, revision2));
            targetMergeInfo = fullMergeInfo[0];
            implicitMergeInfo = fullMergeInfo[1];
            myRepository1.setLocation(url1, false);

            if (!myIsRecordOnly) {
                calculateRemainingRanges(null, mergeTarget, sourceRootURL, url1, revision1, url2, revision2,
                        targetMergeInfo, implicitMergeInfo, false, entry, myRepository1);
                remainingRangeList = mergeTarget.myRemainingRanges;
            }
        }
       
        if (!honorMergeInfo || myIsRecordOnly) {
            remainingRangeList = new SVNMergeRangeList(range);
        }
       
        SVNMergeRange[] remainingRanges = remainingRangeList.getRanges();
        SVNMergeCallback callback = new SVNMergeCallback(adminArea, myURL, myIsForce, myIsDryRun,
                getMergeOptions(), myConflictedPaths, this);

        String targetName = targetWCPath.getName();
        if (!myIsRecordOnly) {
            SVNMergeRangeList rangeListToMerge = remainingRangeList;
            if (myAreSourcesAncestral && remainingRangeList.getSize() > 1) {
                SVNURL oldSessionURL = ensureSessionURL(myRepository1, primaryURL);
                rangeListToMerge = removeNoOpMergeRanges(myRepository1, remainingRangeList);
                if (oldSessionURL != null) {
                    myRepository1.setLocation(oldSessionURL, false);
                }
            }
           
            SVNMergeRange[] rangesToMerge = rangeListToMerge.getRanges();
           
            for (int i = 0; i < rangesToMerge.length; i++) {
                SVNMergeRange nextRange = rangesToMerge[i];
                boolean headerSent = false;
                SVNEvent event = SVNEventFactory.createSVNEvent(targetWCPath, SVNNodeKind.UNKNOWN, null,
                        SVNRepository.INVALID_REVISION, myIsSameRepository ? SVNEventAction.MERGE_BEGIN : SVNEventAction.FOREIGN_MERGE_BEGIN, null, null,
                        myAreSourcesAncestral ? nextRange : null);

                SVNProperties props1 = new SVNProperties();
                SVNProperties props2 = new SVNProperties();
                File f1 = null;
                File f2 = null;

                String mimeType2;
                String mimeType1;
                SVNStatusType[] mergeResult;
               
                SVNRepository repos1 = myRepository1;
                SVNRepository repos2 = myRepository2;
                if (honorMergeInfo && !url1.equals(url2)) {
                    if (!isRollBack && nextRange.getStartRevision() != revision1) {
                        repos1 = repos2;
                    } else if (isRollBack && nextRange.getEndRevision() != revision2) {
                        repos2 = repos1;
                    }
                }

                try {
                    f1 = loadFile(repos1, nextRange.getStartRevision(), props1, adminArea);
                    f2 = loadFile(repos2, nextRange.getEndRevision(), props2, adminArea);

                    mimeType1 = props1.getStringValue(SVNProperty.MIME_TYPE);
                    mimeType2 = props2.getStringValue(SVNProperty.MIME_TYPE);
                    props1 = filterProperties(props1, true, false, false);
                    props2 = filterProperties(props2, true, false, false);

                    SVNProperties propsDiff = computePropsDiff(props1, props2);
                   
                    if (!(myIsIgnoreAncestry || sourcesRelated)) {
                        SVNStatusType cstatus = callback.fileDeleted(targetName, f1, f2, mimeType1,
                                mimeType2, props1);
                        headerSent = notifySingleFileMerge(targetWCPath, SVNEventAction.UPDATE_DELETE, cstatus,
                                SVNStatusType.UNKNOWN, event, headerSent);
                       
                        mergeResult = callback.fileAdded(targetName, f1, f2, nextRange.getStartRevision(),
                                                         nextRange.getEndRevision(), mimeType1, mimeType2,
                                                         props1, propsDiff);
                        headerSent = notifySingleFileMerge(targetWCPath, SVNEventAction.UPDATE_ADD,
                                        mergeResult[0], mergeResult[1], event, headerSent);
                    } else {
                        mergeResult = callback.fileChanged(targetName, f1, f2, nextRange.getStartRevision(),
                                                           nextRange.getEndRevision(), mimeType1,
                                                           mimeType2, props1, propsDiff);
                        headerSent = notifySingleFileMerge(targetWCPath, SVNEventAction.UPDATE_UPDATE,
                                        mergeResult[0], mergeResult[1], event, headerSent);
                    }
                } finally {
View Full Code Here

     
      myChildrenWithMergeInfo = new LinkedList();
      if (!(myAreSourcesAncestral && myIsSameRepository)) {
        if (myAreSourcesAncestral) {
          MergePath item = new MergePath(targetWCPath);
          SVNMergeRange itemRange = new SVNMergeRange(revision1, revision2, true);
          item.myRemainingRanges = new SVNMergeRangeList(itemRange);
          myChildrenWithMergeInfo.add(item);
        }
        driveMergeReportEditor(targetWCPath, url1, revision1, url2, revision2, null, isRollBack,
            depth, adminArea, mergeCallback, null);
        return;
      }
     
      SVNRepository repository = isRollBack ? myRepository1 : myRepository2;
      SVNURL sourceRootURL = repository.getRepositoryRoot(true);
      String mergeInfoPath = getPathRelativeToRoot(null, primaryURL, sourceRootURL, null, null);
      myChildrenWithMergeInfo = getMergeInfoPaths(myChildrenWithMergeInfo, mergeInfoPath, parentEntry,
          sourceRootURL, revision1, revision2, repository, depth);

      MergePath targetMergePath = (MergePath) myChildrenWithMergeInfo.get(0);
        myIsTargetMissingChild = targetMergePath.myHasMissingChildren;
        boolean inheritable = !myIsTargetMissingChild && (depth == SVNDepth.INFINITY ||  depth == SVNDepth.IMMEDIATES);
       
        populateRemainingRanges(myChildrenWithMergeInfo, sourceRootURL, url1, revision1, url2, revision2,
            inheritable, honorMergeInfo, repository);
       
        SVNMergeRange range = new SVNMergeRange(revision1, revision2, inheritable);
        SVNRemoteDiffEditor editor = null;
        SVNErrorMessage err = null;
        if (honorMergeInfo && !myIsRecordOnly) {
          long startRev = getMostInclusiveStartRevision(myChildrenWithMergeInfo, isRollBack);
          if (SVNRevision.isValidRevisionNumber(startRev)) {
            range.setStartRevision(startRev);
                long endRev = getYoungestEndRevision(myChildrenWithMergeInfo, isRollBack);
                while (SVNRevision.isValidRevisionNumber(endRev)) {
                    SVNURL realURL1 = url1;
                    SVNURL realURL2 = url2;
                    SVNURL oldURL1 = null;
                    SVNURL oldURL2 = null;
                    long nextEndRev = SVNRepository.INVALID_REVISION;
                   
                    sliceRemainingRanges(myChildrenWithMergeInfo, isRollBack, endRev);
                    myCurrentAncestorIndex = -1;
                    if (!sameURLs) {
                        if (isRollBack && endRev != revision2) {
                            realURL2 = url1;
                            oldURL2 = ensureSessionURL(myRepository2, realURL2);
                        }
                        if (!isRollBack && startRev != revision1) {
                            realURL1 = url2;
                            oldURL1 = ensureSessionURL(myRepository1, realURL1);
                        }
                    }
                   
                    try {
                        editor = driveMergeReportEditor(myTarget, realURL1, startRev, realURL2, endRev,
                                myChildrenWithMergeInfo, isRollBack, depth, adminArea, mergeCallback, editor);
                    } finally {
                        if (oldURL1 != null) {
                            myRepository1.setLocation(oldURL1, false);
                        }
                        if (oldURL2 != null) {
                            myRepository2.setLocation(oldURL2, false);
                        }
                    }
                   
                    removeFirstRangeFromRemainingRanges(endRev, myChildrenWithMergeInfo);
                    nextEndRev = getYoungestEndRevision(myChildrenWithMergeInfo, isRollBack);
                    if (SVNRevision.isValidRevisionNumber(nextEndRev) && myConflictedPaths != null &&
                            !myConflictedPaths.isEmpty()) {
                        SVNMergeRange conflictedRange = new SVNMergeRange(startRev, endRev, false);
                        err = makeMergeConflictError(myTarget, conflictedRange);
                        range.setEndRevision(endRev);
                        break;
                    }
                    startRev = endRev;
                    endRev = nextEndRev;
                }
          }
        } else {
          if (!myIsRecordOnly) {
                myCurrentAncestorIndex = -1;
                editor = driveMergeReportEditor(myTarget, url1, revision1, url2, revision2, null, isRollBack,
                        depth, adminArea, mergeCallback, editor);
          }
        }

        if (recordMergeInfo) {
            MergePath mergeTarget = (MergePath) myChildrenWithMergeInfo.get(0);
            removeAbsentChildren(myTarget, myChildrenWithMergeInfo);
            SVNMergeRangeList filteredRangeList = filterNaturalHistoryFromMergeInfo(mergeInfoPath,
                    mergeTarget.myImplicitMergeInfo, range);
            if (!filteredRangeList.isEmpty()) {
                Map merges = determinePerformedMerges(myTarget, filteredRangeList, depth);
                recordMergeInfoOnMergedChildren(depth);
                updateWCMergeInfo(myTarget, mergeInfoPath, parentEntry, merges, isRollBack);
            }
         
            for (int i = 0; i < myChildrenWithMergeInfo.size(); i++) {
        MergePath child = (MergePath) myChildrenWithMergeInfo.get(i);
        if (child == null || child.myIsAbsent) {
          continue;
        }
       
        String childReposPath = null;
        if (child.myPath.equals(myTarget)) {
          childReposPath = "";
        } else {
                    childReposPath = SVNPathUtil.getRelativePath(myTarget.getAbsolutePath(),
                        child.myPath.getAbsolutePath());
        }
               
        SVNEntry childEntry = myWCAccess.getVersionedEntry(child.myPath, false);
                String childMergeSourcePath = SVNPathUtil.getAbsolutePath(SVNPathUtil.append(mergeInfoPath,
                    childReposPath));
               
              Map childMerges = new TreeMap();
              SVNMergeRangeList childMergeRangeList = filterNaturalHistoryFromMergeInfo(childMergeSourcePath,
                      child.myImplicitMergeInfo, range);
              if (childMergeRangeList.isEmpty()) {
                  continue;
              }
             
              SVNMergeRange[] childMergeRanges = childMergeRangeList.getRanges();
              for (int j = 0; j < childMergeRangeList.getSize(); j++) {
                  SVNMergeRange rng = childMergeRanges[j];
                  if (childEntry.isFile()) {
                      rng.setInheritable(true);
                  } else {
                      rng.setInheritable(!child.myHasMissingChildren && (depth == SVNDepth.INFINITY ||
                              depth == SVNDepth.IMMEDIATES));
                  }
              }
             
                childMerges.put(child.myPath, childMergeRangeList);
                if (child.myIsIndirectMergeInfo) {
                    SVNPropertiesManager.recordWCMergeInfo(child.myPath, child.myPreMergeMergeInfo,
                            myWCAccess);
                }
                updateWCMergeInfo(child.myPath, childMergeSourcePath, childEntry, childMerges, isRollBack);

        markMergeInfoAsInheritableForARange(child.myPath, childMergeSourcePath,
            child.myPreMergeMergeInfo, range, myChildrenWithMergeInfo, true, i);
                if (i > 0) {
                    boolean isInSwitchedSubTree = false;
                    if (child.myIsSwitched) {
                        isInSwitchedSubTree = true;
                    } else if (i > 1) {
                        for (int j = i - 1; j > 0; j--) {
                            MergePath parent = (MergePath) myChildrenWithMergeInfo.get(j);
                            if (parent != null && parent.myIsSwitched &&
                                    SVNPathUtil.isAncestor(parent.myPath.getAbsolutePath().replace(File.separatorChar, '/'),
                                    child.myPath.getAbsolutePath().replace(File.separatorChar, '/'))) {
                                isInSwitchedSubTree = true;
                                break;
                            }
                        }
                    }
                   
                    elideMergeInfo(myWCAccess, child.myPath, childEntry, isInSwitchedSubTree ? null : myTarget);
                }
          }
        }
       
        if (myAddedPaths != null) {
          for (Iterator addedPathsIter = myAddedPaths.iterator(); addedPathsIter.hasNext();) {
        File addedPath = (File) addedPathsIter.next();
        SVNPropertyValue addedPathParentPropValue = SVNPropertiesManager.getProperty(myWCAccess,
            addedPath.getParentFile(), SVNProperty.MERGE_INFO);
        String addedPathParentPropValueStr = addedPathParentPropValue != null ?
            addedPathParentPropValue.getString() : null;
        if (addedPathParentPropValueStr != null &&
            addedPathParentPropValueStr.indexOf(SVNMergeRangeList.MERGE_INFO_NONINHERITABLE_STRING) != -1) {
          String addedPathStr = addedPath.getAbsolutePath().replace(File.separatorChar, '/');
          String targetMergePathStr = targetMergePath.myPath.getAbsolutePath().replace(File.separatorChar, '/');
          String commonAncestorPath = SVNPathUtil.getCommonPathAncestor(addedPathStr,
              targetMergePathStr);
          String relativeAddedPath = SVNPathUtil.getRelativePath(commonAncestorPath, addedPathStr);
          SVNEntry entry = myWCAccess.getVersionedEntry(addedPath, false);
          Map mergeMergeInfo = new TreeMap();
          SVNMergeRange rng = range.dup();
          if (entry.isFile()) {
            rng.setInheritable(true);
          } else {
            rng.setInheritable(!(depth == SVNDepth.INFINITY || depth == SVNDepth.IMMEDIATES));
          }
          SVNMergeRangeList rangeList = new SVNMergeRangeList(rng);
          mergeMergeInfo.put(SVNPathUtil.getAbsolutePath(SVNPathUtil.append(mergeInfoPath,
              relativeAddedPath)), rangeList);
          boolean[] inherited = { false };
View Full Code Here

                Map filteredMergeInfo = null;
                Map mergeInfo = SVNMergeInfoUtil.parseMergeInfo(new StringBuffer(propValue.getString()), null);
                for (Iterator mergeInfoIter = mergeInfo.keySet().iterator(); mergeInfoIter.hasNext();) {
                    String sourcePath = (String) mergeInfoIter.next();
                    SVNMergeRangeList rangeList = (SVNMergeRangeList) mergeInfo.get(sourcePath);
                    SVNMergeRange ranges[] = rangeList.getRanges();
                    LinkedList adjustedRanges = new LinkedList();
                    SVNURL mergeSourceURL = mergeSourceRootURL.appendPath(sourcePath, false);
                    for (int i = 0; i < ranges.length; i++) {
                        SVNMergeRange range = ranges[i];
                        SVNRepositoryLocation[] locations = null;
                        try {
                            locations = getLocations(targetURL, null, myRepository2,
                                    SVNRevision.create(targetEntry.getRevision()),
                                    SVNRevision.create(range.getStartRevision() + 1), SVNRevision.UNDEFINED);
                            SVNURL startURL = locations[0].getURL();
                            if (!mergeSourceURL.equals(startURL)) {
                                adjustedRanges.add(range);
                            }
                        } catch (SVNException svne) {
View Full Code Here

        for (Iterator pathsIter = historyAsMergeInfo.keySet().iterator(); pathsIter.hasNext();) {
            String path = (String) pathsIter.next();
            SVNMergeRangeList rangeList = (SVNMergeRangeList) historyAsMergeInfo.get(path);
            SVNMergeRange[] ranges = rangeList.getRanges();
            for (int i = 0; i < ranges.length; i++) {
                SVNMergeRange mergeRange = ranges[i];
                if (mergeRange.getStartRevision() >= mergeRange.getEndRevision()) {
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "range start >= end");
                    SVNErrorManager.error(err, SVNLogType.DEFAULT);
                }
               
                SVNDirEntry dirEntry = repository.info(path, mergeRange.getEndRevision());
                if (mergeRangeContainsRevision(mergeRange, dirEntry.getRevision())) {
                    SVNURL fullURL = repository.getLocation();
                    if (path.startsWith("/")) {
                        path = path.substring(1);
                    }
View Full Code Here

                    continue;
                }
                SVNMergeRangeList rangeList = (SVNMergeRangeList) sourceMergeInfo.get(segment.getPath());
                if (rangeList != null && !rangeList.isEmpty()) {
                    SVNMergeRange[] ranges = rangeList.getRanges();
                    SVNMergeRange lastRange = ranges[ranges.length - 1];
                    leftRev[0] = lastRange.getEndRevision();
                    leftURL[0] = sourceReposRoot.appendPath(segment.getPath().startsWith("/") ?
                            segment.getPath().substring(1) : segment.getPath(), false);
                    return SVNMergeInfoUtil.dupMergeInfo(sourceMergeInfo, null);
                }
            }
View Full Code Here

      }
     
      long rangeStartRev = getRevisionNumber(rangeStart, youngestRevision, repository, source);
      long rangeEndRev = getRevisionNumber(rangeEnd, youngestRevision, repository, source);
      if (rangeStartRev != rangeEndRev) {
        SVNMergeRange range = new SVNMergeRange(rangeStartRev, rangeEndRev, true);
        mergeRanges.add(range);
      }
      }
     
      SVNMergeRangeList mergeRangesList = SVNMergeRangeList.fromCollection(mergeRanges);
      mergeRangesList = mergeRangesList.compactMergeRanges();
      mergeRanges = mergeRangesList.getRangesAsList();
      if (mergeRanges.isEmpty()) {
        return mergeRanges;
      }
     
      long oldestRequestedRev = SVNRepository.INVALID_REVISION;
      long youngestRequestedRev = SVNRepository.INVALID_REVISION;
      for (Iterator rangesIter = mergeRanges.iterator(); rangesIter.hasNext();) {
      SVNMergeRange range = (SVNMergeRange) rangesIter.next();
      long minRev = Math.min(range.getStartRevision(), range.getEndRevision());
      long maxRev = Math.max(range.getStartRevision(), range.getEndRevision());
     
      if (!SVNRevision.isValidRevisionNumber(oldestRequestedRev) || minRev < oldestRequestedRev) {
        oldestRequestedRev = minRev;
      }
      if (!SVNRevision.isValidRevisionNumber(youngestRequestedRev) || maxRev > youngestRequestedRev) {
        youngestRequestedRev = maxRev;
      }
    }
     
      if (pegRevNum < youngestRequestedRev) {
            getLocations(sourceURL, null, repository, SVNRevision.create(pegRevNum),
                    SVNRevision.create(youngestRequestedRev), SVNRevision.UNDEFINED);
            pegRevNum = youngestRequestedRev;
      }

      LinkedList segments = (LinkedList) repository.getLocationSegments("", pegRevNum, youngestRequestedRev,
          oldestRequestedRev);

    long trimRevision =  SVNRepository.INVALID_REVISION;
    if (!segments.isEmpty()) {
        SVNLocationSegment segment = (SVNLocationSegment) segments.get(0);
        if (segment.getStartRevision() != oldestRequestedRev) {
            trimRevision = segment.getStartRevision();
        } else if (segment.getPath() == null) {
            if (segments.size() > 1) {
                SVNLocationSegment segment2 = (SVNLocationSegment) segments.get(1);
                SVNURL segmentURL = sourceRootURL.appendPath(segment2.getPath(), false);
                SVNLocationEntry copyFromLocation = getCopySource(null, segmentURL,
                        SVNRevision.create(segment2.getStartRevision()));
                String copyFromPath = copyFromLocation.getPath();
                long copyFromRevision = copyFromLocation.getRevision();
                if (copyFromPath != null && SVNRevision.isValidRevisionNumber(copyFromRevision)) {
                    SVNLocationSegment newSegment = new SVNLocationSegment(copyFromRevision,
                            copyFromRevision, copyFromPath);
                    segment.setStartRevision(copyFromRevision + 1);
                    segments.addFirst(newSegment);
                }
            }
        }
    }

    SVNLocationSegment[] segmentsArray = (SVNLocationSegment[]) segments.toArray(new SVNLocationSegment[segments.size()]);
    List resultMergeSources = new LinkedList();
      for (Iterator rangesIter = mergeRanges.iterator(); rangesIter.hasNext();) {
      SVNMergeRange range = (SVNMergeRange) rangesIter.next();
      if (SVNRevision.isValidRevisionNumber(trimRevision)) {
          if (Math.max(range.getStartRevision(), range.getEndRevision()) < trimRevision) {
              continue;
          }
          if (range.getStartRevision() < trimRevision) {
              range.setStartRevision(trimRevision);
          }
          if (range.getEndRevision() < trimRevision) {
              range.setEndRevision(trimRevision);
          }
      }
      List mergeSources = combineRangeWithSegments(range, segmentsArray, sourceRootURL);
      resultMergeSources.addAll(mergeSources);
      }
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.SVNMergeRange

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.