~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/bindings/javahl/src/org/apache/subversion/javahl/types/RevisionRange.java

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 */
30
30
public class RevisionRange implements Comparable<RevisionRange>, java.io.Serializable
31
31
{
32
 
    // Update the serialVersionUID when there is a incompatible change
33
 
    // made to this class.  See any of the following, depending upon
34
 
    // the Java release.
35
 
    // http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/version.doc7.html
36
 
    // http://java.sun.com/j2se/1.4/pdf/serial-spec.pdf
37
 
    // http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/version.html#6678
38
 
    // http://java.sun.com/javase/6/docs/platform/serialization/spec/version.html#6678
39
 
    private static final long serialVersionUID = 1L;
 
32
    // Update the serialVersionUID when there is a incompatible change made to
 
33
    // this class.  See the java documentation for when a change is incompatible.
 
34
    // http://java.sun.com/javase/7/docs/platform/serialization/spec/version.html#6678
 
35
    private static final long serialVersionUID = 2L;
40
36
 
41
37
    private Revision from;
42
38
    private Revision to;
 
39
    private boolean inheritable;
43
40
 
44
41
    /**
45
42
     * Creates a new instance.  Called by native library.
46
43
     */
47
 
    @SuppressWarnings("unused")
48
 
    private RevisionRange(long from, long to)
 
44
    protected RevisionRange(long from, long to, boolean inheritable)
49
45
    {
50
46
        this.from = Revision.getInstance(from);
51
47
        this.to = Revision.getInstance(to);
 
48
        this.inheritable = inheritable;
 
49
    }
 
50
 
 
51
    /** @since 1.9 */
 
52
    public RevisionRange(Revision from, Revision to, boolean inheritable)
 
53
    {
 
54
        this.from = from;
 
55
        this.to = to;
 
56
        this.inheritable = inheritable;
52
57
    }
53
58
 
54
59
    public RevisionRange(Revision from, Revision to)
55
60
    {
56
61
        this.from = from;
57
62
        this.to = to;
 
63
        this.inheritable = true;
58
64
    }
59
65
 
60
66
    /**
70
76
            return;
71
77
        }
72
78
 
 
79
        this.inheritable = !revisionElement.endsWith("*");
 
80
        if (!this.inheritable)
 
81
            revisionElement =
 
82
                revisionElement.substring(0, revisionElement.length() - 1);
 
83
 
73
84
        int hyphen = revisionElement.indexOf('-');
74
85
        if (hyphen > 0)
75
86
        {
93
104
            try
94
105
            {
95
106
                long revNum = Long.parseLong(revisionElement.trim());
96
 
                this.from = new Revision.Number(revNum);
97
 
                this.to = this.from;
 
107
                if (revNum <= 0)
 
108
                    return;
 
109
                this.to = new Revision.Number(revNum);
 
110
                this.from = new Revision.Number(revNum - 1);
98
111
            }
99
112
            catch (NumberFormatException e)
100
113
            {
113
126
        return to;
114
127
    }
115
128
 
 
129
    public boolean isInheritable()
 
130
    {
 
131
        return inheritable;
 
132
    }
 
133
 
116
134
    public String toString()
117
135
    {
118
136
        if (from != null && to != null)
119
137
        {
120
 
            if (from.equals(to))
121
 
                return from.toString();
 
138
            String rep;
 
139
 
 
140
            if (from.getKind() == Revision.Kind.number
 
141
                && to.getKind() == Revision.Kind.number
 
142
                && (((Revision.Number)from).getNumber() + 1
 
143
                    == ((Revision.Number)to).getNumber()))
 
144
                rep = to.toString();
 
145
            else if (from.equals(to)) // Such ranges should never happen
 
146
                rep = from.toString();
122
147
            else
123
 
                return from.toString() + '-' + to.toString();
 
148
                rep = from.toString() + '-' + to.toString();
 
149
            if (!inheritable)
 
150
                return rep + '*';
 
151
            return rep;
124
152
        }
125
153
        return super.toString();
126
154
    }
138
166
    public int hashCode()
139
167
    {
140
168
        final int prime = 31;
141
 
        int result = 1;
 
169
        int result = (inheritable ? 1 : 2);
142
170
        result = prime * result + ((from == null) ? 0 : from.hashCode());
143
171
        result = prime * result + ((to == null) ? 0 : to.hashCode());
144
172
        return result;
178
206
            return false;
179
207
        }
180
208
 
181
 
        return true;
 
209
        return (inheritable == other.inheritable);
182
210
    }
183
211
 
184
212
    /**
 
213
     * <b>Note:</b> Explicitly ignores inheritable state.
 
214
     *
185
215
     * @param range The RevisionRange to compare this object to.
186
216
     */
187
217
    public int compareTo(RevisionRange range)