Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
25,200
void () { HgShowUnAppliedPatchesAction.showUnAppliedPatches(project, repository); }
onSuccess
25,201
void (@NotNull HgRepository repository, @NotNull Hash commit) { throw new UnsupportedOperationException(); }
actionPerformed
25,202
void (@NotNull AnActionEvent e) { final Project project = e.getRequiredData(CommonDataKeys.PROJECT); VcsLogCommitSelection selection = e.getRequiredData(VcsLogDataKeys.VCS_LOG_COMMIT_SELECTION); selection.requestFullDetails(selectedDetails -> { VcsFullCommitDetails fullCommitDetails = ContainerUtil.getFirstItem(selectedDetails); assert fullCommitDetails != null; final HgRepository repository = getRepositoryForRoot(project, fullCommitDetails.getRoot()); assert repository != null; actionPerformed(repository, fullCommitDetails); }); }
actionPerformed
25,203
boolean (@NotNull HgRepository repository, @NotNull Hash commit) { return super.isEnabled(repository, commit) && isAppliedPatch(repository, commit); }
isEnabled
25,204
boolean (@NotNull HgRepository repository, final @NotNull Hash hash) { return ContainerUtil.exists(repository.getMQAppliedPatches(), info -> info.getHash().equals(hash)); }
isAppliedPatch
25,205
void (@NotNull HgRepository repository, @NotNull Hash commit) { new HgQRenameCommand(repository).execute(commit); }
actionPerformed
25,206
void (@NotNull HgRepository repository, @NotNull Hash commit) { String revisionHash = commit.asString(); new HgQImportCommand(repository).execute(revisionHash); }
actionPerformed
25,207
boolean (@NotNull HgRepository repository, @NotNull Hash commit) { return super.isEnabled(repository, commit) && !HgMqAppliedPatchAction.isAppliedPatch(repository, commit); }
isEnabled
25,208
void (@NotNull HgRepository repository, @NotNull Hash commit) { String revision = commit.asString(); Project project = repository.getProject(); BackgroundTaskUtil.executeOnPooledThread(repository, () -> { HgCommandExecutor executor = new HgCommandExecutor(project); HgCommandResult result = executor.executeInCurrentThread(repository.getRoot(), "qfinish", singletonList("qbase:" + revision)); if (HgErrorUtil.hasErrorsInCommandExecution(result)) { new HgCommandResultNotifier(project).notifyError(QFINISH_ERROR, result, HgBundle.message("action.hg4idea.QFinish.error"), HgBundle.message("action.hg4idea.QFinish.error.msg")); } repository.update(); }); }
actionPerformed
25,209
ActionUpdateThread () { return ActionUpdateThread.EDT; }
getActionUpdateThread
25,210
void (@NotNull AnActionEvent e) { final HgMqUnAppliedPatchesPanel patchInfo = e.getRequiredData(HgMqUnAppliedPatchesPanel.MQ_PATCHES); final List<String> names = patchInfo.getSelectedPatchNames(); final HgRepository repository = patchInfo.getRepository(); Runnable task = () -> { ProgressManager.getInstance().getProgressIndicator().setText(getTitle()); executeInCurrentThread(repository, names); }; patchInfo.updatePatchSeriesInBackground(task); }
actionPerformed
25,211
void (@NotNull AnActionEvent e) { HgMqUnAppliedPatchesPanel patchInfo = e.getData(HgMqUnAppliedPatchesPanel.MQ_PATCHES); e.getPresentation().setEnabled(patchInfo != null && patchInfo.getSelectedRowsCount() != 0 && isEnabled(patchInfo.getRepository())); }
update
25,212
boolean (@NotNull HgRepository repository) { return true; //todo should be improved, param not needed }
isEnabled
25,213
Set<String> (@Nullable String fileListString, @NotNull String separator) { return StringUtil.isEmpty(fileListString) ? Collections.emptySet() : new HashSet<>(StringUtil.split(fileListString, separator)); }
parseFileList
25,214
int (@NotNull String str) { int len = str.length(); int depth = 1; for (int i = 0; i < len; ++i) { char c = str.charAt(i); switch (c) { case '(' -> depth++; case ')' -> depth--; } if (depth == 0) { return i + 1; } } LOG.info("Unexpected output during parse copied files in log command " + str); return -1; }
findRightBracePosition
25,215
List<VcsCommitMetadata> (final @NotNull Project project, final @NotNull VirtualFile root, int limit, @NotNull List<String> parameters) { final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project); if (factory == null) { return Collections.emptyList(); } HgVcs hgvcs = HgVcs.getInstance(project); assert hgvcs != null; HgVersion version = hgvcs.getVersion(); List<String> templateList = HgBaseLogParser.constructDefaultTemplate(version); templateList.add("{desc}"); String[] templates = ArrayUtilRt.toStringArray(templateList); HgCommandResult result = getLogResult(project, root, version, limit, parameters, HgChangesetUtil.makeTemplate(templates)); HgBaseLogParser<VcsCommitMetadata> baseParser = createMetadataParser(root, factory); return getCommitRecords(project, result, baseParser); }
loadMetadata
25,216
VcsFullCommitDetails (@NotNull Project project, @NotNull VirtualFile root, @NotNull VcsLogObjectsFactory factory, @NotNull HgFileRevision revision) { List<List<VcsFileStatusInfo>> reportedChanges = new ArrayList<>(); reportedChanges.add(getStatusInfo(revision)); HgRevisionNumber vcsRevisionNumber = revision.getRevisionNumber(); List<? extends HgRevisionNumber> parents = vcsRevisionNumber.getParents(); for (HgRevisionNumber parent : parents.stream().skip(1).toList()) { reportedChanges.add(getChangesFromParent(project, root, vcsRevisionNumber, parent)); } Hash hash = factory.createHash(vcsRevisionNumber.getChangeset()); List<Hash> parentsHashes = ContainerUtil.map(parents, p -> factory.createHash(p.getChangeset())); long time = revision.getRevisionDate().getTime(); VcsUser author = factory.createUser(vcsRevisionNumber.getName(), vcsRevisionNumber.getEmail()); return new VcsChangesLazilyParsedDetails(project, hash, parentsHashes, time, root, vcsRevisionNumber.getSubject(), author, vcsRevisionNumber.getCommitMessage(), author, time, reportedChanges, new HgChangesParser(vcsRevisionNumber)); }
createDetails
25,217
List<VcsFileStatusInfo> (@NotNull Project project, @NotNull VirtualFile root, @NotNull HgRevisionNumber commit, @NotNull HgRevisionNumber parent) { HgStatusCommand status = new HgStatusCommand.Builder(true).ignored(false).unknown(false).copySource(true) .baseRevision(parent).targetRevision(commit).build(project); return convertHgChanges(status.executeInCurrentThread(root)); }
getChangesFromParent
25,218
List<VcsFileStatusInfo> (@NotNull HgFileRevision revision) { List<VcsFileStatusInfo> firstParentChanges = new ArrayList<>(); for (String file : revision.getModifiedFiles()) { firstParentChanges.add(new VcsFileStatusInfo(Change.Type.MODIFICATION, file, null)); } for (String file : revision.getAddedFiles()) { firstParentChanges.add(new VcsFileStatusInfo(Change.Type.NEW, file, null)); } for (String file : revision.getDeletedFiles()) { firstParentChanges.add(new VcsFileStatusInfo(Change.Type.DELETED, file, null)); } for (Map.Entry<String, String> copiedFile : revision.getMovedFiles().entrySet()) { firstParentChanges.add(new VcsFileStatusInfo(Change.Type.MOVED, copiedFile.getKey(), copiedFile.getValue())); } return firstParentChanges; }
getStatusInfo
25,219
List<VcsFileStatusInfo> (@NotNull Set<HgChange> changes) { Set<String> deleted = new HashSet<>(); Set<String> copied = new HashSet<>(); for (HgChange change : changes) { Change.Type type = getType(change.getStatus()); if (Change.Type.DELETED.equals(type)) { deleted.add(change.beforeFile().getRelativePath()); } else if (Change.Type.MOVED.equals(type)) { copied.add(change.beforeFile().getRelativePath()); } } List<VcsFileStatusInfo> result = new ArrayList<>(); for (HgChange change : changes) { Change.Type type = getType(change.getStatus()); LOG.assertTrue(type != null, "Unsupported status for change " + change); String firstPath; String secondPath; switch (type) { case DELETED -> { firstPath = change.beforeFile().getRelativePath(); secondPath = null; if (copied.contains(firstPath)) continue; // file was renamed } case MOVED -> { firstPath = change.beforeFile().getRelativePath(); secondPath = change.afterFile().getRelativePath(); if (!deleted.contains(firstPath)) { type = Change.Type.NEW; // file was copied, treating it like an addition firstPath = change.afterFile().getRelativePath(); secondPath = null; } } //case MODIFICATION, NEW -> default -> { firstPath = change.afterFile().getRelativePath(); secondPath = null; } } result.add(new VcsFileStatusInfo(type, Objects.requireNonNull(firstPath), secondPath)); } return result; }
convertHgChanges
25,220
HgFile (@NotNull Project project, @NotNull VirtualFile root) { HgFile hgFile = new HgFile(root, VcsUtil.getFilePath(root.getPath())); if (project.isDisposed()) { return hgFile; } FilePath originalFileName = HgUtil.getOriginalFileName(hgFile.toFilePath(), ChangeListManager.getInstance(project)); return new HgFile(hgFile.getRepo(), originalFileName); }
getOriginalHgFile
25,221
HgBaseLogParser<VcsCommitMetadata> (@NotNull VirtualFile root, VcsLogObjectsFactory factory) { return new HgBaseLogParser<>() { @Override protected VcsCommitMetadata convertDetails(@NotNull String rev, @NotNull String changeset, @NotNull SmartList<? extends HgRevisionNumber> parents, @NotNull Date revisionDate, @NotNull String author, @NotNull String email, @NotNull List<String> attributes) { String message = parseAdditionalStringAttribute(attributes, MESSAGE_INDEX); String subject = extractSubject(message); List<Hash> parentsHash = new SmartList<>(); for (HgRevisionNumber parent : parents) { parentsHash.add(factory.createHash(parent.getChangeset())); } return factory.createCommitMetadata(factory.createHash(changeset), parentsHash, revisionDate.getTime(), root, subject, author, email, message, author, email, revisionDate.getTime()); } }; }
createMetadataParser
25,222
VcsCommitMetadata (@NotNull String rev, @NotNull String changeset, @NotNull SmartList<? extends HgRevisionNumber> parents, @NotNull Date revisionDate, @NotNull String author, @NotNull String email, @NotNull List<String> attributes) { String message = parseAdditionalStringAttribute(attributes, MESSAGE_INDEX); String subject = extractSubject(message); List<Hash> parentsHash = new SmartList<>(); for (HgRevisionNumber parent : parents) { parentsHash.add(factory.createHash(parent.getChangeset())); } return factory.createCommitMetadata(factory.createHash(changeset), parentsHash, revisionDate.getTime(), root, subject, author, email, message, author, email, revisionDate.getTime()); }
convertDetails
25,223
List<TimedVcsCommit> (@NotNull Project project, @NotNull VirtualFile root, @NotNull Consumer<? super VcsUser> userRegistry, @NotNull List<String> params) { return readHashes(project, root, userRegistry, -1, params); }
readAllHashes
25,224
List<TimedVcsCommit> (@NotNull Project project, @NotNull VirtualFile root, @NotNull Consumer<? super VcsUser> userRegistry, int limit, @NotNull List<String> params) { final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project); if (factory == null) { return Collections.emptyList(); } HgVcs hgvcs = HgVcs.getInstance(project); assert hgvcs != null; HgVersion version = hgvcs.getVersion(); String[] templates = ArrayUtilRt.toStringArray(HgBaseLogParser.constructDefaultTemplate(version)); HgCommandResult result = getLogResult(project, root, version, limit, params, HgChangesetUtil.makeTemplate(templates)); return getCommitRecords(project, result, new HgBaseLogParser<>() { @Override protected TimedVcsCommit convertDetails(@NotNull String rev, @NotNull String changeset, @NotNull SmartList<? extends HgRevisionNumber> parents, @NotNull Date revisionDate, @NotNull String author, @NotNull String email, @NotNull List<String> attributes) { List<Hash> parentsHash = new SmartList<>(); for (HgRevisionNumber parent : parents) { parentsHash.add(factory.createHash(parent.getChangeset())); } userRegistry.consume(factory.createUser(author, email)); return factory.createTimedCommit(factory.createHash(changeset), parentsHash, revisionDate.getTime()); } }); }
readHashes
25,225
TimedVcsCommit (@NotNull String rev, @NotNull String changeset, @NotNull SmartList<? extends HgRevisionNumber> parents, @NotNull Date revisionDate, @NotNull String author, @NotNull String email, @NotNull List<String> attributes) { List<Hash> parentsHash = new SmartList<>(); for (HgRevisionNumber parent : parents) { parentsHash.add(factory.createHash(parent.getChangeset())); } userRegistry.consume(factory.createUser(author, email)); return factory.createTimedCommit(factory.createHash(changeset), parentsHash, revisionDate.getTime()); }
convertDetails
25,226
Change (@NotNull Project project, @NotNull VirtualFile root, @Nullable String fileBefore, @Nullable HgRevisionNumber revisionBefore, @Nullable String fileAfter, HgRevisionNumber revisionAfter, FileStatus aStatus) { HgContentRevision beforeRevision = fileBefore == null || aStatus == FileStatus.ADDED ? null : HgContentRevision .create(project, new HgFile(root, new File(root.getPath(), fileBefore)), revisionBefore); ContentRevision afterRevision; if (aStatus == FileStatus.DELETED) { afterRevision = null; } else if (revisionAfter == null && fileBefore != null) { afterRevision = CurrentContentRevision.create(new HgFile(root, new File(root.getPath(), fileAfter != null ? fileAfter : fileBefore)).toFilePath()); } else { assert revisionAfter != null; afterRevision = fileAfter == null ? null : HgContentRevision.create(project, new HgFile(root, new File(root.getPath(), fileAfter)), revisionAfter); } return new Change(beforeRevision, afterRevision, aStatus); }
createChange
25,227
List<String> (@NotNull List<String> hashes) { List<String> hashArgs = new ArrayList<>(); for (String hash : hashes) { hashArgs.add("-r"); hashArgs.add(hash); } return hashArgs; }
prepareHashes
25,228
String (String paramName, String value) { return "--" + paramName + "=" + value; // no value escaping needed, because the parameter itself will be quoted by GeneralCommandLine }
prepareParameter
25,229
void (@NotNull String line) { int separatorIndex; while ((separatorIndex = line.indexOf(HgChangesetUtil.CHANGESET_SEPARATOR)) >= 0) { myOutput.append(line, 0, separatorIndex); myConsumer.consume(myOutput); myOutput.setLength(0); // maybe also call myOutput.trimToSize() to free some memory ? line = line.substring(separatorIndex + 1); } myOutput.append(line); }
processOutputLine
25,230
List<Change> (@NotNull Project project, @NotNull VcsShortCommitDetails commit, @NotNull List<VcsFileStatusInfo> changes, int parentIndex) { List<Change> result = new ArrayList<>(); for (VcsFileStatusInfo info : changes) { String filePath = info.getFirstPath(); HgRevisionNumber parentRevision = myRevisionNumber.getParents().isEmpty() ? null : myRevisionNumber.getParents().get(parentIndex); Change change = switch (info.getType()) { case MODIFICATION -> createChange(project, commit.getRoot(), filePath, parentRevision, filePath, myRevisionNumber, FileStatus.MODIFIED); case NEW -> createChange(project, commit.getRoot(), null, null, filePath, myRevisionNumber, FileStatus.ADDED); case DELETED -> createChange(project, commit.getRoot(), filePath, parentRevision, null, myRevisionNumber, FileStatus.DELETED); case MOVED -> createChange(project, commit.getRoot(), filePath, parentRevision, info.getSecondPath(), myRevisionNumber, HgChangeProvider.RENAMED); }; result.add(change); } return result; }
parseStatusInfo
25,231
Comparator<VcsRef> () { return REF_COMPARATOR; }
getLabelsOrderComparator
25,232
List<RefGroup> (@NotNull Collection<? extends VcsRef> refs) { List<VcsRef> sortedRefs = sort(refs); MultiMap<VcsRefType, VcsRef> groupedRefs = ContainerUtil.groupBy(sortedRefs, VcsRef::getType); List<RefGroup> result = new ArrayList<>(); List<VcsRef> branches = new ArrayList<>(); List<VcsRef> bookmarks = new ArrayList<>(); for (Map.Entry<VcsRefType, Collection<VcsRef>> entry : groupedRefs.entrySet()) { if (entry.getKey().equals(TIP) || entry.getKey().equals(HEAD)) { for (VcsRef ref : entry.getValue()) { result.add(new SingletonRefGroup(ref)); } } else if (entry.getKey().equals(BOOKMARK)) { bookmarks.addAll(entry.getValue()); } else { branches.addAll(entry.getValue()); } } if (!branches.isEmpty()) result.add(new SimpleRefGroup(HgBundle.message("hg.ref.group.name.branches"), branches, false)); if (!bookmarks.isEmpty()) result.add(new SimpleRefGroup(HgBundle.message("hg.ref.group.name.bookmarks"), bookmarks, false)); return result; }
groupForBranchFilter
25,233
List<RefGroup> (@NotNull Collection<? extends VcsRef> references, boolean compact, boolean showTagNames) { List<VcsRef> sortedReferences = sort(references); List<VcsRef> headAndTip = new ArrayList<>(); MultiMap<VcsRefType, VcsRef> groupedRefs = MultiMap.createLinked(); for (VcsRef ref : sortedReferences) { if (ref.getType().equals(HEAD) || ref.getType().equals(TIP)) { headAndTip.add(ref); } else { groupedRefs.putValue(ref.getType(), ref); } } List<RefGroup> refGroups = SimpleRefGroup.buildGroups(emptyList(), groupedRefs, compact, showTagNames); if (headAndTip.isEmpty()) return refGroups; RefGroup firstGroup = getFirstItem(refGroups); if (firstGroup != null) { firstGroup.getRefs().addAll(0, headAndTip); return refGroups; } List<RefGroup> result = new ArrayList<>(); result.add(new SimpleRefGroup("", headAndTip)); result.addAll(refGroups); return result; }
groupForTable
25,234
HgBranchType (@NotNull VcsRef reference) { return reference.getType().equals(BOOKMARK) ? HgBranchType.BOOKMARK : HgBranchType.BRANCH; }
getBranchType
25,235
boolean (@NotNull VcsRef reference) { if (reference.getType().equals(HEAD) || reference.getType().equals(TIP)) return true; if (!reference.getType().isBranch()) return false; return myProject.getService(HgBranchManager.class) .isFavorite(getBranchType(reference), getRepository(reference), reference.getName()); }
isFavorite
25,236
void (@NotNull VcsRef reference, boolean favorite) { if (!reference.getType().isBranch() || reference.getType().equals(HEAD) || reference.getType().equals(TIP)) return; myProject.getService(HgBranchManager.class) .setFavorite(getBranchType(reference), getRepository(reference), reference.getName(), favorite); }
setFavorite
25,237
Comparator<VcsRef> () { return REF_COMPARATOR; }
getBranchLayoutComparator
25,238
List<VcsRef> (@NotNull Collection<? extends VcsRef> refs) { return ContainerUtil.sorted(refs, getLabelsOrderComparator()); }
sort
25,239
Set<VcsRef> (@NotNull VirtualFile root) { if (myProject.isDisposed()) { return Collections.emptySet(); } HgRepository repository = getHgRepoManager(myProject).getRepositoryForRoot(root); if (repository == null) { LOG.error("Repository not found for root " + root); return Collections.emptySet(); } repository.update(); Map<String, LinkedHashSet<Hash>> branches = repository.getBranches(); Set<String> openedBranchNames = repository.getOpenedBranches(); Collection<HgNameWithHashInfo> bookmarks = repository.getBookmarks(); Collection<HgNameWithHashInfo> tags = repository.getTags(); Collection<HgNameWithHashInfo> localTags = repository.getLocalTags(); Collection<HgNameWithHashInfo> mqAppliedPatches = repository.getMQAppliedPatches(); Set<VcsRef> refs = new HashSet<>(branches.size() + bookmarks.size()); for (Map.Entry<String, LinkedHashSet<Hash>> entry : branches.entrySet()) { String branchName = entry.getKey(); boolean opened = openedBranchNames.contains(branchName); for (Hash hash : entry.getValue()) { refs.add(myVcsObjectsFactory.createRef(hash, branchName, opened ? HgRefManager.BRANCH : HgRefManager.CLOSED_BRANCH, root)); } } for (HgNameWithHashInfo bookmarkInfo : bookmarks) { refs.add(myVcsObjectsFactory.createRef(bookmarkInfo.getHash(), bookmarkInfo.getName(), HgRefManager.BOOKMARK, root)); } String currentRevision = repository.getCurrentRevision(); if (currentRevision != null) { // null => fresh repository refs.add(myVcsObjectsFactory.createRef(myVcsObjectsFactory.createHash(currentRevision), HEAD_REFERENCE, HgRefManager.HEAD, root)); } String tipRevision = repository.getTipRevision(); if (tipRevision != null) { // null => fresh repository refs.add(myVcsObjectsFactory.createRef(myVcsObjectsFactory.createHash(tipRevision), TIP_REFERENCE, HgRefManager.TIP, root)); } for (HgNameWithHashInfo tagInfo : tags) { refs.add(myVcsObjectsFactory.createRef(tagInfo.getHash(), tagInfo.getName(), HgRefManager.TAG, root)); } for (HgNameWithHashInfo localTagInfo : localTags) { refs.add(myVcsObjectsFactory.createRef(localTagInfo.getHash(), localTagInfo.getName(), HgRefManager.LOCAL_TAG, root)); } for (HgNameWithHashInfo mqPatchRef : mqAppliedPatches) { refs.add(myVcsObjectsFactory.createRef(mqPatchRef.getHash(), mqPatchRef.getName(), HgRefManager.MQ_APPLIED_TAG, root)); } return refs; }
readAllRefs
25,240
VcsKey () { return HgVcs.getKey(); }
getSupportedVcs
25,241
VcsLogRefManager () { return myRefSorter; }
getReferenceManager
25,242
Disposable (final @NotNull Collection<? extends VirtualFile> roots, final @NotNull VcsLogRefresher refresher) { MessageBusConnection connection = myProject.getMessageBus().connect(); connection.subscribe(HgVcs.STATUS_TOPIC, new HgUpdater() { @Override public void update(Project project, @Nullable VirtualFile root) { if (root != null && roots.contains(root)) { refresher.refresh(root); } } }); return connection; }
subscribeToRootRefreshEvents
25,243
void (Project project, @Nullable VirtualFile root) { if (root != null && roots.contains(root)) { refresher.refresh(root); } }
update
25,244
List<TimedVcsCommit> (final @NotNull VirtualFile root, @NotNull VcsLogFilterCollection filterCollection, int maxCount) { List<String> filterParameters = new ArrayList<>(); // branch filter and user filter may be used several times without delimiter VcsLogBranchFilter branchFilter = filterCollection.get(VcsLogFilterCollection.BRANCH_FILTER); if (branchFilter != null) { HgRepository repository = getHgRepoManager(myProject).getRepositoryForRoot(root); if (repository == null) { LOG.error("Repository not found for root " + root); return Collections.emptyList(); } Collection<String> branchNames = repository.getBranches().keySet(); Collection<String> bookmarkNames = HgUtil.getNamesWithoutHashes(repository.getBookmarks()); Collection<String> predefinedNames = Collections.singletonList(TIP_REFERENCE); boolean atLeastOneBranchExists = false; for (String branchName : ContainerUtil.concat(branchNames, bookmarkNames, predefinedNames)) { if (branchFilter.matches(branchName)) { filterParameters.add(HgHistoryUtil.prepareParameter("branch", branchName)); atLeastOneBranchExists = true; } } if (branchFilter.matches(HEAD_REFERENCE)) { filterParameters.add(HgHistoryUtil.prepareParameter("branch", ".")); filterParameters.add("-r"); filterParameters.add("::."); //all ancestors for current revision; atLeastOneBranchExists = true; } if (!atLeastOneBranchExists) { // no such branches => filter matches nothing return Collections.emptyList(); } } VcsLogUserFilter userFilter = filterCollection.get(VcsLogFilterCollection.USER_FILTER); if (userFilter != null) { filterParameters.add("-r"); String authorFilter = StringUtil.join(ContainerUtil.map(ContainerUtil.map(userFilter.getUsers(root), VcsUserUtil::toExactString), UserNameRegex.EXTENDED_INSTANCE), "|"); filterParameters.add("user('re:" + authorFilter + "')"); } VcsLogDateFilter dateFilter = filterCollection.get(VcsLogFilterCollection.DATE_FILTER); if (dateFilter != null) { StringBuilder args = new StringBuilder(); final SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm"); filterParameters.add("-d"); if (dateFilter.getAfter() != null) { if (dateFilter.getBefore() != null) { args.append(dateFormatter.format(dateFilter.getAfter())).append(" to ").append(dateFormatter.format(dateFilter.getBefore())); } else { args.append('>').append(dateFormatter.format(dateFilter.getAfter())); } } else if (dateFilter.getBefore() != null) { args.append('<').append(dateFormatter.format(dateFilter.getBefore())); } filterParameters.add(args.toString()); } VcsLogTextFilter textFilter = filterCollection.get(VcsLogFilterCollection.TEXT_FILTER); if (textFilter != null) { String text = textFilter.getText(); if (textFilter.isRegex()) { filterParameters.add("-r"); filterParameters.add("grep(r'" + text + "')"); } else if (textFilter.matchesCase()) { filterParameters.add("-r"); filterParameters.add("grep(r'" + StringUtil.escapeChars(text, UserNameRegex.EXTENDED_REGEX_CHARS) + "')"); } else { filterParameters.add(HgHistoryUtil.prepareParameter("keyword", text)); } } VcsLogStructureFilter structureFilter = filterCollection.get(VcsLogFilterCollection.STRUCTURE_FILTER); if (structureFilter != null) { for (FilePath file : structureFilter.getFiles()) { filterParameters.add(file.getPath()); } } return HgHistoryUtil.readHashes(myProject, root, EmptyConsumer.getInstance(), maxCount, filterParameters); }
getCommitsMatchingFilter
25,245
HgRepositoryManager (@NotNull Project project) { return project.getService(HgRepositoryManager.class); }
getHgRepoManager
25,246
CommitT (String s) { return convert(s); }
fun
25,247
List<String> (HgVersion currentVersion) { List<String> templates = new ArrayList<>(); templates.add("{rev}"); templates.add("{node}"); if (currentVersion.isParentRevisionTemplateSupported()) { templates.add("{p1rev}:{p1node} {p2rev}:{p2node}"); } else { templates.add("{parents}"); } templates.addAll(Arrays.asList("{date|hgdate}", "{author}")); return templates; }
constructDefaultTemplate
25,248
List<String> (@NotNull List<String> fileTemplates, @NotNull HgVersion currentVersion) { final boolean supported = currentVersion.isBuiltInFunctionSupported(); return ContainerUtil.map(fileTemplates, s -> supported ? "{join(" + s + ",'" + HgChangesetUtil.FILE_SEPARATOR + "')}" : "{" + s + "}"); }
wrapIn
25,249
SmartList<HgRevisionNumber> (@NotNull String parentsString, @NotNull String currentRevisionString) { SmartList<HgRevisionNumber> parents = new SmartList<>(); if (StringUtil.isEmptyOrSpaces(parentsString)) { // parents shouldn't be empty only if not supported long revision = Long.parseLong(currentRevisionString); HgRevisionNumber parentRevision = HgRevisionNumber.getLocalInstance(String.valueOf(revision - 1)); parents.add(parentRevision); return parents; } //hg returns parents in the format 'rev:node rev:node ' (note the trailing space) List<String> parentStrings = StringUtil.split(parentsString.trim(), " "); for (String parentString : parentStrings) { List<String> parentParts = StringUtil.split(parentString, ":"); //if revision has only 1 parent and "--debug" argument were added or if appropriate parent template were used, // its second parent has revision number -1 if (Integer.parseInt(parentParts.get(0)) >= 0) { parents.add(HgRevisionNumber.getInstance(parentParts.get(0), parentParts.get(1))); } } return parents; }
parseParentRevisions
25,250
String (final List<String> attributes, int index) { int numAttributes = attributes.size(); if (numAttributes > index) { return attributes.get(index); } LOG.warn("Couldn't parse hg log commit info attribute " + index); return ""; }
parseAdditionalStringAttribute
25,251
String (@NotNull String message) { int subjectIndex = message.indexOf('\n'); return subjectIndex == -1 ? message : message.substring(0, subjectIndex); }
extractSubject
25,252
VcsKey () { return HgVcs.getKey(); }
getSupportedVcs
25,253
void (final @NotNull List<? extends VcsFullCommitDetails> commits) { Map<HgRepository, List<VcsFullCommitDetails>> commitsInRoots = DvcsUtil.groupCommitsByRoots( HgUtil.getRepositoryManager(myProject), commits); for (Map.Entry<HgRepository, List<VcsFullCommitDetails>> entry : commitsInRoots.entrySet()) { processGrafting(entry.getKey(), ContainerUtil.map(entry.getValue(), commitDetails -> commitDetails.getId().asString())); } }
cherryPick
25,254
void (@NotNull HgRepository repository, @NotNull List<String> hashes) { Project project = repository.getProject(); VirtualFile root = repository.getRoot(); HgGraftCommand command = new HgGraftCommand(project, repository); HgCommandResult result = command.startGrafting(hashes); boolean hasConflicts = HgConflictResolver.hasConflicts(project, root); if (!hasConflicts && HgErrorUtil.isCommandExecutionFailed(result)) { new HgCommandResultNotifier(project).notifyError(GRAFT_ERROR, result, HgBundle.message("hg4idea.hg.error"), HgBundle.message("action.hg4idea.Graft.error")); return; } final UpdatedFiles updatedFiles = UpdatedFiles.create(); while (hasConflicts) { new HgConflictResolver(project, updatedFiles).resolve(root); hasConflicts = HgConflictResolver.hasConflicts(project, root); if (!hasConflicts) { result = command.continueGrafting(); hasConflicts = HgConflictResolver.hasConflicts(project, root); } else { new HgCommandResultNotifier(project).notifyError(GRAFT_CONTINUE_ERROR, result, HgBundle.message("hg4idea.hg.error"), HgBundle.message("action.hg4idea.Graft.continue.error")); break; } } repository.update(); root.refresh(true, true); }
processGrafting
25,255
boolean (@NotNull Collection<? extends VirtualFile> roots) { HgRepositoryManager hgRepositoryManager = HgUtil.getRepositoryManager(myProject); return roots.stream().allMatch(r -> hgRepositoryManager.getRepositoryForRootQuick(r) != null); }
canHandleForRoots
25,256
void (@NotNull DocumentEvent e) { validateFields(); }
textChanged
25,257
String () { return tagTxt.getText(); }
getTagName
25,258
VirtualFile () { return hgRepositorySelectorComponent.getRepository().getRoot(); }
getRepository
25,259
void (@NotNull Collection<HgRepository> repositories, @Nullable HgRepository selectedRepo) { hgRepositorySelectorComponent.setRoots(repositories); hgRepositorySelectorComponent.setSelectedRoot(selectedRepo); }
setRoots
25,260
JComponent () { return contentPanel; }
createCenterPanel
25,261
void () { HgReferenceValidator validator = new HgBranchReferenceValidator(hgRepositorySelectorComponent.getRepository()); String name = getTagName(); if (!validator.checkInput(name)) { String message = validator.getErrorText(name); setErrorText(message == null ? HgBundle.message("action.hg4idea.tag.name.error") : message, tagTxt); setOKActionEnabled(false); return; } setErrorText(null); setOKActionEnabled(true); }
validateFields
25,262
JComponent () { return tagTxt; }
getPreferredFocusedComponent
25,263
JComponent () { return myContentPanel; }
getContentPanel
25,264
void () { myCommitAfterMergeCheckBox.setEnabled(myMergeRadioButton.isSelected()); }
updateEnabledStates
25,265
void (@NotNull HgUpdateConfigurationSettings updateConfiguration) { updateConfiguration.setShouldPull(myPullCheckBox.isSelected()); if (myOnlyUpdateButton.isSelected()) { updateConfiguration.setUpdateType(HgUpdateType.ONLY_UPDATE); } if (myMergeRadioButton.isSelected()) { updateConfiguration.setUpdateType(HgUpdateType.MERGE); } if (myRebaseRadioButton.isSelected()) { updateConfiguration.setUpdateType(HgUpdateType.REBASE); } updateConfiguration.setShouldCommitAfterMerge(myCommitAfterMergeCheckBox.isSelected()); }
applyTo
25,266
JComponent () { String panelConstraints = "flowy, ins 0 0 0 10, fill"; MigLayout migLayout = new MigLayout(panelConstraints); JPanel contentPane = new JPanel(migLayout); myPullCheckBox = new JBCheckBox(HgBundle.message("action.hg4idea.pull.p"), true); myPullCheckBox.setToolTipText(HgBundle.message("action.hg4idea.pull.from.default.remote")); myPullCheckBox.setSelected(true); myOnlyUpdateButton = new JRadioButton(HgBundle.message("action.hg4idea.pull.only.update"), true); myOnlyUpdateButton.setToolTipText(HgBundle.message("action.hg4idea.pull.update.to.head")); myMergeRadioButton = new JRadioButton(HgBundle.message("action.hg4idea.pull.update.merge"), false); myMergeRadioButton.setToolTipText(HgBundle.message("action.hg4idea.pull.merge.if.in.extra")); myMergeRadioButton.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateEnabledStates(); } }); myCommitAfterMergeCheckBox = new JCheckBox(HgBundle.message("action.hg4idea.pull.commit.after.merge"), false); myCommitAfterMergeCheckBox.setToolTipText(HgBundle.message("action.hg4idea.pull.commit.automatically")); myCommitAfterMergeCheckBox.setSelected(false); myRebaseRadioButton = new JRadioButton(HgBundle.message("action.hg4idea.pull.rebase"), false); myRebaseRadioButton.setToolTipText(HgBundle.message("action.hg4idea.pull.rebase.tooltip")); contentPane.add(myPullCheckBox, "left"); JPanel strategyPanel = new JPanel(new MigLayout(panelConstraints)); strategyPanel.setBorder(IdeBorderFactory.createTitledBorder(HgBundle.message("action.hg4idea.pull.update.strategy"), false)); strategyPanel.add(myOnlyUpdateButton, "left"); strategyPanel.add(myMergeRadioButton, "left"); strategyPanel.add(myCommitAfterMergeCheckBox, "gapx 5%"); strategyPanel.add(myRebaseRadioButton, "left"); contentPane.add(strategyPanel); ButtonGroup group = new ButtonGroup(); group.add(myOnlyUpdateButton); group.add(myRebaseRadioButton); group.add(myMergeRadioButton); updateEnabledStates(); return contentPane; }
createCenterPanel
25,267
void (ItemEvent e) { updateEnabledStates(); }
itemStateChanged
25,268
void (@NotNull HgUpdateConfigurationSettings updateConfiguration) { myPullCheckBox.setSelected(updateConfiguration.shouldPull()); HgUpdateType updateType = updateConfiguration.getUpdateType(); JRadioButton button = switch (updateType) { case ONLY_UPDATE -> myOnlyUpdateButton; case MERGE -> myMergeRadioButton; case REBASE -> myRebaseRadioButton; }; button.setSelected(true); myCommitAfterMergeCheckBox.setSelected(updateConfiguration.shouldCommitAfterMerge()); }
updateFrom
25,269
JComponent () { return myBookmarkName; }
getPreferredFocusedComponent
25,270
String () { return HgBookmarkDialog.class.getName(); }
getDimensionServiceKey
25,271
JComponent () { JPanel contentPanel = new JPanel(new GridBagLayout()); GridBag g = new GridBag() .setDefaultInsets(new Insets(0, 0, DEFAULT_VGAP, DEFAULT_HGAP)) .setDefaultAnchor(GridBagConstraints.LINE_START) .setDefaultFill(GridBagConstraints.HORIZONTAL); JLabel icon = new JLabel(UIUtil.getQuestionIcon(), SwingConstants.LEFT); myBookmarkName = new JBTextField(13); myBookmarkName.getDocument().addDocumentListener(new DocumentAdapter() { @Override public void textChanged(@NotNull DocumentEvent e) { validateFields(); } }); JBLabel bookmarkLabel = new JBLabel(HgBundle.message("hg4idea.bookmark.name")); bookmarkLabel.setLabelFor(myBookmarkName); myActiveCheckbox = new JBCheckBox(HgBundle.message("hg4idea.bookmark.inactive"), false); contentPanel.add(icon, g.nextLine().next().coverColumn(3).pady(DEFAULT_HGAP)); contentPanel.add(bookmarkLabel, g.next().fillCellNone().insets(new Insets(0, 6, DEFAULT_VGAP, DEFAULT_HGAP))); contentPanel.add(myBookmarkName, g.next().coverLine().setDefaultWeightX(1)); contentPanel.add(myActiveCheckbox, g.nextLine().next().next().coverLine(2)); return contentPanel; }
createCenterPanel
25,272
void (@NotNull DocumentEvent e) { validateFields(); }
textChanged
25,273
void () { HgReferenceValidator validator = new HgBranchReferenceValidator(myRepository); String name = getName(); if (!validator.checkInput(name)) { String message = validator.getErrorText(name); setErrorText(message == null ? HgBundle.message("hg4idea.bookmark.specify.name") : message, myBookmarkName); setOKActionEnabled(false); return; } setErrorText(null); setOKActionEnabled(true); }
validateFields
25,274
boolean () { return !myActiveCheckbox.isSelected(); }
isActive
25,275
void (ActionEvent e) { onChangeRepository(); }
actionPerformed
25,276
void () { myRepositoryURL = new EditorComboBox(""); myRepositoryURL.addDocumentListener(new DocumentListener() { @Override public void documentChanged(@NotNull DocumentEvent e) { onChangePullSource(); } }); }
createUIComponents
25,277
void (@NotNull DocumentEvent e) { onChangePullSource(); }
documentChanged
25,278
void (@NotNull VirtualFile repo) { Collection<String> paths = HgUtil.getRepositoryPaths(project, repo); for (String path : paths) { myRepositoryURL.prependItem(path); } }
addPathsFromHgrc
25,279
HgRepository () { return hgRepositorySelector.getRepository(); }
getRepository
25,280
String () { return myCurrentRepositoryUrl; }
getSource
25,281
void (@NotNull Collection<HgRepository> repositories, final @Nullable HgRepository selectedRepo) { hgRepositorySelector.setRoots(repositories); hgRepositorySelector.setSelectedRoot(selectedRepo); onChangeRepository(); }
setRoots
25,282
JComponent () { return mainPanel; }
createCenterPanel
25,283
String () { return "reference.mercurial.pull.dialog"; }
getHelpId
25,284
void () { final VirtualFile repo = hgRepositorySelector.getRepository().getRoot(); final String defaultPath = HgUtil.getRepositoryDefaultPath(project, repo); if (!StringUtil.isEmptyOrSpaces(defaultPath)) { addPathsFromHgrc(repo); myRepositoryURL.setText(HgUtil.removePasswordIfNeeded(defaultPath)); myCurrentRepositoryUrl = defaultPath; onChangePullSource(); } }
onChangeRepository
25,285
void () { myCurrentRepositoryUrl = myRepositoryURL.getText(); setOKActionEnabled(!StringUtil.isEmptyOrSpaces(myRepositoryURL.getText())); }
onChangePullSource
25,286
String () { return HgPullDialog.class.getName(); }
getDimensionServiceKey
25,287
void (ActionEvent e) { updateRepository(); }
actionPerformed
25,288
void (ChangeEvent e) { update(); }
stateChanged
25,289
void (Collection<HgRepository> repos, @Nullable HgRepository selectedRepo) { hgRepositorySelectorComponent.setRoots(repos); hgRepositorySelectorComponent.setSelectedRoot(selectedRepo); updateRepository(); }
setRoots
25,290
HgRepository () { return hgRepositorySelectorComponent.getRepository(); }
getRepository
25,291
String () { return (String)tagSelector.getSelectedItem(); }
getTag
25,292
boolean () { return tagOption.isSelected(); }
isTagSelected
25,293
String () { return (String)branchSelector.getSelectedItem(); }
getBranch
25,294
boolean () { return branchOption.isSelected(); }
isBranchSelected
25,295
boolean () { return revisionOption.isSelected(); }
isRevisionSelected
25,296
String () { return (String)bookmarkSelector.getSelectedItem(); }
getBookmark
25,297
boolean () { return bookmarkOption.isSelected(); }
isBookmarkSelected
25,298
String () { return revisionTxt.getText(); }
getRevision
25,299
void () { revisionTxt.setEnabled(revisionOption.isSelected()); branchSelector.setEnabled(branchOption.isSelected()); tagSelector.setEnabled(tagOption.isSelected()); bookmarkSelector.setEnabled(bookmarkOption.isSelected()); }
update