use of org.zmlx.hg4idea.command.HgResolveCommand in project intellij-community by JetBrains.
the class HgRunConflictResolverDialog method onChangeRepository.
private void onChangeRepository() {
VirtualFile repo = repositorySelector.getRepository().getRoot();
HgResolveCommand command = new HgResolveCommand(project);
final ModalityState modalityState = ApplicationManager.getApplication().getModalityStateForComponent(getRootPane());
command.getListAsynchronously(repo, new Consumer<Map<HgFile, HgResolveStatusEnum>>() {
@Override
public void consume(Map<HgFile, HgResolveStatusEnum> status) {
final DefaultListModel model = new DefaultListModel();
for (Map.Entry<HgFile, HgResolveStatusEnum> entry : status.entrySet()) {
if (entry.getValue() == HgResolveStatusEnum.UNRESOLVED) {
model.addElement(entry.getKey().getRelativePath());
}
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
setOKActionEnabled(!model.isEmpty());
if (model.isEmpty()) {
model.addElement("No conflicts to resolve");
}
conflictsList.setModel(model);
}
}, modalityState);
}
});
}
use of org.zmlx.hg4idea.command.HgResolveCommand in project intellij-community by JetBrains.
the class HgMarkResolved method batchPerform.
protected void batchPerform(Project project, HgVcs activeVcs, List<VirtualFile> files, DataContext context) throws VcsException {
HgResolveCommand resolveCommand = new HgResolveCommand(project);
for (VirtualFile file : files) {
VirtualFile root = VcsUtil.getVcsRootFor(project, file);
if (root == null) {
return;
}
resolveCommand.markResolved(root, file);
}
}
use of org.zmlx.hg4idea.command.HgResolveCommand in project intellij-community by JetBrains.
the class HgRollbackEnvironment method revert.
private void revert(@NotNull List<FilePath> filePaths) {
for (Map.Entry<VirtualFile, Collection<FilePath>> entry : HgUtil.groupFilePathsByHgRoots(project, filePaths).entrySet()) {
final VirtualFile repo = entry.getKey();
final Collection<FilePath> files = entry.getValue();
HgRevisionNumber revisionNumber = new HgWorkingCopyRevisionsCommand(project).firstParent(repo);
for (List<String> chunk : VcsFileUtil.chunkPaths(repo, files)) {
HgCommandResult revertResult = new HgRevertCommand(project).execute(repo, chunk, revisionNumber, false);
if (HgErrorUtil.hasUncommittedChangesConflict(revertResult)) {
String message = String.format("<html>Revert failed due to uncommitted merge.<br>" + "Would you like to discard all changes for repository <it><b>%s</b></it>?</html>", repo.getPresentableName());
int exitCode = HgUpdateCommand.showDiscardChangesConfirmation(project, message);
if (exitCode == Messages.OK) {
//discard all changes for this repository//
HgUpdateCommand updateCommand = new HgUpdateCommand(project, repo);
updateCommand.setClean(true);
updateCommand.setRevision(".");
updateCommand.execute();
}
break;
}
new HgResolveCommand(project).markResolved(repo, files);
}
}
}
use of org.zmlx.hg4idea.command.HgResolveCommand in project intellij-community by JetBrains.
the class HgConflictResolver method resolve.
public void resolve(final VirtualFile repo) {
final Map<HgFile, HgResolveStatusEnum> resolves = new HgResolveCommand(myProject).getListSynchronously(repo);
final List<File> conflictFiles = new ArrayList<>();
for (HgFile hgFile : resolves.keySet()) {
File file = hgFile.getFile();
if (resolves.get(hgFile) == HgResolveStatusEnum.UNRESOLVED) {
conflictFiles.add(file);
updateUpdatedFiles(file, true);
} else {
updateUpdatedFiles(file, false);
}
}
if (conflictFiles.isEmpty())
return;
final HgVcs vcs = HgVcs.getInstance(myProject);
if (vcs == null)
return;
final List<VirtualFile> conflicts = sortVirtualFilesByPresentation(findVirtualFilesWithRefresh(conflictFiles));
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
public void run() {
AbstractVcsHelper.getInstance(myProject).showMergeDialog(conflicts, vcs.getMergeProvider());
}
});
}
use of org.zmlx.hg4idea.command.HgResolveCommand in project intellij-community by JetBrains.
the class HgChangeProvider method process.
private Collection<HgChange> process(ChangelistBuilder builder, Collection<FilePath> files) {
final Set<HgChange> hgChanges = new HashSet<>();
for (Map.Entry<VirtualFile, Collection<FilePath>> entry : HgUtil.groupFilePathsByHgRoots(myProject, files).entrySet()) {
VirtualFile repo = entry.getKey();
final HgRevisionNumber workingRevision = new HgWorkingCopyRevisionsCommand(myProject).identify(repo).getFirst();
final HgRevisionNumber parentRevision = new HgWorkingCopyRevisionsCommand(myProject).firstParent(repo);
final Map<HgFile, HgResolveStatusEnum> list = new HgResolveCommand(myProject).getListSynchronously(repo);
hgChanges.addAll(new HgStatusCommand.Builder(true).ignored(false).build(myProject).executeInCurrentThread(repo, entry.getValue()));
final HgRepository hgRepo = HgUtil.getRepositoryForFile(myProject, repo);
if (hgRepo != null && hgRepo.hasSubrepos()) {
hgChanges.addAll(ContainerUtil.mapNotNull(hgRepo.getSubrepos(), info -> findChange(hgRepo, info)));
}
sendChanges(builder, hgChanges, list, workingRevision, parentRevision);
}
return hgChanges;
}
Aggregations