forked from blinkbox/Git-Source-Control-Provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPendingChangesView.bb.cs
85 lines (76 loc) · 3.15 KB
/
PendingChangesView.bb.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PendingChangesView.bb.cs" company="blinkbox">
// blinkbox implementation of PendingChangesView.
// </copyright>
// <summary>
// blinkbox implementation of PendingChangesView.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace GitScc
{
using System;
using System.Windows.Input;
using GitScc.Blinkbox;
using GitScc.Blinkbox.Options;
/// <summary>
/// BB extensions to the PendingChangesView
/// </summary>
public partial class PendingChangesView
{
/// <summary>
/// The name of the branch to be used for reviewing
/// </summary>
private readonly string comparisonBranch;
/// <summary>
/// Initialises the blinkbox extensions.
/// </summary>
public void InitialiseBlinkboxExtensions()
{
// Register this component as a service so that we can use it externally.
BasicSccProvider.RegisterService(this);
}
/// <summary>
/// Writes a message to the diff editor
/// </summary>
/// <param name="message">The message.</param>
public void WriteToDiffWindow(string message)
{
var action = new Action(() => this.DiffEditor.AppendText(Environment.NewLine + message));
this.DiffEditor.Dispatcher.BeginInvoke(action);
}
/// <summary>
/// Clears the diff editor.
/// </summary>
public void ClearDiffEditor()
{
var action = new Action(() => this.DiffEditor.Clear());
this.DiffEditor.Dispatcher.BeginInvoke(action);
}
/// <summary>
/// Replaces the double-click functionality with a tortoise-git diff, if available.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Windows.Input.MouseButtonEventArgs"/> instance containing the event data.</param>
private void dataGrid1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (!BlinkboxSccOptions.Current.TortoiseAvailable)
{
// Compare the file (differs from existing implementation.
this.GetSelectedFileFullName(fileName =>
{
var sccService = BasicSccProvider.GetServiceEx<SccProviderService>();
sccService.CompareFile(fileName, null);
});
return;
}
// Otherwise, use tortiose git to provide the diff.
this.GetSelectedFileFullName(fileName =>
{
var sccHelper = BasicSccProvider.GetServiceEx<SccHelperService>();
// Diff the file in tortoise
var tfsRevision = sccHelper.GetHeadRevisionHash(BlinkboxSccOptions.Current.TfsRemoteBranch);
sccHelper.DiffFileInTortoise(fileName, tfsRevision, BlinkboxSccOptions.WorkingDirectoryRevision);
});
}
}
}