2 * Copyright 2000-2009 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 com
.intellij
.cvsSupport2
.cvsoperations
.dateOrRevision
;
18 import com
.intellij
.cvsSupport2
.application
.CvsEntriesManager
;
19 import com
.intellij
.cvsSupport2
.history
.CvsRevisionNumber
;
20 import com
.intellij
.openapi
.util
.text
.StringUtil
;
21 import com
.intellij
.openapi
.vfs
.VirtualFile
;
22 import org
.jetbrains
.annotations
.NotNull
;
23 import org
.netbeans
.lib
.cvsclient
.admin
.Entry
;
24 import org
.netbeans
.lib
.cvsclient
.command
.Command
;
30 public class SimpleRevision
implements RevisionOrDate
{
31 private final String myRevision
;
33 public static SimpleRevision
createForTheSameVersionOf(@NotNull VirtualFile file
) {
34 Entry entry
= CvsEntriesManager
.getInstance().getEntryFor(file
.getParent(), file
.getName());
35 return new SimpleRevision(entry
.getRevision());
39 public SimpleRevision(String revision
) {
40 myRevision
= prepareRevision(revision
);
43 private String
prepareRevision(String revision
) {
44 if (revision
== null) {
47 else if (StringUtil
.startsWithChar(revision
, '-')) {
48 return revision
.substring(1);
55 public String
getRevision() {
59 public void setForCommand(Command command
) {
60 new CommandWrapper(command
).setUpdateByRevisionOrDate(myRevision
, null);
63 public CvsRevisionNumber
getCvsRevisionNumber() {
64 if (myRevision
== null) return null;
66 return new CvsRevisionNumber(myRevision
);
68 catch (NumberFormatException ex
) {