public IFileSystem GetFileSystem(string path) { // Get the source control providers var providers = _componentModel.GetExtensions <ISourceControlFileSystemProvider>(); // Get the repository path IFileSystem fileSystem = null; var sourceControl = (SourceControl2)_dte.SourceControl; if (providers.Any() && sourceControl != null) { SourceControlBindings binding = null; try { // Get the binding for this solution binding = sourceControl.GetBindings(_dte.Solution.FullName); } catch (NotImplementedException) { // Some source control providers don't bother to implement this. // TFS might be the only one using it } if (binding != null) { fileSystem = providers.Select(provider => GetFileSystemFromProvider(provider, path, binding)) .Where(fs => fs != null) .FirstOrDefault(); } } return(fileSystem ?? new PhysicalFileSystem(path)); }
public SourceControlManager GetTFSSourceControlManager(SourceControlBindings sourceControlBindings) { if (_settings != null) { return new DefaultTFSSourceControlManager(_settings, sourceControlBindings); } return null; }
private static ISourceControlFileSystem GetFileSystemInternal(string path, SourceControlBindings binding) { TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(binding.ServerName)); var versionControl = projectCollection.GetService<VersionControlServer>(); Workspace workspace = versionControl.TryGetWorkspace(binding.LocalBinding); return new TfsFileSystem(workspace, path); }
private static ISourceControlFileSystem GetFileSystemInternal(string path, SourceControlBindings binding) { TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(binding.ServerName)); var versionControl = projectCollection.GetService <VersionControlServer>(); Workspace workspace = versionControl.TryGetWorkspace(binding.LocalBinding); return(new TfsFileSystem(workspace, path)); }
public SourceControlManager GetTFSSourceControlManager(SourceControlBindings sourceControlBindings) { if (_settings != null) { return(new DefaultTFSSourceControlManager(_settings, sourceControlBindings)); } return(null); }
public DefaultTFSSourceControlManager(ISettings settings, SourceControlBindings sourceControlBindings) : base(settings) { if(sourceControlBindings == null) { throw new ArgumentNullException("sourceControlBindings"); } SourceControlBindings = sourceControlBindings; TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(sourceControlBindings.ServerName)); var versionControl = projectCollection.GetService<VersionControlServer>(); PrivateWorkspace = versionControl.TryGetWorkspace(sourceControlBindings.LocalBinding); }
private static IFileSystem GetFileSystemFromProvider(ISourceControlFileSystemProvider provider, string path, SourceControlBindings binding) { try { return provider.GetFileSystem(path, binding); } catch { // Ignore exceptions that can happen when some binaries are missing. e.g. TfsSourceControlFileSystemProvider // would throw a jitting error if TFS is not installed } return null; }
public DefaultTFSSourceControlManager(Configuration.ISettings settings, SourceControlBindings sourceControlBindings) : base(settings) { if (sourceControlBindings == null) { throw new ArgumentNullException(nameof(sourceControlBindings)); } TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(sourceControlBindings.ServerName)); var versionControl = projectCollection.GetService <VersionControlServer>(); PrivateWorkspace = versionControl.TryGetWorkspace(sourceControlBindings.LocalBinding); }
public ISourceControlFileSystem GetFileSystem(string path, SourceControlBindings binding) { // Return null if this binding isn't for us then return null if ((ProviderConstants.SupportedVsVersion != VsVersionHelper.VsMajorVersion) || String.IsNullOrEmpty(binding.ProviderName) || !binding.ProviderName.Equals(TfsProviderName, StringComparison.OrdinalIgnoreCase)) { return(null); } return(GetFileSystemInternal(path, binding)); }
public ISourceControlFileSystem GetFileSystem(string path, SourceControlBindings binding) { // Return null if this binding isn't for us then return null if ((ProviderConstants.SupportedVsVersion != VsVersionHelper.VsMajorVersion) || String.IsNullOrEmpty(binding.ProviderName) || !binding.ProviderName.Equals(TfsProviderName, StringComparison.OrdinalIgnoreCase)) { return null; } return GetFileSystemInternal(path, binding); }
public DefaultTFSSourceControlManager( Configuration.ISettings settings, SourceControlBindings sourceControlBindings) : base(settings) { Assumes.Present(settings); Assumes.Present(sourceControlBindings); var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection( new Uri(sourceControlBindings.ServerName)); var versionControl = projectCollection.GetService <VersionControlServer>(); PrivateWorkspace = versionControl.TryGetWorkspace(sourceControlBindings.LocalBinding); }
public IFileSystem GetFileSystem(string path, SourceControlBindings binding) { // Return null if this this binding isn't for us then return null if (String.IsNullOrEmpty(binding.ProviderName) || !binding.ProviderName.Equals(TfsProviderName, StringComparison.OrdinalIgnoreCase)) { return null; } TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(binding.ServerName)); var versionControl = projectCollection.GetService<VersionControlServer>(); Workspace workspace = versionControl.TryGetWorkspace(binding.LocalBinding); return new TfsFileSystem(workspace, path); }
public IFileSystem GetFileSystem(string path, SourceControlBindings binding) { // Return null if this this binding isn't for us then return null if (String.IsNullOrEmpty(binding.ProviderName) || !binding.ProviderName.Equals(TfsProviderName, StringComparison.OrdinalIgnoreCase)) { return(null); } TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(binding.ServerName)); var versionControl = projectCollection.GetService <VersionControlServer>(); Workspace workspace = versionControl.TryGetWorkspace(binding.LocalBinding); return(new TfsFileSystem(workspace, path)); }
public SourceControlManager GetSourceControlManager() { return(ThreadHelper.JoinableTaskFactory.Run(async delegate { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (_dte != null && _dte.SourceControl != null) { var sourceControl = (SourceControl2)_dte.SourceControl; if (sourceControl != null) { SourceControlBindings sourceControlBinding = null; try { // Get the binding for this solution sourceControlBinding = sourceControl.GetBindings(_dte.Solution.FullName); } catch (NotImplementedException) { // Some source control providers don't bother to implement this. // TFS might be the only one using it } if (sourceControlBinding == null || String.IsNullOrEmpty(sourceControlBinding.ProviderName) || !sourceControlBinding.ProviderName.Equals(TfsProviderName, StringComparison.OrdinalIgnoreCase)) { // Return null, if the Source control provider is not TFS return null; } var tfsProviders = _componentModel.GetExtensions <ITFSSourceControlManagerProvider>(); if (tfsProviders != null && tfsProviders.Any()) { return tfsProviders.Select(provider => provider.GetTFSSourceControlManager(sourceControlBinding)) .FirstOrDefault(tp => tp != null); } } } return null; })); }
public SourceControlManager GetSourceControlManager() { return(NuGetUIThreadHelper.JoinableTaskFactory.Run(async delegate { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); EnvDTE.DTE dte = await _dte.GetValueAsync(); if (dte != null) { var sourceControl = (SourceControl2)dte.SourceControl; if (sourceControl != null) { SourceControlBindings sourceControlBindings = null; try { // Get the binding for this solution sourceControlBindings = sourceControl.GetBindings(dte.Solution.FullName); } catch (NotImplementedException) { // Some source control providers don't bother to implement this. // TFS might be the only one using it } if (sourceControlBindings == null || string.IsNullOrEmpty(sourceControlBindings.ProviderName) || !sourceControlBindings.ProviderName.Equals(TfsProviderName, StringComparison.OrdinalIgnoreCase)) { // Return null, if the Source control provider is not TFS return null; } return new DefaultTFSSourceControlManager(_settings, sourceControlBindings); } } return null; })); }
public SourceControlManager GetTFSSourceControlManager(SourceControlBindings sourceControlBindings) { var underlyingTfsProvider = GetUnderlyingTfsProvider(); return underlyingTfsProvider != null ? underlyingTfsProvider.GetTFSSourceControlManager(sourceControlBindings) : null; }
public ISourceControlFileSystem GetFileSystem(string path, SourceControlBindings binding) { ISourceControlFileSystemProvider tfsProvider = GetUnderlyingTfsProvider(); return(tfsProvider != null?tfsProvider.GetFileSystem(path, binding) : null); }
public SourceControlManager GetTFSSourceControlManager(SourceControlBindings sourceControlBindings) { var underlyingTfsProvider = GetUnderlyingTfsProvider(); return(underlyingTfsProvider != null?underlyingTfsProvider.GetTFSSourceControlManager(sourceControlBindings) : null); }
public ISourceControlFileSystem GetFileSystem(string path, SourceControlBindings binding) { ISourceControlFileSystemProvider tfsProvider = GetUnderlyingTfsProvider(); return tfsProvider != null ? tfsProvider.GetFileSystem(path, binding) : null; }
private static IFileSystem GetFileSystemFromProvider(ISourceControlFileSystemProvider provider, string path, SourceControlBindings binding) { try { return(provider.GetFileSystem(path, binding)); } catch { // Ignore exceptions that can happen when some binaries are missing. e.g. TfsSourceControlFileSystemProvider // would throw a jitting error if TFS is not installed } return(null); }
private void ExecInternal() { try { UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer; UIHierarchyItem hierItem = (UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0); ProjectItem projItem = (ProjectItem)hierItem.Object; #if !(YUKON || KATMAI || DENALI || SQL2014) if (projItem.Name.ToLower().EndsWith(".bim")) { var sandboxWrapper = new BIDSHelper.SSAS.DataModelingSandboxWrapper(this); if (sandboxWrapper.IsTabularMetadata) { string compatibility = sandboxWrapper.DatabaseCompatibilityLevel.ToString(); System.Windows.Forms.MessageBox.Show("BIDS Helper Smart Diff is not supported for " + compatibility + " compatibility level models yet.", "BIDS Helper Smart Diff"); return; } } #endif SourceControl2 oSourceControl = ((SourceControl2)this.ApplicationObject.SourceControl); string sProvider = ""; string sSourceControlServerName = ""; string sServerBinding = ""; string sProject = ""; string sDefaultSourceSafePath = ""; if (oSourceControl != null) { SourceControlBindings bindings = null; try { bindings = oSourceControl.GetBindings(projItem.ContainingProject.FileName); } catch { //now that you can have custom diff viewers via the preferences window } if (bindings != null) { sProvider = bindings.ProviderName; sSourceControlServerName = bindings.ServerName; sServerBinding = bindings.ServerBinding; if (sProvider == PROVIDER_NAME_SOURCESAFE) { if (sServerBinding.IndexOf("\",") <= 0) { throw new Exception("Can't find SourceSafe project path."); } sProject = sServerBinding.Substring(1, sServerBinding.IndexOf("\",") - 1); } else if (sProvider == PROVIDER_NAME_TFS) { sProject = sServerBinding; } if (oSourceControl.IsItemUnderSCC(projItem.get_FileNames(0))) { if (projItem.get_FileNames(0).ToLower().StartsWith(bindings.LocalBinding.ToLower())) { sDefaultSourceSafePath = sProject + projItem.get_FileNames(0).Substring(bindings.LocalBinding.Length).Replace('\\', '/'); } else { sDefaultSourceSafePath = sProject + "/" + projItem.Name; } } } else { try { if (GitHelper.IsPathInGitRepository(projItem.get_FileNames(0))) { sSourceControlServerName = GitHelper.GetGitRepositoryPath(projItem.get_FileNames(0)); sDefaultSourceSafePath = "$/" + GitHelper.GetRelativePath(projItem.get_FileNames(0)); sProvider = PROVIDER_NAME_GIT; } } catch (Exception ex) { package.Log.Exception("Could not check whether solution is a Git repository", ex); } } } if (projItem.Document != null && !projItem.Document.Saved) { if (MessageBox.Show("This command compares the disk version of a file. Do you want to save your changes to disk before proceeding?", "Save Changes?", MessageBoxButtons.YesNo) == DialogResult.Yes) { projItem.Save(""); } } SSIS.SmartDiff form = new BIDSHelper.SSIS.SmartDiff(); form.SourceControlProvider = sProvider; form.DefaultWindowsPath = projItem.get_FileNames(0); if (sProvider == PROVIDER_NAME_SOURCESAFE || sProvider == PROVIDER_NAME_TFS || sProvider == PROVIDER_NAME_GIT) { form.DefaultSourceSafePath = sDefaultSourceSafePath; form.SourceSafeIniDirectory = sSourceControlServerName; } DialogResult res = form.ShowDialog(); if (res != DialogResult.OK) { return; } //get the XSLT for this file extension string sXslt = null; string sProjectItemFileName = projItem.Name.ToLower(); bool bNewLineOnAttributes = true; foreach (string extension in DTS_FILE_EXTENSIONS) { if (sProjectItemFileName.EndsWith(extension)) { sXslt = BIDSHelper.Resources.Common.SmartDiffDtsx; break; } } foreach (string extension in SSAS_FILE_EXTENSIONS) { if (sProjectItemFileName.EndsWith(extension)) { sXslt = BIDSHelper.Resources.Common.SmartDiffSSAS; break; } } foreach (string extension in SSRS_FILE_EXTENSIONS) { if (sProjectItemFileName.EndsWith(extension)) { sXslt = BIDSHelper.Resources.Common.SmartDiffSSRS; bNewLineOnAttributes = false; break; } } string sOldFile = System.IO.Path.GetTempFileName(); string sNewFile = System.IO.Path.GetTempFileName(); try { string sOldFileName = form.txtCompare.Text; string sNewFileName = form.txtTo.Text; if (form.txtCompare.Text.StartsWith("$/")) { if (sProvider == PROVIDER_NAME_SOURCESAFE) { GetSourceSafeFile(sSourceControlServerName, form.txtCompare.Text, sOldFile); } else if (sProvider == PROVIDER_NAME_TFS) { GetTFSFile(sSourceControlServerName, form.txtCompare.Text, sOldFile); } else if (sProvider == PROVIDER_NAME_GIT) { GetGitFile(sSourceControlServerName, form.txtCompare.Text, sOldFile); } sOldFileName += " (server)"; } else { System.IO.File.Copy(form.txtCompare.Text, sOldFile, true); sOldFileName += " (local)"; } if (form.txtTo.Text.StartsWith("$/")) { if (sProvider == PROVIDER_NAME_SOURCESAFE) { GetSourceSafeFile(sSourceControlServerName, form.txtTo.Text, sNewFile); } else if (sProvider == PROVIDER_NAME_TFS) { GetTFSFile(sSourceControlServerName, form.txtTo.Text, sNewFile); } else if (sProvider == PROVIDER_NAME_GIT) { GetGitFile(sSourceControlServerName, form.txtTo.Text, sNewFile); } sNewFileName += " (server)"; } else { System.IO.File.Copy(form.txtTo.Text, sNewFile, true); sNewFileName += " (local)"; } PrepXmlForDiff(sOldFile, sXslt, bNewLineOnAttributes); PrepXmlForDiff(sNewFile, sXslt, bNewLineOnAttributes); ShowDiff(sOldFile, sNewFile, form.checkIgnoreCase.Checked, form.checkIgnoreEOL.Checked, form.checkIgnoreWhiteSpace.Checked, sOldFileName, sNewFileName); } finally { try { System.IO.File.Delete(sOldFile); System.IO.File.Delete(sNewFile); } catch { } } } catch (System.Exception ex) { string sError = ""; Exception exLoop = ex; while (exLoop != null) { sError += exLoop.Message + "\r\n"; exLoop = exLoop.InnerException; } sError += ex.StackTrace; MessageBox.Show(sError, "BIDS Helper Smart Diff Error"); } }