diff --git a/GitTfs.Vs2008/GitTfs.Vs2008.csproj b/GitTfs.Vs2008/GitTfs.Vs2008.csproj index 1a764fe8..e07a837f 100644 --- a/GitTfs.Vs2008/GitTfs.Vs2008.csproj +++ b/GitTfs.Vs2008/GitTfs.Vs2008.csproj @@ -1,148 +1,148 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {09BF8124-19A8-45BE-896B-536CA0F3F0FC} - Library - Properties - Sep.Git.Tfs.Vs2008 - GitTfs.Vs2008 - v4.0 - 512 - - - 3.5 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - - true - bin\Debug\ - DEBUG;TRACE - full - x86 - true - GlobalSuppressions.cs - prompt - AllRules.ruleset - - - bin\Release\ - TRACE - true - pdbonly - x86 - true - GlobalSuppressions.cs - prompt - AllRules.ruleset - - - - C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.dll - - - C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Client.dll - - - C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Common.dll - - - C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Common.Library.dll - - - C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.VersionControl.Client.dll - - - C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.WorkItemTracking.Client.dll - - - - 3.5 - - - 3.5 - - - 3.5 - - - - - False - ..\lib\StructureMap\StructureMap.dll - - - - - Properties\CommonAssemblyInfo.cs - - - TfsApiBridge.cs - - - TfsHelper.Common.cs - - - Wrappers.cs - - - Properties\Version.cs - - - - - - - - {55C169E0-93CC-488C-9885-1D4EAF4EA236} - GitTfs - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - - - xcopy /y "$(TargetDir)*.dll" "$(SolutionDir)GitTfs\$(OutDir)" - + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {09BF8124-19A8-45BE-896B-536CA0F3F0FC} + Library + Properties + Sep.Git.Tfs.Vs2008 + GitTfs.Vs2008 + v4.0 + 512 + + + 3.5 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + + + bin\Release\ + TRACE + true + pdbonly + x86 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + + + + C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.dll + + + C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Client.dll + + + C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Common.dll + + + C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Common.Library.dll + + + C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.VersionControl.Client.dll + + + C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.WorkItemTracking.Client.dll + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + False + ..\lib\StructureMap\StructureMap.dll + + + + + Properties\CommonAssemblyInfo.cs + + + TfsApiBridge.cs + + + TfsHelper.Common.cs + + + Wrappers.cs + + + Properties\Version.cs + + + + + + + + {55C169E0-93CC-488C-9885-1D4EAF4EA236} + GitTfs + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + + xcopy /y "$(TargetDir)*.dll" "$(SolutionDir)GitTfs\$(OutDir)" + \ No newline at end of file diff --git a/GitTfs.Vs2008/TfsHelper.Vs2008.cs b/GitTfs.Vs2008/TfsHelper.Vs2008.cs index fc3bdb32..3932de10 100644 --- a/GitTfs.Vs2008/TfsHelper.Vs2008.cs +++ b/GitTfs.Vs2008/TfsHelper.Vs2008.cs @@ -1,5 +1,5 @@ -using System; -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Microsoft.TeamFoundation.Client; using Sep.Git.Tfs.Core.TfsInterop; @@ -12,15 +12,15 @@ namespace Sep.Git.Tfs.VsCommon public string TfsClientLibraryVersion { get { return typeof(TeamFoundationServer).Assembly.GetName().Version.ToString() + " (MS)"; } - } - - public bool CanShowCheckinDialog { get { return false; } } - - public long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable checkedInfos, string checkinComment) - { - throw new NotImplementedException(); - } - + } + + public bool CanShowCheckinDialog { get { return false; } } + + public long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable checkedInfos, string checkinComment) + { + throw new NotImplementedException(); + } + private void UpdateServer() { if (string.IsNullOrEmpty(Url)) diff --git a/GitTfs.Vs2010/GitTfs.Vs2010.csproj b/GitTfs.Vs2010/GitTfs.Vs2010.csproj index 033f0f41..e640714c 100644 --- a/GitTfs.Vs2010/GitTfs.Vs2010.csproj +++ b/GitTfs.Vs2010/GitTfs.Vs2010.csproj @@ -1,140 +1,140 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {C5A374D3-A2E1-407C-9D6D-541FDB53BD62} - Library - Properties - Sep.Git.Tfs.Vs2010 - GitTfs.Vs2010 - v4.0 - 512 - - - 3.5 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - x86 - prompt - 4 - AllRules.ruleset - - - pdbonly - true - bin\Release\ - TRACE - x86 - prompt - 4 - AllRules.ruleset - - - - - - - - - - - False - ..\lib\StructureMap\StructureMap.dll - - - - 3.5 - - - - 3.5 - - - 3.5 - - - - - - - Properties\CommonAssemblyInfo.cs - - - TfsApiBridge.cs - - - TfsHelper.Common.cs - - - Wrappers.cs - - - Properties\Version.cs - - - Form - - - - - - - - {55C169E0-93CC-488C-9885-1D4EAF4EA236} - GitTfs - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - - - xcopy /y "$(TargetDir)*.dll" "$(SolutionDir)GitTfs\$(OutDir)" - + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {C5A374D3-A2E1-407C-9D6D-541FDB53BD62} + Library + Properties + Sep.Git.Tfs.Vs2010 + GitTfs.Vs2010 + v4.0 + 512 + + + 3.5 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + x86 + prompt + 4 + AllRules.ruleset + + + pdbonly + true + bin\Release\ + TRACE + x86 + prompt + 4 + AllRules.ruleset + + + + + + + + + + + False + ..\lib\StructureMap\StructureMap.dll + + + + 3.5 + + + + 3.5 + + + 3.5 + + + + + + + Properties\CommonAssemblyInfo.cs + + + TfsApiBridge.cs + + + TfsHelper.Common.cs + + + Wrappers.cs + + + Properties\Version.cs + + + Form + + + + + + + + {55C169E0-93CC-488C-9885-1D4EAF4EA236} + GitTfs + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + + xcopy /y "$(TargetDir)*.dll" "$(SolutionDir)GitTfs\$(OutDir)" + \ No newline at end of file diff --git a/GitTfs.Vs2010/ParentForm.cs b/GitTfs.Vs2010/ParentForm.cs index e23341c3..58ae5aa7 100644 --- a/GitTfs.Vs2010/ParentForm.cs +++ b/GitTfs.Vs2010/ParentForm.cs @@ -1,27 +1,27 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -namespace Sep.Git.Tfs.Vs2010 -{ - public class ParentForm : Form - { - public ParentForm() - { - WindowState = FormWindowState.Minimized; - ShowInTaskbar = false; - FormBorderStyle = FormBorderStyle.None; - StartPosition = FormStartPosition.CenterParent; - } - - protected override void OnLoad(EventArgs e) - { - Visible = false; - base.OnLoad(e); - WindowState = FormWindowState.Normal; - CenterToParent(); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Sep.Git.Tfs.Vs2010 +{ + public class ParentForm : Form + { + public ParentForm() + { + WindowState = FormWindowState.Minimized; + ShowInTaskbar = false; + FormBorderStyle = FormBorderStyle.None; + StartPosition = FormStartPosition.CenterParent; + } + + protected override void OnLoad(EventArgs e) + { + Visible = false; + base.OnLoad(e); + WindowState = FormWindowState.Normal; + CenterToParent(); + } + } +} diff --git a/GitTfs.Vs2010/TfsHelper.Vs2010.cs b/GitTfs.Vs2010/TfsHelper.Vs2010.cs index ec73b7b0..8d147330 100644 --- a/GitTfs.Vs2010/TfsHelper.Vs2010.cs +++ b/GitTfs.Vs2010/TfsHelper.Vs2010.cs @@ -1,91 +1,91 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using Microsoft.TeamFoundation.Client; -using Microsoft.TeamFoundation.VersionControl.Client; -using Microsoft.Win32; -using Sep.Git.Tfs.Core.TfsInterop; -using Sep.Git.Tfs.Util; -using Sep.Git.Tfs.Vs2010; - -namespace Sep.Git.Tfs.VsCommon -{ - public partial class TfsHelper : ITfsHelper - { - private TfsTeamProjectCollection server; - - public string TfsClientLibraryVersion - { - get { return typeof(TfsTeamProjectCollection).Assembly.GetName().Version.ToString() + " (MS)"; } - } - - private void UpdateServer() - { - if (string.IsNullOrEmpty(Url)) - { - server = null; - } - else - { - server = new TfsTeamProjectCollection(new Uri(Url), new UICredentialsProvider()); - server.EnsureAuthenticated(); - } - } - - private TfsTeamProjectCollection Server - { - get - { - return server; - } - } - - public bool CanShowCheckinDialog { get { return true; } } - - public long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable checkedInfos, string checkinComment) - { - return ShowCheckinDialog(_bridge.Unwrap(workspace), - pendingChanges.Select(p => _bridge.Unwrap(p)).ToArray(), - checkedInfos.Select(c => _bridge.Unwrap(c)).ToArray(), - checkinComment); - } - - private long ShowCheckinDialog(Workspace workspace, PendingChange[] pendingChanges, - WorkItemCheckedInfo[] checkedInfos, string checkinComment) - { - using (var parentForm = new ParentForm()) - { - parentForm.Show(); - - var dialog = Activator.CreateInstance(GetCheckinDialogType(), new object[] {workspace.VersionControlServer}); - - return dialog.Call("Show", parentForm.Handle, workspace, pendingChanges, pendingChanges, - checkinComment, null, null, checkedInfos); - } - } - - private const string DialogAssemblyName = "Microsoft.TeamFoundation.VersionControl.ControlAdapter"; - - private static Type GetCheckinDialogType() - { - return GetDialogAssembly().GetType(DialogAssemblyName + ".CheckinDialog"); - } - - private static Assembly GetDialogAssembly() - { - return Assembly.LoadFrom(GetDialogAssemblyPath()); - } - - private static string GetDialogAssemblyPath() - { - return Path.Combine(GetVs2010InstallDir(), "PrivateAssemblies", DialogAssemblyName + ".dll"); - } - - private static string GetVs2010InstallDir() - { - return Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\10.0").GetValue("InstallDir").ToString(); - } - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using Microsoft.TeamFoundation.Client; +using Microsoft.TeamFoundation.VersionControl.Client; +using Microsoft.Win32; +using Sep.Git.Tfs.Core.TfsInterop; +using Sep.Git.Tfs.Util; +using Sep.Git.Tfs.Vs2010; + +namespace Sep.Git.Tfs.VsCommon +{ + public partial class TfsHelper : ITfsHelper + { + private TfsTeamProjectCollection server; + + public string TfsClientLibraryVersion + { + get { return typeof(TfsTeamProjectCollection).Assembly.GetName().Version.ToString() + " (MS)"; } + } + + private void UpdateServer() + { + if (string.IsNullOrEmpty(Url)) + { + server = null; + } + else + { + server = new TfsTeamProjectCollection(new Uri(Url), new UICredentialsProvider()); + server.EnsureAuthenticated(); + } + } + + private TfsTeamProjectCollection Server + { + get + { + return server; + } + } + + public bool CanShowCheckinDialog { get { return true; } } + + public long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable checkedInfos, string checkinComment) + { + return ShowCheckinDialog(_bridge.Unwrap(workspace), + pendingChanges.Select(p => _bridge.Unwrap(p)).ToArray(), + checkedInfos.Select(c => _bridge.Unwrap(c)).ToArray(), + checkinComment); + } + + private long ShowCheckinDialog(Workspace workspace, PendingChange[] pendingChanges, + WorkItemCheckedInfo[] checkedInfos, string checkinComment) + { + using (var parentForm = new ParentForm()) + { + parentForm.Show(); + + var dialog = Activator.CreateInstance(GetCheckinDialogType(), new object[] {workspace.VersionControlServer}); + + return dialog.Call("Show", parentForm.Handle, workspace, pendingChanges, pendingChanges, + checkinComment, null, null, checkedInfos); + } + } + + private const string DialogAssemblyName = "Microsoft.TeamFoundation.VersionControl.ControlAdapter"; + + private static Type GetCheckinDialogType() + { + return GetDialogAssembly().GetType(DialogAssemblyName + ".CheckinDialog"); + } + + private static Assembly GetDialogAssembly() + { + return Assembly.LoadFrom(GetDialogAssemblyPath()); + } + + private static string GetDialogAssemblyPath() + { + return Path.Combine(GetVs2010InstallDir(), "PrivateAssemblies", DialogAssemblyName + ".dll"); + } + + private static string GetVs2010InstallDir() + { + return Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\10.0").GetValue("InstallDir").ToString(); + } + } +} diff --git a/GitTfs.VsCommon/TfsHelper.Common.cs b/GitTfs.VsCommon/TfsHelper.Common.cs index 12d549fb..8348b668 100644 --- a/GitTfs.VsCommon/TfsHelper.Common.cs +++ b/GitTfs.VsCommon/TfsHelper.Common.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; +using System.Linq; using Microsoft.TeamFoundation.Server; using Microsoft.TeamFoundation.VersionControl.Client; using Microsoft.TeamFoundation.WorkItemTracking.Client; @@ -17,27 +17,27 @@ namespace Sep.Git.Tfs.VsCommon { private readonly TextWriter _stdout; private string _url; - private readonly TfsApiBridge _bridge; - private readonly IContainer _container; - + private readonly TfsApiBridge _bridge; + private readonly IContainer _container; + public TfsHelper(TextWriter stdout, TfsApiBridge bridge, IContainer container) { _stdout = stdout; - _bridge = bridge; - _container = container; + _bridge = bridge; + _container = container; } public string Url { get { return _url; } set { _url = value; UpdateServer(); } - } - - private string[] _legacyUrls; - public string[] LegacyUrls - { - get { return _legacyUrls ?? (_legacyUrls = new string[0]); } - set { _legacyUrls = value; } + } + + private string[] _legacyUrls; + public string[] LegacyUrls + { + get { return _legacyUrls ?? (_legacyUrls = new string[0]); } + set { _legacyUrls = value; } } private VersionControlServer VersionControl @@ -105,60 +105,60 @@ namespace Sep.Git.Tfs.VsCommon } private Workspace GetWorkspace(string localDirectory, string repositoryPath) - { - try - { - var workspace = VersionControl.CreateWorkspace(GenerateWorkspaceName()); - workspace.CreateMapping(new WorkingFolder(repositoryPath, localDirectory)); - return workspace; - } - catch (MappingConflictException e) - { - throw new GitTfsException(e.Message, new string[] { "Run 'git tfs cleanup-workspace' to remove the workspace." }, e); - } + { + try + { + var workspace = VersionControl.CreateWorkspace(GenerateWorkspaceName()); + workspace.CreateMapping(new WorkingFolder(repositoryPath, localDirectory)); + return workspace; + } + catch (MappingConflictException e) + { + throw new GitTfsException(e.Message, new string[] { "Run 'git tfs cleanup-workspace' to remove the workspace." }, e); + } } private string GenerateWorkspaceName() { return "git-tfs-" + Guid.NewGuid().ToString(); - } - - public void CleanupWorkspaces(string workingDirectory) - { - Trace.WriteLine("Looking for workspaces mapped to @\"" + workingDirectory +"\"...", "cleanup-workspace"); - var workspace = VersionControl.TryGetWorkspace(workingDirectory); - if(workspace != null) - { - Trace.WriteLine("Found mapping in workspace \"" + workspace.DisplayName + "\".", "cleanup-workspace"); - if (workspace.Folders.Length == 1) - { - _stdout.WriteLine("Removing workspace \"" + workspace.DisplayName + "\"."); - workspace.Delete(); - } - else - { - foreach (var mapping in workspace.Folders.Where(f => Path.GetFullPath(f.LocalItem).ToLower() == Path.GetFullPath(workingDirectory).ToLower())) - { - _stdout.WriteLine("Removing @\"" + mapping.LocalItem + "\" from workspace \"" + workspace.DisplayName + "\"."); - workspace.DeleteMapping(mapping); - } - - } - } - } - - public bool HasShelveset(string shelvesetName) - { - var matchingShelvesets = VersionControl.QueryShelvesets(shelvesetName, VersionControl.AuthenticatedUser); - return matchingShelvesets != null && matchingShelvesets.Length > 0; - } - - public IShelveset CreateShelveset(IWorkspace workspace, string shelvesetName) - { - var shelveset = new Shelveset(_bridge.Unwrap(workspace).VersionControlServer, shelvesetName, workspace.OwnerName); - return _bridge.Wrap(shelveset); - } - + } + + public void CleanupWorkspaces(string workingDirectory) + { + Trace.WriteLine("Looking for workspaces mapped to @\"" + workingDirectory +"\"...", "cleanup-workspace"); + var workspace = VersionControl.TryGetWorkspace(workingDirectory); + if(workspace != null) + { + Trace.WriteLine("Found mapping in workspace \"" + workspace.DisplayName + "\".", "cleanup-workspace"); + if (workspace.Folders.Length == 1) + { + _stdout.WriteLine("Removing workspace \"" + workspace.DisplayName + "\"."); + workspace.Delete(); + } + else + { + foreach (var mapping in workspace.Folders.Where(f => Path.GetFullPath(f.LocalItem).ToLower() == Path.GetFullPath(workingDirectory).ToLower())) + { + _stdout.WriteLine("Removing @\"" + mapping.LocalItem + "\" from workspace \"" + workspace.DisplayName + "\"."); + workspace.DeleteMapping(mapping); + } + + } + } + } + + public bool HasShelveset(string shelvesetName) + { + var matchingShelvesets = VersionControl.QueryShelvesets(shelvesetName, VersionControl.AuthenticatedUser); + return matchingShelvesets != null && matchingShelvesets.Length > 0; + } + + public IShelveset CreateShelveset(IWorkspace workspace, string shelvesetName) + { + var shelveset = new Shelveset(_bridge.Unwrap(workspace).VersionControlServer, shelvesetName, workspace.OwnerName); + return _bridge.Wrap(shelveset); + } + public IIdentity GetIdentity(string username) { return _bridge.Wrap(GroupSecurityService.ReadIdentity(SearchFactor.AccountName, username, QueryMembership.None)); @@ -175,35 +175,35 @@ namespace Sep.Git.Tfs.VsCommon public IChangeset GetChangeset(int changesetId) { return _bridge.Wrap(VersionControl.GetChangeset(changesetId)); - } - - public bool MatchesUrl(string tfsUrl) - { - return Url == tfsUrl || LegacyUrls.Contains(tfsUrl); - } - - public IEnumerable GetWorkItemInfos(IEnumerable workItems, TfsWorkItemCheckinAction checkinAction) - { - return - GetWorkItemInfosHelper( - workItems, checkinAction, GetWorkItemInfo); - } - - public IEnumerable GetWorkItemCheckedInfos(IEnumerable workItems, TfsWorkItemCheckinAction checkinAction) - { - return - GetWorkItemInfosHelper( - workItems, checkinAction, GetWorkItemCheckedInfo); } - private IEnumerable GetWorkItemInfosHelper(IEnumerable workItems, - TfsWorkItemCheckinAction checkinAction, Func func) - where TWrapper : class - { - return (from workItem in workItems - select _bridge.Wrap( - func(workItem, _bridge.Convert(checkinAction)))) - .Cast(); + public bool MatchesUrl(string tfsUrl) + { + return Url == tfsUrl || LegacyUrls.Contains(tfsUrl); + } + + public IEnumerable GetWorkItemInfos(IEnumerable workItems, TfsWorkItemCheckinAction checkinAction) + { + return + GetWorkItemInfosHelper( + workItems, checkinAction, GetWorkItemInfo); + } + + public IEnumerable GetWorkItemCheckedInfos(IEnumerable workItems, TfsWorkItemCheckinAction checkinAction) + { + return + GetWorkItemInfosHelper( + workItems, checkinAction, GetWorkItemCheckedInfo); + } + + private IEnumerable GetWorkItemInfosHelper(IEnumerable workItems, + TfsWorkItemCheckinAction checkinAction, Func func) + where TWrapper : class + { + return (from workItem in workItems + select _bridge.Wrap( + func(workItem, _bridge.Convert(checkinAction)))) + .Cast(); } private WorkItemCheckinInfo GetWorkItemInfo(string workItem, WorkItemCheckinAction checkinAction) @@ -213,9 +213,9 @@ namespace Sep.Git.Tfs.VsCommon - private static WorkItemCheckedInfo GetWorkItemCheckedInfo(string workitem, WorkItemCheckinAction checkinAction) - { - return new WorkItemCheckedInfo(Convert.ToInt32(workitem), true, checkinAction); + private static WorkItemCheckedInfo GetWorkItemCheckedInfo(string workitem, WorkItemCheckinAction checkinAction) + { + return new WorkItemCheckedInfo(Convert.ToInt32(workitem), true, checkinAction); } } } \ No newline at end of file diff --git a/GitTfs.VsCommon/Wrappers.cs b/GitTfs.VsCommon/Wrappers.cs index 1dbdf5bb..af7f3fa7 100644 --- a/GitTfs.VsCommon/Wrappers.cs +++ b/GitTfs.VsCommon/Wrappers.cs @@ -204,14 +204,14 @@ namespace Sep.Git.Tfs.VsCommon public WrapperForWorkItemCheckinInfo(WorkItemCheckinInfo workItemCheckinInfo) : base(workItemCheckinInfo) { } - } - - public class WrapperForWorkItemCheckedInfo : WrapperFor, IWorkItemCheckedInfo - { - public WrapperForWorkItemCheckedInfo(WorkItemCheckedInfo workItemCheckinInfo) - : base(workItemCheckinInfo) - { - } + } + + public class WrapperForWorkItemCheckedInfo : WrapperFor, IWorkItemCheckedInfo + { + public WrapperForWorkItemCheckedInfo(WorkItemCheckedInfo workItemCheckinInfo) + : base(workItemCheckinInfo) + { + } } public class WrapperForPendingChange : WrapperFor, IPendingChange diff --git a/GitTfs.sln b/GitTfs.sln index bda062db..7e90b8ef 100644 --- a/GitTfs.sln +++ b/GitTfs.sln @@ -1,62 +1,62 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1F1648A7-FD88-4016-82DB-35E25BCBB038}" - ProjectSection(SolutionItems) = preProject - GitTfs.vsmdi = GitTfs.vsmdi - GitTfs1.vsmdi = GitTfs1.vsmdi - LocalTestRun.testrunconfig = LocalTestRun.testrunconfig - README = README - TODO = TODO - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTfs", "GitTfs\GitTfs.csproj", "{55C169E0-93CC-488C-9885-1D4EAF4EA236}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTfsTest", "GitTfsTest\GitTfsTest.csproj", "{DDFB4746-2BCE-4B34-8E45-056324CF140D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTfsBenchmarks", "GitTfsBenchmarks\GitTfsBenchmarks.csproj", "{7C7FEA7A-24A1-4834-9815-1DF980C340F3}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTfs.Vs2008", "GitTfs.Vs2008\GitTfs.Vs2008.csproj", "{09BF8124-19A8-45BE-896B-536CA0F3F0FC}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTfs.Vs2010", "GitTfs.Vs2010\GitTfs.Vs2010.csproj", "{C5A374D3-A2E1-407C-9D6D-541FDB53BD62}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTfsTest.Vs2010", "GitTfsTest.Vs2010\GitTfsTest.Vs2010.csproj", "{B2BF1C1C-BB58-4DEF-BFEF-DE0D2FE2E8F7}" -EndProject -Global - GlobalSection(TestCaseManagementSettings) = postSolution - CategoryFile = GitTfs1.vsmdi - EndGlobalSection - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {55C169E0-93CC-488C-9885-1D4EAF4EA236}.Debug|x86.ActiveCfg = Debug|x86 - {55C169E0-93CC-488C-9885-1D4EAF4EA236}.Debug|x86.Build.0 = Debug|x86 - {55C169E0-93CC-488C-9885-1D4EAF4EA236}.Release|x86.ActiveCfg = Release|x86 - {55C169E0-93CC-488C-9885-1D4EAF4EA236}.Release|x86.Build.0 = Release|x86 - {DDFB4746-2BCE-4B34-8E45-056324CF140D}.Debug|x86.ActiveCfg = Debug|x86 - {DDFB4746-2BCE-4B34-8E45-056324CF140D}.Debug|x86.Build.0 = Debug|x86 - {DDFB4746-2BCE-4B34-8E45-056324CF140D}.Release|x86.ActiveCfg = Release|x86 - {DDFB4746-2BCE-4B34-8E45-056324CF140D}.Release|x86.Build.0 = Release|x86 - {7C7FEA7A-24A1-4834-9815-1DF980C340F3}.Debug|x86.ActiveCfg = Debug|x86 - {7C7FEA7A-24A1-4834-9815-1DF980C340F3}.Debug|x86.Build.0 = Debug|x86 - {7C7FEA7A-24A1-4834-9815-1DF980C340F3}.Release|x86.ActiveCfg = Release|x86 - {7C7FEA7A-24A1-4834-9815-1DF980C340F3}.Release|x86.Build.0 = Release|x86 - {09BF8124-19A8-45BE-896B-536CA0F3F0FC}.Debug|x86.ActiveCfg = Debug|x86 - {09BF8124-19A8-45BE-896B-536CA0F3F0FC}.Debug|x86.Build.0 = Debug|x86 - {09BF8124-19A8-45BE-896B-536CA0F3F0FC}.Release|x86.ActiveCfg = Release|x86 - {09BF8124-19A8-45BE-896B-536CA0F3F0FC}.Release|x86.Build.0 = Release|x86 - {C5A374D3-A2E1-407C-9D6D-541FDB53BD62}.Debug|x86.ActiveCfg = Debug|x86 - {C5A374D3-A2E1-407C-9D6D-541FDB53BD62}.Debug|x86.Build.0 = Debug|x86 - {C5A374D3-A2E1-407C-9D6D-541FDB53BD62}.Release|x86.ActiveCfg = Release|x86 - {C5A374D3-A2E1-407C-9D6D-541FDB53BD62}.Release|x86.Build.0 = Release|x86 - {B2BF1C1C-BB58-4DEF-BFEF-DE0D2FE2E8F7}.Debug|x86.ActiveCfg = Debug|x86 - {B2BF1C1C-BB58-4DEF-BFEF-DE0D2FE2E8F7}.Debug|x86.Build.0 = Debug|x86 - {B2BF1C1C-BB58-4DEF-BFEF-DE0D2FE2E8F7}.Release|x86.ActiveCfg = Release|x86 - {B2BF1C1C-BB58-4DEF-BFEF-DE0D2FE2E8F7}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1F1648A7-FD88-4016-82DB-35E25BCBB038}" + ProjectSection(SolutionItems) = preProject + GitTfs.vsmdi = GitTfs.vsmdi + GitTfs1.vsmdi = GitTfs1.vsmdi + LocalTestRun.testrunconfig = LocalTestRun.testrunconfig + README = README + TODO = TODO + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTfs", "GitTfs\GitTfs.csproj", "{55C169E0-93CC-488C-9885-1D4EAF4EA236}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTfsTest", "GitTfsTest\GitTfsTest.csproj", "{DDFB4746-2BCE-4B34-8E45-056324CF140D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTfsBenchmarks", "GitTfsBenchmarks\GitTfsBenchmarks.csproj", "{7C7FEA7A-24A1-4834-9815-1DF980C340F3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTfs.Vs2008", "GitTfs.Vs2008\GitTfs.Vs2008.csproj", "{09BF8124-19A8-45BE-896B-536CA0F3F0FC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTfs.Vs2010", "GitTfs.Vs2010\GitTfs.Vs2010.csproj", "{C5A374D3-A2E1-407C-9D6D-541FDB53BD62}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTfsTest.Vs2010", "GitTfsTest.Vs2010\GitTfsTest.Vs2010.csproj", "{B2BF1C1C-BB58-4DEF-BFEF-DE0D2FE2E8F7}" +EndProject +Global + GlobalSection(TestCaseManagementSettings) = postSolution + CategoryFile = GitTfs1.vsmdi + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {55C169E0-93CC-488C-9885-1D4EAF4EA236}.Debug|x86.ActiveCfg = Debug|x86 + {55C169E0-93CC-488C-9885-1D4EAF4EA236}.Debug|x86.Build.0 = Debug|x86 + {55C169E0-93CC-488C-9885-1D4EAF4EA236}.Release|x86.ActiveCfg = Release|x86 + {55C169E0-93CC-488C-9885-1D4EAF4EA236}.Release|x86.Build.0 = Release|x86 + {DDFB4746-2BCE-4B34-8E45-056324CF140D}.Debug|x86.ActiveCfg = Debug|x86 + {DDFB4746-2BCE-4B34-8E45-056324CF140D}.Debug|x86.Build.0 = Debug|x86 + {DDFB4746-2BCE-4B34-8E45-056324CF140D}.Release|x86.ActiveCfg = Release|x86 + {DDFB4746-2BCE-4B34-8E45-056324CF140D}.Release|x86.Build.0 = Release|x86 + {7C7FEA7A-24A1-4834-9815-1DF980C340F3}.Debug|x86.ActiveCfg = Debug|x86 + {7C7FEA7A-24A1-4834-9815-1DF980C340F3}.Debug|x86.Build.0 = Debug|x86 + {7C7FEA7A-24A1-4834-9815-1DF980C340F3}.Release|x86.ActiveCfg = Release|x86 + {7C7FEA7A-24A1-4834-9815-1DF980C340F3}.Release|x86.Build.0 = Release|x86 + {09BF8124-19A8-45BE-896B-536CA0F3F0FC}.Debug|x86.ActiveCfg = Debug|x86 + {09BF8124-19A8-45BE-896B-536CA0F3F0FC}.Debug|x86.Build.0 = Debug|x86 + {09BF8124-19A8-45BE-896B-536CA0F3F0FC}.Release|x86.ActiveCfg = Release|x86 + {09BF8124-19A8-45BE-896B-536CA0F3F0FC}.Release|x86.Build.0 = Release|x86 + {C5A374D3-A2E1-407C-9D6D-541FDB53BD62}.Debug|x86.ActiveCfg = Debug|x86 + {C5A374D3-A2E1-407C-9D6D-541FDB53BD62}.Debug|x86.Build.0 = Debug|x86 + {C5A374D3-A2E1-407C-9D6D-541FDB53BD62}.Release|x86.ActiveCfg = Release|x86 + {C5A374D3-A2E1-407C-9D6D-541FDB53BD62}.Release|x86.Build.0 = Release|x86 + {B2BF1C1C-BB58-4DEF-BFEF-DE0D2FE2E8F7}.Debug|x86.ActiveCfg = Debug|x86 + {B2BF1C1C-BB58-4DEF-BFEF-DE0D2FE2E8F7}.Debug|x86.Build.0 = Debug|x86 + {B2BF1C1C-BB58-4DEF-BFEF-DE0D2FE2E8F7}.Release|x86.ActiveCfg = Release|x86 + {B2BF1C1C-BB58-4DEF-BFEF-DE0D2FE2E8F7}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/GitTfs.vsmdi b/GitTfs.vsmdi index bc83fa74..0e7284d3 100644 --- a/GitTfs.vsmdi +++ b/GitTfs.vsmdi @@ -1,11 +1,11 @@ - - - - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/GitTfs/Commands/CheckinTool.cs b/GitTfs/Commands/CheckinTool.cs index 6a7378f6..357e2349 100644 --- a/GitTfs/Commands/CheckinTool.cs +++ b/GitTfs/Commands/CheckinTool.cs @@ -1,27 +1,27 @@ -using System.ComponentModel; -using System.IO; -using Sep.Git.Tfs.Core; -using Sep.Git.Tfs.Util; - +using System.ComponentModel; +using System.IO; +using Sep.Git.Tfs.Core; +using Sep.Git.Tfs.Util; + namespace Sep.Git.Tfs.Commands -{ - [PluggableWithAliases("checkintool", "ct")] - [Description("checkintool [options] [ref-to-checkin]")] - [RequiresValidGitRepository] - public class CheckinTool : CheckinBase - { - public CheckinTool(TextWriter stdout, CheckinOptions checkinOptions, TfsWriter writer) : base(stdout, checkinOptions, writer) - { - } - - protected override long DoCheckin(TfsChangesetInfo changeset, string refToCheckin) - { - if (!changeset.Remote.Tfs.CanShowCheckinDialog) - throw new GitTfsException( - "checkintool does not work with this TFS version (" + changeset.Remote.Tfs.TfsClientLibraryVersion + ").", - new[] {"Try installing the VS2010 edition of Team Explorer."}); - - return changeset.Remote.CheckinTool(refToCheckin, changeset); - } +{ + [PluggableWithAliases("checkintool", "ct")] + [Description("checkintool [options] [ref-to-checkin]")] + [RequiresValidGitRepository] + public class CheckinTool : CheckinBase + { + public CheckinTool(TextWriter stdout, CheckinOptions checkinOptions, TfsWriter writer) : base(stdout, checkinOptions, writer) + { + } + + protected override long DoCheckin(TfsChangesetInfo changeset, string refToCheckin) + { + if (!changeset.Remote.Tfs.CanShowCheckinDialog) + throw new GitTfsException( + "checkintool does not work with this TFS version (" + changeset.Remote.Tfs.TfsClientLibraryVersion + ").", + new[] {"Try installing the VS2010 edition of Team Explorer."}); + + return changeset.Remote.CheckinTool(refToCheckin, changeset); + } } } diff --git a/GitTfs/Commands/Clone.cs b/GitTfs/Commands/Clone.cs index 858c54dc..2f80ed80 100644 --- a/GitTfs/Commands/Clone.cs +++ b/GitTfs/Commands/Clone.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; @@ -28,17 +28,17 @@ namespace Sep.Git.Tfs.Commands get { return this.MakeNestedOptionResults(init, fetch); } } - public int Run(string tfsUrl, string tfsRepositoryPath) - { - return Run(tfsUrl, tfsRepositoryPath, Path.GetFileName(tfsRepositoryPath)); - } - + public int Run(string tfsUrl, string tfsRepositoryPath) + { + return Run(tfsUrl, tfsRepositoryPath, Path.GetFileName(tfsRepositoryPath)); + } + public int Run(string tfsUrl, string tfsRepositoryPath, string gitRepositoryPath) - { - var retVal = 0; - retVal = init.Run(tfsUrl, tfsRepositoryPath, gitRepositoryPath); - if (retVal == 0) retVal = fetch.Run(); - if (retVal == 0) globals.Repository.CommandNoisy("merge", globals.Repository.ReadAllTfsRemotes().First().RemoteRef); + { + var retVal = 0; + retVal = init.Run(tfsUrl, tfsRepositoryPath, gitRepositoryPath); + if (retVal == 0) retVal = fetch.Run(); + if (retVal == 0) globals.Repository.CommandNoisy("merge", globals.Repository.ReadAllTfsRemotes().First().RemoteRef); return retVal; } } diff --git a/GitTfs/Commands/Fetch.cs b/GitTfs/Commands/Fetch.cs index 9b0bda9f..006cea92 100644 --- a/GitTfs/Commands/Fetch.cs +++ b/GitTfs/Commands/Fetch.cs @@ -1,79 +1,79 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; -using CommandLine.OptParse; -using Sep.Git.Tfs.Core; -using StructureMap; - -namespace Sep.Git.Tfs.Commands -{ - [Pluggable("fetch")] - [Description("fetch [options] [tfs-remote-id]...")] - [RequiresValidGitRepository] - public class Fetch : GitTfsCommand - { - private readonly FcOptions fcOptions; - private readonly RemoteOptions remoteOptions; - private readonly Globals globals; - - public Fetch(Globals globals, RemoteOptions remoteOptions, FcOptions fcOptions) - { - this.fcOptions = fcOptions; - this.remoteOptions = remoteOptions; - this.globals = globals; - } - -// [OptDef(OptValType.ValueReq)] -// [ShortOptionName('r')] -// public int? revision { get; set; } - - [OptDef(OptValType.Flag)] - [LongOptionName("fetch-all")] - public bool all { get; set; } - - [OptDef(OptValType.Flag)] - [ShortOptionName('p')] - public bool parents { get; set; } - - public IEnumerable ExtraOptions - { - get { return this.MakeNestedOptionResults(fcOptions, remoteOptions); } - } - - public int Run() - { - return Run(globals.RemoteId); - } - - public int Run(params string[] args) - { - foreach(var remote in GetRemotesToFetch(args)) - { - Trace.WriteLine("Fetching from TFS remote " + remote.Id); - DoFetch(remote); - } - return 0; - } - - protected virtual void DoFetch(IGitTfsRemote remote) - { - remote.Fetch(); - } - - private IEnumerable GetRemotesToFetch(IList args) - { - IEnumerable remotesToFetch; - if (parents) - remotesToFetch = globals.Repository.GetParentTfsCommits("HEAD").Select(commit => commit.Remote); - else if (all) - remotesToFetch = globals.Repository.ReadAllTfsRemotes(); - else - remotesToFetch = args.Select(arg => globals.Repository.ReadTfsRemote(arg)); - return remotesToFetch; - } - } -} +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using CommandLine.OptParse; +using Sep.Git.Tfs.Core; +using StructureMap; + +namespace Sep.Git.Tfs.Commands +{ + [Pluggable("fetch")] + [Description("fetch [options] [tfs-remote-id]...")] + [RequiresValidGitRepository] + public class Fetch : GitTfsCommand + { + private readonly FcOptions fcOptions; + private readonly RemoteOptions remoteOptions; + private readonly Globals globals; + + public Fetch(Globals globals, RemoteOptions remoteOptions, FcOptions fcOptions) + { + this.fcOptions = fcOptions; + this.remoteOptions = remoteOptions; + this.globals = globals; + } + +// [OptDef(OptValType.ValueReq)] +// [ShortOptionName('r')] +// public int? revision { get; set; } + + [OptDef(OptValType.Flag)] + [LongOptionName("fetch-all")] + public bool all { get; set; } + + [OptDef(OptValType.Flag)] + [ShortOptionName('p')] + public bool parents { get; set; } + + public IEnumerable ExtraOptions + { + get { return this.MakeNestedOptionResults(fcOptions, remoteOptions); } + } + + public int Run() + { + return Run(globals.RemoteId); + } + + public int Run(params string[] args) + { + foreach(var remote in GetRemotesToFetch(args)) + { + Trace.WriteLine("Fetching from TFS remote " + remote.Id); + DoFetch(remote); + } + return 0; + } + + protected virtual void DoFetch(IGitTfsRemote remote) + { + remote.Fetch(); + } + + private IEnumerable GetRemotesToFetch(IList args) + { + IEnumerable remotesToFetch; + if (parents) + remotesToFetch = globals.Repository.GetParentTfsCommits("HEAD").Select(commit => commit.Remote); + else if (all) + remotesToFetch = globals.Repository.ReadAllTfsRemotes(); + else + remotesToFetch = args.Select(arg => globals.Repository.ReadTfsRemote(arg)); + return remotesToFetch; + } + } +} diff --git a/GitTfs/Commands/Help.cs b/GitTfs/Commands/Help.cs index bb877175..f2b243b6 100644 --- a/GitTfs/Commands/Help.cs +++ b/GitTfs/Commands/Help.cs @@ -1,31 +1,31 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; +using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.Linq; using CommandLine.OptParse; -using Sep.Git.Tfs.Core; -using Sep.Git.Tfs.Util; -using StructureMap; -using StructureMap.Pipeline; -using StructureMap.Query; -using IContainer = StructureMap.IContainer; - +using Sep.Git.Tfs.Core; +using Sep.Git.Tfs.Util; +using StructureMap; +using StructureMap.Pipeline; +using StructureMap.Query; +using IContainer = StructureMap.IContainer; + namespace Sep.Git.Tfs.Commands { [Pluggable("help")] [Description("help [command-name]")] public class Help : GitTfsCommand { - private readonly TextWriter output; - private readonly GitTfsCommandFactory commandFactory; - private readonly IContainer _container; - + private readonly TextWriter output; + private readonly GitTfsCommandFactory commandFactory; + private readonly IContainer _container; + public Help(TextWriter output, GitTfsCommandFactory commandFactory, IContainer container) { - this.output = output; - this.commandFactory = commandFactory; - _container = container; + this.output = output; + this.commandFactory = commandFactory; + _container = container; } public IEnumerable ExtraOptions @@ -39,15 +39,15 @@ namespace Sep.Git.Tfs.Commands /// public int Run(IList args) { - foreach(var arg in args) - { + foreach(var arg in args) + { var command = commandFactory.GetCommand(arg); if(command != null) { return Run(command); } - } - return GitTfsExitCodes.InvalidArguments; + } + return GitTfsExitCodes.InvalidArguments; } /// @@ -56,17 +56,17 @@ namespace Sep.Git.Tfs.Commands public int Run() { output.WriteLine("Usage: git-tfs [command] [options]"); - foreach(var pair in GetCommandMap()) + foreach(var pair in GetCommandMap()) { - output.Write(" " + pair.Key); - - if (pair.Value.Any()) - { - output.WriteLine(" (" + string.Join(", ", pair.Value) + ")"); - } - else - { - output.WriteLine(); + output.Write(" " + pair.Key); + + if (pair.Value.Any()) + { + output.WriteLine(" (" + string.Join(", ", pair.Value) + ")"); + } + else + { + output.WriteLine(); } } output.WriteLine(" (use 'git-tfs help [command]' for more information)"); @@ -91,36 +91,36 @@ namespace Sep.Git.Tfs.Commands return GitTfsExitCodes.Help; } - private Dictionary> GetCommandMap() - { - return (from instance in GetCommandInstances() - where instance.Name != null - orderby instance.Name - select instance.Name) - .ToDictionary(s => s, s => commandFactory.GetAliasesForCommandName(s)); - } - - private string GetCommandName(GitTfsCommand command) - { - return (from instance in GetCommandInstances() - where instance.ConcreteType == command.GetType() - select instance.Name).Single(); - } - - private IEnumerable GetCommandInstances() - { - return _container.Model - .PluginTypes - .Single(p => p.PluginType == typeof (GitTfsCommand)) - .Instances - .Where(i => i != null); + private Dictionary> GetCommandMap() + { + return (from instance in GetCommandInstances() + where instance.Name != null + orderby instance.Name + select instance.Name) + .ToDictionary(s => s, s => commandFactory.GetAliasesForCommandName(s)); + } + + private string GetCommandName(GitTfsCommand command) + { + return (from instance in GetCommandInstances() + where instance.ConcreteType == command.GetType() + select instance.Name).Single(); + } + + private IEnumerable GetCommandInstances() + { + return _container.Model + .PluginTypes + .Single(p => p.PluginType == typeof (GitTfsCommand)) + .Instances + .Where(i => i != null); } private string GetCommandUsage(GitTfsCommand command) { var descriptionAttribute = command.GetType().GetCustomAttributes(typeof (DescriptionAttribute), false).FirstOrDefault() as - DescriptionAttribute; + DescriptionAttribute; var commandName = GetCommandName(command); return (descriptionAttribute != null) ? descriptionAttribute.Description @@ -128,18 +128,18 @@ namespace Sep.Git.Tfs.Commands } } - public interface IHelpHelper - { - int ShowHelp(GitTfsCommand command); - int ShowHelpForInvalidArguments(GitTfsCommand command); + public interface IHelpHelper + { + int ShowHelp(GitTfsCommand command); + int ShowHelpForInvalidArguments(GitTfsCommand command); } public class HelpHelper : IHelpHelper - { - private readonly IContainer _container; - - public HelpHelper(IContainer container) - { - _container = container; + { + private readonly IContainer _container; + + public HelpHelper(IContainer container) + { + _container = container; } public int ShowHelp(GitTfsCommand command) diff --git a/GitTfs/Commands/QuickClone.cs b/GitTfs/Commands/QuickClone.cs index 507247de..a125c465 100644 --- a/GitTfs/Commands/QuickClone.cs +++ b/GitTfs/Commands/QuickClone.cs @@ -1,14 +1,14 @@ -using System.ComponentModel; -using StructureMap; - -namespace Sep.Git.Tfs.Commands -{ - [Pluggable("quick-clone")] - [Description("quick-clone [options] tfs-url repository-path ")] - public class QuickClone : Clone - { - public QuickClone(Globals globals, Init init, QuickFetch fetch) : base(globals, fetch, init) - { - } - } -} +using System.ComponentModel; +using StructureMap; + +namespace Sep.Git.Tfs.Commands +{ + [Pluggable("quick-clone")] + [Description("quick-clone [options] tfs-url repository-path ")] + public class QuickClone : Clone + { + public QuickClone(Globals globals, Init init, QuickFetch fetch) : base(globals, fetch, init) + { + } + } +} diff --git a/GitTfs/Commands/QuickFetch.cs b/GitTfs/Commands/QuickFetch.cs index 7be6a9f0..0061c12d 100644 --- a/GitTfs/Commands/QuickFetch.cs +++ b/GitTfs/Commands/QuickFetch.cs @@ -1,16 +1,16 @@ -using Sep.Git.Tfs.Core; - -namespace Sep.Git.Tfs.Commands -{ - public class QuickFetch : Fetch - { - public QuickFetch(Globals globals, RemoteOptions remoteOptions, FcOptions fcOptions) : base(globals, remoteOptions, fcOptions) - { - } - - protected override void DoFetch(IGitTfsRemote remote) - { - remote.QuickFetch(); - } - } -} +using Sep.Git.Tfs.Core; + +namespace Sep.Git.Tfs.Commands +{ + public class QuickFetch : Fetch + { + public QuickFetch(Globals globals, RemoteOptions remoteOptions, FcOptions fcOptions) : base(globals, remoteOptions, fcOptions) + { + } + + protected override void DoFetch(IGitTfsRemote remote) + { + remote.QuickFetch(); + } + } +} diff --git a/GitTfs/Core/GitRepository.cs b/GitTfs/Core/GitRepository.cs index c459d55f..2691f975 100644 --- a/GitTfs/Core/GitRepository.cs +++ b/GitTfs/Core/GitRepository.cs @@ -64,10 +64,10 @@ namespace Sep.Git.Tfs.Core { try { - var allRemotes = GetTfsRemotes(); - return - allRemotes.Values.First( - remote => remote.Tfs.MatchesUrl(tfsUrl) && remote.TfsRepositoryPath == tfsRepositoryPath); + var allRemotes = GetTfsRemotes(); + return + allRemotes.Values.First( + remote => remote.Tfs.MatchesUrl(tfsUrl) && remote.TfsRepositoryPath == tfsRepositoryPath); } catch (Exception e) { @@ -119,8 +119,8 @@ namespace Sep.Git.Tfs.Core case "url": remote.Tfs.Url = value; break; - case "legacy-urls": - remote.Tfs.LegacyUrls = value.Split(','); + case "legacy-urls": + remote.Tfs.LegacyUrls = value.Split(','); break; case "repository": remote.TfsRepositoryPath = value; @@ -258,8 +258,8 @@ namespace Sep.Git.Tfs.Core } } - private IGitChangedFile BuildGitChangedFile(GitChangeInfo change) - { + private IGitChangedFile BuildGitChangedFile(GitChangeInfo change) + { return change.ToGitChangedFile(_container.With((IGitRepository)this)); } diff --git a/GitTfs/Core/GitTfsRemote.cs b/GitTfs/Core/GitTfsRemote.cs index 6e2c58f7..2e7d2bed 100644 --- a/GitTfs/Core/GitTfsRemote.cs +++ b/GitTfs/Core/GitTfsRemote.cs @@ -1,403 +1,403 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; -using Sep.Git.Tfs.Commands; -using Sep.Git.Tfs.Core.TfsInterop; - -namespace Sep.Git.Tfs.Core -{ - public class GitTfsRemote : IGitTfsRemote - { - private static readonly Regex isInDotGit = new Regex("(?:^|/)\\.git(?:/|$)"); - private static readonly Regex treeShaRegex = new Regex("^tree (" + GitTfsConstants.Sha1 + ")"); - - private readonly Globals globals; - private readonly TextWriter stdout; - private readonly RemoteOptions remoteOptions; - private long? maxChangesetId; - private string maxCommitHash; - - public GitTfsRemote(RemoteOptions remoteOptions, Globals globals, ITfsHelper tfsHelper, TextWriter stdout) - { - this.remoteOptions = remoteOptions; - this.globals = globals; - this.stdout = stdout; - Tfs = tfsHelper; - } - - public string Id { get; set; } - public string TfsRepositoryPath { get; set; } - public string IgnoreRegexExpression { get; set; } - public IGitRepository Repository { get; set; } - public ITfsHelper Tfs { get; set; } - - public long MaxChangesetId - { - get { InitHistory(); return maxChangesetId.Value; } - set { maxChangesetId = value; } - } - - public string MaxCommitHash - { - get { InitHistory(); return maxCommitHash; } - set { maxCommitHash = value; } - } - - private void InitHistory() - { - if (maxChangesetId == null) - { - var mostRecentUpdate = Repository.GetParentTfsCommits(RemoteRef).FirstOrDefault(); - if (mostRecentUpdate != null) - { - MaxCommitHash = mostRecentUpdate.GitCommit; - MaxChangesetId = mostRecentUpdate.ChangesetId; - } - else - { - MaxChangesetId = 0; - } - } - } - - private string Dir - { - get - { - return Ext.CombinePaths(globals.GitDir, "tfs", Id); - } - } - - private string IndexFile - { - get - { - return Path.Combine(Dir, "index"); - } - } - - private string WorkingDirectory - { - get - { - return Path.Combine(Dir, "workspace"); - } - } - - public void CleanupWorkspace() - { - Tfs.CleanupWorkspaces(WorkingDirectory); - } - - public bool ShouldSkip(string path) - { - return IsInDotGit(path) || - IsIgnored(path, IgnoreRegexExpression) || - IsIgnored(path, remoteOptions.IgnoreRegex); - } - - private bool IsIgnored(string path, string expression) - { - return expression != null && new Regex(expression).IsMatch(path); - } - - private bool IsInDotGit(string path) - { - return isInDotGit.IsMatch(path); - } - - public string GetPathInGitRepo(string tfsPath) - { - if(!tfsPath.StartsWith(TfsRepositoryPath,StringComparison.InvariantCultureIgnoreCase)) return null; - tfsPath = tfsPath.Substring(TfsRepositoryPath.Length); - while (tfsPath.StartsWith("/")) - tfsPath = tfsPath.Substring(1); - return tfsPath; - } - - public void Fetch(Dictionary mergeInfo) - { - foreach (var changeset in FetchChangesets()) - { - AssertTemporaryIndexClean(MaxCommitHash); - var log = Apply(MaxCommitHash, changeset); - if(mergeInfo.ContainsKey(changeset.Summary.ChangesetId)) - log.CommitParents.Add(mergeInfo[changeset.Summary.ChangesetId]); - UpdateRef(Commit(log), changeset.Summary.ChangesetId); - DoGcIfNeeded(); - } - } - - public void QuickFetch() - { - var changeset = Tfs.GetLatestChangeset(this); - AssertTemporaryIndexEmpty(); - var log = CopyTree(MaxCommitHash, changeset); - UpdateRef(Commit(log), changeset.Summary.ChangesetId); - DoGcIfNeeded(); - } - - private IEnumerable FetchChangesets() - { - Trace.WriteLine(RemoteRef + ": Getting changesets from " + (MaxChangesetId + 1) + " to current ...", "info"); - var changesets = Tfs.GetChangesets(TfsRepositoryPath, MaxChangesetId + 1, this); - changesets = changesets.OrderBy(cs => cs.Summary.ChangesetId); - return changesets; - } - - private void UpdateRef(string commitHash, long changesetId) - { - MaxCommitHash = commitHash; - MaxChangesetId = changesetId; - Repository.CommandNoisy("update-ref", "-m", "C" + MaxChangesetId, RemoteRef, MaxCommitHash); - Repository.CommandNoisy("update-ref", TagPrefix + "C" + MaxChangesetId, MaxCommitHash); - LogCurrentMapping(); - } - - private void LogCurrentMapping() - { - stdout.WriteLine("C" + MaxChangesetId + " = " + MaxCommitHash); - } - - private string TagPrefix - { - get { return "refs/tags/tfs/" + Id + "/"; } - } - - public string RemoteRef - { - get { return "refs/remotes/tfs/" + Id; } - } - - private void DoGcIfNeeded() - { - Trace.WriteLine("GC Countdown: " + globals.GcCountdown); - if(--globals.GcCountdown < 0) - { - globals.GcCountdown = globals.GcPeriod; - Repository.CommandNoisy("gc", "--auto"); - } - } - - private void AssertTemporaryIndexClean(string treeish) - { - if(string.IsNullOrEmpty(treeish)) - { - AssertTemporaryIndexEmpty(); - return; - } - WithTemporaryIndex(() => AssertIndexClean(treeish)); - } - - private void AssertTemporaryIndexEmpty() - { - if (File.Exists(IndexFile)) - File.Delete(IndexFile); - } - - private void AssertIndexClean(string treeish) - { - if (!File.Exists(IndexFile)) Repository.CommandNoisy("read-tree", treeish); - var currentTree = Repository.CommandOneline("write-tree"); - var expectedCommitInfo = Repository.Command("cat-file", "commit", treeish); - var expectedCommitTree = treeShaRegex.Match(expectedCommitInfo).Groups[1].Value; - if (expectedCommitTree != currentTree) - { - Trace.WriteLine("Index mismatch: " + expectedCommitTree + " != " + currentTree); - Trace.WriteLine("rereading " + treeish); - File.Delete(IndexFile); - Repository.CommandNoisy("read-tree", treeish); - currentTree = Repository.CommandOneline("write-tree"); - if (expectedCommitTree != currentTree) - { - throw new Exception("Unable to create a clean temporary index: trees (" + treeish + ") " + expectedCommitTree + " != " + currentTree); - } - } - } - - private LogEntry Apply(string lastCommit, ITfsChangeset changeset) - { - LogEntry result = null; - WithTemporaryIndex( - () => GitIndexInfo.Do(Repository, index => result = changeset.Apply(lastCommit, index))); - WithTemporaryIndex( - () => result.Tree = Repository.CommandOneline("write-tree")); - if(!String.IsNullOrEmpty(lastCommit)) result.CommitParents.Add(lastCommit); - return result; - } - - private LogEntry CopyTree(string lastCommit, ITfsChangeset changeset) - { - LogEntry result = null; - WithTemporaryIndex( - () => GitIndexInfo.Do(Repository, index => result = changeset.CopyTree(index))); - WithTemporaryIndex( - () => result.Tree = Repository.CommandOneline("write-tree")); - if (!String.IsNullOrEmpty(lastCommit)) result.CommitParents.Add(lastCommit); - return result; - } - - private string Commit(LogEntry logEntry) - { - string commitHash = null; - WithCommitHeaderEnv(logEntry, () => commitHash = WriteCommit(logEntry)); - // TODO (maybe): StoreChangesetMetadata(commitInfo); - return commitHash; - } - - private string WriteCommit(LogEntry logEntry) - { - // TODO (maybe): encode logEntry.Log according to 'git config --get i18n.commitencoding', if specified - //var commitEncoding = Repository.CommandOneline("config", "i18n.commitencoding"); - //var encoding = LookupEncoding(commitEncoding) ?? Encoding.UTF8; - string commitHash = null; - Repository.CommandInputOutputPipe((procIn, procOut) => - { - procIn.WriteLine(logEntry.Log); - procIn.WriteLine(GitTfsConstants.TfsCommitInfoFormat, Tfs.Url, - TfsRepositoryPath, logEntry.ChangesetId); - procIn.Close(); - commitHash = ParseCommitInfo(procOut.ReadToEnd()); - }, BuildCommitCommand(logEntry)); - return commitHash; - } - - private string[] BuildCommitCommand(LogEntry logEntry) - { - var tree = logEntry.Tree ?? GetTemporaryIndexTreeSha(); - tree.AssertValidSha(); - var commitCommand = new List { "commit-tree", tree }; - foreach (var parent in logEntry.CommitParents) - { - commitCommand.Add("-p"); - commitCommand.Add(parent); - } - return commitCommand.ToArray(); - } - - private string GetTemporaryIndexTreeSha() - { - string tree = null; - WithTemporaryIndex(() => tree = Repository.CommandOneline("write-tree")); - return tree; - } - - private string ParseCommitInfo(string commitTreeOutput) - { - return commitTreeOutput.Trim(); - } - - //private Encoding LookupEncoding(string encoding) - //{ - // if(encoding == null) - // return null; - // throw new NotImplementedException("Need to implement encoding lookup for " + encoding); - //} - - private void WithCommitHeaderEnv(LogEntry logEntry, Action action) - { - WithTemporaryEnvironment(action, new Dictionary - { - {"GIT_AUTHOR_NAME", logEntry.AuthorName}, - {"GIT_AUTHOR_EMAIL", logEntry.AuthorEmail}, - {"GIT_AUTHOR_DATE", logEntry.Date.FormatForGit()}, - {"GIT_COMMITTER_DATE", logEntry.Date.FormatForGit()}, - {"GIT_COMMITTER_NAME", logEntry.CommitterName ?? logEntry.AuthorName}, - {"GIT_COMMITTER_EMAIL", logEntry.CommitterEmail ?? logEntry.AuthorEmail} - }); - } - - private void WithTemporaryIndex(Action action) - { - WithTemporaryEnvironment(() => - { - Directory.CreateDirectory(Path.GetDirectoryName(IndexFile)); - action(); - }, new Dictionary {{"GIT_INDEX_FILE", IndexFile}}); - } - - private void WithTemporaryEnvironment(Action action, IDictionary newEnvironment) - { - var oldEnvironment = new Dictionary(); - PushEnvironment(newEnvironment, oldEnvironment); - try - { - action(); - } - finally - { - PushEnvironment(oldEnvironment); - } - } - - private void PushEnvironment(IDictionary desiredEnvironment) - { - PushEnvironment(desiredEnvironment, new Dictionary()); - } - - private void PushEnvironment(IDictionary desiredEnvironment, IDictionary oldEnvironment) - { - foreach(var key in desiredEnvironment.Keys) - { - oldEnvironment[key] = Environment.GetEnvironmentVariable(key); - Environment.SetEnvironmentVariable(key, desiredEnvironment[key]); - } - } - - public void Shelve(string shelvesetName, string head, TfsChangesetInfo parentChangeset, bool evaluateCheckinPolicies) - { - Tfs.WithWorkspace(WorkingDirectory, this, parentChangeset, - workspace => Shelve(shelvesetName, head, parentChangeset, evaluateCheckinPolicies, workspace)); - } - - public bool HasShelveset(string shelvesetName) - { - return Tfs.HasShelveset(shelvesetName); - } - - private void Shelve(string shelvesetName, string head, TfsChangesetInfo parentChangeset, bool evaluateCheckinPolicies, ITfsWorkspace workspace) - { - PendChangesToWorkspace(head, parentChangeset, workspace); - workspace.Shelve(shelvesetName, evaluateCheckinPolicies); - } - - public long CheckinTool(string head, TfsChangesetInfo parentChangeset) - { - var changeset = 0L; - Tfs.WithWorkspace(WorkingDirectory, this, parentChangeset, - workspace => changeset = CheckinTool(head, parentChangeset, workspace)); - return changeset; - } - - private long CheckinTool(string head, TfsChangesetInfo parentChangeset, ITfsWorkspace workspace) - { - PendChangesToWorkspace(head, parentChangeset, workspace); - return workspace.CheckinTool(); - } - - private void PendChangesToWorkspace(string head, TfsChangesetInfo parentChangeset, ITfsWorkspace workspace) - { - foreach (var change in Repository.GetChangedFiles(parentChangeset.GitCommit, head)) - { - change.Apply(workspace); - } - } - - public long Checkin(string head, TfsChangesetInfo parentChangeset) - { - var changeset = 0L; - Tfs.WithWorkspace(WorkingDirectory, this, parentChangeset, - workspace => changeset = Checkin(head, parentChangeset, workspace)); - return changeset; - } - - private long Checkin(string head, TfsChangesetInfo parentChangeset, ITfsWorkspace workspace) - { - PendChangesToWorkspace(head, parentChangeset, workspace); - return workspace.Checkin(); - } - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using Sep.Git.Tfs.Commands; +using Sep.Git.Tfs.Core.TfsInterop; + +namespace Sep.Git.Tfs.Core +{ + public class GitTfsRemote : IGitTfsRemote + { + private static readonly Regex isInDotGit = new Regex("(?:^|/)\\.git(?:/|$)"); + private static readonly Regex treeShaRegex = new Regex("^tree (" + GitTfsConstants.Sha1 + ")"); + + private readonly Globals globals; + private readonly TextWriter stdout; + private readonly RemoteOptions remoteOptions; + private long? maxChangesetId; + private string maxCommitHash; + + public GitTfsRemote(RemoteOptions remoteOptions, Globals globals, ITfsHelper tfsHelper, TextWriter stdout) + { + this.remoteOptions = remoteOptions; + this.globals = globals; + this.stdout = stdout; + Tfs = tfsHelper; + } + + public string Id { get; set; } + public string TfsRepositoryPath { get; set; } + public string IgnoreRegexExpression { get; set; } + public IGitRepository Repository { get; set; } + public ITfsHelper Tfs { get; set; } + + public long MaxChangesetId + { + get { InitHistory(); return maxChangesetId.Value; } + set { maxChangesetId = value; } + } + + public string MaxCommitHash + { + get { InitHistory(); return maxCommitHash; } + set { maxCommitHash = value; } + } + + private void InitHistory() + { + if (maxChangesetId == null) + { + var mostRecentUpdate = Repository.GetParentTfsCommits(RemoteRef).FirstOrDefault(); + if (mostRecentUpdate != null) + { + MaxCommitHash = mostRecentUpdate.GitCommit; + MaxChangesetId = mostRecentUpdate.ChangesetId; + } + else + { + MaxChangesetId = 0; + } + } + } + + private string Dir + { + get + { + return Ext.CombinePaths(globals.GitDir, "tfs", Id); + } + } + + private string IndexFile + { + get + { + return Path.Combine(Dir, "index"); + } + } + + private string WorkingDirectory + { + get + { + return Path.Combine(Dir, "workspace"); + } + } + + public void CleanupWorkspace() + { + Tfs.CleanupWorkspaces(WorkingDirectory); + } + + public bool ShouldSkip(string path) + { + return IsInDotGit(path) || + IsIgnored(path, IgnoreRegexExpression) || + IsIgnored(path, remoteOptions.IgnoreRegex); + } + + private bool IsIgnored(string path, string expression) + { + return expression != null && new Regex(expression).IsMatch(path); + } + + private bool IsInDotGit(string path) + { + return isInDotGit.IsMatch(path); + } + + public string GetPathInGitRepo(string tfsPath) + { + if(!tfsPath.StartsWith(TfsRepositoryPath,StringComparison.InvariantCultureIgnoreCase)) return null; + tfsPath = tfsPath.Substring(TfsRepositoryPath.Length); + while (tfsPath.StartsWith("/")) + tfsPath = tfsPath.Substring(1); + return tfsPath; + } + + public void Fetch(Dictionary mergeInfo) + { + foreach (var changeset in FetchChangesets()) + { + AssertTemporaryIndexClean(MaxCommitHash); + var log = Apply(MaxCommitHash, changeset); + if(mergeInfo.ContainsKey(changeset.Summary.ChangesetId)) + log.CommitParents.Add(mergeInfo[changeset.Summary.ChangesetId]); + UpdateRef(Commit(log), changeset.Summary.ChangesetId); + DoGcIfNeeded(); + } + } + + public void QuickFetch() + { + var changeset = Tfs.GetLatestChangeset(this); + AssertTemporaryIndexEmpty(); + var log = CopyTree(MaxCommitHash, changeset); + UpdateRef(Commit(log), changeset.Summary.ChangesetId); + DoGcIfNeeded(); + } + + private IEnumerable FetchChangesets() + { + Trace.WriteLine(RemoteRef + ": Getting changesets from " + (MaxChangesetId + 1) + " to current ...", "info"); + var changesets = Tfs.GetChangesets(TfsRepositoryPath, MaxChangesetId + 1, this); + changesets = changesets.OrderBy(cs => cs.Summary.ChangesetId); + return changesets; + } + + private void UpdateRef(string commitHash, long changesetId) + { + MaxCommitHash = commitHash; + MaxChangesetId = changesetId; + Repository.CommandNoisy("update-ref", "-m", "C" + MaxChangesetId, RemoteRef, MaxCommitHash); + Repository.CommandNoisy("update-ref", TagPrefix + "C" + MaxChangesetId, MaxCommitHash); + LogCurrentMapping(); + } + + private void LogCurrentMapping() + { + stdout.WriteLine("C" + MaxChangesetId + " = " + MaxCommitHash); + } + + private string TagPrefix + { + get { return "refs/tags/tfs/" + Id + "/"; } + } + + public string RemoteRef + { + get { return "refs/remotes/tfs/" + Id; } + } + + private void DoGcIfNeeded() + { + Trace.WriteLine("GC Countdown: " + globals.GcCountdown); + if(--globals.GcCountdown < 0) + { + globals.GcCountdown = globals.GcPeriod; + Repository.CommandNoisy("gc", "--auto"); + } + } + + private void AssertTemporaryIndexClean(string treeish) + { + if(string.IsNullOrEmpty(treeish)) + { + AssertTemporaryIndexEmpty(); + return; + } + WithTemporaryIndex(() => AssertIndexClean(treeish)); + } + + private void AssertTemporaryIndexEmpty() + { + if (File.Exists(IndexFile)) + File.Delete(IndexFile); + } + + private void AssertIndexClean(string treeish) + { + if (!File.Exists(IndexFile)) Repository.CommandNoisy("read-tree", treeish); + var currentTree = Repository.CommandOneline("write-tree"); + var expectedCommitInfo = Repository.Command("cat-file", "commit", treeish); + var expectedCommitTree = treeShaRegex.Match(expectedCommitInfo).Groups[1].Value; + if (expectedCommitTree != currentTree) + { + Trace.WriteLine("Index mismatch: " + expectedCommitTree + " != " + currentTree); + Trace.WriteLine("rereading " + treeish); + File.Delete(IndexFile); + Repository.CommandNoisy("read-tree", treeish); + currentTree = Repository.CommandOneline("write-tree"); + if (expectedCommitTree != currentTree) + { + throw new Exception("Unable to create a clean temporary index: trees (" + treeish + ") " + expectedCommitTree + " != " + currentTree); + } + } + } + + private LogEntry Apply(string lastCommit, ITfsChangeset changeset) + { + LogEntry result = null; + WithTemporaryIndex( + () => GitIndexInfo.Do(Repository, index => result = changeset.Apply(lastCommit, index))); + WithTemporaryIndex( + () => result.Tree = Repository.CommandOneline("write-tree")); + if(!String.IsNullOrEmpty(lastCommit)) result.CommitParents.Add(lastCommit); + return result; + } + + private LogEntry CopyTree(string lastCommit, ITfsChangeset changeset) + { + LogEntry result = null; + WithTemporaryIndex( + () => GitIndexInfo.Do(Repository, index => result = changeset.CopyTree(index))); + WithTemporaryIndex( + () => result.Tree = Repository.CommandOneline("write-tree")); + if (!String.IsNullOrEmpty(lastCommit)) result.CommitParents.Add(lastCommit); + return result; + } + + private string Commit(LogEntry logEntry) + { + string commitHash = null; + WithCommitHeaderEnv(logEntry, () => commitHash = WriteCommit(logEntry)); + // TODO (maybe): StoreChangesetMetadata(commitInfo); + return commitHash; + } + + private string WriteCommit(LogEntry logEntry) + { + // TODO (maybe): encode logEntry.Log according to 'git config --get i18n.commitencoding', if specified + //var commitEncoding = Repository.CommandOneline("config", "i18n.commitencoding"); + //var encoding = LookupEncoding(commitEncoding) ?? Encoding.UTF8; + string commitHash = null; + Repository.CommandInputOutputPipe((procIn, procOut) => + { + procIn.WriteLine(logEntry.Log); + procIn.WriteLine(GitTfsConstants.TfsCommitInfoFormat, Tfs.Url, + TfsRepositoryPath, logEntry.ChangesetId); + procIn.Close(); + commitHash = ParseCommitInfo(procOut.ReadToEnd()); + }, BuildCommitCommand(logEntry)); + return commitHash; + } + + private string[] BuildCommitCommand(LogEntry logEntry) + { + var tree = logEntry.Tree ?? GetTemporaryIndexTreeSha(); + tree.AssertValidSha(); + var commitCommand = new List { "commit-tree", tree }; + foreach (var parent in logEntry.CommitParents) + { + commitCommand.Add("-p"); + commitCommand.Add(parent); + } + return commitCommand.ToArray(); + } + + private string GetTemporaryIndexTreeSha() + { + string tree = null; + WithTemporaryIndex(() => tree = Repository.CommandOneline("write-tree")); + return tree; + } + + private string ParseCommitInfo(string commitTreeOutput) + { + return commitTreeOutput.Trim(); + } + + //private Encoding LookupEncoding(string encoding) + //{ + // if(encoding == null) + // return null; + // throw new NotImplementedException("Need to implement encoding lookup for " + encoding); + //} + + private void WithCommitHeaderEnv(LogEntry logEntry, Action action) + { + WithTemporaryEnvironment(action, new Dictionary + { + {"GIT_AUTHOR_NAME", logEntry.AuthorName}, + {"GIT_AUTHOR_EMAIL", logEntry.AuthorEmail}, + {"GIT_AUTHOR_DATE", logEntry.Date.FormatForGit()}, + {"GIT_COMMITTER_DATE", logEntry.Date.FormatForGit()}, + {"GIT_COMMITTER_NAME", logEntry.CommitterName ?? logEntry.AuthorName}, + {"GIT_COMMITTER_EMAIL", logEntry.CommitterEmail ?? logEntry.AuthorEmail} + }); + } + + private void WithTemporaryIndex(Action action) + { + WithTemporaryEnvironment(() => + { + Directory.CreateDirectory(Path.GetDirectoryName(IndexFile)); + action(); + }, new Dictionary {{"GIT_INDEX_FILE", IndexFile}}); + } + + private void WithTemporaryEnvironment(Action action, IDictionary newEnvironment) + { + var oldEnvironment = new Dictionary(); + PushEnvironment(newEnvironment, oldEnvironment); + try + { + action(); + } + finally + { + PushEnvironment(oldEnvironment); + } + } + + private void PushEnvironment(IDictionary desiredEnvironment) + { + PushEnvironment(desiredEnvironment, new Dictionary()); + } + + private void PushEnvironment(IDictionary desiredEnvironment, IDictionary oldEnvironment) + { + foreach(var key in desiredEnvironment.Keys) + { + oldEnvironment[key] = Environment.GetEnvironmentVariable(key); + Environment.SetEnvironmentVariable(key, desiredEnvironment[key]); + } + } + + public void Shelve(string shelvesetName, string head, TfsChangesetInfo parentChangeset, bool evaluateCheckinPolicies) + { + Tfs.WithWorkspace(WorkingDirectory, this, parentChangeset, + workspace => Shelve(shelvesetName, head, parentChangeset, evaluateCheckinPolicies, workspace)); + } + + public bool HasShelveset(string shelvesetName) + { + return Tfs.HasShelveset(shelvesetName); + } + + private void Shelve(string shelvesetName, string head, TfsChangesetInfo parentChangeset, bool evaluateCheckinPolicies, ITfsWorkspace workspace) + { + PendChangesToWorkspace(head, parentChangeset, workspace); + workspace.Shelve(shelvesetName, evaluateCheckinPolicies); + } + + public long CheckinTool(string head, TfsChangesetInfo parentChangeset) + { + var changeset = 0L; + Tfs.WithWorkspace(WorkingDirectory, this, parentChangeset, + workspace => changeset = CheckinTool(head, parentChangeset, workspace)); + return changeset; + } + + private long CheckinTool(string head, TfsChangesetInfo parentChangeset, ITfsWorkspace workspace) + { + PendChangesToWorkspace(head, parentChangeset, workspace); + return workspace.CheckinTool(); + } + + private void PendChangesToWorkspace(string head, TfsChangesetInfo parentChangeset, ITfsWorkspace workspace) + { + foreach (var change in Repository.GetChangedFiles(parentChangeset.GitCommit, head)) + { + change.Apply(workspace); + } + } + + public long Checkin(string head, TfsChangesetInfo parentChangeset) + { + var changeset = 0L; + Tfs.WithWorkspace(WorkingDirectory, this, parentChangeset, + workspace => changeset = Checkin(head, parentChangeset, workspace)); + return changeset; + } + + private long Checkin(string head, TfsChangesetInfo parentChangeset, ITfsWorkspace workspace) + { + PendChangesToWorkspace(head, parentChangeset, workspace); + return workspace.Checkin(); + } + } +} diff --git a/GitTfs/Core/IGitTfsRemote.cs b/GitTfs/Core/IGitTfsRemote.cs index 0c5d7574..da731eaf 100644 --- a/GitTfs/Core/IGitTfsRemote.cs +++ b/GitTfs/Core/IGitTfsRemote.cs @@ -1,34 +1,34 @@ -using System.Collections.Generic; -using Sep.Git.Tfs.Core.TfsInterop; - -namespace Sep.Git.Tfs.Core -{ - public interface IGitTfsRemote - { - string Id { get; set; } - string TfsRepositoryPath { get; set; } - string IgnoreRegexExpression { get; set; } - IGitRepository Repository { get; set; } - ITfsHelper Tfs { get; set; } - long MaxChangesetId { get; set; } - string MaxCommitHash { get; set; } - string RemoteRef { get; } - bool ShouldSkip(string path); - string GetPathInGitRepo(string tfsPath); - void Fetch(Dictionary mergeInfo); - void QuickFetch(); - void Shelve(string shelvesetName, string treeish, TfsChangesetInfo parentChangeset, bool evaluateCheckinPolicies); - bool HasShelveset(string shelvesetName); - long CheckinTool(string head, TfsChangesetInfo parentChangeset); - long Checkin(string treeish, TfsChangesetInfo parentChangeset); - void CleanupWorkspace(); - } - - public static partial class Ext - { - public static void Fetch(this IGitTfsRemote remote) - { - remote.Fetch(new Dictionary()); - } - } +using System.Collections.Generic; +using Sep.Git.Tfs.Core.TfsInterop; + +namespace Sep.Git.Tfs.Core +{ + public interface IGitTfsRemote + { + string Id { get; set; } + string TfsRepositoryPath { get; set; } + string IgnoreRegexExpression { get; set; } + IGitRepository Repository { get; set; } + ITfsHelper Tfs { get; set; } + long MaxChangesetId { get; set; } + string MaxCommitHash { get; set; } + string RemoteRef { get; } + bool ShouldSkip(string path); + string GetPathInGitRepo(string tfsPath); + void Fetch(Dictionary mergeInfo); + void QuickFetch(); + void Shelve(string shelvesetName, string treeish, TfsChangesetInfo parentChangeset, bool evaluateCheckinPolicies); + bool HasShelveset(string shelvesetName); + long CheckinTool(string head, TfsChangesetInfo parentChangeset); + long Checkin(string treeish, TfsChangesetInfo parentChangeset); + void CleanupWorkspace(); + } + + public static partial class Ext + { + public static void Fetch(this IGitTfsRemote remote) + { + remote.Fetch(new Dictionary()); + } + } } \ No newline at end of file diff --git a/GitTfs/Core/ITfsChangeset.cs b/GitTfs/Core/ITfsChangeset.cs index 13f9418d..c452bd4a 100644 --- a/GitTfs/Core/ITfsChangeset.cs +++ b/GitTfs/Core/ITfsChangeset.cs @@ -1,9 +1,9 @@ -namespace Sep.Git.Tfs.Core -{ - public interface ITfsChangeset - { - TfsChangesetInfo Summary { get; } - LogEntry Apply(string lastCommit, GitIndexInfo index); - LogEntry CopyTree(GitIndexInfo index); - } -} +namespace Sep.Git.Tfs.Core +{ + public interface ITfsChangeset + { + TfsChangesetInfo Summary { get; } + LogEntry Apply(string lastCommit, GitIndexInfo index); + LogEntry CopyTree(GitIndexInfo index); + } +} diff --git a/GitTfs/Core/ITfsWorkspace.cs b/GitTfs/Core/ITfsWorkspace.cs index 19e1703b..1b9d7f5d 100644 --- a/GitTfs/Core/ITfsWorkspace.cs +++ b/GitTfs/Core/ITfsWorkspace.cs @@ -15,7 +15,7 @@ namespace Sep.Git.Tfs.Core void Add(string path); void Edit(string path); void Delete(string path); - void Rename(string pathFrom, string pathTo, string score); - long CheckinTool(); + void Rename(string pathFrom, string pathTo, string score); + long CheckinTool(); } } \ No newline at end of file diff --git a/GitTfs/Core/TfsChangeset.cs b/GitTfs/Core/TfsChangeset.cs index 31dc0eb2..3110553b 100644 --- a/GitTfs/Core/TfsChangeset.cs +++ b/GitTfs/Core/TfsChangeset.cs @@ -83,16 +83,16 @@ namespace Sep.Git.Tfs.Core private string GetPathBeforeRename(IItem item) { - var previousChangeset = item.ChangesetId - 1; - var oldItem = item.VersionControlServer.GetItem(item.ItemId, previousChangeset); - if (null == oldItem) - { - var history = item.VersionControlServer.QueryHistory(item.ServerItem, item.ChangesetId, 0, - TfsRecursionType.None, null, 1, previousChangeset, - 1, true, false, false); - var previousChange = history.First(); - oldItem = previousChange.Changes[0].Item; - } + var previousChangeset = item.ChangesetId - 1; + var oldItem = item.VersionControlServer.GetItem(item.ItemId, previousChangeset); + if (null == oldItem) + { + var history = item.VersionControlServer.QueryHistory(item.ServerItem, item.ChangesetId, 0, + TfsRecursionType.None, null, 1, previousChangeset, + 1, true, false, false); + var previousChange = history.First(); + oldItem = previousChange.Changes[0].Item; + } return oldItem.ServerItem; } @@ -193,10 +193,10 @@ namespace Sep.Git.Tfs.Core } private LogEntry MakeNewLogEntry(IChangeset changesetToLog) - { + { var log = new LogEntry(); - var identity = tfs.GetIdentity(changesetToLog.Committer); - log.CommitterName = log.AuthorName = null != identity ? identity.DisplayName ?? "Unknown TFS user" : changesetToLog.Committer ?? "Unknown TFS user"; + var identity = tfs.GetIdentity(changesetToLog.Committer); + log.CommitterName = log.AuthorName = null != identity ? identity.DisplayName ?? "Unknown TFS user" : changesetToLog.Committer ?? "Unknown TFS user"; log.CommitterEmail = log.AuthorEmail = null != identity ? identity.MailAddress ?? changesetToLog.Committer : changesetToLog.Committer; log.Date = changesetToLog.CreationDate; log.Log = changesetToLog.Comment + Environment.NewLine; diff --git a/GitTfs/Core/TfsInterop/IChangeset.cs b/GitTfs/Core/TfsInterop/IChangeset.cs index 95942f56..d37a5c88 100644 --- a/GitTfs/Core/TfsInterop/IChangeset.cs +++ b/GitTfs/Core/TfsInterop/IChangeset.cs @@ -8,7 +8,7 @@ namespace Sep.Git.Tfs.Core.TfsInterop string Committer { get; } DateTime CreationDate { get; } string Comment { get; } - int ChangesetId { get; } + int ChangesetId { get; } IVersionControlServer VersionControlServer { get; } } } \ No newline at end of file diff --git a/GitTfs/Core/TfsInterop/ITfsHelper.cs b/GitTfs/Core/TfsInterop/ITfsHelper.cs index 0750916c..f0d17080 100644 --- a/GitTfs/Core/TfsInterop/ITfsHelper.cs +++ b/GitTfs/Core/TfsInterop/ITfsHelper.cs @@ -6,20 +6,20 @@ namespace Sep.Git.Tfs.Core.TfsInterop public interface ITfsHelper { string TfsClientLibraryVersion { get; } - string Url { get; set; } - string[] LegacyUrls { get; set; } + string Url { get; set; } + string[] LegacyUrls { get; set; } IEnumerable GetChangesets(string path, long startVersion, GitTfsRemote remote); void WithWorkspace(string directory, IGitTfsRemote remote, TfsChangesetInfo versionToFetch, Action action); IShelveset CreateShelveset(IWorkspace workspace, string shelvesetName); - IEnumerable GetWorkItemInfos(IEnumerable workItems, TfsWorkItemCheckinAction checkinAction); + IEnumerable GetWorkItemInfos(IEnumerable workItems, TfsWorkItemCheckinAction checkinAction); IEnumerable GetWorkItemCheckedInfos(IEnumerable workItems, TfsWorkItemCheckinAction checkinAction); IIdentity GetIdentity(string username); ITfsChangeset GetLatestChangeset(GitTfsRemote remote); - IChangeset GetChangeset(int changesetId); - bool MatchesUrl(string tfsUrl); - bool HasShelveset(string shelvesetName); - bool CanShowCheckinDialog { get; } - long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable checkedInfos, string checkinComment); - void CleanupWorkspaces(string workingDirectory); + IChangeset GetChangeset(int changesetId); + bool MatchesUrl(string tfsUrl); + bool HasShelveset(string shelvesetName); + bool CanShowCheckinDialog { get; } + long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable checkedInfos, string checkinComment); + void CleanupWorkspaces(string workingDirectory); } } \ No newline at end of file diff --git a/GitTfs/Core/TfsInterop/IVersionControlServer.cs b/GitTfs/Core/TfsInterop/IVersionControlServer.cs index 080553ad..ca825215 100644 --- a/GitTfs/Core/TfsInterop/IVersionControlServer.cs +++ b/GitTfs/Core/TfsInterop/IVersionControlServer.cs @@ -1,13 +1,13 @@ -using System.Collections.Generic; -namespace Sep.Git.Tfs.Core.TfsInterop -{ - public interface IVersionControlServer - { - IItem GetItem(int itemId, int changesetNumber); - IItem GetItem(string itemPath, int changesetNumber); - IItem[] GetItems(string itemPath, int changesetNumber, TfsRecursionType recursionType); - IEnumerable QueryHistory(string path, int version, int deletionId, TfsRecursionType recursion, - string user, int versionFrom, int versionTo, int maxCount, bool includeChanges, bool slotMode, - bool includeDownloadInfo); - } -} +using System.Collections.Generic; +namespace Sep.Git.Tfs.Core.TfsInterop +{ + public interface IVersionControlServer + { + IItem GetItem(int itemId, int changesetNumber); + IItem GetItem(string itemPath, int changesetNumber); + IItem[] GetItems(string itemPath, int changesetNumber, TfsRecursionType recursionType); + IEnumerable QueryHistory(string path, int version, int deletionId, TfsRecursionType recursion, + string user, int versionFrom, int versionTo, int maxCount, bool includeChanges, bool slotMode, + bool includeDownloadInfo); + } +} diff --git a/GitTfs/Core/TfsInterop/IWorkItemCheckedInfo.cs b/GitTfs/Core/TfsInterop/IWorkItemCheckedInfo.cs index 0f52b2bc..0c93d80d 100644 --- a/GitTfs/Core/TfsInterop/IWorkItemCheckedInfo.cs +++ b/GitTfs/Core/TfsInterop/IWorkItemCheckedInfo.cs @@ -1,6 +1,6 @@ -namespace Sep.Git.Tfs.Core.TfsInterop -{ - public interface IWorkItemCheckedInfo - { - } -} +namespace Sep.Git.Tfs.Core.TfsInterop +{ + public interface IWorkItemCheckedInfo + { + } +} diff --git a/GitTfs/Core/TfsInterop/TfsRecursionType.cs b/GitTfs/Core/TfsInterop/TfsRecursionType.cs index d721b394..77616f25 100644 --- a/GitTfs/Core/TfsInterop/TfsRecursionType.cs +++ b/GitTfs/Core/TfsInterop/TfsRecursionType.cs @@ -1,9 +1,9 @@ -namespace Sep.Git.Tfs.Core.TfsInterop -{ - public enum TfsRecursionType - { - None, - OneLevel, - Full - } -} +namespace Sep.Git.Tfs.Core.TfsInterop +{ + public enum TfsRecursionType + { + None, + OneLevel, + Full + } +} diff --git a/GitTfs/Core/TfsWorkspace.cs b/GitTfs/Core/TfsWorkspace.cs index 0f7a0697..2078abf9 100644 --- a/GitTfs/Core/TfsWorkspace.cs +++ b/GitTfs/Core/TfsWorkspace.cs @@ -1,157 +1,157 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Sep.Git.Tfs.Commands; -using Sep.Git.Tfs.Core.TfsInterop; - -namespace Sep.Git.Tfs.Core -{ - public class TfsWorkspace : ITfsWorkspace - { - private readonly IWorkspace _workspace; - private readonly string _localDirectory; - private readonly TextWriter _stdout; - private readonly TfsChangesetInfo _contextVersion; - private readonly IGitTfsRemote _remote; - private readonly CheckinOptions _checkinOptions; - private readonly ITfsHelper _tfsHelper; - private readonly CheckinPolicyEvaluator _policyEvaluator; - - public TfsWorkspace(IWorkspace workspace, string localDirectory, TextWriter stdout, TfsChangesetInfo contextVersion, IGitTfsRemote remote, CheckinOptions checkinOptions, ITfsHelper tfsHelper, CheckinPolicyEvaluator policyEvaluator) - { - _workspace = workspace; - _policyEvaluator = policyEvaluator; - _contextVersion = contextVersion; - _remote = remote; - _checkinOptions = checkinOptions; - _tfsHelper = tfsHelper; - _localDirectory = localDirectory; - _stdout = stdout; - } - - public void Shelve(string shelvesetName, bool evaluateCheckinPolicies) - { - var pendingChanges = _workspace.GetPendingChanges(); - - if (pendingChanges.IsEmpty()) - throw new GitTfsException("Nothing to shelve!"); - - var shelveset = _tfsHelper.CreateShelveset(_workspace, shelvesetName); - shelveset.Comment = _checkinOptions.CheckinComment; - shelveset.WorkItemInfo = GetWorkItemInfos().ToArray(); - if(evaluateCheckinPolicies) - { - foreach(var message in _policyEvaluator.EvaluateCheckin(_workspace, pendingChanges, shelveset.Comment, shelveset.WorkItemInfo)) - { - _stdout.WriteLine("[Checkin Policy] " + message); - } - } - _workspace.Shelve(shelveset, pendingChanges, _checkinOptions.Force ? TfsShelvingOptions.Replace : TfsShelvingOptions.None); - } - - public long CheckinTool() - { - var pendingChanges = _workspace.GetPendingChanges(); - - if (pendingChanges.IsEmpty()) - throw new GitTfsException("Nothing to checkin!"); - - var newChangesetId = _tfsHelper.ShowCheckinDialog(_workspace, pendingChanges, GetWorkItemCheckedInfos(), - _checkinOptions.CheckinComment); - if(newChangesetId == 0) - throw new GitTfsException("Checkin cancelled!"); - return newChangesetId; - } - - public long Checkin() - { - var pendingChanges = _workspace.GetPendingChanges(); - - if(pendingChanges.IsEmpty()) - throw new GitTfsException("Nothing to checkin!"); - - var workItemInfos = GetWorkItemInfos(); - var checkinProblems = _policyEvaluator.EvaluateCheckin(_workspace, pendingChanges, _checkinOptions.CheckinComment, workItemInfos); - if(checkinProblems.Any()) - { - foreach (var message in checkinProblems) - { - _stdout.WriteLine("[ERROR] " + message); - } - throw new GitTfsException("No changes checked in."); - } - else - { - var newChangeset = _workspace.Checkin(pendingChanges, _checkinOptions.CheckinComment, null, workItemInfos); - if(newChangeset == 0) - { - throw new GitTfsException("Checkin failed!"); - } - else - { - return newChangeset; - } - } - } - - public string GetLocalPath(string path) - { - return Path.Combine(_localDirectory, path); - } - - public void Add(string path) - { - _stdout.WriteLine(" add " + path); - var added = _workspace.PendAdd(GetLocalPath(path)); - if (added != 1) throw new Exception("One item should have been added, but actually added " + added + " items."); - } - - public void Edit(string path) - { - _stdout.WriteLine(" edit " + path); - GetFromTfs(path); - var edited = _workspace.PendEdit(GetLocalPath(path)); - if(edited != 1) throw new Exception("One item should have been edited, but actually edited " + edited + " items."); - } - - public void Delete(string path) - { - _stdout.WriteLine(" delete " + path); - GetFromTfs(path); - var deleted = _workspace.PendDelete(GetLocalPath(path)); - if (deleted != 1) throw new Exception("One item should have been deleted, but actually deleted " + deleted + " items."); - } - - public void Rename(string pathFrom, string pathTo, string score) - { - _stdout.WriteLine(" rename " + pathFrom + " to " + pathTo + " (score: " + score + ")"); - GetFromTfs(pathFrom); - var result = _workspace.PendRename(GetLocalPath(pathFrom), GetLocalPath(pathTo)); - if (result != 1) throw new ApplicationException("Unable to rename item from " + pathFrom + " to " + pathTo); - } - - private void GetFromTfs(string path) - { - _workspace.ForceGetFile(_remote.TfsRepositoryPath + "/" + path, (int) _contextVersion.ChangesetId); - } - - private IEnumerable GetWorkItemInfos() - { - return GetWorkItemInfosHelper(_tfsHelper.GetWorkItemInfos); - } - - private IEnumerable GetWorkItemCheckedInfos() - { - return GetWorkItemInfosHelper(_tfsHelper.GetWorkItemCheckedInfos); - } - - private IEnumerable GetWorkItemInfosHelper(Func, TfsWorkItemCheckinAction, IEnumerable> func) - { - var workItemInfos = func(_checkinOptions.WorkItemsToAssociate, TfsWorkItemCheckinAction.Associate); - workItemInfos = workItemInfos.Append( - func(_checkinOptions.WorkItemsToResolve, TfsWorkItemCheckinAction.Resolve)); - return workItemInfos; - } - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Sep.Git.Tfs.Commands; +using Sep.Git.Tfs.Core.TfsInterop; + +namespace Sep.Git.Tfs.Core +{ + public class TfsWorkspace : ITfsWorkspace + { + private readonly IWorkspace _workspace; + private readonly string _localDirectory; + private readonly TextWriter _stdout; + private readonly TfsChangesetInfo _contextVersion; + private readonly IGitTfsRemote _remote; + private readonly CheckinOptions _checkinOptions; + private readonly ITfsHelper _tfsHelper; + private readonly CheckinPolicyEvaluator _policyEvaluator; + + public TfsWorkspace(IWorkspace workspace, string localDirectory, TextWriter stdout, TfsChangesetInfo contextVersion, IGitTfsRemote remote, CheckinOptions checkinOptions, ITfsHelper tfsHelper, CheckinPolicyEvaluator policyEvaluator) + { + _workspace = workspace; + _policyEvaluator = policyEvaluator; + _contextVersion = contextVersion; + _remote = remote; + _checkinOptions = checkinOptions; + _tfsHelper = tfsHelper; + _localDirectory = localDirectory; + _stdout = stdout; + } + + public void Shelve(string shelvesetName, bool evaluateCheckinPolicies) + { + var pendingChanges = _workspace.GetPendingChanges(); + + if (pendingChanges.IsEmpty()) + throw new GitTfsException("Nothing to shelve!"); + + var shelveset = _tfsHelper.CreateShelveset(_workspace, shelvesetName); + shelveset.Comment = _checkinOptions.CheckinComment; + shelveset.WorkItemInfo = GetWorkItemInfos().ToArray(); + if(evaluateCheckinPolicies) + { + foreach(var message in _policyEvaluator.EvaluateCheckin(_workspace, pendingChanges, shelveset.Comment, shelveset.WorkItemInfo)) + { + _stdout.WriteLine("[Checkin Policy] " + message); + } + } + _workspace.Shelve(shelveset, pendingChanges, _checkinOptions.Force ? TfsShelvingOptions.Replace : TfsShelvingOptions.None); + } + + public long CheckinTool() + { + var pendingChanges = _workspace.GetPendingChanges(); + + if (pendingChanges.IsEmpty()) + throw new GitTfsException("Nothing to checkin!"); + + var newChangesetId = _tfsHelper.ShowCheckinDialog(_workspace, pendingChanges, GetWorkItemCheckedInfos(), + _checkinOptions.CheckinComment); + if(newChangesetId == 0) + throw new GitTfsException("Checkin cancelled!"); + return newChangesetId; + } + + public long Checkin() + { + var pendingChanges = _workspace.GetPendingChanges(); + + if(pendingChanges.IsEmpty()) + throw new GitTfsException("Nothing to checkin!"); + + var workItemInfos = GetWorkItemInfos(); + var checkinProblems = _policyEvaluator.EvaluateCheckin(_workspace, pendingChanges, _checkinOptions.CheckinComment, workItemInfos); + if(checkinProblems.Any()) + { + foreach (var message in checkinProblems) + { + _stdout.WriteLine("[ERROR] " + message); + } + throw new GitTfsException("No changes checked in."); + } + else + { + var newChangeset = _workspace.Checkin(pendingChanges, _checkinOptions.CheckinComment, null, workItemInfos); + if(newChangeset == 0) + { + throw new GitTfsException("Checkin failed!"); + } + else + { + return newChangeset; + } + } + } + + public string GetLocalPath(string path) + { + return Path.Combine(_localDirectory, path); + } + + public void Add(string path) + { + _stdout.WriteLine(" add " + path); + var added = _workspace.PendAdd(GetLocalPath(path)); + if (added != 1) throw new Exception("One item should have been added, but actually added " + added + " items."); + } + + public void Edit(string path) + { + _stdout.WriteLine(" edit " + path); + GetFromTfs(path); + var edited = _workspace.PendEdit(GetLocalPath(path)); + if(edited != 1) throw new Exception("One item should have been edited, but actually edited " + edited + " items."); + } + + public void Delete(string path) + { + _stdout.WriteLine(" delete " + path); + GetFromTfs(path); + var deleted = _workspace.PendDelete(GetLocalPath(path)); + if (deleted != 1) throw new Exception("One item should have been deleted, but actually deleted " + deleted + " items."); + } + + public void Rename(string pathFrom, string pathTo, string score) + { + _stdout.WriteLine(" rename " + pathFrom + " to " + pathTo + " (score: " + score + ")"); + GetFromTfs(pathFrom); + var result = _workspace.PendRename(GetLocalPath(pathFrom), GetLocalPath(pathTo)); + if (result != 1) throw new ApplicationException("Unable to rename item from " + pathFrom + " to " + pathTo); + } + + private void GetFromTfs(string path) + { + _workspace.ForceGetFile(_remote.TfsRepositoryPath + "/" + path, (int) _contextVersion.ChangesetId); + } + + private IEnumerable GetWorkItemInfos() + { + return GetWorkItemInfosHelper(_tfsHelper.GetWorkItemInfos); + } + + private IEnumerable GetWorkItemCheckedInfos() + { + return GetWorkItemInfosHelper(_tfsHelper.GetWorkItemCheckedInfos); + } + + private IEnumerable GetWorkItemInfosHelper(Func, TfsWorkItemCheckinAction, IEnumerable> func) + { + var workItemInfos = func(_checkinOptions.WorkItemsToAssociate, TfsWorkItemCheckinAction.Associate); + workItemInfos = workItemInfos.Append( + func(_checkinOptions.WorkItemsToResolve, TfsWorkItemCheckinAction.Resolve)); + return workItemInfos; + } + } +} diff --git a/GitTfs/GitTfs.cs b/GitTfs/GitTfs.cs index 95668f2b..6209f8b1 100644 --- a/GitTfs/GitTfs.cs +++ b/GitTfs/GitTfs.cs @@ -7,27 +7,27 @@ using System.Text.RegularExpressions; using CommandLine.OptParse; using Sep.Git.Tfs.Commands; using Sep.Git.Tfs.Core; -using Sep.Git.Tfs.Core.TfsInterop; -using Sep.Git.Tfs.Util; +using Sep.Git.Tfs.Core.TfsInterop; +using Sep.Git.Tfs.Util; using StructureMap; namespace Sep.Git.Tfs { public class GitTfs { - private ITfsHelper tfsHelper; - private GitTfsCommandFactory commandFactory; - private readonly IHelpHelper _help; - private readonly IContainer _container; - private readonly GitTfsCommandRunner _runner; - + private ITfsHelper tfsHelper; + private GitTfsCommandFactory commandFactory; + private readonly IHelpHelper _help; + private readonly IContainer _container; + private readonly GitTfsCommandRunner _runner; + public GitTfs(ITfsHelper tfsHelper, GitTfsCommandFactory commandFactory, IHelpHelper help, IContainer container, GitTfsCommandRunner runner) { - this.tfsHelper = tfsHelper; - this.commandFactory = commandFactory; - _help = help; - _container = container; - _runner = runner; + this.tfsHelper = tfsHelper; + this.commandFactory = commandFactory; + _help = help; + _container = container; + _runner = runner; } public void Run(IList args) @@ -47,7 +47,7 @@ namespace Sep.Git.Tfs Environment.ExitCode = _help.ShowHelp(command); } else if(globals.ShowVersion) - { + { _container.GetInstance().WriteLine(MakeVersionString()); Environment.ExitCode = GitTfsExitCodes.OK; } @@ -101,8 +101,8 @@ namespace Sep.Git.Tfs } public void InitializeGlobals() - { - var git = _container.GetInstance(); + { + var git = _container.GetInstance(); var globals = _container.GetInstance(); try { @@ -124,8 +124,8 @@ namespace Sep.Git.Tfs } public void AssertValidGitRepository() - { - var globals = _container.GetInstance(); + { + var globals = _container.GetInstance(); var git = _container.GetInstance(); if (!Directory.Exists(globals.GitDir)) { @@ -159,20 +159,20 @@ namespace Sep.Git.Tfs public GitTfsCommand ExtractCommand(IList args) { - for (int i = 0; i < args.Count; i++) - { + for (int i = 0; i < args.Count; i++) + { var command = commandFactory.GetCommand(args[i]); if (command != null) { args.RemoveAt(i); return command; } - } + } return _container.GetInstance(); } public IList ParseOptions(GitTfsCommand command, IList args) - { + { foreach (var parseHelper in command.GetOptionParseHelpers(_container)) { var parser = new Parser(parseHelper); diff --git a/GitTfs/GitTfs.csproj b/GitTfs/GitTfs.csproj index 3f7667ef..342ed2ea 100644 --- a/GitTfs/GitTfs.csproj +++ b/GitTfs/GitTfs.csproj @@ -1,214 +1,214 @@ - - - - Debug - x86 - 9.0.30729 - 2.0 - {55C169E0-93CC-488C-9885-1D4EAF4EA236} - Exe - Properties - Sep.Git.Tfs - git-tfs - v4.0 - 512 - - - 3.5 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - - true - bin\Debug\ - DEBUG;TRACE - full - x86 - true - GlobalSuppressions.cs - prompt - AllRules.ruleset - - - bin\Release\ - TRACE - true - pdbonly - x86 - true - GlobalSuppressions.cs - prompt - AllRules.ruleset - - - - False - ..\lib\CSharpOptParse\CSharpOptParse.dll - - - False - ..\lib\GitSharp-0.3\GitSharp.Core.dll - - - False - ..\lib\StructureMap\StructureMap.dll - - - - 3.5 - - - 3.5 - - - 3.5 - - - - - - - Properties\CommonAssemblyInfo.cs - - - Properties\Version.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - - - - - + + + + Debug + x86 + 9.0.30729 + 2.0 + {55C169E0-93CC-488C-9885-1D4EAF4EA236} + Exe + Properties + Sep.Git.Tfs + git-tfs + v4.0 + 512 + + + 3.5 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + + + bin\Release\ + TRACE + true + pdbonly + x86 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + + + + False + ..\lib\CSharpOptParse\CSharpOptParse.dll + + + False + ..\lib\GitSharp-0.3\GitSharp.Core.dll + + + False + ..\lib\StructureMap\StructureMap.dll + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + Properties\CommonAssemblyInfo.cs + + + Properties\Version.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + + + + \ No newline at end of file diff --git a/GitTfs/Util/GitTfsCommandFactory.cs b/GitTfs/Util/GitTfsCommandFactory.cs index fe19cbca..1f56b136 100644 --- a/GitTfs/Util/GitTfsCommandFactory.cs +++ b/GitTfs/Util/GitTfsCommandFactory.cs @@ -1,61 +1,61 @@ -using System.Collections.Generic; -using System.Linq; -using StructureMap; - -namespace Sep.Git.Tfs.Util -{ - [StructureMapSingleton] - public class GitTfsCommandFactory - { - private readonly IContainer container; - - public GitTfsCommandFactory(IContainer container) - { - this.container = container; - } - - private Dictionary _aliasMap; - public Dictionary AliasMap - { - get { return _aliasMap ?? (_aliasMap = CreateAliasMap()); } - } - - private Dictionary CreateAliasMap() - { - var aliasMap = new Dictionary(); - var commandPluginType = container.Model.PluginTypes.First(p => p.PluginType == typeof (GitTfsCommand)); - - foreach (var instance in commandPluginType.Instances) - { - var attribte = instance.ConcreteType.GetCustomAttributes(typeof (PluggableWithAliases), true) - .Cast().FirstOrDefault(); - - if(attribte != null) - { - foreach (var alias in attribte.Aliases) - { - aliasMap[alias] = instance.Name; - } - } - } - - return aliasMap; - } - - public GitTfsCommand GetCommand(string name) - { - return container.TryGetInstance(GetCommandName(name)); - } - - private string GetCommandName(string name) - { - string commandName; - return AliasMap.TryGetValue(name, out commandName) ? commandName : name; - } - - public IEnumerable GetAliasesForCommandName(string name) - { - return AliasMap.Where(p => p.Value == name).Select(p => p.Key); - } - } -} +using System.Collections.Generic; +using System.Linq; +using StructureMap; + +namespace Sep.Git.Tfs.Util +{ + [StructureMapSingleton] + public class GitTfsCommandFactory + { + private readonly IContainer container; + + public GitTfsCommandFactory(IContainer container) + { + this.container = container; + } + + private Dictionary _aliasMap; + public Dictionary AliasMap + { + get { return _aliasMap ?? (_aliasMap = CreateAliasMap()); } + } + + private Dictionary CreateAliasMap() + { + var aliasMap = new Dictionary(); + var commandPluginType = container.Model.PluginTypes.First(p => p.PluginType == typeof (GitTfsCommand)); + + foreach (var instance in commandPluginType.Instances) + { + var attribte = instance.ConcreteType.GetCustomAttributes(typeof (PluggableWithAliases), true) + .Cast().FirstOrDefault(); + + if(attribte != null) + { + foreach (var alias in attribte.Aliases) + { + aliasMap[alias] = instance.Name; + } + } + } + + return aliasMap; + } + + public GitTfsCommand GetCommand(string name) + { + return container.TryGetInstance(GetCommandName(name)); + } + + private string GetCommandName(string name) + { + string commandName; + return AliasMap.TryGetValue(name, out commandName) ? commandName : name; + } + + public IEnumerable GetAliasesForCommandName(string name) + { + return AliasMap.Where(p => p.Value == name).Select(p => p.Key); + } + } +} diff --git a/GitTfs/Util/PluggableWithAliases.cs b/GitTfs/Util/PluggableWithAliases.cs index 4878de55..dde32b27 100644 --- a/GitTfs/Util/PluggableWithAliases.cs +++ b/GitTfs/Util/PluggableWithAliases.cs @@ -1,15 +1,15 @@ -using StructureMap; - -namespace Sep.Git.Tfs.Util -{ - public class PluggableWithAliases : PluggableAttribute - { - public readonly string[] Aliases; - - public PluggableWithAliases(string concreteKey, params string[] aliases) - : base(concreteKey) - { - Aliases = aliases; - } - } -} +using StructureMap; + +namespace Sep.Git.Tfs.Util +{ + public class PluggableWithAliases : PluggableAttribute + { + public readonly string[] Aliases; + + public PluggableWithAliases(string concreteKey, params string[] aliases) + : base(concreteKey) + { + Aliases = aliases; + } + } +} diff --git a/GitTfsBenchmarks/GitTfsBenchmarks.csproj b/GitTfsBenchmarks/GitTfsBenchmarks.csproj index 0987d6d4..d0626598 100644 --- a/GitTfsBenchmarks/GitTfsBenchmarks.csproj +++ b/GitTfsBenchmarks/GitTfsBenchmarks.csproj @@ -1,116 +1,116 @@ - - - - Debug - x86 - 9.0.30729 - 2.0 - {7C7FEA7A-24A1-4834-9815-1DF980C340F3} - Exe - Properties - Sep.Git.Tfs - GitTfsBenchmarks - v4.0 - 512 - - - 3.5 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - - true - bin\Debug\ - DEBUG;TRACE - full - x86 - true - GlobalSuppressions.cs - prompt - AllRules.ruleset - - - bin\Release\ - TRACE - true - pdbonly - x86 - true - GlobalSuppressions.cs - prompt - AllRules.ruleset - - - - False - ..\lib\GitSharp-0.3\GitSharp.Core.dll - - - False - ..\lib\StructureMap\StructureMap.dll - - - - 3.5 - - - 3.5 - - - 3.5 - - - - - - - - - - - - {55C169E0-93CC-488C-9885-1D4EAF4EA236} - GitTfs - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - + + + + Debug + x86 + 9.0.30729 + 2.0 + {7C7FEA7A-24A1-4834-9815-1DF980C340F3} + Exe + Properties + Sep.Git.Tfs + GitTfsBenchmarks + v4.0 + 512 + + + 3.5 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + + + bin\Release\ + TRACE + true + pdbonly + x86 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + + + + False + ..\lib\GitSharp-0.3\GitSharp.Core.dll + + + False + ..\lib\StructureMap\StructureMap.dll + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + {55C169E0-93CC-488C-9885-1D4EAF4EA236} + GitTfs + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + --> \ No newline at end of file diff --git a/GitTfsTest.Vs2010/GitTfsTest.Vs2010.csproj b/GitTfsTest.Vs2010/GitTfsTest.Vs2010.csproj index 8c62893c..4b43dabe 100644 --- a/GitTfsTest.Vs2010/GitTfsTest.Vs2010.csproj +++ b/GitTfsTest.Vs2010/GitTfsTest.Vs2010.csproj @@ -1,121 +1,121 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {B2BF1C1C-BB58-4DEF-BFEF-DE0D2FE2E8F7} - Library - Properties - GitTfsTest.Vs2010 - GitTfsTest.Vs2010 - v4.0 - 512 - - - 3.5 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - true - GlobalSuppressions.cs - prompt - AllRules.ruleset - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - true - GlobalSuppressions.cs - prompt - AllRules.ruleset - - - - - - False - ..\lib\StructureMap\Rhino.Mocks.dll - - - False - ..\lib\StructureMap\StructureMap.AutoMocking.dll - - - - 3.5 - - - 3.5 - - - 3.5 - - - - - - - - - - - {C5A374D3-A2E1-407C-9D6D-541FDB53BD62} - GitTfs.Vs2010 - - - {55C169E0-93CC-488C-9885-1D4EAF4EA236} - GitTfs - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {B2BF1C1C-BB58-4DEF-BFEF-DE0D2FE2E8F7} + Library + Properties + GitTfsTest.Vs2010 + GitTfsTest.Vs2010 + v4.0 + 512 + + + 3.5 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + + + + + + False + ..\lib\StructureMap\Rhino.Mocks.dll + + + False + ..\lib\StructureMap\StructureMap.AutoMocking.dll + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + {C5A374D3-A2E1-407C-9D6D-541FDB53BD62} + GitTfs.Vs2010 + + + {55C169E0-93CC-488C-9885-1D4EAF4EA236} + GitTfs + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + --> \ No newline at end of file diff --git a/GitTfsTest/Commands/ShelveTest.cs b/GitTfsTest/Commands/ShelveTest.cs index ce8fe700..837a97d9 100644 --- a/GitTfsTest/Commands/ShelveTest.cs +++ b/GitTfsTest/Commands/ShelveTest.cs @@ -156,9 +156,9 @@ namespace Sep.Git.Tfs.Test.Commands private TfsChangesetInfo ChangesetForRemote(string remoteId) { - var mockRemote = mocks.AddAdditionalMockFor(); - mockRemote.Stub(x => x.Id).Return(remoteId); - return new TfsChangesetInfo() {Remote = mockRemote}; + var mockRemote = mocks.AddAdditionalMockFor(); + mockRemote.Stub(x => x.Id).Return(remoteId); + return new TfsChangesetInfo() {Remote = mockRemote}; } private void WireUpMockRemote() diff --git a/GitTfsTest/GitTfsTest.csproj b/GitTfsTest/GitTfsTest.csproj index 6475a67c..943eed68 100644 --- a/GitTfsTest/GitTfsTest.csproj +++ b/GitTfsTest/GitTfsTest.csproj @@ -1,140 +1,140 @@ - - - - Debug - x86 - 9.0.30729 - 2.0 - {DDFB4746-2BCE-4B34-8E45-056324CF140D} - Library - Properties - Sep.Git.Tfs.Test - GitTfsTest - v4.0 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - - 3.5 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - true - bin\Debug\ - DEBUG;TRACE - full - x86 - true - GlobalSuppressions.cs - prompt - AllRules.ruleset - - - bin\Release\ - TRACE - true - pdbonly - x86 - true - GlobalSuppressions.cs - prompt - AllRules.ruleset - - - - False - ..\lib\CSharpOptParse\CSharpOptParse.dll - - - False - ..\lib\GitSharp-0.3\GitSharp.Core.dll - - - - False - C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.VersionControl.Client.dll - - - - False - ..\lib\StructureMap\Rhino.Mocks.dll - - - False - ..\lib\StructureMap\StructureMap.dll - - - False - ..\lib\StructureMap\StructureMap.AutoMocking.dll - - - - 3.5 - - - - - - - - - - - - - - - - - - - {55C169E0-93CC-488C-9885-1D4EAF4EA236} - GitTfs - - - - - False - Microsoft .NET Framework 4 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - - - False - Windows Installer 3.1 - true - - - + + + + Debug + x86 + 9.0.30729 + 2.0 + {DDFB4746-2BCE-4B34-8E45-056324CF140D} + Library + Properties + Sep.Git.Tfs.Test + GitTfsTest + v4.0 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + 3.5 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + + + bin\Release\ + TRACE + true + pdbonly + x86 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + + + + False + ..\lib\CSharpOptParse\CSharpOptParse.dll + + + False + ..\lib\GitSharp-0.3\GitSharp.Core.dll + + + + False + C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.VersionControl.Client.dll + + + + False + ..\lib\StructureMap\Rhino.Mocks.dll + + + False + ..\lib\StructureMap\StructureMap.dll + + + False + ..\lib\StructureMap\StructureMap.AutoMocking.dll + + + + 3.5 + + + + + + + + + + + + + + + + + + + {55C169E0-93CC-488C-9885-1D4EAF4EA236} + GitTfs + + + + + False + Microsoft .NET Framework 4 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 3.1 + true + + + + --> \ No newline at end of file diff --git a/LocalTestRun.testrunconfig b/LocalTestRun.testrunconfig index 9490dc8b..dfe0b507 100644 --- a/LocalTestRun.testrunconfig +++ b/LocalTestRun.testrunconfig @@ -1,5 +1,5 @@ - - - This is a default test run configuration for a local test run. - + + + This is a default test run configuration for a local test run. + \ No newline at end of file diff --git a/README b/README index 9ca10185..60071b28 100644 --- a/README +++ b/README @@ -1,35 +1,35 @@ -git-tfs is a two-way bridge between TFS and git, similar to git-svn. - -To use, you need to get the source, build it, and then fetch from TFS to -git. - -git-tfs was developed using .NET 3.5 and VS 2008. It uses the TFS 2008 -client libraries. All other dependencies are stored in the repository. -From the root directory of the repository, you should be able to run this: -> msbuild GitTfs.sln - -To fetch, you can do this: -# git init (optional) -# git tfs init http://tfs:8080 $/some_project -# git tfs fetch - -If you do "git tfs clone" instead of "git tfs init", you won't need to do -the initial fetch. - -If you do "git tfs quick-clone" instead of "git tfs clone", git-tfs won't -pull all the history from TFS. This is intended for developer private -branches. "git tfs fetch" should still work, but you won't want to -push/pull from other repositories that were independently cloned with -git-tfs. - -The shelve command replicates your changes in a shelveset in TFS. By default, -it will shelve the current HEAD. -# git tfs shelve SOME_SHELVESET -# git tfs shelve SOME_SHELVESET some-treeish - -Help is available on the command line. Use "-h" with any command to see a -description of the relevant options. - -I've only tried it out with the TFS 2008 client libraries. I intend to -make this work transparently with TFS 2005 or the codeplex client libs at -some point. +git-tfs is a two-way bridge between TFS and git, similar to git-svn. + +To use, you need to get the source, build it, and then fetch from TFS to +git. + +git-tfs was developed using .NET 3.5 and VS 2008. It uses the TFS 2008 +client libraries. All other dependencies are stored in the repository. +From the root directory of the repository, you should be able to run this: +> msbuild GitTfs.sln + +To fetch, you can do this: +# git init (optional) +# git tfs init http://tfs:8080 $/some_project +# git tfs fetch + +If you do "git tfs clone" instead of "git tfs init", you won't need to do +the initial fetch. + +If you do "git tfs quick-clone" instead of "git tfs clone", git-tfs won't +pull all the history from TFS. This is intended for developer private +branches. "git tfs fetch" should still work, but you won't want to +push/pull from other repositories that were independently cloned with +git-tfs. + +The shelve command replicates your changes in a shelveset in TFS. By default, +it will shelve the current HEAD. +# git tfs shelve SOME_SHELVESET +# git tfs shelve SOME_SHELVESET some-treeish + +Help is available on the command line. Use "-h" with any command to see a +description of the relevant options. + +I've only tried it out with the TFS 2008 client libraries. I intend to +make this work transparently with TFS 2005 or the codeplex client libs at +some point.