2 * Copyright 2000-2005 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.jetbrains
.idea
.svn
;
18 import com
.intellij
.openapi
.vcs
.history
.VcsRevisionNumber
;
19 import org
.jetbrains
.annotations
.NotNull
;
20 import org
.tmatesoft
.svn
.core
.wc
.SVNRevision
;
23 * Created by IntelliJ IDEA.
27 * To change this template use File | Settings | File Templates.
29 public class SvnRevisionNumber
implements VcsRevisionNumber
{
31 private final SVNRevision myRevision
;
33 public SvnRevisionNumber(@NotNull SVNRevision revision
) {
34 myRevision
= revision
;
37 public String
asString() {
38 return myRevision
.toString();
41 public int compareTo(VcsRevisionNumber vcsRevisionNumber
) {
42 if (vcsRevisionNumber
== null || vcsRevisionNumber
.getClass() != SvnRevisionNumber
.class) {
45 SVNRevision rev
= ((SvnRevisionNumber
)vcsRevisionNumber
).myRevision
;
46 if (!myRevision
.isValid()) {
47 return !rev
.isValid() ?
0 : -1;
49 if (myRevision
.getNumber() >= 0 && rev
.getNumber() >= 0) {
50 return myRevision
.getNumber() == rev
.getNumber() ?
0 : myRevision
.getNumber() > rev
.getNumber() ?
1 : -1;
52 else if (myRevision
.getDate() != null && rev
.getDate() != null) {
53 return myRevision
.getDate().compareTo(rev
.getDate());
55 if (myRevision
.equals(SVNRevision
.HEAD
)) {
56 return rev
.equals(SVNRevision
.HEAD
) ?
0 : 1; // HEAD is greater than a specific rev
58 return myRevision
.getID() == rev
.getID() ?
0 : myRevision
.getID() > rev
.getID() ?
1 : -1;
61 public SVNRevision
getRevision() {
65 public boolean equals(final Object o
) {
66 if (this == o
) return true;
67 if (o
== null || getClass() != o
.getClass()) return false;
69 final SvnRevisionNumber that
= (SvnRevisionNumber
)o
;
71 return myRevision
.equals(that
.myRevision
);
75 public int hashCode() {
76 return myRevision
.hashCode();
79 public String
toString() {
80 return myRevision
.toString();