本文整理汇总了Java中com.intellij.openapi.vcs.VcsException类的典型用法代码示例。如果您正苦于以下问题:Java VcsException类的具体用法?Java VcsException怎么用?Java VcsException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VcsException类属于com.intellij.openapi.vcs包,在下文中一共展示了VcsException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContent
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
@Nullable
public String getContent() throws VcsException {
if (myFile.isDirectory()) {
return null;
}
try {
return ContentRevisionCache
.getOrLoadAsString(myProject, myFile, myRevision, GitVcs.getKey(), ContentRevisionCache.UniqueType.REPOSITORY_CONTENT,
new Throwable2Computable<byte[], VcsException, IOException>() {
@Override
public byte[] compute() throws VcsException, IOException {
return loadContent();
}
}, myCharset);
}
catch (IOException e) {
throw new VcsException(e);
}
}
示例2: loadBackwards
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
private void loadBackwards(SVNURL svnurl) throws SVNException, VcsException {
// this method is called when svnurl does not exist in latest repository revision - thus concrete old revision is used for "info"
// command to get repository url
Info info = myVcs.getInfo(svnurl, myPeg, myPeg);
final SVNURL rootURL = info != null ? info.getRepositoryRootURL() : null;
final String root = rootURL != null ? rootURL.toString() : "";
String relativeUrl = myUrl;
if (myUrl.startsWith(root)) {
relativeUrl = myUrl.substring(root.length());
}
final RepositoryLogEntryHandler repositoryLogEntryHandler =
new RepositoryLogEntryHandler(myVcs, myUrl, SVNRevision.UNDEFINED, relativeUrl,
new ThrowableConsumer<VcsFileRevision, SVNException>() {
@Override
public void consume(VcsFileRevision revision) throws SVNException {
myConsumer.consume(revision);
}
}, rootURL);
repositoryLogEntryHandler.setThrowCancelOnMeetPathCreation(true);
SvnTarget target = SvnTarget.fromURL(rootURL, myFrom);
myVcs.getFactory(target).createHistoryClient()
.doLog(target, myFrom, myTo == null ? SVNRevision.create(1) : myTo, false, true, myShowMergeSources && mySupport15, 1, null,
repositoryLogEntryHandler);
}
示例3: setRevisionProperty
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
@Override
public void setRevisionProperty(@NotNull SvnTarget target,
@NotNull String property,
@NotNull SVNRevision revision,
@Nullable PropertyValue value,
boolean force) throws VcsException {
try {
if (target.isFile()) {
createClient().doSetRevisionProperty(target.getFile(), revision, property, toPropertyValue(value), force, null);
}
else {
createClient().doSetRevisionProperty(target.getURL(), revision, property, toPropertyValue(value), force, null);
}
}
catch (SVNException e) {
throw new SvnBindException(e);
}
}
示例4: doMerge
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
protected void doMerge() throws VcsException {
for (Change change : mySelectedChanges) {
SvnRepositoryContentRevision before = (SvnRepositoryContentRevision)change.getBeforeRevision();
SvnRepositoryContentRevision after = (SvnRepositoryContentRevision)change.getAfterRevision();
if (before == null) {
//noinspection ConstantConditions
add(after);
}
else if (after == null) {
delete(before);
}
else {
merge(before, after);
}
}
}
示例5: runCommit
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
@NotNull
private CommitInfo[] runCommit(@NotNull List<File> paths, @NotNull String message) throws VcsException {
if (ContainerUtil.isEmpty(paths)) return new CommitInfo[]{CommitInfo.EMPTY};
Command command = newCommand(SvnCommandName.ci);
command.put(Depth.EMPTY);
command.put("-m", message);
// TODO: seems that sort is not necessary here
ContainerUtil.sort(paths);
command.setTargets(paths);
IdeaCommitHandler handler = new IdeaCommitHandler(ProgressManager.getInstance().getProgressIndicator());
CmdCheckinClient.CommandListener listener = new CommandListener(handler);
listener.setBaseDirectory(CommandUtil.requireExistingParent(paths.get(0)));
execute(myVcs, SvnTarget.fromFile(paths.get(0)), null, command, listener);
listener.throwExceptionIfOccurred();
long revision = validateRevisionNumber(listener.getCommittedRevision());
return new CommitInfo[]{new CommitInfo.Builder().setRevision(revision).build()};
}
示例6: registerFile
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
/**
* Register file in the map under appropriate root
*
* @param files a map to use
* @param file a file to register
* @param exceptions the list of exceptions to update
*/
private static void registerFile(Map<VirtualFile, List<FilePath>> files, FilePath file, List<VcsException> exceptions) {
final VirtualFile root;
try {
root = GitUtil.getGitRoot(file);
}
catch (VcsException e) {
exceptions.add(e);
return;
}
List<FilePath> paths = files.get(root);
if (paths == null) {
paths = new ArrayList<FilePath>();
files.put(root, paths);
}
paths.add(file);
}
示例7: checkout
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
@Override
public void checkout(@NotNull SvnTarget source,
@NotNull File destination,
@Nullable SVNRevision revision,
@Nullable Depth depth,
boolean ignoreExternals,
boolean force,
@NotNull WorkingCopyFormat format,
@Nullable ProgressTracker handler) throws VcsException {
validateFormat(format, getSupportedFormats());
List<String> parameters = new ArrayList<String>();
CommandUtil.put(parameters, source);
CommandUtil.put(parameters, destination, false);
CommandUtil.put(parameters, depth);
CommandUtil.put(parameters, revision);
CommandUtil.put(parameters, ignoreExternals, "--ignore-externals");
CommandUtil.put(parameters, force, "--force"); // corresponds to "allowUnversionedObstructions" in SVNKit
run(source, destination, handler, parameters);
}
示例8: updateShouldMergeAndCommitChanges
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
@Test
public void updateShouldMergeAndCommitChanges() throws Exception{
changeFile_A_AndCommitInRemoteRepository();
createAndCommitNewFileInLocalRepository();
//we've got diverging heads in remote and local now
PreUpdateInformation preUpdateInformation = new PreUpdateInformation().getPreUpdateInformation();
HgRevisionNumber incomingHead = preUpdateInformation.getIncomingHead();
HgRevisionNumber headBeforeUpdate = preUpdateInformation.getHeadBeforeUpdate();
List<VcsException> warnings = updateThroughPlugin();
assertEquals(warnings.size(), 0, "Plain update should not generate warnings");
assertCurrentHeadIsMerge(incomingHead, headBeforeUpdate);
}
示例9: executeCommand
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
private void executeCommand(final DirectoryContentProvider command, final GetContentCallback callback) {
final CvsOperationExecutor executor = new CvsOperationExecutor(false, callback.getProject(), callback.getModalityState());
executor.setIsQuietOperation(true);
final CancellableCvsHandler cvsHandler = new CancellableCvsHandler(CvsBundle.message("browse.repository.operation.name"), (CvsOperation)command);
callback.useForCancel(cvsHandler.getProgressListener());
executor.performActionSync(cvsHandler, new DefaultCvsOperationExecutorCallback() {
@Override
public void executionFinished(boolean successfully) {
if (!successfully) {
final List<VcsException> errors = cvsHandler.getErrorsExceptAborted();
if (!errors.isEmpty()) {
myErrorCallback.consume(errors.get(0));
}
}
callback.finished();
}
});
}
示例10: getChange
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
@Nullable
private static Change getChange(@NotNull DiffRequestPresentable presentable) {
if (presentable instanceof DiffRequestPresentableProxy) {
try {
presentable = ((DiffRequestPresentableProxy)presentable).init();
}
catch (VcsException e) {
LOG.info(e);
return null;
}
}
if (presentable instanceof ChangeDiffRequestPresentable) {
return ((ChangeDiffRequestPresentable)presentable).getChange();
}
return null;
}
示例11: runGetProperty
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
private void runGetProperty(@NotNull SvnTarget target,
@Nullable String property,
@Nullable SVNRevision revision,
@Nullable Depth depth,
@Nullable PropertyConsumer handler) throws VcsException {
SVNWCClient client = createClient();
try {
if (target.isURL()) {
client.doGetProperty(target.getURL(), property, target.getPegRevision(), revision, toDepth(depth), toHandler(handler));
} else {
client.doGetProperty(target.getFile(), property, target.getPegRevision(), revision, toDepth(depth), toHandler(handler), null);
}
} catch (SVNException e) {
throw new VcsException(e);
}
}
示例12: onlyHashesHistory
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
public static List<Pair<SHAHash, Date>> onlyHashesHistory(Project project, FilePath path, final VirtualFile root, final String... parameters)
throws VcsException {
// adjust path using change manager
path = getLastCommitName(project, path);
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
GitLogParser parser = new GitLogParser(project, HASH, COMMIT_TIME);
h.setStdoutSuppressed(true);
h.addParameters(parameters);
h.addParameters(parser.getPretty(), "--encoding=UTF-8");
h.endOptions();
h.addRelativePaths(path);
String output = h.run();
final List<Pair<SHAHash, Date>> rc = new ArrayList<Pair<SHAHash, Date>>();
for (GitLogRecord record : parser.parse(output)) {
record.setUsedHandler(h);
rc.add(Pair.create(new SHAHash(record.getHash()), record.getDate()));
}
return rc;
}
示例13: export
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
@Override
public void export(@NotNull SvnTarget from,
@NotNull File to,
@Nullable SVNRevision revision,
@Nullable Depth depth,
@Nullable String nativeLineEnd,
boolean force,
boolean ignoreExternals,
@Nullable ProgressTracker handler) throws VcsException {
SVNUpdateClient client = myVcs.getSvnKitManager().createUpdateClient();
client.setEventHandler(toEventHandler(handler));
client.setIgnoreExternals(ignoreExternals);
try {
if (from.isFile()) {
client.doExport(from.getFile(), to, from.getPegRevision(), revision, nativeLineEnd, force, toDepth(depth));
}
else {
client.doExport(from.getURL(), to, from.getPegRevision(), revision, nativeLineEnd, force, toDepth(depth));
}
}
catch (SVNException e) {
throw new SvnBindException(e);
}
}
示例14: updateShouldMergeButNotCommitWithConflicts
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
@Test
public void updateShouldMergeButNotCommitWithConflicts() throws Exception{
changeFile_A_AndCommitInRemoteRepository();
VirtualFile commonFile = projectRepoVirtualFile.findChild("com").findChild("a.txt");
assertNotNull(commonFile);
VcsTestUtil.editFileInCommand(myProject, commonFile, "conflicting content");
runHg(projectRepo, "commit", "-m", "adding conflicting history to local repository");
PreUpdateInformation preUpdateInformation = new PreUpdateInformation().getPreUpdateInformation();
HgRevisionNumber incomingHead = preUpdateInformation.getIncomingHead();
HgRevisionNumber headBeforeUpdate = preUpdateInformation.getHeadBeforeUpdate();
List<VcsException> warnings = updateThroughPlugin();
assertFalse(warnings.isEmpty());
assertTrue(warnings.get(warnings.size()-1).getMessage().contains("conflicts"));
assertTrue(warnings.get(warnings.size()-1).getMessage().contains("commit"));
List<HgRevisionNumber> parents = new HgWorkingCopyRevisionsCommand(myProject).parents(projectRepoVirtualFile);
assertEquals(parents.size(), 2);
assertTrue(parents.contains(incomingHead));
assertTrue(parents.contains(headBeforeUpdate));
}
示例15: annotate
import com.intellij.openapi.vcs.VcsException; //导入依赖的package包/类
public FileAnnotation annotate(VirtualFile file, VcsFileRevision revision) throws VcsException {
final VirtualFile vcsRoot = VcsUtil.getVcsRootFor(myProject, VcsUtil.getFilePath(file.getPath()));
if (vcsRoot == null) {
throw new VcsException("vcs root is null for " + file);
}
final HgFile hgFile = new HgFile(vcsRoot, VfsUtilCore.virtualToIoFile(file));
HgFile fileToAnnotate = revision instanceof HgFileRevision
? HgUtil.getFileNameInTargetRevision(myProject, ((HgFileRevision)revision).getRevisionNumber(), hgFile)
: new HgFile(vcsRoot,
HgUtil.getOriginalFileName(hgFile.toFilePath(), ChangeListManager.getInstance(myProject)));
final List<HgAnnotationLine> annotationResult = (new HgAnnotateCommand(myProject)).execute(fileToAnnotate, revision);
final List<HgFileRevision> logResult;
try {
HgLogCommand logCommand = new HgLogCommand(myProject);
logCommand.setFollowCopies(true);
logResult = logCommand.execute(fileToAnnotate, -1, false);
}
catch (HgCommandException e) {
throw new VcsException("Can not annotate, " + HgVcsMessages.message("hg4idea.error.log.command.execution"), e);
}
VcsRevisionNumber revisionNumber = revision == null ?
new HgWorkingCopyRevisionsCommand(myProject).tip(vcsRoot) :
revision.getRevisionNumber();
return new HgAnnotation(myProject, hgFile, annotationResult, logResult, revisionNumber);
}