void (@NotNull LightActionGroup popupGroup, @NotNull AbstractRepositoryManager<HgRepository> repositoryManager) { List<HgRepository> allRepositories = repositoryManager.getRepositories(); popupGroup.add(new HgBranchPopupActions.HgNewBranchAction(myProject, allRepositories, myCurrentRepository)); popupGroup.addAction(new HgBranchPopupActions.HgNewBookmarkAction(allRepositories, myCurrentRepository)); popupGroup.addAction(new HgBranchPopupActions.HgCloseBranchAction(allRepositories, myCurrentRepository)); popupGroup.addAction(new HgBranchPopupActions.HgShowUnnamedHeadsForCurrentBranchAction(myCurrentRepository)); popupGroup.addAll(createRepositoriesActions()); popupGroup.addSeparator(HgBundle.message("hg4idea.branch.common.branches.separator")); List<HgCommonBranchActions> branchActions = myMultiRootBranchConfig.getLocalBranchNames().stream() .map(b -> createLocalBranchActions(allRepositories, b, false)) .filter(Objects::nonNull).sorted(FAVORITE_BRANCH_COMPARATOR).collect(toList()); int topShownBranches = getNumOfTopShownBranches(branchActions); String commonBranch = MultiRootBranches.getCommonName(myRepositoryManager.getRepositories(), Repository::getCurrentBranchName); if (commonBranch != null) { branchActions.add(0, new HgBranchPopupActions.CurrentBranch(myProject, allRepositories, commonBranch)); topShownBranches++; } wrapWithMoreActionIfNeeded(myProject, popupGroup, branchActions, topShownBranches, SHOW_ALL_BRANCHES_KEY, true); popupGroup.addSeparator(HgBundle.message("hg4idea.branch.common.bookmarks.separator")); List<HgCommonBranchActions> bookmarkActions = ((HgMultiRootBranchConfig)myMultiRootBranchConfig).getBookmarkNames().stream() .map(bm -> createLocalBranchActions(allRepositories, bm, true)) .filter(Objects::nonNull).sorted(FAVORITE_BRANCH_COMPARATOR).collect(toList()); int topShownBookmarks = getNumOfTopShownBranches(bookmarkActions); String commonBookmark = MultiRootBranches.getCommonName(repositoryManager.getRepositories(), HgRepository::getCurrentBookmark); if (commonBookmark != null) { bookmarkActions.add(0, new HgBranchPopupActions.CurrentActiveBookmark(myProject, allRepositories, commonBookmark)); topShownBookmarks++; } wrapWithMoreActionIfNeeded(myProject, popupGroup, bookmarkActions, topShownBookmarks, SHOW_ALL_BOOKMARKS_KEY, true); }