IDEADEV-41265 (IU-9.0 Beta - Undo does not revert file to unchanged)
[fedora-idea.git] / platform / vcs-impl / src / com / intellij / openapi / vcs / impl / PlatformVcsPathPresenter.java
blob9f5907f85f6315a49e052e2dd1323c623a564fec
1 /*
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.openapi.vcs.impl;
18 import com.intellij.openapi.util.io.FileUtil;
19 import com.intellij.openapi.vcs.FilePath;
20 import com.intellij.openapi.vcs.changes.ContentRevision;
21 import com.intellij.openapi.vcs.changes.patch.RelativePathCalculator;
22 import com.intellij.openapi.vfs.VirtualFile;
24 import java.io.File;
26 /**
27 * @author yole
29 public class PlatformVcsPathPresenter extends VcsPathPresenter {
30 public String getPresentableRelativePathFor(final VirtualFile file) {
31 return FileUtil.toSystemDependentName(file.getPath());
34 public String getPresentableRelativePath(final ContentRevision fromRevision, final ContentRevision toRevision) {
35 FilePath fromPath = fromRevision.getFile();
36 FilePath toPath = toRevision.getFile();
38 final RelativePathCalculator calculator =
39 new RelativePathCalculator(toPath.getIOFile().getAbsolutePath(), fromPath.getIOFile().getAbsolutePath());
40 calculator.execute();
41 final String result = calculator.getResult();
42 return (result == null) ? null : result.replace("/", File.separator);