Browse Source

Add Git AddIn (not complete, so its not part of SharpDevelop.sln and won't be compiled by default)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6278 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 15 years ago
parent
commit
d860af3201
  1. 31
      src/AddIns/VersionControl/GitAddIn/Configuration/AssemblyInfo.cs
  2. 51
      src/AddIns/VersionControl/GitAddIn/GitAddIn.addin
  3. 91
      src/AddIns/VersionControl/GitAddIn/GitAddIn.csproj
  4. 84
      src/AddIns/VersionControl/GitAddIn/GitAddIn.sln
  5. 110
      src/AddIns/VersionControl/GitAddIn/Src/Commands.cs
  6. 126
      src/AddIns/VersionControl/GitAddIn/Src/Git.cs
  7. 101
      src/AddIns/VersionControl/GitAddIn/Src/GitGuiWrapper.cs
  8. 51
      src/AddIns/VersionControl/GitAddIn/Src/GitMessageView.cs
  9. 183
      src/AddIns/VersionControl/GitAddIn/Src/GitStatusCache.cs
  10. 47
      src/AddIns/VersionControl/GitAddIn/Src/IsUnderGitControlCondition.cs
  11. 220
      src/AddIns/VersionControl/GitAddIn/Src/OverlayIconManager.cs
  12. 73
      src/AddIns/VersionControl/GitAddIn/Src/RegisterEventsCommand.cs

31
src/AddIns/VersionControl/GitAddIn/Configuration/AssemblyInfo.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("GitAddIn")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GitAddIn")]
[assembly: AssemblyCopyright("2008, Daniel Grunwald")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

51
src/AddIns/VersionControl/GitAddIn/GitAddIn.addin

@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
<AddIn name = "GitAddIn"
author = "Daniel Grunwald"
description = "Git Binding">
<Manifest>
<Identity name="ICSharpCode.GitAddIn" version="@GitAddIn.dll"/>
</Manifest>
<Runtime>
<Import assembly = "GitAddIn.dll">
<ConditionEvaluator name="IsUnderGitControl" class="ICSharpCode.GitAddIn.IsUnderGitControlCondition"/>
</Import>
</Runtime>
<Path name = "/Workspace/Autostart">
<Class id = "ICSharpCode.GitAddIn.RegisterEventsCommand"
class = "ICSharpCode.GitAddIn.RegisterEventsCommand"/>
</Path>
<Path name = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/GitItem">
<Condition name = "IsUnderGitControl">
<MenuItem id = "GitSeparator" type = "Separator"/>
<MenuItem id = "GitCommit"
label = "Git ${res:AddIns.Subversion.Commit}..."
icon = "Svn.Commit"
class = "ICSharpCode.GitAddIn.GitCommitCommand"/>
<MenuItem id = "GitDiff"
label = "Git ${res:AddIns.Subversion.Diff}..."
icon = "Svn.Diff"
class = "ICSharpCode.GitAddIn.GitDiffCommand"/>
</Condition>
</Path>
<Path name = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/SolutionNode">
<Include id = "SubversionInclude" path = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/GitItem"/>
</Path>
<Path name = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectNode">
<Include id = "SubversionInclude" path = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/GitItem"/>
</Path>
<Path name = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/FolderNode">
<Include id = "SubversionInclude" path = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/GitItem"/>
</Path>
<Path name = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/FileNode">
<Include id = "SubversionInclude" path = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/GitItem"/>
</Path>
</AddIn>

91
src/AddIns/VersionControl/GitAddIn/GitAddIn.csproj

@ -0,0 +1,91 @@ @@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectGuid>{83F15BA7-8478-4664-81BB-A82F146D88B3}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.GitAddIn</RootNamespace>
<AssemblyName>GitAddIn</AssemblyName>
<OutputPath>..\..\..\..\AddIns\AddIns\VersionControl\</OutputPath>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' ">v4.0</TargetFrameworkVersion>
<DefineConstants Condition="'$(TargetFrameworkVersion)' == 'v4.0' ">SD4</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>$(DefineConstants);DEBUG;TRACE</DefineConstants>
<Optimize>False</Optimize>
<StartAction>Program</StartAction>
<StartProgram>..\..\..\..\bin\SharpDevelop.exe</StartProgram>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\Commands.cs" />
<Compile Include="Src\Git.cs" />
<Compile Include="Src\GitGuiWrapper.cs" />
<Compile Include="Src\GitMessageView.cs" />
<Compile Include="Src\GitStatusCache.cs" />
<Compile Include="Src\IsUnderGitControlCondition.cs" />
<Compile Include="Src\OverlayIconManager.cs" />
<Compile Include="Src\RegisterEventsCommand.cs" />
<None Include="GitAddIn.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Src" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj">
<Project>{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}</Project>
<Name>ICSharpCode.Core.WinForms</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
</Project>

84
src/AddIns/VersionControl/GitAddIn/GitAddIn.sln

@ -0,0 +1,84 @@ @@ -0,0 +1,84 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.0.0.6197
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitAddIn", "GitAddIn.csproj", "{83F15BA7-8478-4664-81BB-A82F146D88B3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\..\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit", "..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj", "{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonDock", "..\..\..\Libraries\AvalonDock\AvalonDock\AvalonDock.csproj", "{87E61430-4243-45F2-B74E-0A4C096CEBF3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Presentation", "..\..\..\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj", "{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.WinForms", "..\..\..\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj", "{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubversionAddIn", "..\..\Misc\SubversionAddIn\Project\SubversionAddIn.csproj", "{17F4D7E0-6933-4C2E-8714-FD7E98D625D5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartUp", "..\..\..\Main\StartUp\Project\StartUp.csproj", "{1152B71B-3C05-4598-B20D-823B5D40559E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{83F15BA7-8478-4664-81BB-A82F146D88B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83F15BA7-8478-4664-81BB-A82F146D88B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{83F15BA7-8478-4664-81BB-A82F146D88B3}.Release|Any CPU.Build.0 = Release|Any CPU
{83F15BA7-8478-4664-81BB-A82F146D88B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.Build.0 = Release|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.Build.0 = Release|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.Build.0 = Release|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87E61430-4243-45F2-B74E-0A4C096CEBF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87E61430-4243-45F2-B74E-0A4C096CEBF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87E61430-4243-45F2-B74E-0A4C096CEBF3}.Release|Any CPU.Build.0 = Release|Any CPU
{87E61430-4243-45F2-B74E-0A4C096CEBF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Release|Any CPU.Build.0 = Release|Any CPU
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|Any CPU.Build.0 = Debug|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.Build.0 = Release|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.Build.0 = Release|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17F4D7E0-6933-4C2E-8714-FD7E98D625D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17F4D7E0-6933-4C2E-8714-FD7E98D625D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17F4D7E0-6933-4C2E-8714-FD7E98D625D5}.Release|Any CPU.Build.0 = Release|Any CPU
{17F4D7E0-6933-4C2E-8714-FD7E98D625D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Any CPU.Build.0 = Release|Any CPU
{1152B71B-3C05-4598-B20D-823B5D40559E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.Build.0 = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

110
src/AddIns/VersionControl/GitAddIn/Src/Commands.cs

@ -0,0 +1,110 @@ @@ -0,0 +1,110 @@
// Copyright (c) 2008-2009 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using ICSharpCode.SharpDevelop.Util;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.GitAddIn
{
public abstract class GitCommand : AbstractMenuCommand
{
protected abstract void Run(string filename, Action callback);
public override void Run()
{
AbstractProjectBrowserTreeNode node = ProjectBrowserPad.Instance.SelectedNode;
if (node != null) {
string nodeFileName = null;
if (node is DirectoryNode) {
nodeFileName = ((DirectoryNode)node).Directory;
} else if (node is FileNode) {
nodeFileName = ((FileNode)node).FileName;
} else if (node is SolutionNode) {
nodeFileName = ((SolutionNode)node).Solution.Directory;
}
if (nodeFileName != null) {
List<OpenedFile> unsavedFiles = new List<OpenedFile>();
foreach (OpenedFile file in FileService.OpenedFiles) {
if (file.IsDirty && !file.IsUntitled) {
if (string.IsNullOrEmpty(file.FileName)) continue;
if (FileUtility.IsUrl(file.FileName)) continue;
if (FileUtility.IsBaseDirectory(nodeFileName, file.FileName)) {
unsavedFiles.Add(file);
}
}
}
if (unsavedFiles.Count > 0) {
if (MessageService.ShowCustomDialog(
MessageService.DefaultMessageBoxTitle,
"The version control operation would affect files with unsaved modifications.\n" +
"You have to save those files before running the operation.",
0, 1,
"Save files", "Cancel")
== 0)
{
// Save
foreach (OpenedFile file in unsavedFiles) {
ICSharpCode.SharpDevelop.Commands.SaveFile.Save(file);
}
} else {
// Cancel
return;
}
}
// now run the actual operation:
Run(nodeFileName, AfterCommand(nodeFileName, node));
}
}
}
Action AfterCommand(string nodeFileName, AbstractProjectBrowserTreeNode node)
{
return delegate {
WorkbenchSingleton.AssertMainThread();
// and then refresh the project browser:
GitStatusCache.ClearCachedStatus(nodeFileName);
OverlayIconManager.EnqueueRecursive(node);
OverlayIconManager.EnqueueParents(node);
};
}
}
public class GitCommitCommand : GitCommand
{
protected override void Run(string filename, Action callback)
{
GitGuiWrapper.Commit(filename, callback);
}
}
public class GitDiffCommand : GitCommand
{
protected override void Run(string filename, Action callback)
{
GitGuiWrapper.Diff(filename, callback);
}
}
}

126
src/AddIns/VersionControl/GitAddIn/Src/Git.cs

@ -0,0 +1,126 @@ @@ -0,0 +1,126 @@
// Copyright (c) 2008-2009 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using ICSharpCode.SharpDevelop.Gui;
using System;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Util;
namespace ICSharpCode.GitAddIn
{
/// <summary>
/// Description of Git.
/// </summary>
public class Git
{
public static bool IsInWorkingCopy(string fileName)
{
return FindWorkingCopyRoot(fileName) != null;
}
public static string FindWorkingCopyRoot(string fileName)
{
try {
if (!Path.IsPathRooted(fileName))
return null;
} catch (ArgumentException) {
return null;
}
if (!Directory.Exists(fileName))
fileName = Path.GetDirectoryName(fileName);
DirectoryInfo info = new DirectoryInfo(Path.GetDirectoryName(fileName));
while (info != null) {
if (Directory.Exists(Path.Combine(info.FullName, ".git")))
return info.FullName;
info = info.Parent;
}
return null;
}
public static void Add(string fileName, Action<int> callback)
{
string wcRoot = FindWorkingCopyRoot(fileName);
if (wcRoot == null)
return;
RunGit(wcRoot, "add " + AdaptFileName(wcRoot, fileName), callback);
}
public static string AdaptFileName(string wcRoot, string fileName)
{
return '"' + AdaptFileNameNoQuotes(wcRoot, fileName) + '"';
}
public static string AdaptFileNameNoQuotes(string wcRoot, string fileName)
{
string relFileName = FileUtility.GetRelativePath(wcRoot, fileName);
return relFileName.Replace('\\', '/');
}
public static void RunGit(string workingDir, string arguments, Action<int> finished)
{
GitMessageView.AppendLine("$ git " + arguments);
ProcessRunner runner = new ProcessRunner();
runner.WorkingDirectory = workingDir;
runner.LogStandardOutputAndError = false;
runner.OutputLineReceived += (sender, e) => GitMessageView.AppendLine(e.Line);
runner.ErrorLineReceived += (sender, e) => GitMessageView.AppendLine(e.Line);
runner.ProcessExited += delegate {
GitMessageView.AppendLine("Done. (exit code " + runner.ExitCode + ")");
if (finished != null)
finished(runner.ExitCode);
};
runner.Start("cmd", "/c git " + arguments);
}
/*
/// <summary>
/// Runs git and returns the output if successful (exit code 0).
/// If not successful, returns null and displays output to message view.
/// </summary>
public static string RunGit(string workingDir, string arguments)
{
return RunGit(workingDir, arguments, false);
}
public static string RunGit(string workingDir, string arguments, bool ignoreNothingToCommitError)
{
using (AsynchronousWaitDialog dlg = AsynchronousWaitDialog.ShowWaitDialog("git " + arguments, true)) {
ProcessRunner runner = new ProcessRunner();
dlg.Cancelled += delegate {
runner.Kill();
};
runner.WorkingDirectory = workingDir;
runner.Start("git", arguments);
runner.WaitForExit();
if (runner.ExitCode == 0) {
return runner.StandardOutput;
} else {
GitMessageView.Category.ClearText();
GitMessageView.AppendLine("$ git " + arguments);
GitMessageView.AppendLine(runner.StandardOutput);
GitMessageView.AppendLine(runner.StandardError);
GitMessageView.AppendLine("Failed with exit code " + runner.ExitCode);
return null;
}
}
}
*/
}
}

101
src/AddIns/VersionControl/GitAddIn/Src/GitGuiWrapper.cs

@ -0,0 +1,101 @@ @@ -0,0 +1,101 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Diagnostics;
using System.Text;
using ICSharpCode.Core;
using Microsoft.Win32;
namespace ICSharpCode.GitAddIn
{
/// <summary>
/// Wraps commands opening a dialog window.
/// The current implementation launches TortoiseSVN.
/// </summary>
public static class GitGuiWrapper
{
static string GetPathFromRegistry(RegistryHive hive, string valueName)
{
RegistryView view = Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Default;
using (RegistryKey baseKey = RegistryKey.OpenBaseKey(hive, view)) {
using (RegistryKey key = baseKey.OpenSubKey("SOFTWARE\\TortoiseGit")) {
if (key != null)
return key.GetValue(valueName) as string;
else
return null;
}
}
}
static string GetPathFromRegistry(string valueName)
{
return GetPathFromRegistry(RegistryHive.CurrentUser, valueName)
?? GetPathFromRegistry(RegistryHive.LocalMachine, valueName);
}
static void Proc(string command, string fileName, Action callback)
{
Proc(command, fileName, callback, null);
}
static void Proc(string command, string fileName, Action callback, string argument)
{
string path = GetPathFromRegistry("ProcPath");
if (path == null) {
MessageService.ShowError("Could not find TortoiseGit.");
} else {
try {
StringBuilder arguments = new StringBuilder();
arguments.Append("/command:");
arguments.Append(command);
if (fileName != null) {
arguments.Append(" /notempfile ");
arguments.Append(" /path:\"");
arguments.Append(fileName);
arguments.Append('"');
}
if (argument != null) {
arguments.Append(' ');
arguments.Append(argument);
}
Process p = new Process();
p.StartInfo.FileName = path;
p.StartInfo.Arguments = arguments.ToString();
//p.StartInfo.RedirectStandardError = true;
//p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.EnableRaisingEvents = true;
p.Exited += delegate {
p.Dispose();
if (callback != null) { ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.SafeThreadAsyncCall(callback); }
};
// p.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e) {
// SvnClient.Instance.SvnCategory.AppendText(e.Data);
// };
// p.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e) {
// SvnClient.Instance.SvnCategory.AppendText(e.Data);
// };
p.Start();
} catch (Exception ex) {
MessageService.ShowError(ex.Message);
}
}
}
public static void Commit(string fileName, Action callback)
{
Proc("commit", fileName, callback);
}
public static void Diff(string fileName, Action callback)
{
Proc("diff", fileName, callback);
}
}
}

51
src/AddIns/VersionControl/GitAddIn/Src/GitMessageView.cs

@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
// Copyright (c) 2008 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using ICSharpCode.SharpDevelop.Gui;
using System;
namespace ICSharpCode.GitAddIn
{
/// <summary>
/// Output pad category for git.
/// </summary>
public static class GitMessageView
{
static MessageViewCategory category;
/// <summary>
/// Gets the git message view category.
/// </summary>
public static MessageViewCategory Category {
get {
if (category == null) {
MessageViewCategory.Create(ref category, "Git");
}
return category;
}
}
/// <summary>
/// Appends a line to the git message view.
/// </summary>
public static void AppendLine(string text)
{
Category.AppendLine(text);
}
}
}

183
src/AddIns/VersionControl/GitAddIn/Src/GitStatusCache.cs

@ -0,0 +1,183 @@ @@ -0,0 +1,183 @@
// Copyright (c) 2008-2009 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using ICSharpCode.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using ICSharpCode.SharpDevelop.Util;
namespace ICSharpCode.GitAddIn
{
public enum GitStatus
{
None,
Added,
Modified,
Deleted,
OK,
Ignored
}
public static class GitStatusCache
{
static List<KeyValuePair<string, GitStatusSet>> statusSetDict = new List<KeyValuePair<string, GitStatusSet>>();
public static void ClearCachedStatus(string fileName)
{
lock (statusSetDict) {
for (int i = 0; i < statusSetDict.Count; i++) {
if (FileUtility.IsBaseDirectory(statusSetDict[i].Key, fileName)) {
statusSetDict.RemoveAt(i--);
}
}
}
}
public static GitStatus GetFileStatus(string fileName)
{
string wcroot = Git.FindWorkingCopyRoot(fileName);
if (wcroot == null)
return GitStatus.None;
GitStatusSet gss = GetStatusSet(wcroot);
return gss.GetStatus(Git.AdaptFileNameNoQuotes(wcroot, fileName));
}
public static GitStatusSet GetStatusSet(string wcRoot)
{
lock (statusSetDict) {
GitStatusSet statusSet;
foreach (var pair in statusSetDict) {
if (FileUtility.IsEqualFileName(pair.Key, wcRoot))
return pair.Value;
}
statusSet = new GitStatusSet();
GitGetFiles(wcRoot, statusSet);
GitGetStatus(wcRoot, statusSet);
statusSetDict.Add(new KeyValuePair<string, GitStatusSet>(wcRoot, statusSet));
return statusSet;
}
}
static void GitGetFiles(string wcRoot, GitStatusSet statusSet)
{
ProcessRunner runner = new ProcessRunner();
runner.WorkingDirectory = wcRoot;
runner.LogStandardOutputAndError = false;
runner.OutputLineReceived += delegate(object sender, LineReceivedEventArgs e) {
if (string.IsNullOrEmpty(e.Line))
return;
statusSet.AddEntry(e.Line, GitStatus.OK);
};
runner.Start("cmd", "/c git ls-files");
runner.WaitForExit();
}
static void GitGetStatus(string wcRoot, GitStatusSet statusSet)
{
ProcessRunner runner = new ProcessRunner();
runner.WorkingDirectory = wcRoot;
runner.LogStandardOutputAndError = false;
runner.OutputLineReceived += delegate(object sender, LineReceivedEventArgs e) {
if (string.IsNullOrEmpty(e.Line))
return;
Match m = statusParseRegex.Match(e.Line);
if (m.Success) {
statusSet.AddEntry(m.Groups[2].Value, StatusFromText(m.Groups[1].Value));
}
};
runner.Start("cmd", "/c git status -a --untracked-files=no");
runner.WaitForExit();
}
static GitStatus StatusFromText(string text)
{
switch (text) {
case "deleted":
return GitStatus.Deleted;
case "modified":
return GitStatus.Modified;
case "new file":
return GitStatus.Added;
default:
throw new NotSupportedException();
}
}
static readonly Regex statusParseRegex = new Regex(@"#\s+(deleted|modified|new file):\s+(\S.*)$");
}
public class GitStatusSet
{
Dictionary<string, GitStatusSet> entries;
GitStatus status = GitStatus.OK;
public GitStatus AddEntry(string path, GitStatus status)
{
if (string.IsNullOrEmpty(path) || path == ".") {
this.status = status;
return status;
}
if (entries == null)
entries = new Dictionary<string, GitStatusSet>();
string entry;
string subpath;
int pos = path.IndexOf('/');
if (pos < 0) {
entry = path;
subpath = null;
} else {
entry = path.Substring(0, pos);
subpath = path.Substring(pos + 1);
}
GitStatusSet subset;
if (!entries.TryGetValue(entry, out subset))
entries[entry] = subset = new GitStatusSet();
status = subset.AddEntry(subpath, status);
if (status == GitStatus.Added || status == GitStatus.Deleted || status == GitStatus.Modified) {
this.status = GitStatus.Modified;
}
return this.status;
}
public GitStatus GetStatus(string path)
{
if (string.IsNullOrEmpty(path) || path == ".")
return status;
if (entries == null)
return GitStatus.None;
string entry;
string subpath;
int pos = path.IndexOf('/');
if (pos < 0) {
entry = path;
subpath = null;
} else {
entry = path.Substring(0, pos);
subpath = path.Substring(pos + 1);
}
GitStatusSet subset;
if (!entries.TryGetValue(entry, out subset))
return GitStatus.None;
else
return subset.GetStatus(subpath);
}
}
}

47
src/AddIns/VersionControl/GitAddIn/Src/IsUnderGitControlCondition.cs

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
// Copyright (c) 2008-2009 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using ICSharpCode.SharpDevelop.Project;
using System;
using ICSharpCode.Core;
namespace ICSharpCode.GitAddIn
{
/// <summary>
/// Description of IsUnderGitControlCondition.
/// </summary>
public class IsUnderGitControlCondition : IConditionEvaluator
{
public bool IsValid(object caller, Condition condition)
{
FileNode node = ProjectBrowserPad.Instance.SelectedNode as FileNode;
if (node != null) {
return Git.IsInWorkingCopy(node.FileName);
}
DirectoryNode dir = ProjectBrowserPad.Instance.SelectedNode as DirectoryNode;
if (dir != null) {
return Git.IsInWorkingCopy(dir.Directory);
}
SolutionNode sol = ProjectBrowserPad.Instance.SelectedNode as SolutionNode;
if (sol != null) {
return Git.IsInWorkingCopy(sol.Solution.Directory);
}
return false;
}
}
}

220
src/AddIns/VersionControl/GitAddIn/Src/OverlayIconManager.cs

@ -0,0 +1,220 @@ @@ -0,0 +1,220 @@
// Copyright (c) 2008-2009 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.Core.WinForms;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.GitAddIn
{
public static class OverlayIconManager
{
static Queue<AbstractProjectBrowserTreeNode> queue = new Queue<AbstractProjectBrowserTreeNode>();
static HashSet<AbstractProjectBrowserTreeNode> inQueue = new HashSet<AbstractProjectBrowserTreeNode>();
static bool threadRunning;
public static void Enqueue(AbstractProjectBrowserTreeNode node)
{
lock (queue) {
if (inQueue.Add(node)) {
queue.Enqueue(node);
if (!threadRunning) {
threadRunning = true;
ThreadPool.QueueUserWorkItem(Run);
}
}
}
}
public static void EnqueueRecursive(AbstractProjectBrowserTreeNode node)
{
lock (queue) {
if (inQueue.Add(node))
queue.Enqueue(node);
// use breadth-first search
Queue<AbstractProjectBrowserTreeNode> q = new Queue<AbstractProjectBrowserTreeNode>();
q.Enqueue(node);
while (q.Count > 0) {
node = q.Dequeue();
foreach (TreeNode n in node.Nodes) {
node = n as AbstractProjectBrowserTreeNode;
if (node != null) {
q.Enqueue(node);
if (inQueue.Add(node))
queue.Enqueue(node);
}
}
}
if (!threadRunning) {
threadRunning = true;
ThreadPool.QueueUserWorkItem(Run);
}
}
}
public static void EnqueueParents(AbstractProjectBrowserTreeNode node)
{
lock (queue) {
while (node != null) {
if (inQueue.Add(node))
queue.Enqueue(node);
node = node.Parent as AbstractProjectBrowserTreeNode;
}
if (!threadRunning) {
threadRunning = true;
ThreadPool.QueueUserWorkItem(Run);
}
}
}
static void Run(object state)
{
LoggingService.Debug("Git: OverlayIconManager Thread started");
// sleep a tiny bit to give main thread time to add more jobs to the queue
Thread.Sleep(100);
while (true) {
if (ICSharpCode.SharpDevelop.ParserService.LoadSolutionProjectsThreadRunning) {
// Run OverlayIconManager much more slowly while solution is being loaded.
// This prevents the disk from seeking too much
Thread.Sleep(100);
}
AbstractProjectBrowserTreeNode node;
lock (queue) {
if (queue.Count == 0) {
LoggingService.Debug("Git: OverlayIconManager Thread finished");
Debug.Assert(inQueue.Count == 0);
inQueue.Clear();
threadRunning = false;
return;
}
node = queue.Dequeue();
inQueue.Remove(node);
}
try {
RunStep(node);
} catch (Exception ex) {
#if SD4
MessageService.ShowException(ex);
#else
MessageService.ShowError(ex);
#endif
}
}
}
static void RunStep(AbstractProjectBrowserTreeNode node)
{
if (node.IsDisposed) return;
FileNode fileNode = node as FileNode;
GitStatus status;
if (fileNode != null) {
status = GitStatusCache.GetFileStatus(fileNode.FileName);
} else {
DirectoryNode directoryNode = node as DirectoryNode;
if (directoryNode != null) {
status = GitStatusCache.GetFileStatus(directoryNode.Directory);
} else {
SolutionNode solNode = node as SolutionNode;
if (solNode != null) {
status = GitStatusCache.GetFileStatus(solNode.Solution.Directory);
} else {
return;
}
}
}
WorkbenchSingleton.SafeThreadAsyncCall(
delegate {
node.Overlay = GetImage(status);
});
}
public static Image GetImage(GitStatus status)
{
switch (status) {
case GitStatus.Added:
return GetImage(StatusIcon.Added);
case GitStatus.Deleted:
return GetImage(StatusIcon.Deleted);
case GitStatus.Modified:
return GetImage(StatusIcon.Modified);
case GitStatus.OK:
return GetImage(StatusIcon.OK);
default:
return null;
}
}
#region SVN icons
static Bitmap statusImages;
public static Bitmap StatusImages {
get {
if (statusImages == null) {
statusImages = WinFormsResourceService.GetBitmap("Icons.Svn.StatusImages");
}
return statusImages;
}
}
enum StatusIcon {
Empty = 0,
OK,
Added,
Deleted,
Info,
Empty2,
Exclamation,
PropertiesModified,
Unknown,
Modified
}
static Image[] statusIcons = new Image[10];
static Image GetImage(StatusIcon status)
{
int index = (int)status;
if (statusIcons[index] == null) {
Bitmap statusImages = StatusImages;
Bitmap smallImage = new Bitmap(7, 10);
using (Graphics g = Graphics.FromImage(smallImage)) {
//g.DrawImageUnscaled(statusImages, -index * 7, -3);
Rectangle srcRect = new Rectangle(index * 7, 3, 7, 10);
Rectangle destRect = new Rectangle(0, 0, 7, 10);
g.DrawImage(statusImages, destRect, srcRect, GraphicsUnit.Pixel);
//g.DrawLine(Pens.Black, 0, 0, 7, 10);
}
statusIcons[index] = smallImage;
}
return statusIcons[index];
}
#endregion
}
}

73
src/AddIns/VersionControl/GitAddIn/Src/RegisterEventsCommand.cs

@ -0,0 +1,73 @@ @@ -0,0 +1,73 @@
// Copyright (c) 2008 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using System.Windows.Forms;
namespace ICSharpCode.GitAddIn
{
public class RegisterEventsCommand : AbstractCommand
{
public override void Run()
{
FileService.FileCreated += (sender, args) => {
Git.Add(args.FileName,
exitcode => WorkbenchSingleton.SafeThreadAsyncCall(ClearStatusCacheAndEnqueueFile, args.FileName)
);
};
FileUtility.FileSaved += (sender, e) => {
ClearStatusCacheAndEnqueueFile(e.FileName);
};
AbstractProjectBrowserTreeNode.OnNewNode += TreeNodeCreated;
}
void TreeNodeCreated(object sender, TreeViewEventArgs e)
{
SolutionNode sn = e.Node as SolutionNode;
if (sn != null) {
GitStatusCache.ClearCachedStatus(sn.Solution.FileName);
OverlayIconManager.Enqueue(sn);
} else {
DirectoryNode dn = e.Node as DirectoryNode;
if (dn != null) {
OverlayIconManager.Enqueue(dn);
} else {
FileNode fn = e.Node as FileNode;
if (fn != null) {
OverlayIconManager.Enqueue(fn);
}
}
}
}
void ClearStatusCacheAndEnqueueFile(string fileName)
{
GitStatusCache.ClearCachedStatus(fileName);
ProjectBrowserPad pad = ProjectBrowserPad.Instance;
if (pad == null) return;
FileNode node = pad.ProjectBrowserControl.FindFileNode(fileName);
if (node == null) return;
OverlayIconManager.EnqueueParents(node);
}
}
}
Loading…
Cancel
Save