Package org.tmatesoft.svn.core
Class SVNMergeRangeList
java.lang.Object
org.tmatesoft.svn.core.SVNMergeRangeList
public class SVNMergeRangeList
extends java.lang.Object
The SVNMergeRangeList represents an array of merge ranges applied to a single target.
Provides addition functionality to operate with merge range lists.
- Since:
- 1.2
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic java.lang.String
A string that is used in mergeinfo to mark the mergeinfo as being non-inheritable.private SVNMergeRange[]
-
Constructor Summary
ConstructorsConstructorDescriptionSVNMergeRangeList
(long start, long end, boolean inheritable) Creates a new merge range list initializing it with a single merge range which parameters are passed to this constructor.SVNMergeRangeList
(SVNMergeRange range) Creates a new merge range list initializing it with the specified single merge range.SVNMergeRangeList
(SVNMergeRange[] ranges) Creates a new merge range list initializing it with an array of merge ranges. -
Method Summary
Modifier and TypeMethodDescriptionprivate SVNMergeRange
combineWithLastRange
(java.util.Collection rangeList, SVNMergeRange lastRange, SVNMergeRange mRange, boolean dupMRange, boolean considerInheritance) diff
(SVNMergeRangeList eraserRangeList, boolean considerInheritance) RemoveseraserRangeList
(the subtrahend) from this range list (the minuend), and places the resulting difference into a newSVNMergeRangeList
object.dup()
Makes a copy of this merge range list.static SVNMergeRangeList
fromCollection
(java.util.Collection mergeRanges) Creates a newSVNMergeRangeList
from a collection ofmerge ranges
.getInheritableRangeList
(long startRev, long endRev) Returns a sublist of this range list which excludes all non-inheritable merge ranges.getInheritableRangeList
(long startRev, long endRev, boolean inheritable) Returns an array ofSVNMergeRange
ranges backed by this merge range list object.java.util.List<SVNMergeRange>
Returns a list of merge ranges backed by this merge range list.int
getSize()
Returns number of merge ranges stored in this merge range list.boolean
includes
(long revision) Runs through all merge ranges in this object and says, whether the specifiedrevision
falls between start and end revision of any of those ranges.intersect
(SVNMergeRangeList rangeList, boolean considerInheritance) Finds the intersection of this range list andrangeList
and places the result into a newSVNMergeRangeList
object.boolean
isEmpty()
Checks whether this merge range list has no merge ranges.merge
(SVNMergeRangeList rangeList) Merges two range lists placing the results into a newSVNMergeRangeList
object.mergeRevision
(long revision) void
pushRange
(long start, long end, boolean inheritable) Appends a new merge range to the end of the ranges list.remove
(SVNMergeRangeList remove, boolean considerInheritance) private SVNMergeRangeList
removeOrIntersect
(SVNMergeRangeList eraserRangeList, boolean remove, boolean considerInheritance) reverse()
Reverses this range list, and the start and end fields of each range in this range list, in place.void
setInheritable
(boolean inheritable) void
setRanges
(SVNMergeRange[] ranges) Replaces the array ofSVNMergeRange
objects backed by this object with a new one.java.lang.String
toString()
Returns a string representation of this object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
MERGE_INFO_NONINHERITABLE_STRING
public static java.lang.String MERGE_INFO_NONINHERITABLE_STRINGA string that is used in mergeinfo to mark the mergeinfo as being non-inheritable. -
myRanges
-
-
Constructor Details
-
SVNMergeRangeList
public SVNMergeRangeList(long start, long end, boolean inheritable) Creates a new merge range list initializing it with a single merge range which parameters are passed to this constructor.- Parameters:
start
- merge range start revisionend
- merge range end revisioninheritable
- inheritance information
-
SVNMergeRangeList
Creates a new merge range list initializing it with the specified single merge range.- Parameters:
range
- merge range
-
SVNMergeRangeList
Creates a new merge range list initializing it with an array of merge ranges. Note:ranges
are not copied to a separate array but stored immediately, as is.- Parameters:
ranges
- merge ranges array
-
-
Method Details
-
setRanges
Replaces the array ofSVNMergeRange
objects backed by this object with a new one. This method was introduced because of purposes of convenience. Use this method with care as it changes the internal state of thisSVNMergeRangeList
object.- Parameters:
ranges
- new merge ranges array- Since:
- 1.2.2
-
setInheritable
public void setInheritable(boolean inheritable) -
getRanges
Returns an array ofSVNMergeRange
ranges backed by this merge range list object. Note: this method does not make a copy of the original array, instead it returns the original array itself. If you want a safe copy of merge ranges, usegetRangesAsList()
instead. Note: merge ranges returned in the array are not copied.- Returns:
- array of merge ranges
-
getRangesAsList
Returns a list of merge ranges backed by this merge range list. Note: ranges themselves are not copied but placed in the list as is.- Returns:
- a new list instance containing all of the ranges stored in this merge range list
-
pushRange
public void pushRange(long start, long end, boolean inheritable) Appends a new merge range to the end of the ranges list. A newSVNMergeRange
is created used the parameters passed to this method.- Parameters:
start
- merge range start revisionend
- merge range end revisioninheritable
- inheritance information
-
getSize
public int getSize()Returns number of merge ranges stored in this merge range list.- Returns:
- number of merge ranges
-
isEmpty
public boolean isEmpty()Checks whether this merge range list has no merge ranges.- Returns:
- true if this merge range list is empty; otherwise false
-
dup
Makes a copy of this merge range list. All merge ranges stored in this list will be copied to a new array which will be covered into a newSVNMergeRangeList
instance.- Returns:
- copy of this merge range list
-
merge
Merges two range lists placing the results into a newSVNMergeRangeList
object. Either range list may be empty. When intersecting range lists are merged, the inheritability of the resultingSVNMergeRange
depends on the inheritability of the operands. If two non-inheritable ranges are merged the result is always non-inheritable, in all other cases the resulting range is inheritable. Note: range lists must be sorted in ascending order. The return range list is guaranteed to remain in sorted order and be compacted to the minimal number of ranges needed to represent the merged result. Note: this method does not change the state of this object. Instead it produces a result in a new object.- Parameters:
rangeList
- range list to merge with- Returns:
- resultant range list
- Throws:
SVNException
-
toString
public java.lang.String toString()Returns a string representation of this object.- Overrides:
toString
in classjava.lang.Object
- Returns:
- this object as a string
-
diff
RemoveseraserRangeList
(the subtrahend) from this range list (the minuend), and places the resulting difference into a newSVNMergeRangeList
object.- Parameters:
eraserRangeList
- ranges to remove from this range listconsiderInheritance
- whether inheritance information should be taken into account- Returns:
- the resultant difference
-
intersect
Finds the intersection of this range list andrangeList
and places the result into a newSVNMergeRangeList
object.- Parameters:
rangeList
- range list to intersect withconsiderInheritance
- whether inheritance information should be taken into account- Returns:
- the result of intersection
-
includes
public boolean includes(long revision) Runs through all merge ranges in this object and says, whether the specifiedrevision
falls between start and end revision of any of those ranges.- Parameters:
revision
- revision to find in ranges- Returns:
- true if one of the ranges in this list includes the
specified
revision
-
reverse
Reverses this range list, and the start and end fields of each range in this range list, in place.- Returns:
- this object itself
-
getInheritableRangeList
Returns a sublist of this range list which excludes all non-inheritable merge ranges. IfstartRev
andendRev
arevalid
revisions andstartRev
is less than or equal toendRev
, then excludes only the non-inheritable revision ranges that intersect inclusively with the range defined bystartRev
andendRev
. If this range list contains no elements, returns an empty array.- Parameters:
startRev
- start revisionendRev
- end revision- Returns:
- a new
SVNMergeRangeList
object with only inheritable ranges from this range list
-
getInheritableRangeList
-
fromCollection
Creates a newSVNMergeRangeList
from a collection ofmerge ranges
.- Parameters:
mergeRanges
- merge ranges collection- Returns:
- merge range list containing all the ranges from
mergeRanges
-
removeOrIntersect
private SVNMergeRangeList removeOrIntersect(SVNMergeRangeList eraserRangeList, boolean remove, boolean considerInheritance) -
remove
-
combineWithLastRange
private SVNMergeRange combineWithLastRange(java.util.Collection rangeList, SVNMergeRange lastRange, SVNMergeRange mRange, boolean dupMRange, boolean considerInheritance) -
mergeRevision
-