use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class SvnMergeProvider method loadRevisions.
@NotNull
public MergeData loadRevisions(@NotNull final VirtualFile file) throws VcsException {
final MergeData data = new MergeData();
VcsRunnable runnable = () -> {
File oldFile = null;
File newFile = null;
File workingFile = null;
boolean mergeCase = false;
SvnVcs vcs = SvnVcs.getInstance(myProject);
Info info = vcs.getInfo(file);
if (info != null) {
oldFile = info.getConflictOldFile();
newFile = info.getConflictNewFile();
workingFile = info.getConflictWrkFile();
mergeCase = workingFile == null || workingFile.getName().contains("working");
// for debug
if (workingFile == null) {
LOG.info("Null working file when merging text conflict for " + file.getPath() + " old file: " + oldFile + " new file: " + newFile);
}
if (mergeCase) {
// this is merge case
oldFile = info.getConflictNewFile();
newFile = info.getConflictOldFile();
workingFile = info.getConflictWrkFile();
}
data.LAST_REVISION_NUMBER = new SvnRevisionNumber(info.getRevision());
} else {
throw new VcsException("Could not get info for " + file.getPath());
}
if (oldFile == null || newFile == null || workingFile == null) {
ByteArrayOutputStream bos = getBaseRevisionContents(vcs, file);
data.ORIGINAL = bos.toByteArray();
data.LAST = bos.toByteArray();
data.CURRENT = readFile(virtualToIoFile(file));
} else {
data.ORIGINAL = readFile(oldFile);
data.LAST = readFile(newFile);
data.CURRENT = readFile(workingFile);
}
if (mergeCase) {
final ByteArrayOutputStream contents = getBaseRevisionContents(vcs, file);
if (!Arrays.equals(contents.toByteArray(), data.ORIGINAL)) {
// swap base and server: another order of merge arguments
byte[] original = data.ORIGINAL;
data.ORIGINAL = data.LAST;
data.LAST = original;
}
}
};
VcsUtil.runVcsProcessWithProgress(runnable, VcsBundle.message("multiple.file.merge.loading.progress.title"), false, myProject);
return data;
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class DefaultBranchConfigInitializer method getDefaultConfiguration.
@Nullable
public SvnBranchConfigurationNew getDefaultConfiguration() {
SvnBranchConfigurationNew result = null;
SvnVcs vcs = SvnVcs.getInstance(myProject);
SVNURL rootUrl = SvnUtil.getUrl(vcs, VfsUtilCore.virtualToIoFile(myRoot));
if (rootUrl != null) {
try {
result = getDefaultConfiguration(vcs, rootUrl);
} catch (SVNException | VcsException e) {
LOG.info(e);
}
} else {
LOG.info("Directory is not a working copy: " + myRoot.getPresentableUrl());
}
return result;
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class HgTaskHandler method mergeAndClose.
@Override
protected void mergeAndClose(@NotNull final String branch, @NotNull final List<HgRepository> repositories) {
String bookmarkRevisionArg = "bookmark(\"" + branch + "\")";
FileDocumentManager.getInstance().saveAllDocuments();
final UpdatedFiles updatedFiles = UpdatedFiles.create();
for (final HgRepository repository : repositories) {
HgMergeCommand.mergeWith(repository, bookmarkRevisionArg, updatedFiles, new Runnable() {
@Override
public void run() {
Project project = repository.getProject();
VirtualFile repositoryRoot = repository.getRoot();
try {
new HgCommitCommand(project, repository, "Automated merge with " + branch).executeInCurrentThread();
HgBookmarkCommand.deleteBookmarkSynchronously(project, repositoryRoot, branch);
} catch (HgCommandException e) {
HgErrorUtil.handleException(project, e);
} catch (VcsException e) {
VcsNotifier.getInstance(project).notifyError("Exception during merge commit with " + branch, e.getMessage());
}
}
});
}
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class HgCompareWithBranchAction method getDiffChanges.
@Override
@NotNull
protected Collection<Change> getDiffChanges(@NotNull Project project, @NotNull VirtualFile file, @NotNull String branchToCompare) throws VcsException {
HgRepository repository = getRepositoryManager(project).getRepositoryForFile(file);
if (repository == null) {
throw new VcsException("Couldn't find repository for " + file.getName());
}
final FilePath filePath = VcsUtil.getFilePath(file);
final VirtualFile repositoryRoot = repository.getRoot();
final HgFile hgFile = new HgFile(repositoryRoot, filePath);
Hash refHashToCompare = detectActiveHashByName(repository, branchToCompare);
if (refHashToCompare == null) {
throw new VcsException(String.format("Couldn't detect commit related to %s name for %s.", branchToCompare, file));
}
final HgRevisionNumber compareWithRevisionNumber = HgRevisionNumber.getInstance(branchToCompare, refHashToCompare.toString());
List<Change> changes = HgUtil.getDiff(project, repositoryRoot, filePath, compareWithRevisionNumber, null);
if (changes.isEmpty() && !existInBranch(repository, filePath, compareWithRevisionNumber)) {
throw new VcsException(fileDoesntExistInBranchError(file, branchToCompare));
}
return changes.isEmpty() && !filePath.isDirectory() ? createChangesWithCurrentContentForFile(filePath, HgContentRevision.create(project, hgFile, compareWithRevisionNumber)) : changes;
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class SvnContentRevision method getUpToDateBinaryContent.
private byte[] getUpToDateBinaryContent() throws VcsException {
File file = myFile.getIOFile();
File lock = new File(file.getParentFile(), SvnUtil.PATH_TO_LOCK_FILE);
if (lock.exists()) {
throw new VcsException("Can not access file base revision contents: administrative area is locked");
}
return SvnUtil.getFileContents(myVcs, SvnTarget.fromFile(file), myUseBaseRevision ? SVNRevision.BASE : myRevision, SVNRevision.UNDEFINED);
}
Aggregations