use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class HgRegularUpdater method update.
public boolean update(final UpdatedFiles updatedFiles, ProgressIndicator indicator, List<VcsException> warnings) throws VcsException {
indicator.setText(HgVcsMessages.message("hg4idea.progress.updating", repoRoot.getPath()));
String defaultPath = HgUtil.getRepositoryDefaultPath(project, repoRoot);
if (StringUtil.isEmptyOrSpaces(defaultPath)) {
throw new VcsException(HgVcsMessages.message("hg4idea.warning.no-default-update-path", repoRoot.getPath()));
}
List<HgRevisionNumber> branchHeadsBeforePull = new HgHeadsCommand(project, repoRoot).executeInCurrentThread();
if (branchHeadsBeforePull.size() > 1) {
reportWarning(warnings, HgVcsMessages.message("hg4idea.update.warning.multipleHeadsBeforeUpdate", repoRoot.getPath()));
}
if (updateConfiguration.shouldPull()) {
HgCommandExitCode pullResult = pull(repoRoot, indicator);
if (pullResult == HgCommandExitCode.ERROR) {
return false;
}
}
List<HgRevisionNumber> parentsBeforeUpdate = new HgWorkingCopyRevisionsCommand(project).parents(repoRoot);
if (parentsBeforeUpdate.size() > 1) {
throw new VcsException(HgVcsMessages.message("hg4idea.update.error.uncommittedMerge", repoRoot.getPath()));
}
indicator.setText2(HgVcsMessages.message("hg4idea.progress.countingHeads"));
List<HgRevisionNumber> branchHeadsAfterPull = new HgHeadsCommand(project, repoRoot).executeInCurrentThread();
List<HgRevisionNumber> pulledBranchHeads = determinePulledBranchHeads(branchHeadsBeforePull, branchHeadsAfterPull);
List<HgRevisionNumber> remainingOriginalBranchHeads = determingRemainingOriginalBranchHeads(branchHeadsBeforePull, branchHeadsAfterPull);
HgUpdateType updateType = updateConfiguration.getUpdateType();
if (branchHeadsAfterPull.size() > 1 && updateType != ONLY_UPDATE) {
// merge strategy
if (updateType == MERGE) {
abortOnLocalChanges();
abortOnMultiplePulledHeads(pulledBranchHeads);
abortOnMultipleLocalHeads(remainingOriginalBranchHeads);
HgCommandResult mergeResult = doMerge(indicator);
if (updateConfiguration.shouldCommitAfterMerge()) {
commitOrWarnAboutConflicts(warnings, mergeResult);
}
} else //rebase strategy
{
//resolve conflicts processed during rebase
processRebase(indicator, updatedFiles);
return true;
}
} else //if pull complete successfully and there are only one head, we need just update working directory to the head
{
//in case of multiple heads the update will report the appropriate error
update(repoRoot, indicator, updatedFiles, warnings);
}
//any kind of update could have resulted in merges and merge conflicts, so run the resolver
resolvePossibleConflicts(updatedFiles);
return true;
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class HgUpdateEnvironment method updateDirectories.
@NotNull
public UpdateSession updateDirectories(@NotNull FilePath[] contentRoots, UpdatedFiles updatedFiles, ProgressIndicator indicator, @NotNull Ref<SequentialUpdatesContext> context) {
List<VcsException> exceptions = new LinkedList<>();
boolean result = true;
for (FilePath contentRoot : contentRoots) {
if (indicator != null) {
indicator.checkCanceled();
indicator.startNonCancelableSection();
}
VirtualFile repository = ProjectLevelVcsManager.getInstance(project).getVcsRootFor(contentRoot);
if (repository == null) {
continue;
}
try {
HgUpdater updater = new HgRegularUpdater(project, repository, updateConfiguration);
result &= updater.update(updatedFiles, indicator, exceptions);
} catch (VcsException e) {
//TODO include module name where exception occurred
exceptions.add(e);
}
if (indicator != null) {
indicator.finishNonCancelableSection();
}
}
return new UpdateSessionAdapter(exceptions, !result);
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class SvnCheckinEnvironment method doCommitOneRepo.
private void doCommitOneRepo(@NotNull Collection<FilePath> committables, String comment, List<VcsException> exception, final Set<String> feedback, @NotNull WorkingCopyFormat format) throws VcsException {
if (committables.isEmpty()) {
return;
}
CommitInfo[] results = mySvnVcs.getFactory(format).createCheckinClient().commit(ChangesUtil.filePathsToFiles(committables), comment);
final StringBuilder committedRevisions = new StringBuilder();
for (CommitInfo result : results) {
if (result.getErrorMessage() != null) {
exception.add(new VcsException(result.getErrorMessage().getFullMessage()));
} else if (result != CommitInfo.EMPTY && result.getRevision() > 0) {
if (committedRevisions.length() > 0) {
committedRevisions.append(", ");
}
committedRevisions.append(result.getRevision());
}
}
if (committedRevisions.length() > 0) {
reportCommittedRevisions(feedback, committedRevisions.toString());
}
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class SvnAnnotationProvider method annotate.
public FileAnnotation annotate(final VirtualFile file) throws VcsException {
final SvnDiffProvider provider = (SvnDiffProvider) myVcs.getDiffProvider();
final SVNRevision currentRevision = ((SvnRevisionNumber) provider.getCurrentRevision(file)).getRevision();
final VcsRevisionDescription lastChangedRevision = provider.getCurrentRevisionDescription(file);
if (lastChangedRevision == null) {
throw new VcsException("Can not get current revision for file " + file.getPath());
}
final SVNRevision svnRevision = ((SvnRevisionNumber) lastChangedRevision.getRevisionNumber()).getRevision();
if (!svnRevision.isValid()) {
throw new VcsException("Can not get last changed revision for file: " + file.getPath() + "\nPlease run svn info for this file and file an issue.");
}
return annotate(file, new SvnFileRevision(myVcs, currentRevision, currentRevision, null, null, null, null, null), lastChangedRevision.getRevisionNumber(), true);
}
use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.
the class SvnAnnotationProvider method annotateNonExisting.
private SvnRemoteFileAnnotation annotateNonExisting(Pair<SvnChangeList, FilePath> pair, VcsFileRevision revision, Info info, Charset charset, final VirtualFile current) throws VcsException, SVNException, IOException {
final File wasFile = pair.getSecond().getIOFile();
final File root = getCommonAncestor(wasFile, info.getFile());
if (root == null) {
throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString());
}
final String relativePath = FileUtil.getRelativePath(root.getPath(), wasFile.getPath(), File.separatorChar);
if (relativePath == null) {
throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString());
}
Info wcRootInfo = myVcs.getInfo(root);
if (wcRootInfo == null || wcRootInfo.getURL() == null) {
throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString());
}
SVNURL wasUrl = wcRootInfo.getURL();
final String[] strings = relativePath.replace('\\', '/').split("/");
for (String string : strings) {
wasUrl = wasUrl.appendPath(string, true);
}
final SVNRevision svnRevision = ((SvnRevisionNumber) revision.getRevisionNumber()).getRevision();
byte[] data = SvnUtil.getFileContents(myVcs, SvnTarget.fromURL(wasUrl), svnRevision, svnRevision);
final String contents = LoadTextUtil.getTextByBinaryPresentation(data, charset == null ? CharsetToolkit.UTF8_CHARSET : charset).toString();
final SvnRemoteFileAnnotation result = new SvnRemoteFileAnnotation(myVcs, contents, revision.getRevisionNumber(), current);
final AnnotationConsumer annotateHandler = createAnnotationHandler(ProgressManager.getInstance().getProgressIndicator(), result);
boolean calculateMergeinfo = myVcs.getSvnConfiguration().isShowMergeSourcesInAnnotate() && SvnUtil.checkRepositoryVersion15(myVcs, wasUrl.toString());
AnnotateClient client = myVcs.getFactory().createAnnotateClient();
client.annotate(SvnTarget.fromURL(wasUrl, svnRevision), SVNRevision.create(1), svnRevision, calculateMergeinfo, getLogClientOptions(myVcs), annotateHandler);
return result;
}
Aggregations