cvs file history in Browse CVS Repository

This commit is contained in:
Bas Leijdekkers
2014-05-16 21:17:25 +02:00
parent 727804a83a
commit 53e5113b5a
14 changed files with 161 additions and 47 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -145,7 +145,7 @@ public class MockVcsHelper extends AbstractVcsHelper {
}
@Override
public void showFileHistory(VcsHistoryProvider vcsHistoryProvider, FilePath path, AbstractVcs vcs, String repositoryPath) {
public void showFileHistory(VcsHistoryProvider vcsHistoryProvider, FilePath path, AbstractVcs vcs, RepositoryLocation repositoryLocation) {
throw new UnsupportedOperationException();
}
@@ -153,7 +153,7 @@ public class MockVcsHelper extends AbstractVcsHelper {
public void showFileHistory(VcsHistoryProvider vcsHistoryProvider,
AnnotationProvider annotationProvider,
FilePath path,
String repositoryPath,
RepositoryLocation repositoryLocation,
AbstractVcs vcs) {
throw new UnsupportedOperationException();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -144,10 +144,10 @@ public abstract class AbstractVcsHelper {
}
public abstract void showFileHistory(VcsHistoryProvider vcsHistoryProvider, FilePath path, final AbstractVcs vcs,
final String repositoryPath);
final RepositoryLocation repositoryLocation);
public abstract void showFileHistory(VcsHistoryProvider vcsHistoryProvider, AnnotationProvider annotationProvider, FilePath path,
final String repositoryPath, final AbstractVcs vcs);
final RepositoryLocation repositoryLocation, final AbstractVcs vcs);
/**
* Shows the "Rollback Changes" dialog with the specified list of changes.
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.actions.VcsContextFactory;
import com.intellij.openapi.vcs.annotate.AnnotationProvider;
@@ -199,6 +200,12 @@ public class VcsAnnotationCachedProxy implements AnnotationProvider {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,9 @@
*/
package com.intellij.openapi.vcs.history;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import org.jetbrains.annotations.Nullable;
/**
* @author irengrig
@@ -53,6 +55,12 @@ public class VcsAppendableHistoryPartnerAdapter implements VcsAppendableHistoryS
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
public void check() throws VcsException {
if (myException != null) throw myException;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,9 @@
*/
package com.intellij.openapi.vcs.history;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import org.jetbrains.annotations.Nullable;
public interface VcsAppendableHistorySessionPartner {
void reportCreatedEmptySession(VcsAbstractHistorySession session);
@@ -24,4 +26,7 @@ public interface VcsAppendableHistorySessionPartner {
void finished();
void forceRefresh();
void beforeRefresh();
@Nullable
RepositoryLocation getRepositoryLocation();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@ package com.intellij.openapi.vcs.history;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.annotate.AnnotationProvider;
/**
@@ -35,12 +36,12 @@ public class FileHistoryRefresher implements FileHistoryRefresherI {
public FileHistoryRefresher(final VcsHistoryProvider vcsHistoryProvider,
final AnnotationProvider annotationProvider,
final FilePath path,
final String repositoryPath,
final RepositoryLocation repositoryLocation,
final AbstractVcs vcs) {
myVcsHistoryProvider = vcsHistoryProvider;
myPath = path;
myVcs = vcs;
mySessionPartner = new FileHistorySessionPartner(vcsHistoryProvider, annotationProvider, path, repositoryPath, vcs, this);
mySessionPartner = new FileHistorySessionPartner(vcsHistoryProvider, annotationProvider, path, repositoryLocation, vcs, this);
myCanUseCache = true;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,10 +17,7 @@ package com.intellij.openapi.vcs.history;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.annotate.AnnotationProvider;
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
@@ -33,6 +30,7 @@ import com.intellij.ui.content.ContentManager;
import com.intellij.util.BufferedListConsumer;
import com.intellij.util.Consumer;
import com.intellij.util.ContentsUtil;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -45,7 +43,7 @@ public class FileHistorySessionPartner implements VcsAppendableHistorySessionPar
private final VcsHistoryProvider myVcsHistoryProvider;
private final AnnotationProvider myAnnotationProvider;
private final FilePath myPath;
private final String myRepositoryPath;
private final RepositoryLocation myRepositoryLocation;
private final AbstractVcs myVcs;
private final FileHistoryRefresherI myRefresherI;
private volatile VcsAbstractHistorySession mySession;
@@ -53,14 +51,14 @@ public class FileHistorySessionPartner implements VcsAppendableHistorySessionPar
public FileHistorySessionPartner(final VcsHistoryProvider vcsHistoryProvider, final AnnotationProvider annotationProvider,
final FilePath path,
final String repositoryPath,
final RepositoryLocation repositoryLocation,
final AbstractVcs vcs,
final FileHistoryRefresherI refresherI) {
myVcsHistoryProvider = vcsHistoryProvider;
myAnnotationProvider = annotationProvider;
myPath = path;
myLimitHistoryCheck = new LimitHistoryCheck(vcs.getProject(), path.getPath());
myRepositoryPath = repositoryPath;
myRepositoryLocation = repositoryLocation;
myVcs = vcs;
myRefresherI = refresherI;
myBuffer = new BufferedListConsumer<VcsFileRevision>(5, new Consumer<List<VcsFileRevision>>() {
@@ -76,6 +74,12 @@ public class FileHistorySessionPartner implements VcsAppendableHistorySessionPar
}, 1000);
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return myRepositoryLocation;
}
public void acceptRevision(VcsFileRevision revision) {
myLimitHistoryCheck.checkNumber();
myBuffer.consumeOne(revision);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -221,6 +221,12 @@ public class VcsHistoryProviderBackgroundableProxy {
myPartner.beforeRefresh();
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return myPartner.getRepositoryLocation();
}
@Override
public void forceRefresh() {
myPartner.forceRefresh();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -116,13 +116,13 @@ public class AbstractVcsHelperImpl extends AbstractVcsHelper {
}
public void showFileHistory(final VcsHistoryProvider vcsHistoryProvider, final FilePath path, final AbstractVcs vcs,
final String repositoryPath) {
showFileHistory(vcsHistoryProvider, null, path, repositoryPath, vcs);
final RepositoryLocation repositoryLocation) {
showFileHistory(vcsHistoryProvider, null, path, repositoryLocation, vcs);
}
public void showFileHistory(final VcsHistoryProvider vcsHistoryProvider, final AnnotationProvider annotationProvider, final FilePath path,
final String repositoryPath, final AbstractVcs vcs) {
final FileHistoryRefresherI refresherI = new FileHistoryRefresher(vcsHistoryProvider, annotationProvider, path, repositoryPath, vcs);
final RepositoryLocation repositoryLocation, final AbstractVcs vcs) {
final FileHistoryRefresherI refresherI = new FileHistoryRefresher(vcsHistoryProvider, annotationProvider, path, repositoryLocation, vcs);
refresherI.run(false, true);
}
@@ -35,11 +35,9 @@ import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.AbstractVcsHelper;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.annotate.FileAnnotation;
import com.intellij.openapi.vcs.history.VcsHistoryProvider;
import com.intellij.openapi.vcs.vfs.VcsVirtualFile;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.Navigatable;
@@ -88,8 +86,7 @@ public class BrowserPanel extends JPanel implements DataProvider, CvsTabbedWindo
DefaultActionGroup result = new DefaultActionGroup();
result.add(new EditSourceAction());
result.add(new MyCheckoutAction());
//TODO lesya
//result.add(new ShowLightCvsFileHistoryAction());
result.add(new MyHistoryAction());
result.add(new MyAnnotateAction());
result.add(new BrowseChangesAction());
return result;
@@ -154,6 +151,33 @@ public class BrowserPanel extends JPanel implements DataProvider, CvsTabbedWindo
}
}
private class MyHistoryAction extends AnAction implements DumbAware {
public MyHistoryAction() {
super(CvsBundle.message("operation.name.show.file.history"),
CvsBundle.message("operation.name.show.file.history.description"), AllIcons.Vcs.History);
}
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
presentation.setVisible(true);
CvsLightweightFile cvsLightFile = getCvsLightFile();
presentation.setEnabled(cvsLightFile != null && cvsLightFile.getCvsFile() != null);
}
public void actionPerformed(AnActionEvent e) {
CvsElement[] currentSelection = myTree.getCurrentSelection();
if (currentSelection.length != 1) return;
final CvsElement cvsElement = currentSelection[0];
final VirtualFile virtualFile = cvsElement.getVirtualFile();
if (virtualFile == null || virtualFile.isDirectory()) return;
final CvsVcs2 vcs = CvsVcs2.getInstance(myProject);
final VcsHistoryProvider historyProvider = vcs.getVcsHistoryProvider();
final String moduleName = cvsElement.getElementPath();
final CvsRepositoryLocation location = new CvsRepositoryLocation(null, myCvsRootConfiguration, moduleName);
AbstractVcsHelper.getInstance(myProject).showFileHistory(historyProvider, new FilePathImpl(virtualFile), vcs, location);
}
}
private class MyAnnotateAction extends AnAction implements DumbAware {
public MyAnnotateAction() {
super(CvsBundle.message("operation.name.annotate"), null, AllIcons.Actions.Annotate);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,9 @@ import com.intellij.CvsBundle;
import com.intellij.cvsSupport2.CvsUtil;
import com.intellij.cvsSupport2.application.CvsEntriesManager;
import com.intellij.cvsSupport2.changeBrowser.CvsChangeList;
import com.intellij.cvsSupport2.changeBrowser.CvsRepositoryLocation;
import com.intellij.cvsSupport2.connections.CvsConnectionSettings;
import com.intellij.cvsSupport2.connections.CvsEnvironment;
import com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor;
import com.intellij.cvsSupport2.cvsExecution.DefaultCvsOperationExecutorCallback;
import com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler;
@@ -201,9 +203,17 @@ public class CvsHistoryProvider implements VcsHistoryProvider {
}
public void reportAppendableHistory(FilePath path, VcsAppendableHistorySessionPartner partner) throws VcsException {
// todo some time after ... this could be done
final VcsHistorySession session = createSessionFor(path);
partner.reportCreatedEmptySession((VcsAbstractHistorySession) session);
final CvsRepositoryLocation location = (CvsRepositoryLocation)partner.getRepositoryLocation();
final VcsHistorySession session;
if (location != null) {
final List<VcsFileRevision> fileRevisionList = createRevisions(location.getEnvironment(), path.getIOFile());
if (fileRevisionList == null) return;
session = new MyHistorySession(fileRevisionList, path);
}
else {
session = createSessionFor(path);
}
partner.reportCreatedEmptySession((VcsAbstractHistorySession)session);
}
private static VcsRevisionNumber getCurrentRevision(FilePath filePath) {
@@ -222,21 +232,26 @@ public class CvsHistoryProvider implements VcsHistoryProvider {
final VirtualFile root = CvsVfsUtil.refreshAndFindFileByIoFile(file.getParentFile());
// check if we have a history pane open for a file in a package which has just been deleted
if (root == null) return null;
final LocalPathIndifferentLogOperation logOperation = new LocalPathIndifferentLogOperation(file);
final CvsConnectionSettings env = CvsEntriesManager.getInstance().getCvsConnectionSettingsFor(filePath.getVirtualFileParent());
final File lightweightFileForFile = CvsUtil.getCvsLightweightFileForFile(file);
return createRevisions(env, lightweightFileForFile);
}
private List<VcsFileRevision> createRevisions(final CvsEnvironment connectionSettings, final File lightweightFileForFile) {
final LocalPathIndifferentLogOperation logOperation = new LocalPathIndifferentLogOperation(connectionSettings);
logOperation.addFile(lightweightFileForFile);
final CvsOperationExecutor executor = new CvsOperationExecutor(myProject);
final ArrayList<VcsFileRevision> result = new ArrayList<VcsFileRevision>();
executor.performActionSync(new CommandCvsHandler(CvsBundle.message("operation.name.load.file.content"), logOperation),
new DefaultCvsOperationExecutorCallback() {
@Override
public void executionFinishedSuccessfully() {
final CvsConnectionSettings env = CvsEntriesManager.getInstance()
.getCvsConnectionSettingsFor(filePath.getVirtualFileParent());
final LogInformation firstLogInformation = logOperation.getFirstLogInformation();
if (firstLogInformation != null) {
final List<Revision> revisionList = firstLogInformation.getRevisionList();
for (Revision revision : revisionList) {
result.add(new CvsFileRevisionImpl(revision, CvsUtil.getCvsLightweightFileForFile(file),
firstLogInformation, env, myProject));
result.add(new CvsFileRevisionImpl(revision, lightweightFileForFile,
firstLogInformation, connectionSettings, myProject));
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -124,14 +124,14 @@ public class HgMockVcsHelper extends AbstractVcsHelper {
}
@Override
public void showFileHistory(VcsHistoryProvider vcsHistoryProvider, FilePath path, AbstractVcs vcs, String repositoryPath) {
public void showFileHistory(VcsHistoryProvider vcsHistoryProvider, FilePath path, AbstractVcs vcs, RepositoryLocation repositoryLocation) {
}
@Override
public void showFileHistory(VcsHistoryProvider vcsHistoryProvider,
AnnotationProvider annotationProvider,
FilePath path,
String repositoryPath,
RepositoryLocation repositoryLocation,
AbstractVcs vcs) {
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -351,9 +351,10 @@ public class RepositoryBrowserDialog extends DialogWrapper {
boolean isDirectory = node.getUserObject() instanceof SVNURL ||
(node.getSVNDirEntry() != null && node.getSVNDirEntry().getKind() == SVNNodeKind.DIR);
String url = node.getURL().toDecodedString();
final SvnRepositoryLocation repositoryLocation = new SvnRepositoryLocation(node.getURL().toString());
AbstractVcsHelper.getInstance(myProject)
.showFileHistory(myVCS.getVcsHistoryProvider(), VcsUtil.getFilePathOnNonLocal(url, isDirectory), myVCS, url);
.showFileHistory(myVCS.getVcsHistoryProvider(), VcsUtil.getFilePathOnNonLocal(url, isDirectory), myVCS, repositoryLocation);
node.reload(false);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import com.intellij.openapi.vcs.history.VcsFileRevision;
import com.intellij.openapi.vcs.history.VcsHistoryProvider;
import com.intellij.util.concurrency.Semaphore;
import junit.framework.Assert;
import org.jetbrains.annotations.Nullable;
import org.junit.Test;
/**
@@ -77,6 +78,12 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -127,6 +134,12 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -176,6 +189,12 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -229,6 +248,12 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -283,6 +308,12 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -317,6 +348,12 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}
@@ -350,6 +387,12 @@ public class SvnHistoryTest extends Svn17TestCase {
public void beforeRefresh() {
}
@Nullable
@Override
public RepositoryLocation getRepositoryLocation() {
return null;
}
@Override
public void forceRefresh() {
}