private void ShowMergeBranchHelper(bool fromMenu) { var branchesList = TypicalMergeBranchesWithOrigin .Where(branch => WorkBranches.Any(b => b.StartsWith(branch, StringComparison.OrdinalIgnoreCase))) .Select(branch => branch + "*") .ToList(); if (branchesList.Count == 0) { if (fromMenu) { Utils.ShowMessage("There are no branches in the Work list that we would consider as belonging in the Merge list.\r\nIf you want to make changes, you can use the Right-Click Popup menu from each list or selecting a branch + Ctrl/Arrow keys to move branches between lists."); } } else { var introText = WorkBranches.Count > 0 && MergeBranches.Count == 0 ? "This project is new for WhatsMerged. Please select how you want to treat the branches that it contains.\r\n" + "We recognized some popular branch names, please tell us if these are Merge branches or not.\r\n\r\n" : ""; introText += "What we call Work branches (the left list) is where you implement your changes and fixes.\r\n" + "What we call Merge branches (the middle list) is where those changes are then merged, typically using PRs.\r\n\r\n" + "Note: these settings are stored in '" + Path.Combine(UserHomePath, UserSettingsFilename) + "'.\r\n\r\n" + "Please check/uncheck which groups of branches to set as Merge branches, with * meaning a wildcard that matches all text:"; var frm = new CheckboxListForm { Intro = introText, Items = branchesList, StartPosition = FormStartPosition.CenterParent }; frm.ShowDialog(this); if (frm.Items.Count > 0) { branchesList.Clear(); for (var i = 0; i < frm.Items.Count; i++) { var branch = frm.Items[i].RemoveAtEnd("*"); branchesList.AddRange(WorkBranches.Where(b => b.StartsWith(branch))); } WorkBranches.RemoveRange(branchesList); MergeBranches.AddRange(branchesList); WMEngine.SortByCommitDate(MergeBranches); // Workbranches always gets sorted on load, so no need to do that again. lstMergeBranches.SelectedIndex = -1; SaveUserSettings(); } } }
private void ShowMergeStatusInGrid(string title, bool fromWork = false, bool fromMerge = false, bool toWork = false, bool toMerge = false) { Status($"Gathering data for {title} overview..."); SetEnabled(busy: true); try { ClearError(); ClearGrid(); if ((fromWork || toWork) && WorkBranches.IsNullOrEmpty()) { ShowError($"{title}: {lblWorkBranches.Text} list is empty."); return; } if ((fromMerge || toMerge) && MergeBranches.IsNullOrEmpty()) { ShowError($"{title}: {lblMergeBranches.Text} list is empty."); return; } var mergeTable = WMEngine.GetMergeTable(title, fromWork, fromMerge, toWork, toMerge); if (HasError() || mergeTable == null) { return; } LoadGrid(mergeTable); StatusAdd("Done."); } catch (Exception ex) { ShowError("Exception: " + ex.Message); StatusAdd("Error occurred."); } finally { SetEnabled(busy: false); } }