Skip to content

Commit

Permalink
WIP: try to solve "Blame to previous revision" gitextensions#6605
Browse files Browse the repository at this point in the history
  • Loading branch information
pmiossec committed Jun 1, 2019
1 parent c97ece9 commit ca1b455
Showing 1 changed file with 37 additions and 13 deletions.
50 changes: 37 additions & 13 deletions GitUI/UserControls/BlameControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -551,23 +551,47 @@ private void blamePreviousRevisionToolStripMenuItem_Click(object sender, EventAr

var objectId = _blame.Lines[line].Commit.ObjectId;
int originalLine = _blame.Lines[line].OriginLineNumber;
GitBlame blame = Module.Blame(_fileName, objectId + "^", _encoding, originalLine + ",+1");
if (blame.Lines.Count > 0)

// TODO: Finish => blame the direct parent commit from the selected line

var selectedRevision = _revGrid.GetRevision(objectId);
if (!selectedRevision.HasParent)
{
var revision = blame.Lines[0].Commit.ObjectId;
if (_revGrid != null)
{
_clickedBlameLine = blame.Lines[0];
_revGrid.SetSelectedRevision(revision);
}
else
_revGrid.SetSelectedRevision(selectedRevision);
using (var frm = new FormCommitDiff(UICommands, selectedRevision.ObjectId))
{
using (var frm = new FormCommitDiff(UICommands, revision))
{
frm.ShowDialog(this);
}
frm.ShowDialog(this);
}

return;
}

if (selectedRevision.ParentIds.Count == 1)
{
_revGrid.SetSelectedRevision(selectedRevision.FirstParentGuid);
return;
}

// TODO: Finish => What to do when there are more than 1 parents?!?
_revGrid.SetSelectedRevision(selectedRevision.FirstParentGuid);

////GitBlame blame = Module.Blame(_fileName, objectId + "^", _encoding, originalLine + ",+1");
////if (blame.Lines.Count > 0)
////{
//// var revision = blame.Lines[0].Commit.ObjectId;
//// if (_revGrid != null)
//// {
//// _clickedBlameLine = blame.Lines[0];
//// _revGrid.SetSelectedRevision(revision);
//// }
//// else
//// {
//// using (var frm = new FormCommitDiff(UICommands, revision))
//// {
//// frm.ShowDialog(this);
//// }
//// }
////}
}

private void showChangesToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down

0 comments on commit ca1b455

Please sign in to comment.