mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
optimize<WorkingCopyChanges>: better implementation to unstage renamed changes
This commit is contained in:
parent
2f02b23b51
commit
5e593e4916
1 changed files with 21 additions and 14 deletions
|
@ -122,20 +122,20 @@ namespace SourceGit.Views.Widgets {
|
|||
}
|
||||
|
||||
public void StageSelected() {
|
||||
var files = new List<string>();
|
||||
var changes = new List<Models.Change>();
|
||||
switch (Mode) {
|
||||
case Models.Change.DisplayMode.Tree:
|
||||
var changes = new List<Models.Change>();
|
||||
foreach (var node in modeTree.Selected) GetChangesFromNode(node as ChangeNode, changes);
|
||||
foreach (var c in changes) files.Add(c.Path);
|
||||
break;
|
||||
case Models.Change.DisplayMode.List:
|
||||
foreach (var c in modeList.SelectedItems) files.Add((c as Models.Change).Path);
|
||||
foreach (var c in modeList.SelectedItems) changes.Add(c as Models.Change);
|
||||
break;
|
||||
case Models.Change.DisplayMode.Grid:
|
||||
foreach (var c in modeGrid.SelectedItems) files.Add((c as Models.Change).Path);
|
||||
foreach (var c in modeGrid.SelectedItems) changes.Add(c as Models.Change);
|
||||
break;
|
||||
}
|
||||
|
||||
var files = GetPathsFromChanges(changes);
|
||||
if (files.Count > 0) DoStage(files);
|
||||
}
|
||||
|
||||
|
@ -144,20 +144,20 @@ namespace SourceGit.Views.Widgets {
|
|||
}
|
||||
|
||||
public void UnstageSelected() {
|
||||
var files = new List<string>();
|
||||
var changes = new List<Models.Change>();
|
||||
switch (Mode) {
|
||||
case Models.Change.DisplayMode.Tree:
|
||||
var changes = new List<Models.Change>();
|
||||
foreach (var node in modeTree.Selected) GetChangesFromNode(node as ChangeNode, changes);
|
||||
foreach (var c in changes) files.Add(c.Path);
|
||||
break;
|
||||
case Models.Change.DisplayMode.List:
|
||||
foreach (var c in modeList.SelectedItems) files.Add((c as Models.Change).Path);
|
||||
foreach (var c in modeList.SelectedItems) changes.Add(c as Models.Change);
|
||||
break;
|
||||
case Models.Change.DisplayMode.Grid:
|
||||
foreach (var c in modeGrid.SelectedItems) files.Add((c as Models.Change).Path);
|
||||
foreach (var c in modeGrid.SelectedItems) changes.Add(c as Models.Change);
|
||||
break;
|
||||
}
|
||||
|
||||
var files = GetPathsFromChanges(changes);
|
||||
if (files.Count > 0) DoUnstage(files);
|
||||
}
|
||||
|
||||
|
@ -285,6 +285,15 @@ namespace SourceGit.Views.Widgets {
|
|||
foreach (var sub in node.Children) GetChangesFromNode(sub, changes);
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> GetPathsFromChanges(List<Models.Change> changes) {
|
||||
var files = new List<string>();
|
||||
foreach (var c in changes) {
|
||||
files.Add(c.Path);
|
||||
if (!string.IsNullOrEmpty(c.OriginalPath)) files.Add(c.OriginalPath);
|
||||
}
|
||||
return files;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UNSTAGED
|
||||
|
@ -582,8 +591,7 @@ namespace SourceGit.Views.Widgets {
|
|||
}
|
||||
|
||||
private void OpenStagedContextMenuByNodes(ContextMenu menu, List<ChangeNode> nodes, List<Models.Change> changes) {
|
||||
var files = new List<string>();
|
||||
foreach (var c in changes) files.Add(c.Path);
|
||||
var files = GetPathsFromChanges(changes);
|
||||
|
||||
if (nodes.Count == 1) {
|
||||
var node = nodes[0];
|
||||
|
@ -624,8 +632,7 @@ namespace SourceGit.Views.Widgets {
|
|||
}
|
||||
|
||||
private void OpenStagedContextMenuByChanges(ContextMenu menu, List<Models.Change> changes) {
|
||||
var files = new List<string>();
|
||||
foreach (var c in changes) files.Add(c.Path);
|
||||
var files = GetPathsFromChanges(changes);
|
||||
|
||||
if (changes.Count == 1) {
|
||||
var change = changes[0];
|
||||
|
|
Loading…
Reference in a new issue