Skip to content

Commit

Permalink
More improvements to revision history
Browse files Browse the repository at this point in the history
Show initial SHA when it differs from the HEAD
Rewrote show changelist using LINQ
Implemented show Next, Previous and HEAD differences
Handle copy selected text from a changelist
  • Loading branch information
Goran Devic committed Nov 11, 2012
1 parent a4e8030 commit a3c66cd
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 54 deletions.
23 changes: 20 additions & 3 deletions FormRevisionHistory.cs
Expand Up @@ -22,6 +22,11 @@ public partial class FormRevisionHistory : Form
/// </summary>
private string _file;

/// <summary>
/// The current SHA string to initialize the list
/// </summary>
public string Sha { private get; set; }

/// <summary>
/// 2 last recently selected SHA submits
/// </summary>
Expand All @@ -40,6 +45,7 @@ public FormRevisionHistory(string file)
statusStrip.SizingGrip = false;

_file = file;
Sha = String.Empty;
Text = @"Revision History for //" + file;
}

Expand Down Expand Up @@ -85,8 +91,12 @@ private void FormRevisionHistoryLoad(object sender, EventArgs e)
if(result.Success())
PanelRevlist.UpdateList(listRev, result.stdout);

// Activate the first item
listRev.SelectedIndices.Add(0);
// Activate the given SHA item or the first one if none given
int index = listRev.Items.IndexOfKey(Sha);
if (index < 0)
index = 0;
listRev.SelectedIndices.Add(index);
listRev.Items[index].EnsureVisible();
}

/// <summary>
Expand Down Expand Up @@ -256,7 +266,14 @@ private string GetTempFile(string file, string sha)
// Create a temp file based on our file and write content to it
file = file.Replace(Path.DirectorySeparatorChar, '_');
string temp = Path.Combine(Path.GetTempPath(), sha) + "_" + file;
File.WriteAllText(temp, response);
try
{
File.WriteAllText(temp, response);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "System error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

// Add the temp file to the global list of temp files to be removed at the app exit time
ClassGlobals.TempFiles.Add(temp);
Expand Down
81 changes: 81 additions & 0 deletions FormShowChangelist.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a3c66cd

Please sign in to comment.