private void RestoreSelectedFiles(IList<GitItemStatus> unStagedFiles, IList<GitItemStatus> stagedFiles, IList<GitItemStatus> lastSelection) { if (_currentFilesList == null || _currentFilesList.IsEmpty) { SelectStoredNextIndex(); return; } var newItems = _currentFilesList == Staged ? stagedFiles : unStagedFiles; var names = lastSelection.ToHashSet(x => x.Name); var newSelection = newItems.Where(x => names.Contains(x.Name)).ToList(); if (newSelection.Any()) _currentFilesList.SelectedItems = newSelection; else SelectStoredNextIndex(); }
private void ProcessHeads(string remote, IList<IGitRef> localHeads, IList<IGitRef> remoteHeads) { var remoteBranches = remoteHeads.ToHashSet(h => h.LocalName); // Add all the local branches. foreach (var head in localHeads) { DataRow row = _branchTable.NewRow(); row["Force"] = false; row["Delete"] = false; row["Local"] = head.Name; string remoteName; if (head.Remote == remote) remoteName = head.MergeWith ?? head.Name; else remoteName = head.Name; row["Remote"] = remoteName; bool knownAtRemote = remoteBranches.Contains(remoteName); row["New"] = knownAtRemote ? _no.Text : _yes.Text; row["Push"] = knownAtRemote; _branchTable.Rows.Add(row); } // Offer to delete all the left over remote branches. foreach (var remoteHead in remoteHeads) { var head = remoteHead; if (localHeads.All(h => h.Name != head.LocalName)) { DataRow row = _branchTable.NewRow(); row["Local"] = null; row["Remote"] = remoteHead.LocalName; row["New"] = _no.Text; row["Push"] = false; row["Force"] = false; row["Delete"] = false; _branchTable.Rows.Add(row); } } BranchGrid.Enabled = true; }