Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
24,700
boolean (final Object obj) { if (!(obj instanceof HgVersion)) { return false; } return compareTo((HgVersion)obj) == 0; }
equals
24,701
int () { return Objects.hash(myMajor, myMiddle, myMinor); }
hashCode
24,702
int (@NotNull HgVersion o) { int d = myMajor - o.myMajor; if (d != 0) { return d; } d = myMiddle - o.myMiddle; if (d != 0) { return d; } return myMinor - o.myMinor; }
compareTo
24,703
String () { return myMajor + "." + myMiddle + "." + myMinor; }
toString
24,704
Charset (@NotNull Project project) { if (HGENCODING != null && HGENCODING.length() > 0 && Charset.isSupported(HGENCODING)) { return Charset.forName(HGENCODING); } Charset defaultCharset = null; if (!project.isDisposed()) { defaultCharset = EncodingProjectManager.getInstance(project).getDefaultCharset(); } return defaultCharset != null ? defaultCharset : Charset.defaultCharset(); }
getDefaultCharset
24,705
String (@NotNull Charset charset) { //workaround for x_MacRoman encoding etc; todo: create map with encoding aliases because some encodings name are not supported by hg String name = charset.name(); if (name.startsWith("x-M")) { //NON-NLS return name.substring(2); // without "x-" prefix; } return name; }
getNameFor
24,706
boolean (@NotNull HgCommandResult result) { return result.getExitValue() == 255 || result.getRawError().contains("** unknown exception encountered"); //NON-NLS }
fatalErrorOccurred
24,707
boolean (@Nullable HgCommandResult result) { return result == null || getAbortLine(result) != null; }
isAbort
24,708
boolean (@Nullable HgCommandResult result) { if (result == null) return false; String errorLine = getAbortLine(result); return errorLine != null && StringUtil.contains(errorLine, MERGE_WITH_ANCESTOR_ERROR); }
isAncestorMergeError
24,709
boolean (@Nullable HgCommandResult result) { if (result == null) return false; return ContainerUtil.exists(result.getOutputLines(), s -> StringUtil.contains(s, NOTHING_TO_REBASE_WARNING)); }
isNothingToRebase
24,710
boolean (@Nullable HgCommandResult result) { if (result == null) { return false; } String line = getLastErrorLine(result); return isAuthorizationError(line); }
isAuthorizationError
24,711
boolean (@Nullable HgCommandResult result) { return isAbort(result) || result.getExitValue() != 0; }
hasErrorsInCommandExecution
24,712
boolean (@Nullable HgCommandResult result) { return isAbort(result) || result.getExitValue() > 1; }
isCommandExecutionFailed
24,713
boolean (@Nullable String destinationPath) { if (StringUtil.isEmptyOrSpaces(destinationPath)) { return false; } return HgUtil.URL_WITH_PASSWORD.matcher(destinationPath).matches(); }
hasAuthorizationInDestinationPath
24,714
boolean (@NotNull List<String> errorLines) { if (errorLines.isEmpty()) { return false; } String line = errorLines.get(0); return !StringUtil.isEmptyOrSpaces(line) && (line.contains("abort") && line.contains("unknown encoding")); //NON-NLS }
isUnknownEncodingError
24,715
boolean (@Nullable HgCommandResult result) { if (result == null) { return false; } // error messages from mercurial after update command failed: "abort: outstanding uncommitted merges", "abort: uncommitted changes"; //after revert command failed: abort: "uncommitted merge" final Pattern UNCOMMITTED_PATTERN = Pattern.compile(".*abort.*uncommitted\\s*(change|merge).*", Pattern.DOTALL); Matcher matcher = UNCOMMITTED_PATTERN.matcher(result.getRawError()); return matcher.matches(); }
hasUncommittedChangesConflict
24,716
boolean (String line) { return !StringUtil.isEmptyOrSpaces(line) && (line.contains("authorization required") || line.contains("authorization failed")); //NON-NLS }
isAuthorizationError
24,717
boolean (String line) { return !StringUtil.isEmptyOrSpaces(line) && line.trim().startsWith("abort:"); //NON-NLS }
isAbortLine
24,718
void (@Nullable Project project, @NonNls @Nullable String notificationDisplayId, @NotNull Exception e) { handleException(project, notificationDisplayId, CommonBundle.message("title.error"), e); }
handleException
24,719
void (@Nullable Project project, @NonNls @Nullable String notificationDisplayId, @NotificationTitle @NotNull String title, @NotNull Exception e) { LOG.info(e); new HgCommandResultNotifier(project).notifyError(notificationDisplayId, null, title, e.getMessage()); }
handleException
24,720
boolean (@Nullable HgCommandResult result) { //abort: working directory of repo_name: timed out waiting for lock held by 'process:id' // or //waiting for lock on working directory of repo_name if (result == null) return false; return isAbort(result) && result.getRawError().contains("waiting for lock"); //NON-NLS }
isWLockError
24,721
HgReferenceValidator () { return INSTANCE; }
getInstance
24,722
boolean (String inputString) { if (StringUtil.isEmptyOrSpaces(inputString)) { return false; } if (containsIllegalSymbols(inputString)) return false; return !isReservedWord(inputString) && !onlyDigits(inputString) && !hasConflictsWithAnotherNames(inputString); }
checkInput
24,723
boolean (@Nullable String inputString) { if (inputString != null && ILLEGAL.matcher(inputString).find()) { myErrorText = HgBundle.message("hg4idea.validation.name.no.colons"); return true; } return false; }
containsIllegalSymbols
24,724
boolean (@Nullable String inputString) { if (inputString != null && DIGITS_ILLEGAL.matcher(inputString).matches()) { myErrorText = HgBundle.message("hg4idea.validation.name.invalid"); return true; } return false; }
onlyDigits
24,725
boolean (@Nullable String name) { return checkInput(name); }
canClose
24,726
boolean (@Nullable String name) { myErrorText = TIP_REFERENCE.equals(name) ? HgBundle.message("hg4idea.validation.name.reserved", name) : null; return myErrorText != null; }
isReservedWord
24,727
boolean (@Nullable String name) { return false; }
hasConflictsWithAnotherNames
24,728
String (@NotNull String branchName) { if (onlyDigits(branchName)) return branchName + "_"; return branchName.replaceAll(ILLEGAL.pattern(), "_").replaceAll("\"", ""); }
cleanUpBranchName
24,729
boolean (@Nullable String name) { Collection<String> branches = myRepository.getBranches().keySet(); String currentBranch = myRepository.getCurrentBranch(); // branches set doesn't contain uncommitted branch -> need an addition check myErrorText = currentBranch.equals(name) || branches.contains(name) ? HgBundle.message("hg4idea.branch.duplicated.name.error", name) : null; return myErrorText != null; }
hasConflictsWithAnotherNames
24,730
boolean (@NotNull VirtualFile file) { return file.findChild(HgUtil.DOT_HG) != null; }
isRoot
24,731
boolean (@NotNull VirtualFile file) { return Files.exists(file.toNioPath().resolve(HgUtil.DOT_HG)); }
validateRoot
24,732
VcsKey () { return HgVcs.getKey(); }
getSupportedVcs
24,733
boolean (@NotNull String dirName) { return dirName.equalsIgnoreCase(HgUtil.DOT_HG); }
isVcsDir
24,734
boolean (final @NotNull VirtualFile directory) { if (HgInit.createRepository(myProject, directory)) { refreshVcsDir(directory, HgUtil.DOT_HG); return true; } return false; }
initOrNotifyError
24,735
List<String> (HgRevisionNumber vcsRevisionNumber, String fileName) { final List<String> arguments = new LinkedList<>(); if (vcsRevisionNumber != null) { arguments.add("--rev"); if (!StringUtil.isEmptyOrSpaces(vcsRevisionNumber.getChangeset())) { arguments.add(vcsRevisionNumber.getChangeset()); } else { arguments.add(vcsRevisionNumber.getRevision()); } } arguments.add(fileName); return arguments; }
createArguments
24,736
void (HgFile @NotNull ... hgFiles) { executeInCurrentThread(Arrays.asList(hgFiles)); }
executeInCurrentThread
24,737
void (@NotNull Collection<HgFile> hgFiles) { for( Map.Entry<VirtualFile, List<String>> entry : HgUtil.getRelativePathsByRepository(hgFiles).entrySet()) { List<String> filePaths = entry.getValue(); for (List<String> chunkFiles : VcsFileUtil.chunkArguments(filePaths)) { List<String> parameters = new LinkedList<>(); parameters.addAll(chunkFiles); parameters.add(0, "--after"); new HgCommandExecutor(myProject).executeInCurrentThread(entry.getKey(), "remove", parameters); } } }
executeInCurrentThread
24,738
void (@NotNull Collection<? extends VirtualFile> files) { executeInCurrentThread(files, null); }
executeInCurrentThread
24,739
void (final Collection<? extends VirtualFile> files) { if (files.size() >= HgUtil.MANY_FILES) { new Task.Backgroundable(myProject, HgBundle.message("hg4idea.add.progress"), true) { @Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(false); executeInCurrentThread(files, indicator); } }.queue(); } else { BackgroundTaskUtil.executeOnPooledThread(HgDisposable.getInstance(myProject), () -> executeInCurrentThread(files)); } }
addWithProgress
24,740
void (@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(false); executeInCurrentThread(files, indicator); }
run
24,741
void (@NotNull Collection<? extends VirtualFile> files, @Nullable ProgressIndicator indicator) { final Map<VirtualFile, Collection<VirtualFile>> sorted = HgUtil.sortByHgRoots(myProject, files); for (Map.Entry<VirtualFile, Collection<VirtualFile>> entry : sorted.entrySet()) { if (indicator != null) { if (indicator.isCanceled()) return; indicator.setFraction(0); indicator.setText2(HgBundle.message("hg4idea.add.files.progress", entry.getKey().getPresentableUrl())); } addFilesSynchronously(entry.getKey(), entry.getValue(), indicator); } }
executeInCurrentThread
24,742
void (VirtualFile repo, Collection<? extends VirtualFile> files, @Nullable ProgressIndicator indicator) { final List<List<String>> chunks = VcsFileUtil.chunkFiles(repo, files); int currentChunk = 0; for (List<String> paths : chunks) { if (indicator != null) { if (indicator.isCanceled()) return; indicator.setFraction((double)currentChunk / chunks.size()); currentChunk++; } new HgCommandExecutor(myProject).executeInCurrentThread(repo, "add", paths); } }
addFilesSynchronously
24,743
void (@NonNls String revision) { this.revision = revision; }
setRevision
24,744
void (boolean clean) { this.clean = clean; }
setClean
24,745
int (final @NotNull Project project, @NotNull @NlsContexts.DialogTitle String confirmationMessage) { final AtomicInteger exitCode = new AtomicInteger(); UIUtil.invokeAndWaitIfNeeded(() -> { exitCode.set(Messages.showOkCancelDialog(project, confirmationMessage, HgBundle.message("hg4idea.update.uncommitted.problem"), HgBundle.message("changes.discard"), CommonBundle.message("button.cancel.c"), Messages.getWarningIcon())); }); return exitCode.get(); }
showDiscardChangesConfirmation
24,746
void (final @NotNull @NonNls String targetRevision, @NotNull List<? extends HgRepository> repos, final @Nullable Runnable callInAwtLater) { FileDocumentManager.getInstance().saveAllDocuments(); for (HgRepository repo : repos) { final VirtualFile repository = repo.getRoot(); Project project = repo.getProject(); updateRepoTo(project, repository, targetRevision, callInAwtLater); } }
updateTo
24,747
void (final @NotNull Project project, final @NotNull VirtualFile repository, final @NotNull @NonNls String targetRevision, final @Nullable Runnable callInAwtLater) { updateRepoTo(project, repository, targetRevision, false, callInAwtLater); }
updateRepoTo
24,748
void (final @NotNull Project project, final @NotNull VirtualFile repository, final @NotNull @NonNls String targetRevision, final boolean clean, final @Nullable Runnable callInAwtLater) { new Task.Backgroundable(project, HgBundle.message("action.hg4idea.updateTo.description")) { @Override public void onSuccess() { if (callInAwtLater != null) { callInAwtLater.run(); } } @Override public void run(@NotNull ProgressIndicator indicator) { updateRepoToInCurrentThread(project, repository, targetRevision, clean); } }.queue(); }
updateRepoTo
24,749
void () { if (callInAwtLater != null) { callInAwtLater.run(); } }
onSuccess
24,750
void (@NotNull ProgressIndicator indicator) { updateRepoToInCurrentThread(project, repository, targetRevision, clean); }
run
24,751
boolean (final @NotNull Project project, final @NotNull VirtualFile repository, final @NotNull @NonNls String targetRevision, final boolean clean) { final HgUpdateCommand hgUpdateCommand = new HgUpdateCommand(project, repository); hgUpdateCommand.setRevision(targetRevision); hgUpdateCommand.setClean(clean); HgCommandResult result = hgUpdateCommand.execute(); new HgConflictResolver(project).resolve(repository); boolean success = !HgErrorUtil.isCommandExecutionFailed(result); boolean hasUnresolvedConflicts = HgConflictResolver.hasConflicts(project, repository); if (!success) { new HgCommandResultNotifier(project) .notifyError(UPDATE_ERROR, result, "", HgBundle.message("hg4idea.update.failed")); } else if (hasUnresolvedConflicts) { new VcsNotifier(project) .notifyImportantWarning(UPDATE_UNRESOLVED_CONFLICTS_ERROR, HgBundle.message("hg4idea.update.unresolved.conflicts"), HgBundle.message("hg4idea.update.warning.merge.conflicts", repository.getPath())); } getRepositoryManager(project).updateRepository(repository); HgUtil.markDirectoryDirty(project, repository); return success; }
updateRepoToInCurrentThread
24,752
List<HgAnnotationLine> (@NotNull HgFile hgFile, @Nullable HgRevisionNumber revision) { final List<String> arguments = new ArrayList<>(); arguments.add("-cvnudl"); HgVcs vcs = HgVcs.getInstance(myProject); if (vcs != null && vcs.getProjectSettings().isWhitespacesIgnoredInAnnotations() && vcs.getVersion().isIgnoreWhitespaceDiffInAnnotationsSupported()) { arguments.add("-w"); } if (revision != null) { arguments.add("-r"); arguments.add(revision.getChangeset()); } arguments.add(hgFile.getRelativePath()); final HgCommandResult result = new HgCommandExecutor(myProject).executeInCurrentThread(hgFile.getRepo(), "annotate", arguments); if (result == null) { LOG.debug("No result from annotate command"); return Collections.emptyList(); } List<String> outputLines = result.getOutputLines(); return parse(outputLines); }
execute
24,753
List<HgAnnotationLine> (List<String> outputLines) { List<HgAnnotationLine> annotations = new ArrayList<>(outputLines.size()); for (String line : outputLines) { Matcher matcher = LINE_PATTERN.matcher(line); if (matcher.matches()) { String user = matcher.group(USER_GROUP).trim(); HgRevisionNumber rev = HgRevisionNumber.getInstance(matcher.group(REVISION_GROUP), matcher.group(CHANGESET_GROUP)); String dateGroup = matcher.group(DATE_GROUP).trim(); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.US); String date = ""; try { date = FileAnnotation.formatDate(dateFormat.parse(dateGroup)); } catch (ParseException e) { LOG.error("Couldn't parse annotation date ", e); } Integer lineNumber = Integer.valueOf(matcher.group(LINE_NUMBER_GROUP)); String content = matcher.group(CONTENT_GROUP); HgAnnotationLine annotationLine = new HgAnnotationLine( user, rev, date, lineNumber, content ); annotations.add(annotationLine); } else { if (LOG.isDebugEnabled()) { LOG.debug("Line does not match blame pattern: " + line); } } } return annotations; }
parse
24,754
List<HgRevisionNumber> () { return executeInCurrentThread("."); }
executeInCurrentThread
24,755
List<HgRevisionNumber> (String branch) { return new HeadsCommand(project, branch).executeInCurrentThread(repo); }
executeInCurrentThread
24,756
void (List<String> args) { if (!StringUtil.isEmpty(branch)) { args.add(branch); } }
addArguments
24,757
void (List<String> args) { args.add("--newest-first"); }
addArguments
24,758
boolean () { return true; }
isSilentCommand
24,759
HgCommandResult (VirtualFile repo, List<String> args) { String repositoryURL = getRepositoryUrl(repo); if (repositoryURL == null) { LOG.info("executeCommand no default path configured"); return null; } HgRemoteCommandExecutor executor = new HgRemoteCommandExecutor(project, repositoryURL); HgCommandResult result = executor.executeInCurrentThread(repo, command, args); if (result == HgCommandResult.CANCELLED || HgErrorUtil.isAuthorizationError(result)) { final HgVcs vcs = HgVcs.getInstance(project); if (vcs == null) { return result; } new HgCommandResultNotifier(project).notifyError(CHANGESETS_ERROR, result, HgBundle.message("hg4idea.changesets.error"), HgBundle.message("hg4idea.changesets.error.msg", repositoryURL), new NotificationListener() { @Override public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) { ShowSettingsUtil.getInstance() .showSettingsDialog(project, HgProjectConfigurable.class); } }); final HgProjectSettings projectSettings = vcs.getProjectSettings(); projectSettings.setCheckIncomingOutgoing(false); } return result; }
executeCommandInCurrentThread
24,760
void (@NotNull Notification notification, @NotNull HyperlinkEvent event) { ShowSettingsUtil.getInstance() .showSettingsDialog(project, HgProjectConfigurable.class); }
hyperlinkUpdate
24,761
void (boolean includeRemoved) { myIncludeRemoved = includeRemoved; }
setIncludeRemoved
24,762
void (boolean followCopies) { myFollowCopies = followCopies; }
setFollowCopies
24,763
void (boolean logFile) { myLogFile = logFile; }
setLogFile
24,764
List<HgFileRevision> (final HgFile hgFile, int limit, boolean includeFiles) { return execute(hgFile, limit, includeFiles, null); }
execute
24,765
HgVersion () { return myVersion; }
getVersion
24,766
List<HgFileRevision> (final HgFile hgFile, int limit, boolean includeFiles, @Nullable List<String> argsForCmd) { if ((limit <= 0 && limit != -1) || hgFile == null) { return Collections.emptyList(); } String[] templates = HgBaseLogParser.constructFullTemplateArgument(includeFiles, myVersion); String template = HgChangesetUtil.makeTemplate(templates); FilePath originalFileName = HgUtil.getOriginalFileName(hgFile.toFilePath(), ChangeListManager.getInstance(myProject)); HgFile originalHgFile = new HgFile(hgFile.getRepo(), originalFileName); HgCommandResult result = execute(hgFile.getRepo(), template, limit, originalHgFile, argsForCmd); return HgHistoryUtil.getCommitRecords(myProject, result, new HgFileRevisionLogParser(myProject, originalHgFile, myVersion)); }
execute
24,767
List<String> (@NotNull String template, int limit, @Nullable HgFile hgFile, @Nullable List<String> argsForCmd) { List<String> arguments = new LinkedList<>(); if (myIncludeRemoved) { // There is a bug in mercurial that causes --follow --removed <file> to cause // an error (http://mercurial.selenic.com/bts/issue2139). Avoid this combination // for now, preferring to use --follow over --removed. if (!(myFollowCopies && myLogFile)) { arguments.add("--removed"); } } if (myFollowCopies) { arguments.add("--follow"); //workaround: --follow options doesn't work with largefiles extension, so we need to switch off this extension in log command //see http://selenic.com/pipermail/mercurial-devel/2013-May/051209.html fixed since 2.7 if (!myLargeFilesWithFollowSupported) { arguments.add("--config"); arguments.add("extensions.largefiles=!"); } } arguments.add("--template"); arguments.add(template); if (!CommitCountStageKt.isAll(limit)) { arguments.add("--limit"); arguments.add(String.valueOf(limit)); } if (argsForCmd != null) { arguments.addAll(argsForCmd); } //to do double check the same condition should be simplified if (myLogFile && hgFile != null) { arguments.add(hgFile.getRelativePath()); } return arguments; }
createArguments
24,768
boolean (@NotNull VirtualFile repo, @NotNull String template, int limit, @Nullable HgFile hgFile, @Nullable List<String> argsForCmd, @NotNull HgLineProcessListener listener) { List<String> arguments = createArguments(template, limit, hgFile, argsForCmd); HgCommandExecutor commandExecutor = new HgCommandExecutor(myProject); commandExecutor.setOutputAlwaysSuppressed(true); return commandExecutor.executeInCurrentThread(repo, "log", arguments, false, listener); }
execute
24,769
HgCommandResult (@NotNull VirtualFile repoRoot, @NotNull FilePath sourcePath, @NotNull FilePath targetPath) { // hg wlock error may occur while execute this command // since hg version 2017 config timeout.warn=time_in_seconds can be added as argument to wait before warn File repoFile = VfsUtilCore.virtualToIoFile(repoRoot); return new HgCommandExecutor(project).executeInCurrentThread(repoRoot, "rename", asList("--after", getRelativePath(repoFile, sourcePath.getIOFile()), getRelativePath(repoFile, targetPath.getIOFile()))); }
execute
24,770
HgCommandResult (@NotNull String rootPath) { final HgCommandExecutor executor = new HgCommandExecutor(myProject, rootPath); executor.setShowOutput(true); return executor.executeInCurrentThread(null, "init", Collections.singletonList(rootPath)); }
execute
24,771
Set<String> (@NotNull HgCommandResult result) { Set<String> branches = new TreeSet<>(); for (final String line : result.getOutputLines()) { Matcher matcher = BRANCH_LINE.matcher(line); if (matcher.matches()) { branches.add(matcher.group(NAME_INDEX).trim()); } } return branches; }
collectNames
24,772
void (String directory) { this.directory = directory; }
setDirectory
24,773
void (String repositoryURL) { this.repositoryURL = repositoryURL; }
setRepositoryURL
24,774
void (@NotNull @NonNls String revision) { this.revision = revision; }
setRevision
24,775
void (final @NotNull HgRepository repository, final @NotNull @NonNls String branchName, final @NotNull UpdatedFiles updatedFiles) { mergeWith(repository, branchName, updatedFiles, null); }
mergeWith
24,776
void (final @NotNull HgRepository repository, final @NotNull @NonNls String branchName, final @NotNull UpdatedFiles updatedFiles, final @Nullable Runnable onSuccessHandler) { final Project project = repository.getProject(); final VirtualFile repositoryRoot = repository.getRoot(); final HgMergeCommand hgMergeCommand = new HgMergeCommand(project, repository); hgMergeCommand.setRevision(branchName);//there is no difference between branch or revision or bookmark as parameter to merge, // we need just a string new Task.Backgroundable(project, HgBundle.message("action.hg4idea.merge.progress")) { @Override public void run(@NotNull ProgressIndicator indicator) { try { HgCommandResult result = hgMergeCommand.mergeSynchronously(); if (HgErrorUtil.isAncestorMergeError(result)) { //skip and notify VcsNotifier.getInstance(project) .notifyMinorWarning(MERGE_WITH_ANCESTOR_SKIPPED, HgBundle.message("action.hg4idea.merge.skipped.title", repositoryRoot.getPresentableName()), HgBundle.message("action.hg4idea.merge.skipped")); return; } new HgConflictResolver(project, updatedFiles).resolve(repositoryRoot); if (!HgConflictResolver.hasConflicts(project, repositoryRoot) && onSuccessHandler != null) { onSuccessHandler.run(); // for example commit changes } } catch (VcsException exception) { if (exception.isWarning()) { VcsNotifier.getInstance(project).notifyWarning(MERGE_WARNING, HgBundle.message("action.hg4idea.merge.warning"), exception.getMessage()); } else { VcsNotifier.getInstance(project).notifyError(MERGE_EXCEPTION, HgBundle.message("action.hg4idea.merge.exception"), exception.getMessage()); } } } }.queue(); }
mergeWith
24,777
void (@NotNull ProgressIndicator indicator) { try { HgCommandResult result = hgMergeCommand.mergeSynchronously(); if (HgErrorUtil.isAncestorMergeError(result)) { //skip and notify VcsNotifier.getInstance(project) .notifyMinorWarning(MERGE_WITH_ANCESTOR_SKIPPED, HgBundle.message("action.hg4idea.merge.skipped.title", repositoryRoot.getPresentableName()), HgBundle.message("action.hg4idea.merge.skipped")); return; } new HgConflictResolver(project, updatedFiles).resolve(repositoryRoot); if (!HgConflictResolver.hasConflicts(project, repositoryRoot) && onSuccessHandler != null) { onSuccessHandler.run(); // for example commit changes } } catch (VcsException exception) { if (exception.isWarning()) { VcsNotifier.getInstance(project).notifyWarning(MERGE_WARNING, HgBundle.message("action.hg4idea.merge.warning"), exception.getMessage()); } else { VcsNotifier.getInstance(project).notifyError(MERGE_EXCEPTION, HgBundle.message("action.hg4idea.merge.exception"), exception.getMessage()); } } }
run
24,778
List<HgRevisionNumber> (@NotNull VirtualFile repo) { return getRevisions(repo, "parents", null, null, true); }
parents
24,779
Couple<HgRevisionNumber> (@NotNull VirtualFile repo, @Nullable VirtualFile file) { return parents(repo, file, null); }
parents
24,780
Couple<HgRevisionNumber> (@NotNull VirtualFile repo, @Nullable VirtualFile file, @Nullable HgRevisionNumber revision) { return parents(repo, VcsUtil.getFilePath(file), revision); }
parents
24,781
Couple<HgRevisionNumber> (@NotNull VirtualFile repo, @Nullable FilePath file) { return parents(repo, file, null); }
parents
24,782
Couple<HgRevisionNumber> (@NotNull VirtualFile repo, @Nullable FilePath file, @Nullable HgRevisionNumber revision) { final List<HgRevisionNumber> revisions = getRevisions(repo, "parents", file, revision, true); return switch (revisions.size()) { case 1 -> Couple.of(revisions.get(0), null); case 2 -> Couple.of(revisions.get(0), revisions.get(1)); default -> Couple.of(null, null); }; }
parents
24,783
Couple<HgRevisionNumber> (@NotNull VirtualFile repo) { HgCommandExecutor commandExecutor = new HgCommandExecutor(myProject); commandExecutor.setSilent(true); HgCommandResult result = commandExecutor.executeInCurrentThread(repo, "identify", Arrays.asList("--num", "--id")); if (result == null) { return Couple.of(HgRevisionNumber.NULL_REVISION_NUMBER, null); } final List<String> lines = result.getOutputLines(); if (!lines.isEmpty()) { List<String> parts = StringUtil.split(lines.get(0), " "); if (parts.size() >= 2) { String changesets = parts.get(0); String revisions = parts.get(1); if (changesets.indexOf('+') != changesets.lastIndexOf('+')) { // in the case of unresolved merge we have 2 revisions at once, both current, so with "+" // 9f2e6c02913c+b311eb4eb004+ 186+183+ List<String> chsets = StringUtil.split(changesets, "+"); List<String> revs = StringUtil.split(revisions, "+"); return Couple.of(HgRevisionNumber.getInstance(revs.get(0) + "+", chsets.get(0) + "+"), HgRevisionNumber.getInstance(revs.get(1) + "+", chsets.get(1) + "+")); } else { return Couple.of(HgRevisionNumber.getInstance(revisions, changesets), null); } } } return Couple.of(HgRevisionNumber.NULL_REVISION_NUMBER, null); }
identify
24,784
List<HgRevisionNumber> (@NotNull VirtualFile repo, @NotNull @NonNls String command, @Nullable FilePath file, @Nullable HgRevisionNumber revision, boolean silent) { final List<String> args = new LinkedList<>(); args.add("--template"); args.add(HgChangesetUtil.makeTemplate("{rev}", "{node}")); if (revision != null) { args.add("-r"); args.add(revision.getChangeset()); } if (file != null) { // NB: this must be the last argument args.add(HgUtil.getOriginalFileName(file, ChangeListManager.getInstance(myProject)).getPath()); } final HgCommandExecutor executor = new HgCommandExecutor(myProject); executor.setSilent(silent); final HgCommandResult result = executor.executeInCurrentThread(repo, command, args); if (result == null) { return new ArrayList<>(0); } final List<String> lines = new ArrayList<>(); for (String line : result.getRawOutput().split(HgChangesetUtil.CHANGESET_SEPARATOR)) { if (!line.trim().isEmpty()) { // filter out empty lines lines.add(line); } } if (lines.isEmpty()) { return new ArrayList<>(); } final List<HgRevisionNumber> revisions = new ArrayList<>(lines.size()); for(String line: lines) { final List<String> parts = StringUtil.split(line, HgChangesetUtil.ITEM_SEPARATOR); if (parts.size() < 2) { LOG.error("getRevisions output parse error in line [" + line + "]\n All lines: \n" + lines); continue; } revisions.add(HgRevisionNumber.getInstance(parts.get(0), parts.get(1))); } return revisions; }
getRevisions
24,785
void (final VirtualFile repo, final Consumer<Map<HgFile, HgResolveStatusEnum>> resultHandler) { if (repo == null) { resultHandler.consume(Collections.emptyMap()); } HgCommandExecutor executor = new HgCommandExecutor(myProject); executor.setSilent(true); BackgroundTaskUtil.executeOnPooledThread(HgDisposable.getInstance(myProject), () -> { HgCommandResult result = executor.executeInCurrentThread(repo, "resolve", Collections.singletonList("--list")); resultHandler.consume(result == null ? Collections.emptyMap() : handleResult(repo, result)); }); }
getListAsynchronously
24,786
void (@NotNull VirtualFile repo, @NotNull VirtualFile path) { markResolved(repo, Collections.singleton(VcsUtil.getFilePath(path))); }
markResolved
24,787
void (@NotNull VirtualFile repo, @NotNull Collection<FilePath> paths) { for (List<String> chunk : VcsFileUtil.chunkPaths(repo, paths)) { List<String> args = new ArrayList<>(); args.add("--mark"); args.addAll(chunk); BackgroundTaskUtil.executeOnPooledThread(HgDisposable.getInstance(myProject), () -> new HgCommandExecutor(myProject).executeInCurrentThread(repo, "resolve", args)); } }
markResolved
24,788
void (String revision) { myRevision = revision; }
setRevision
24,789
void (boolean force) { myForce = force; }
setForce
24,790
void (String branchName) { myBranchName = branchName; }
setBranchName
24,791
void (boolean isNewBranch) { myIsNewBranch = isNewBranch; }
setIsNewBranch
24,792
void (String bookmark) { myBookmarkName = bookmark; }
setBookmarkName
24,793
HgCommandResult () { final List<String> arguments = new LinkedList<>(); if (!StringUtil.isEmptyOrSpaces(myRevision)) { arguments.add("-r"); arguments.add(myRevision); } if (myBranchName != null) { arguments.add("-b"); arguments.add(myBranchName); } if (myIsNewBranch) { arguments.add("--new-branch"); } if (!StringUtil.isEmptyOrSpaces(myBookmarkName)) { arguments.add("-B"); arguments.add(myBookmarkName); } if (myForce) { arguments.add("-f"); } arguments.add(myDestination); final HgRemoteCommandExecutor executor = new HgRemoteCommandExecutor(myProject, myDestination); executor.setShowOutput(true); HgCommandResult result = executor.executeInCurrentThread(myRepo, "push", arguments); BackgroundTaskUtil.syncPublisher(myProject, HgVcs.REMOTE_TOPIC).update(myProject, null); return result; }
executeInCurrentThread
24,794
VirtualFile () { return myRepo; }
getRepo
24,795
List<HgRevisionNumber> (VirtualFile repo) { return getRevisions(repo); }
executeInCurrentThread
24,796
List<HgRevisionNumber> (VirtualFile repo) { List<String> args = new ArrayList<>(Arrays.asList( "--template", HgChangesetUtil.makeTemplate("{rev}", "{node}", "{author}", "{desc|firstline}"), "--quiet" )); addArguments(args); HgCommandResult result = executeCommandInCurrentThread(repo, args); if (result == null) { return Collections.emptyList(); } String output = result.getRawOutput(); if (StringUtil.isEmpty(output)) { return Collections.emptyList(); } String[] changesets = output.split(HgChangesetUtil.CHANGESET_SEPARATOR); List<HgRevisionNumber> revisions = new ArrayList<>(changesets.length); for(String changeset: changesets) { List<String> parts = StringUtil.split(changeset, HgChangesetUtil.ITEM_SEPARATOR); if (parts.size() >= 3) { //support zero commit message revisions.add(HgRevisionNumber.getInstance(parts.get(0), parts.get(1), parts.get(2), parts.size() > 3 ? parts.get(3) : "")); } else { LOG.warn("Could not parse changeset [" + changeset + "]"); } } return revisions; }
getRevisions
24,797
boolean () { return false; }
isSilentCommand
24,798
void (VirtualFile source, VirtualFile target) { VirtualFile sourceRepo = VcsUtil.getVcsRootFor(myProject, source); VirtualFile targetRepo = VcsUtil.getVcsRootFor(myProject, target); HgCommandExecutor executor = new HgCommandExecutor(myProject, VcsFileUtil.relativeOrFullPath(sourceRepo, source)); if (sourceRepo != null && targetRepo != null && sourceRepo.equals(targetRepo)) { HgCommandResult result; int attempt = 0; do { result = executor.executeInCurrentThread(sourceRepo, "copy", Arrays.asList("--after", VcsFileUtil.relativeOrFullPath(sourceRepo, source), VcsFileUtil.relativeOrFullPath(targetRepo, target))); } while (HgErrorUtil.isWLockError(result) && attempt++ < 2); } else { // copying from one repository to another => 'hg add' in new repo if (targetRepo != null) { new HgAddCommand(myProject).executeInCurrentThread(Collections.singleton(target)); } } }
executeInCurrentThread
24,799
void (List<String> args) { args.add("-r"); args.add("0:" + mySource.getChangeset()); args.add("--prune"); args.add(myDest.getChangeset()); args.add("--limit"); args.add(String.valueOf(myLimit)); }
addArguments