diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs index 979d753bdb..89aa8fa9c3 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs @@ -13,8 +13,6 @@ using System.Windows.Forms; using ICSharpCode.Core; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Project; -using NSvn.Common; -using NSvn.Core; namespace ICSharpCode.Svn.Commands { @@ -54,62 +52,44 @@ namespace ICSharpCode.Svn.Commands string projectDir = Path.GetFullPath(e.Project.Directory); try { - Status status = SvnClient.Instance.Client.SingleStatus(projectDir); - if (status.TextStatus != StatusKind.Unversioned) - return; - SvnClient.Instance.Client.Add(projectDir, Recurse.None); - if (FileUtility.IsBaseDirectory(Path.Combine(projectDir, "bin"), e.Project.OutputAssemblyFullPath)) { - AddToIgnoreList(projectDir, "bin"); - } - CompilableProject compilableProject = e.Project as CompilableProject; - if (compilableProject != null) { - if (FileUtility.IsBaseDirectory(Path.Combine(projectDir, "obj"), compilableProject.IntermediateOutputFullPath)) { - AddToIgnoreList(projectDir, "obj"); + using (SvnClientWrapper client = new SvnClientWrapper()) { + Status status = client.SingleStatus(projectDir); + if (status.TextStatus != StatusKind.Unversioned) + return; + client.Add(projectDir, Recurse.None); + if (FileUtility.IsBaseDirectory(Path.Combine(projectDir, "bin"), e.Project.OutputAssemblyFullPath)) { + client.AddToIgnoreList(projectDir, "bin"); } - } - foreach (ProjectItem item in e.Project.Items) { - FileProjectItem fileItem = item as FileProjectItem; - if (fileItem != null) { - if (FileUtility.IsBaseDirectory(projectDir, fileItem.FileName)) { - AddFileWithParentDirectoriesToSvn(fileItem.FileName); + CompilableProject compilableProject = e.Project as CompilableProject; + if (compilableProject != null) { + if (FileUtility.IsBaseDirectory(Path.Combine(projectDir, "obj"), compilableProject.IntermediateOutputFullPath)) { + client.AddToIgnoreList(projectDir, "obj"); } } + foreach (ProjectItem item in e.Project.Items) { + FileProjectItem fileItem = item as FileProjectItem; + if (fileItem != null) { + if (FileUtility.IsBaseDirectory(projectDir, fileItem.FileName)) { + AddFileWithParentDirectoriesToSvn(client, fileItem.FileName); + } + } + } + AddFileWithParentDirectoriesToSvn(client, e.Project.FileName); } - AddFileWithParentDirectoriesToSvn(e.Project.FileName); } catch (Exception ex) { MessageService.ShowError("Project add exception: " + ex); } } - void AddFileWithParentDirectoriesToSvn(string fileName) + void AddFileWithParentDirectoriesToSvn(SvnClientWrapper client, string fileName) { if (!CanBeVersionControlledFile(fileName)) { - AddFileWithParentDirectoriesToSvn(FileUtility.GetAbsolutePath(fileName, "..")); + AddFileWithParentDirectoriesToSvn(client, FileUtility.GetAbsolutePath(fileName, "..")); } - Status status = SvnClient.Instance.Client.SingleStatus(fileName); + Status status = client.SingleStatus(fileName); if (status.TextStatus != StatusKind.Unversioned) return; - SvnClient.Instance.Client.Add(fileName, Recurse.None); - } - - void AddToIgnoreList(string directory, string file) - { - PropertyDictionary pd = SvnClient.Instance.Client.PropGet("svn:ignore", directory, Revision.Working, Recurse.None); - StringBuilder b = new StringBuilder(); - foreach (Property p in pd.Values) { - using (StreamReader r = new StreamReader(new MemoryStream(p.Data))) { - string line; - while ((line = r.ReadLine()) != null) { - if (line.Length > 0) { - b.AppendLine(line); - } - } - } - break; - } - b.AppendLine(file); - SvnClient.Instance.Client.PropSet(new Property("svn:ignore", b.ToString()), - directory, Recurse.None); + client.Add(fileName, Recurse.None); } internal static bool CanBeVersionControlledFile(string fileName) @@ -130,8 +110,8 @@ namespace ICSharpCode.Svn.Commands if (!CanBeVersionControlledFile(fileName)) return; FileNode node = pad.ProjectBrowserControl.FindFileNode(fileName); if (node == null) return; + OverlayIconManager.ClearStatusCache(); OverlayIconManager.Enqueue(node); - SubversionStateCondition.ResetCache(); } void FileCreated(object sender, FileEventArgs e) @@ -143,14 +123,14 @@ namespace ICSharpCode.Svn.Commands string fullName = Path.GetFullPath(e.FileName); if (!CanBeVersionControlledFile(fullName)) return; try { - Status status = SvnClient.Instance.Client.SingleStatus(fullName); - switch (status.TextStatus) { - case StatusKind.Unversioned: - case StatusKind.Deleted: - if (SvnClient.Instance.Client.IsIgnored(fullName)) - return; - SvnClient.Instance.Client.Add(fullName, Recurse.None); - break; + using (SvnClientWrapper client = new SvnClientWrapper()) { + Status status = client.SingleStatus(fullName); + switch (status.TextStatus) { + case StatusKind.Unversioned: + case StatusKind.Deleted: + client.Add(fullName, Recurse.None); + break; + } } } catch (Exception ex) { MessageService.ShowError("File add exception: " + ex); @@ -167,46 +147,48 @@ namespace ICSharpCode.Svn.Commands // show "cannot delete directories" message even if // AutomaticallyDeleteFiles (see below) is off! - Status status = SvnClient.Instance.Client.SingleStatus(fullName); - switch (status.TextStatus) { - case StatusKind.None: - case StatusKind.Unversioned: - break; - default: - // must be done using the subversion client, even if - // AutomaticallyDeleteFiles is off, because we don't want to corrupt the - // working copy - e.OperationAlreadyDone = true; - try { - SvnClient.Instance.Client.Delete(new string[] { fullName }, false); - } catch (SvnClientException ex) { - LoggingService.Warn("SVN Error code " + ex.ErrorCode); - LoggingService.Warn(ex); - - if (ex.ErrorCode == CannotDeleteFileWithLocalModifications - || ex.ErrorCode == CannotDeleteFileNotUnderVersionControl) - { - if (MessageService.ShowCustomDialog("Delete directory", - "Error deleting " + fullName + ":\n" + - ex.Message, 0, 1, - "Force delete", "${res:Global.CancelButtonText}") - == 0) + using (SvnClientWrapper client = new SvnClientWrapper()) { + Status status = client.SingleStatus(fullName); + switch (status.TextStatus) { + case StatusKind.None: + case StatusKind.Unversioned: + break; + default: + // must be done using the subversion client, even if + // AutomaticallyDeleteFiles is off, because we don't want to corrupt the + // working copy + e.OperationAlreadyDone = true; + try { + client.Delete(new string[] { fullName }, false); + } catch (SvnClientException ex) { + LoggingService.Warn("SVN Error code " + ex.ErrorCode); + LoggingService.Warn(ex); + + if (ex.ErrorCode == CannotDeleteFileWithLocalModifications + || ex.ErrorCode == CannotDeleteFileNotUnderVersionControl) { - try { - SvnClient.Instance.Client.Delete(new string[] { fullName }, true); - } catch (SvnClientException ex2) { + if (MessageService.ShowCustomDialog("Delete directory", + "Error deleting " + fullName + ":\n" + + ex.Message, 0, 1, + "Force delete", "${res:Global.CancelButtonText}") + == 0) + { + try { + client.Delete(new string[] { fullName }, true); + } catch (SvnClientException ex2) { + e.Cancel = true; + MessageService.ShowError(ex2.Message); + } + } else { e.Cancel = true; - MessageService.ShowError(ex2.Message); } } else { e.Cancel = true; + MessageService.ShowError(ex.Message); } - } else { - e.Cancel = true; - MessageService.ShowError(ex.Message); } - } - break; + break; + } } return; } @@ -214,40 +196,42 @@ namespace ICSharpCode.Svn.Commands if (!AddInOptions.AutomaticallyDeleteFiles) return; try { - Status status = SvnClient.Instance.Client.SingleStatus(fullName); - switch (status.TextStatus) { - case StatusKind.None: - case StatusKind.Unversioned: - case StatusKind.Deleted: - return; // nothing to do - case StatusKind.Normal: - // remove without problem - break; - case StatusKind.Modified: - case StatusKind.Replaced: - if (MessageService.AskQuestion("The file has local modifications. Do you really want to remove it?")) { - // modified files cannot be deleted, so we need to revert the changes first - SvnClient.Instance.Client.Revert(new string[] { fullName }, e.IsDirectory ? Recurse.Full : Recurse.None); - } else { - e.Cancel = true; - return; - } - break; - case StatusKind.Added: - if (status.Copied) { - if (!MessageService.AskQuestion("The file has just been moved to this location, do you really want to remove it?")) { + using (SvnClientWrapper client = new SvnClientWrapper()) { + Status status = client.SingleStatus(fullName); + switch (status.TextStatus) { + case StatusKind.None: + case StatusKind.Unversioned: + case StatusKind.Deleted: + return; // nothing to do + case StatusKind.Normal: + // remove without problem + break; + case StatusKind.Modified: + case StatusKind.Replaced: + if (MessageService.AskQuestion("The file has local modifications. Do you really want to remove it?")) { + // modified files cannot be deleted, so we need to revert the changes first + client.Revert(new string[] { fullName }, e.IsDirectory ? Recurse.Full : Recurse.None); + } else { e.Cancel = true; return; } - } - SvnClient.Instance.Client.Revert(new string[] { fullName }, e.IsDirectory ? Recurse.Full : Recurse.None); - return; - default: - MessageService.ShowError("The file/directory cannot be removed because it is in subversion status '" + status.TextStatus + "'."); - e.Cancel = true; - return; + break; + case StatusKind.Added: + if (status.Copied) { + if (!MessageService.AskQuestion("The file has just been moved to this location, do you really want to remove it?")) { + e.Cancel = true; + return; + } + } + client.Revert(new string[] { fullName }, e.IsDirectory ? Recurse.Full : Recurse.None); + return; + default: + MessageService.ShowError("The file/directory cannot be removed because it is in subversion status '" + status.TextStatus + "'."); + e.Cancel = true; + return; + } + client.Delete(new string [] { fullName }, true); } - SvnClient.Instance.Client.Delete(new string [] { fullName }, true); e.OperationAlreadyDone = true; } catch (Exception ex) { MessageService.ShowError("File removed exception: " + ex); @@ -261,36 +245,38 @@ namespace ICSharpCode.Svn.Commands string fullSource = Path.GetFullPath(e.SourceFile); if (!CanBeVersionControlledFile(fullSource)) return; try { - Status status = SvnClient.Instance.Client.SingleStatus(fullSource); - switch (status.TextStatus) { - case StatusKind.Unversioned: - case StatusKind.None: - return; // nothing to do - case StatusKind.Normal: - case StatusKind.Modified: - case StatusKind.Replaced: - // rename without problem - break; - case StatusKind.Added: - if (status.Copied) { - MessageService.ShowError("The file was moved/copied and cannot be renamed without losing it's history."); + using (SvnClientWrapper client = new SvnClientWrapper()) { + Status status = client.SingleStatus(fullSource); + switch (status.TextStatus) { + case StatusKind.Unversioned: + case StatusKind.None: + return; // nothing to do + case StatusKind.Normal: + case StatusKind.Modified: + case StatusKind.Replaced: + // rename without problem + break; + case StatusKind.Added: + if (status.Copied) { + MessageService.ShowError("The file was moved/copied and cannot be renamed without losing it's history."); + e.Cancel = true; + } else if (e.IsDirectory) { + goto default; + } else { + client.Revert(new string[] { fullSource }, Recurse.None); + FileService.FileRenamed += new AutoAddAfterRenameHelper(e).Renamed; + } + return; + default: + MessageService.ShowError("The file/directory cannot be renamed because it is in subversion status '" + status.TextStatus + "'."); e.Cancel = true; - } else if (e.IsDirectory) { - goto default; - } else { - SvnClient.Instance.Client.Revert(new string[] { fullSource }, Recurse.None); - FileService.FileRenamed += new AutoAddAfterRenameHelper(e).Renamed; - } - return; - default: - MessageService.ShowError("The file/directory cannot be renamed because it is in subversion status '" + status.TextStatus + "'."); - e.Cancel = true; - return; + return; + } + client.Move(fullSource, + Path.GetFullPath(e.TargetFile), + true + ); } - SvnClient.Instance.Client.Move(fullSource, - Path.GetFullPath(e.TargetFile), - true - ); e.OperationAlreadyDone = true; } catch (Exception ex) { MessageService.ShowError("File renamed exception: " + ex); @@ -312,7 +298,9 @@ namespace ICSharpCode.Svn.Commands return; if (args.SourceFile != e.SourceFile || args.TargetFile != e.TargetFile) return; - SvnClient.Instance.Client.Add(e.TargetFile, Recurse.None); + using (SvnClientWrapper client = new SvnClientWrapper()) { + client.Add(e.TargetFile, Recurse.None); + } } } } diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/ProjectBrowserCommands.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/ProjectBrowserCommands.cs index 0a250e91f7..0185e03881 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/ProjectBrowserCommands.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/ProjectBrowserCommands.cs @@ -14,8 +14,6 @@ using ICSharpCode.Core; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Project; -using NSvn.Common; -using NSvn.Core; namespace ICSharpCode.Svn.Commands { @@ -45,6 +43,7 @@ namespace ICSharpCode.Svn.Commands } } if (unsavedFiles.Count > 0) { + // TODO: Translate if (MessageService.ShowCustomDialog( MessageService.DefaultMessageBoxTitle, "The version control operation would affect files with unsaved modifications.\n" + @@ -75,7 +74,7 @@ namespace ICSharpCode.Svn.Commands static void CallbackInvoked() { - SubversionStateCondition.ResetCache(); + OverlayIconManager.ClearStatusCache(); AbstractProjectBrowserTreeNode node = ProjectBrowserPad.Instance.SelectedNode; if (node != null) { OverlayIconManager.EnqueueRecursive(node); @@ -246,13 +245,13 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - PropertyDictionary pd = SvnClient.Instance.Client.PropGet("svn:ignore", Path.GetDirectoryName(filename), Revision.Working, Recurse.None); - if (pd != null) { - ProjectWatcher watcher = WatchProjects(); - string shortFileName = Path.GetFileName(filename); - foreach (Property p in pd.Values) { + using (SvnClientWrapper client = new SvnClientWrapper()) { + string propertyValue = client.GetPropertyValue(Path.GetDirectoryName(filename), "svn:ignore"); + if (propertyValue != null) { + ProjectWatcher watcher = WatchProjects(); + string shortFileName = Path.GetFileName(filename); StringBuilder b = new StringBuilder(); - using (StreamReader r = new StreamReader(new MemoryStream(p.Data))) { + using (StringReader r = new StringReader(propertyValue)) { string line; while ((line = r.ReadLine()) != null) { if (!string.Equals(line, shortFileName, StringComparison.InvariantCultureIgnoreCase)) { @@ -260,11 +259,10 @@ namespace ICSharpCode.Svn.Commands } } } - SvnClient.Instance.Client.PropSet(new Property(p.Name, b.ToString()), - Path.GetDirectoryName(filename), Recurse.None); + client.SetPropertyValue(Path.GetDirectoryName(filename), "svn:ignore", b.ToString()); + MessageService.ShowMessage(shortFileName + " was removed from the ignore list."); + watcher.Callback(); } - MessageService.ShowMessage(shortFileName + " was removed from the ignore list."); - watcher.Callback(); } } } diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/ClientCertDialog.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/ClientCertDialog.cs index 61564e506f..2ea7d81f4c 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/ClientCertDialog.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/ClientCertDialog.cs @@ -10,7 +10,8 @@ using System.Reflection; using System.Windows.Forms; using ICSharpCode.SharpDevelop.Gui.XmlForms; -using NSvn.Core; +using PumaCode.SvnDotNet.AprSharp; +using PumaCode.SvnDotNet.SubversionSharp; namespace ICSharpCode.Svn.Gui { @@ -46,15 +47,14 @@ namespace ICSharpCode.Svn.Gui } } - public SslClientCertificateCredential Credential { - get { - SslClientCertificateCredential cred = new SslClientCertificateCredential(); - cred.CertificateFile = FileName; - cred.MaySave = MaySave; - return cred; - } + public SvnAuthCredSslClientCert CreateCredential(AprPool pool) + { + SvnAuthCredSslClientCert cred = SvnAuthCredSslClientCert.Alloc(pool); + cred.CertFile = new SvnPath(FileName, pool); + cred.MaySave = MaySave; + return cred; } - + public ClientCertDialog(string realm, bool maySave) { SetupFromXmlStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("ICSharpCode.Svn.Resources.ClientCertDialog.xfrm")); diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/ClientCertPassphraseDialog.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/ClientCertPassphraseDialog.cs index 57f4874ddc..b435ad3380 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/ClientCertPassphraseDialog.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/ClientCertPassphraseDialog.cs @@ -10,7 +10,8 @@ using System.Reflection; using System.Windows.Forms; using ICSharpCode.SharpDevelop.Gui.XmlForms; -using NSvn.Core; +using PumaCode.SvnDotNet.AprSharp; +using PumaCode.SvnDotNet.SubversionSharp; namespace ICSharpCode.Svn.Gui { @@ -46,13 +47,12 @@ namespace ICSharpCode.Svn.Gui } } - public SslClientCertificatePasswordCredential Credential { - get { - SslClientCertificatePasswordCredential cred = new SslClientCertificatePasswordCredential(); - cred.Password = Passphrase; - cred.MaySave = MaySave; - return cred; - } + public SvnAuthCredSslClientCertPw CreateCredential(AprPool pool) + { + SvnAuthCredSslClientCertPw cred = SvnAuthCredSslClientCertPw.Alloc(pool); + cred.CertFile = new SvnPath(Passphrase, pool); // this should be cred.Password, the property is named incorrectly in Svn.Net + cred.MaySave = MaySave; + return cred; } public ClientCertPassphraseDialog(string realm, bool maySave) diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/LoginDialog.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/LoginDialog.cs index 94346c2b60..01c76a0493 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/LoginDialog.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/LoginDialog.cs @@ -10,7 +10,8 @@ using System.Reflection; using System.Windows.Forms; using ICSharpCode.SharpDevelop.Gui.XmlForms; -using NSvn.Core; +using PumaCode.SvnDotNet.AprSharp; +using PumaCode.SvnDotNet.SubversionSharp; namespace ICSharpCode.Svn.Gui { @@ -46,12 +47,13 @@ namespace ICSharpCode.Svn.Gui } } - public SimpleCredential Credential { - get { - return new SimpleCredential(UserName, - Password, - MaySave); - } + public SvnAuthCredSimple CreateCredential(AprPool pool) + { + SvnAuthCredSimple cred = SvnAuthCredSimple.Alloc(pool); + cred.Username = new AprString(UserName, pool); + cred.Password = new AprString(Password, pool); + cred.MaySave = MaySave; + return cred; } string Password { diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/SslServerTrustDialog.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/SslServerTrustDialog.cs index 6edbeebc04..f767216724 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/SslServerTrustDialog.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/SslServerTrustDialog.cs @@ -11,7 +11,8 @@ using System.Reflection; using System.Windows.Forms; using ICSharpCode.SharpDevelop.Gui.XmlForms; -using NSvn.Core; +using PumaCode.SvnDotNet.AprSharp; +using PumaCode.SvnDotNet.SubversionSharp; namespace ICSharpCode.Svn.Gui { @@ -20,10 +21,10 @@ namespace ICSharpCode.Svn.Gui /// public class SslServerTrustDialog : BaseSharpDevelopForm { - SslServerCertificateInfo certificateInfo; - SslFailures failures; + SvnAuthSslServerCertInfo certificateInfo; + SvnAuthCredSslServerTrust.CertFailures failures; - public SslServerCertificateInfo CertificateInfo { + public SvnAuthSslServerCertInfo CertificateInfo { get { return certificateInfo; } @@ -33,7 +34,7 @@ namespace ICSharpCode.Svn.Gui } } - public SslFailures Failures { + public SvnAuthCredSslServerTrust.CertFailures Failures { get { return failures; } @@ -52,16 +53,15 @@ namespace ICSharpCode.Svn.Gui } } - public SslServerTrustCredential Credential { - get { - SslServerTrustCredential cred = new SslServerTrustCredential(); - cred.AcceptedFailures = failures; - cred.MaySave = MaySave; - return cred; - } + public SvnAuthCredSslServerTrust CreateCredential(AprPool pool) + { + SvnAuthCredSslServerTrust cred = SvnAuthCredSslServerTrust.Alloc(pool); + cred.AcceptedFailures = failures; + cred.MaySave = MaySave; + return cred; } - public SslServerTrustDialog(SslServerCertificateInfo certificateInfo, SslFailures failures, bool maySave) + public SslServerTrustDialog(SvnAuthSslServerCertInfo certificateInfo, SvnAuthCredSslServerTrust.CertFailures failures, bool maySave) { SetupFromXmlStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("ICSharpCode.Svn.Resources.SslServerTrustDialog.xfrm")); this.CertificateInfo = certificateInfo; @@ -71,12 +71,12 @@ namespace ICSharpCode.Svn.Gui void UpdateCertificateInfo() { - if (certificateInfo != null) { - ControlDictionary["hostNameLabel"].Text = certificateInfo.HostName; - ControlDictionary["fingerPrintlabel"].Text = certificateInfo.FingerPrint; + if (!certificateInfo.IsNull) { + ControlDictionary["hostNameLabel"].Text = certificateInfo.Hostname.Value; + ControlDictionary["fingerPrintlabel"].Text = certificateInfo.Fingerprint.Value; ControlDictionary["validLabel"].Text = "From " + certificateInfo.ValidFrom + " to " + certificateInfo.ValidUntil; - ControlDictionary["issuerLabel"].Text = certificateInfo.Issuer; - ControlDictionary["certificateTextBox"].Text = certificateInfo.AsciiCertificate; + ControlDictionary["issuerLabel"].Text = certificateInfo.IssuerDName.Value; + ControlDictionary["certificateTextBox"].Text = certificateInfo.AsciiCert.Value; } else { ControlDictionary["hostNameLabel"].Text = String.Empty; ControlDictionary["fingerPrintlabel"].Text = String.Empty; @@ -86,14 +86,14 @@ namespace ICSharpCode.Svn.Gui } } - bool HasFailures(SslFailures testFailures) + bool HasFailures(SvnAuthCredSslServerTrust.CertFailures testFailures) { return (failures & testFailures) == testFailures; } void UpdateFailures() { - if (HasFailures(SslFailures.CertificateAuthorityUnknown)) { + if (HasFailures(SvnAuthCredSslServerTrust.CertFailures.UnknownCA)) { ControlDictionary["certificateAuthorityStatusLabel"].Text = "The issuing certificate authority(CA) is not trusted."; ControlDictionary["certificateAuthorityStatusLabel"].ForeColor = Color.Red; } else { @@ -101,7 +101,7 @@ namespace ICSharpCode.Svn.Gui ControlDictionary["certificateAuthorityStatusLabel"].ForeColor = Color.Green; } - if (HasFailures(SslFailures.CertificateNameMismatch)) { + if (HasFailures(SvnAuthCredSslServerTrust.CertFailures.CNMismatch)) { ControlDictionary["certificateNameStatusLabel"].Text = "The certificate's hostname does not match the hostname of the server."; ControlDictionary["certificateNameStatusLabel"].ForeColor = Color.Red; } else { @@ -109,17 +109,16 @@ namespace ICSharpCode.Svn.Gui ControlDictionary["certificateNameStatusLabel"].ForeColor = Color.Green; } - if (HasFailures(SslFailures.Expired)) { + if (HasFailures(SvnAuthCredSslServerTrust.CertFailures.Expired)) { ControlDictionary["certificateDateStatusLabel"].Text = "The server certificate has expired."; ControlDictionary["certificateDateStatusLabel"].ForeColor = Color.Red; - } else if (HasFailures(SslFailures.NotYetValid)) { + } else if (HasFailures(SvnAuthCredSslServerTrust.CertFailures.NotYetValid)) { ControlDictionary["certificateDateStatusLabel"].Text = "The server certificate is not yet valid."; ControlDictionary["certificateDateStatusLabel"].ForeColor = Color.Red; } else { ControlDictionary["certificateDateStatusLabel"].Text = "The server certificate date is valid."; ControlDictionary["certificateDateStatusLabel"].ForeColor = Color.Green; } - } } } diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/DiffPanel.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/DiffPanel.cs index fb7b5a7819..2d4159e79f 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/DiffPanel.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/DiffPanel.cs @@ -14,8 +14,6 @@ using ICSharpCode.TextEditor.Document; using ICSharpCode.TextEditor.Gui; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; -using NSvn.Core; -using NSvn.Common; using System.IO; using System.Text; @@ -84,16 +82,16 @@ namespace ICSharpCode.Svn output = null; MemoryStream outStream = new MemoryStream(); MemoryStream errStream = new MemoryStream(); - SvnClient.Instance.Client.Diff(new string [] {} , - fileName, - fromRevision, - fileName, - toRevision, - Recurse.None, - false, - true, - outStream, - errStream); +// SvnClient.Instance.Client.Diff(new string [] {} , +// fileName, +// fromRevision, +// fileName, +// toRevision, +// Recurse.None, +// false, +// true, +// outStream, +// errStream); output = Encoding.Default.GetString(outStream.ToArray()); WorkbenchSingleton.SafeThreadCall(SetOutput); } @@ -127,7 +125,7 @@ namespace ICSharpCode.Svn if (fromRevision.ToString() == toRevision.ToString()) { output = ""; } else { - SvnClient.Instance.OperationStart("Diff", DoDiffOperation); + //SvnClient.Instance.OperationStart("Diff", DoDiffOperation); } } diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs index d7436fd56b..3db3030a60 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs @@ -9,7 +9,6 @@ using System; using System.IO; using ICSharpCode.Core; using ICSharpCode.SharpDevelop; -using NSvn.Core; namespace ICSharpCode.Svn { @@ -30,40 +29,6 @@ namespace ICSharpCode.Svn return new ICSharpCode.SharpDevelop.Gui.IViewContent[] { new HistoryView(viewContent) }; } - private static class SvnHelper { - // load NSvn.Core only when a directory actually contains the ".svn" folder - static Client client; - static bool firstSvnClientException = true; - - // prevent initialization of SvnHelper and therefore Client (and NSvn.Core.dll) unless it is - // really required - static SvnHelper() {} - - internal static bool IsVersionControlled(string fileName) - { - if (client == null) { - LoggingService.Info("SVN: HistoryViewDisplayBinding initializes client"); - try { - client = new Client(); - } catch (Exception ex) { - LoggingService.Warn(ex); - } - } - try { - Status status = client.SingleStatus(Path.GetFullPath(fileName)); - return status != null && status.Entry != null; - } catch (SvnClientException ex) { - if (firstSvnClientException) { - firstSvnClientException = false; - MessageService.ShowWarning("An error occurred while getting the Subversion status: " + ex.Message); - } else { - LoggingService.Warn("Svn: IsVersionControlled Exception", ex); - } - return false; - } - } - } - public bool CanAttachTo(ICSharpCode.SharpDevelop.Gui.IViewContent content) { if (!AddInOptions.UseHistoryDisplayBinding) { @@ -74,7 +39,8 @@ namespace ICSharpCode.Svn return false; } if (Commands.RegisterEventsCommand.CanBeVersionControlledFile(file.FileName)) { - return SvnHelper.IsVersionControlled(file.FileName); + StatusKind status = OverlayIconManager.GetStatus(file.FileName); + return status != StatusKind.None && status != StatusKind.Unversioned && status != StatusKind.Ignored; } else { return false; } diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs index 8515eb0884..9bb828fa07 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs @@ -12,7 +12,6 @@ using System.Windows.Forms; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui; -using NSvn.Core; namespace ICSharpCode.Svn { @@ -24,7 +23,7 @@ namespace ICSharpCode.Svn IViewContent viewContent; InfoPanel infoPanel; - DiffPanel diffPanel; + DiffPanel diffPanel = null; public HistoryViewPanel(IViewContent viewContent) { @@ -41,6 +40,7 @@ namespace ICSharpCode.Svn void Initialize() { + /* TabControl mainTab = new TabControl(); mainTab.Dock = DockStyle.Fill; mainTab.Alignment = TabAlignment.Bottom; @@ -61,6 +61,7 @@ namespace ICSharpCode.Svn mainTab.TabPages.Add(diffTabPage); diffPanel.Dock = DockStyle.Fill; + */ /* TabPage conflictTabPage = new TabPage("Conflicts"); @@ -68,7 +69,11 @@ namespace ICSharpCode.Svn todoLabel.Text = "TODO :)"; conflictTabPage.Controls.Add(todoLabel); mainTab.TabPages.Add(conflictTabPage); - */ + */ + + infoPanel = new InfoPanel(viewContent); + infoPanel.Dock = DockStyle.Fill; + Controls.Add(infoPanel); Thread logMessageThread = new Thread(new ThreadStart(GetLogMessages)); logMessageThread.Name = "svnLogMessage"; @@ -82,13 +87,16 @@ namespace ICSharpCode.Svn string fileName = Path.GetFullPath(viewContent.PrimaryFileName); LoggingService.Info("SVN: Get log of " + fileName); if (File.Exists(fileName)) { - Client client = SvnClient.Instance.Client; - client.Log(new string[] { fileName}, - Revision.Head, // Revision start - Revision.FromNumber(1), // Revision end - false, // bool discoverChangePath - false, // bool strictNodeHistory - new LogMessageReceiver(ReceiveLogMessage)); + using (SvnClientWrapper client = new SvnClientWrapper()) { + client.AllowInteractiveAuthorization = true; + client.Log(new string[] { fileName }, + Revision.Head, // Revision start + Revision.FromNumber(1), // Revision end + int.MaxValue, // Limit + false, // bool discoverChangePath + false, // bool strictNodeHistory + ReceiveLogMessage); + } } } catch (Exception ex) { // if exceptions aren't caught here, they force SD to exit @@ -103,8 +111,12 @@ namespace ICSharpCode.Svn void ReceiveLogMessage(LogMessage logMessage) { - WorkbenchSingleton.SafeThreadAsyncCall(infoPanel.AddLogMessage, logMessage); - WorkbenchSingleton.SafeThreadAsyncCall(diffPanel.AddLogMessage, logMessage); + if (infoPanel != null) { + WorkbenchSingleton.SafeThreadAsyncCall(infoPanel.AddLogMessage, logMessage); + } + if (diffPanel != null) { + WorkbenchSingleton.SafeThreadAsyncCall(diffPanel.AddLogMessage, logMessage); + } } } } diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/InfoPanel.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/InfoPanel.cs index 96fa7c7798..15e0a4f2da 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/InfoPanel.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/InfoPanel.cs @@ -7,6 +7,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Threading; @@ -14,7 +15,6 @@ using System.Windows.Forms; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui; -using NSvn.Core; namespace ICSharpCode.Svn { @@ -45,8 +45,8 @@ namespace ICSharpCode.Svn SvnClientException svn; txt.Text = ""; while ((svn = ex as SvnClientException) != null) { - txt.Text += svn.SvnError + Environment.NewLine; - ex = svn.InnerException; + txt.Text += svn.Message + Environment.NewLine; + ex = svn.GetInnerException(); } if (ex != null) { txt.Text += ex.ToString(); @@ -83,7 +83,7 @@ namespace ICSharpCode.Svn ListViewItem item = revisionListView.SelectedItems[0]; LogMessage logMessage = item.Tag as LogMessage; commentRichTextBox.Text = logMessage.Message; - ChangedPathDictionary changes = logMessage.ChangedPaths; + List changes = logMessage.ChangedPaths; if (changes == null) { changesListView.Items.Add("Loading..."); if (!isLoadingChangedPaths) { @@ -95,13 +95,12 @@ namespace ICSharpCode.Svn int pathWidth = 70; int copyFromWidth = 70; using (Graphics g = CreateGraphics()) { - foreach (DictionaryEntry entry in changes) { - string path = (string)entry.Key; + foreach (ChangedPath change in changes) { + string path = change.Path; path = path.Replace('\\', '/'); SizeF size = g.MeasureString(path, changesListView.Font); if (size.Width + 4 > pathWidth) pathWidth = (int)size.Width + 4; - ChangedPath change = (ChangedPath)entry.Value; string copyFrom = change.CopyFromPath; if (copyFrom == null) { copyFrom = string.Empty; @@ -112,7 +111,7 @@ namespace ICSharpCode.Svn copyFromWidth = (int)size.Width + 4; } ListViewItem newItem = new ListViewItem(new string[] { - SvnClient.GetActionString(change.Action), + SvnClientWrapper.GetActionString(change.Action), path, copyFrom }); @@ -132,28 +131,32 @@ namespace ICSharpCode.Svn try { LogMessage logMessage = (LogMessage)loadChangedPathsItem.Tag; string fileName = System.IO.Path.GetFullPath(viewContent.PrimaryFileName); - Client client = SvnClient.Instance.Client; - try { - client.Log(new string[] { fileName }, - Revision.FromNumber(logMessage.Revision), // Revision start - Revision.FromNumber(logMessage.Revision), // Revision end - true, // bool discoverChangePath - false, // bool strictNodeHistory - new LogMessageReceiver(ReceiveChangedPaths)); - } catch (SvnClientException ex) { - if (ex.ErrorCode == 160013) { - // This can happen when the file was renamed/moved so it cannot be found - // directly in the old revision. In that case, we do a full download of - // all revisions (so the file can be found in the new revision and svn can - // follow back its history). + using (SvnClientWrapper client = new SvnClientWrapper()) { + client.AllowInteractiveAuthorization = true; + try { client.Log(new string[] { fileName }, - Revision.FromNumber(1), // Revision start - Revision.FromNumber(lastRevision), // Revision end + Revision.FromNumber(logMessage.Revision), // Revision start + Revision.FromNumber(logMessage.Revision), // Revision end + int.MaxValue, // limit true, // bool discoverChangePath false, // bool strictNodeHistory - new LogMessageReceiver(ReceiveAllChangedPaths)); - } else { - throw; + ReceiveChangedPaths); + } catch (SvnClientException ex) { + if (ex.ErrorCode == 160013) { + // This can happen when the file was renamed/moved so it cannot be found + // directly in the old revision. In that case, we do a full download of + // all revisions (so the file can be found in the new revision and svn can + // follow back its history). + client.Log(new string[] { fileName }, + Revision.FromNumber(1), // Revision start + Revision.FromNumber(lastRevision), // Revision end + int.MaxValue, // limit + true, // bool discoverChangePath + false, // bool strictNodeHistory + ReceiveAllChangedPaths); + } else { + throw; + } } } loadChangedPathsItem = null; diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs index db0c390283..68f90928a0 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs @@ -13,8 +13,6 @@ using System.Windows.Forms; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Project; -using NSvn.Common; -using NSvn.Core; namespace ICSharpCode.Svn { @@ -67,9 +65,9 @@ namespace ICSharpCode.Svn return statusIcons[index]; } - public static Image GetImage(Status status) + public static Image GetImage(StatusKind status) { - switch (status.TextStatus) { + switch (status) { case StatusKind.Added: return GetImage(StatusIcon.Added); case StatusKind.Deleted: @@ -79,6 +77,9 @@ namespace ICSharpCode.Svn return GetImage(StatusIcon.Modified); case StatusKind.Normal: return GetImage(StatusIcon.OK); + case StatusKind.Conflicted: + case StatusKind.Obstructed: + return GetImage(StatusIcon.Exclamation); default: return null; } @@ -126,7 +127,8 @@ namespace ICSharpCode.Svn } } - static Client client; + static readonly object clientLock = new object(); + static SvnClientWrapper client; static bool subversionDisabled; static void Run(object state) @@ -143,6 +145,7 @@ namespace ICSharpCode.Svn AbstractProjectBrowserTreeNode node; lock (queue) { if (queue.Count == 0) { + ClearStatusCache(); LoggingService.Debug("SVN: OverlayIconManager Thread finished"); return; } @@ -156,42 +159,63 @@ namespace ICSharpCode.Svn } } - static void RunStep(AbstractProjectBrowserTreeNode node) + public static void ClearStatusCache() + { + if (client != null) { + client.ClearStatusCache(); + } + } + + public static StatusKind GetStatus(string fileName) { - if (subversionDisabled || node.IsDisposed) return; - if (client == null) { + lock (clientLock) { + if (subversionDisabled) + return StatusKind.None; + + if (client == null) { + try { + client = new SvnClientWrapper(); + } catch (Exception ex) { + subversionDisabled = true; + SharpDevelop.Gui.WorkbenchSingleton.SafeThreadAsyncCall( + MessageService.ShowWarning, + "Error initializing Subversion library:\n" + ex.ToString() + ); + return StatusKind.None; + } + } + try { - client = new Client(); - } catch (Exception ex) { - SharpDevelop.Gui.WorkbenchSingleton.SafeThreadAsyncCall( - MessageService.ShowWarning, - "Error initializing Subversion library:\n" + ex.ToString() - ); - subversionDisabled = true; - return; + return client.SingleStatus(fileName).TextStatus; + } catch (SvnClientException ex) { + LoggingService.Warn("Error getting status of " + fileName, ex); + return StatusKind.None; } } + } + + static void RunStep(AbstractProjectBrowserTreeNode node) + { + if (node.IsDisposed) return; + FileNode fileNode = node as FileNode; - Status status; - try { - if (fileNode != null) { - status = client.SingleStatus(fileNode.FileName); + StatusKind status; + if (fileNode != null) { + status = GetStatus(fileNode.FileName); + } else { + DirectoryNode directoryNode = node as DirectoryNode; + if (directoryNode != null) { + status = GetStatus(directoryNode.Directory); } else { - DirectoryNode directoryNode = node as DirectoryNode; - if (directoryNode != null) { - status = client.SingleStatus(directoryNode.Directory); + SolutionNode solNode = node as SolutionNode; + if (solNode != null) { + status = GetStatus(solNode.Solution.Directory); } else { - SolutionNode solNode = node as SolutionNode; - if (solNode != null) { - status = client.SingleStatus(solNode.Solution.Directory); - } else { - return; - } + return; } } - } catch (SvnException) { - return; } + SharpDevelop.Gui.WorkbenchSingleton.SafeThreadAsyncCall( delegate { node.Overlay = GetImage(status); diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/SvnGuiWrapper.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/SvnGuiWrapper.cs index 0a76197261..592ae8c10b 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/SvnGuiWrapper.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/SvnGuiWrapper.cs @@ -66,20 +66,20 @@ namespace ICSharpCode.Svn Process p = new Process(); p.StartInfo.FileName = path; p.StartInfo.Arguments = arguments.ToString(); - p.StartInfo.RedirectStandardError = true; - p.StartInfo.RedirectStandardOutput = true; + //p.StartInfo.RedirectStandardError = true; + //p.StartInfo.RedirectStandardOutput = true; p.StartInfo.UseShellExecute = false; p.EnableRaisingEvents = true; p.Exited += delegate { p.Dispose(); if (callback != null) { callback(); } }; - p.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e) { - SvnClient.Instance.SvnCategory.AppendText(e.Data); - }; - p.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e) { - SvnClient.Instance.SvnCategory.AppendText(e.Data); - }; +// p.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e) { +// SvnClient.Instance.SvnCategory.AppendText(e.Data); +// }; +// p.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e) { +// SvnClient.Instance.SvnCategory.AppendText(e.Data); +// }; p.Start(); } catch (Exception ex) { MessageService.ShowError(ex.Message); diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/SubversionStateCondition.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/SubversionStateCondition.cs index b23eded830..e9aca5a85f 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/SubversionStateCondition.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/SubversionStateCondition.cs @@ -10,8 +10,8 @@ using System.IO; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.Svn.Commands; -using NSvn.Common; -using NSvn.Core; +using PumaCode.SvnDotNet.SubversionSharp; +using PumaCode.SvnDotNet.AprSharp; namespace ICSharpCode.Svn { @@ -74,51 +74,31 @@ namespace ICSharpCode.Svn return false; } - static string lastTestFileName; - static string lastTestStatus; - - internal static void ResetCache() - { - lastTestFileName = null; - } - bool Test(Condition condition, string fileName) { string[] allowedStatus = condition.Properties["state"].Split(';'); if (allowedStatus.Length == 0 || (allowedStatus.Length == 1 && allowedStatus[0].Length == 0)) { return true; } - string status; - if (fileName == lastTestFileName) { - status = lastTestStatus; - } else { - try { - status = SvnClient.Instance.Client.SingleStatus(fileName).TextStatus.ToString(); - if (status == "Unversioned") { - PropertyDictionary pd = SvnClient.Instance.Client.PropGet("svn:ignore", Path.GetDirectoryName(fileName), Revision.Working, Recurse.None); - if (pd != null) { - string shortFileName = Path.GetFileName(fileName); - foreach (Property p in pd.Values) { - using (StreamReader r = new StreamReader(new MemoryStream(p.Data))) { - string line; - while ((line = r.ReadLine()) != null) { - if (string.Equals(line, shortFileName, StringComparison.InvariantCultureIgnoreCase)) { - status = "Ignored"; - break; - } - } + string status = OverlayIconManager.GetStatus(fileName).ToString(); + /*if (status == "Unversioned") { + PropertyDictionary pd = SvnClient.Instance.Client.PropGet("svn:ignore", Path.GetDirectoryName(fileName), Revision.Working, Recurse.None); + if (pd != null) { + string shortFileName = Path.GetFileName(fileName); + foreach (Property p in pd.Values) { + using (StreamReader r = new StreamReader(new MemoryStream(p.Data))) { + string line; + while ((line = r.ReadLine()) != null) { + if (string.Equals(line, shortFileName, StringComparison.InvariantCultureIgnoreCase)) { + status = "Ignored"; + break; } } } } - } catch (SvnClientException ex) { - LoggingService.Warn("Error getting status of " + fileName, ex); - status = "Unversioned"; } - LoggingService.Debug("Status of " + fileName + " is " + status); - lastTestFileName = fileName; - lastTestStatus = status; - } + }*/ + //LoggingService.Debug("Status of " + fileName + " is " + status); return Array.IndexOf(allowedStatus, status) >= 0; } } diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClient.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClient.cs deleted file mode 100644 index 0c3df9086c..0000000000 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClient.cs +++ /dev/null @@ -1,282 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Threading; -using System.Windows.Forms; - -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.Svn.Gui; -using NSvn.Core; - -namespace ICSharpCode.Svn -{ - /// - /// Description of SvnClient. - /// - public class SvnClient - { - public static SvnClient Instance = new SvnClient(); - - Client client; - string logMessage = String.Empty; - - - MessageViewCategory svnCategory; - - public MessageViewCategory SvnCategory { - get { - if (svnCategory == null) { - svnCategory = new MessageViewCategory("Subversion", "Subversion"); - CompilerMessageView compilerMessageView = (CompilerMessageView)WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).PadContent; - compilerMessageView.AddCategory(svnCategory); - } - return svnCategory; - } - } - - public NSvn.Core.Client Client { - get { - return client; - } - } - - public string LogMessage { - get { - return logMessage; - } - set { - logMessage = value; - } - } - - string GetKindString(NodeKind kind) - { - switch (kind) { - case NodeKind.Directory: - return "directory "; - case NodeKind.File: - return "file "; - } - return null; - } - - public static string GetActionString(ChangedPathAction action) - { - switch (action) { - case ChangedPathAction.Add: - return GetActionString(NotifyAction.CommitAdded); - case ChangedPathAction.Delete: - return GetActionString(NotifyAction.CommitDeleted); - case ChangedPathAction.Modify: - return GetActionString(NotifyAction.CommitModified); - case ChangedPathAction.Replace: - return GetActionString(NotifyAction.CommitReplaced); - default: - return "unknown"; - } - } - - public static string GetActionString(NotifyAction action) - { - switch (action) { - case NotifyAction.Add: - case NotifyAction.UpdateAdd: - case NotifyAction.CommitAdded: - return "added"; - case NotifyAction.Copy: - return "copied"; - case NotifyAction.Delete: - case NotifyAction.UpdateDelete: - case NotifyAction.CommitDeleted: - return "deleted"; - case NotifyAction.Restore: - return "restored"; - case NotifyAction.Revert: - return "reverted"; - case NotifyAction.FailedRevert: - return "revert failed"; - case NotifyAction.Resolved: - return "resolved"; - case NotifyAction.Skip: - return "skipped"; - case NotifyAction.UpdateUpdate: - return "updated"; - case NotifyAction.CommitPostfixTxDelta: - case NotifyAction.UpdateCompleted: - return ""; - case NotifyAction.UpdateExternal: - return "updated external"; - case NotifyAction.CommitModified: - return "modified"; - case NotifyAction.CommitReplaced: - return "replaced"; - default: - return "unknown"; - } - } - - void ReceiveNotification(object sender, NotificationEventArgs e) - { - if (e.Action == NotifyAction.UpdateCompleted) { - SvnCategory.AppendText(Environment.NewLine + "Updated " + e.Path + " to revision " + e.RevisionNumber + "."); - return; - } - if (e.Action == NotifyAction.CommitPostfixTxDelta) { - SvnCategory.AppendText("."); - return; - } - - string kind = GetKindString(e.NodeKind); - string action = GetActionString(e.Action); - SvnCategory.AppendText(Environment.NewLine + kind + action + " : " + e.Path); - } - - void SetLogMessage(object sender, LogMessageEventArgs e) - { - if (e.Message == null) { - e.Message = logMessage; - } - } - - void WriteMid(string str) - { - const int max = 40; - string filler = new String('-', max - str.Length / 2); - SvnCategory.AppendText(Environment.NewLine + filler + " " + str + " " + filler); - if (str.Length % 2 == 0) { - SvnCategory.AppendText("-"); - } - } - - class ThreadStartWrapper - { - ThreadStart innerDelegate; - - public ThreadStartWrapper(ThreadStart innerDelegate) - { - this.innerDelegate = innerDelegate; - } - - public void Start() - { - try { - innerDelegate(); - } catch (ThreadAbortException) { - // don't show error message, silently cancel thread - } catch (Exception e) { - SvnClient.Instance.OperationDone(); - - MessageService.ShowError(e); - } finally { - SvnClient.Instance.OperationDone(); - } - } - } - - InOperationDialog inOperationForm; - bool done = false; - public void OperationStart(string operationName, ThreadStart threadStart) - { - done = false; - WriteMid(operationName); - - Thread thread = new Thread(new ThreadStart(new ThreadStartWrapper(threadStart).Start)); - thread.Name = "SvnOperation"; - thread.IsBackground = true; - inOperationForm = new InOperationDialog(operationName, thread); - inOperationForm.Owner = WorkbenchSingleton.MainForm; - inOperationForm.Show(); - thread.Start(); - } - - void OperationDone() - { - if (done) { - return; - } - WorkbenchSingleton.SafeThreadCall(WriteMid, "Done"); - try { - if (inOperationForm != null) { - inOperationForm.Operation = null; - WorkbenchSingleton.SafeThreadCall(inOperationForm.Close); - inOperationForm = null; - } - } catch (Exception e) { - MessageService.ShowError(e); - } finally { - done = true; - } - } - - public void WaitForOperationEnd() - { - while (!done) { - Application.DoEvents(); - } - } - - SvnClient() - { - LoggingService.Info("SVN: SvnClient initialized"); - client = new Client(); - client.LogMessage += new LogMessageDelegate(SetLogMessage); - client.Notification += new NotificationDelegate(ReceiveNotification); - - client.AuthBaton.Add(AuthenticationProvider.GetUsernameProvider()); - client.AuthBaton.Add(AuthenticationProvider.GetSimpleProvider()); - client.AuthBaton.Add(AuthenticationProvider.GetSimplePromptProvider(new SimplePromptDelegate(this.PasswordPrompt), 3)); - client.AuthBaton.Add(AuthenticationProvider.GetSslServerTrustFileProvider()); - client.AuthBaton.Add(AuthenticationProvider.GetSslServerTrustPromptProvider(new SslServerTrustPromptDelegate(this.SslServerTrustPrompt))); - client.AuthBaton.Add(AuthenticationProvider.GetSslClientCertPasswordFileProvider()); - client.AuthBaton.Add(AuthenticationProvider.GetSslClientCertPasswordPromptProvider(new SslClientCertPasswordPromptDelegate(this.ClientCertificatePasswordPrompt), 3)); - client.AuthBaton.Add(AuthenticationProvider.GetSslClientCertFileProvider()); - client.AuthBaton.Add(AuthenticationProvider.GetSslClientCertPromptProvider(new SslClientCertPromptDelegate(this.ClientCertificatePrompt), 3)); - } - - SimpleCredential PasswordPrompt(string realm, string userName, bool maySave) - { - using (LoginDialog loginDialog = new LoginDialog(realm, userName, maySave)) { - if (WorkbenchSingleton.SafeThreadFunction(loginDialog.ShowDialog, WorkbenchSingleton.MainForm) == DialogResult.OK) { - return loginDialog.Credential; - } - } - return null; - } - - SslServerTrustCredential SslServerTrustPrompt(string realm, SslFailures failures, SslServerCertificateInfo info, bool maySave) - { - using (SslServerTrustDialog sslServerTrustDialog = new SslServerTrustDialog(info, failures, maySave)) { - if (WorkbenchSingleton.SafeThreadFunction(sslServerTrustDialog.ShowDialog, WorkbenchSingleton.MainForm) == DialogResult.OK) { - return sslServerTrustDialog.Credential; - } - } - return null; - } - - SslClientCertificatePasswordCredential ClientCertificatePasswordPrompt(string realm, bool maySave) - { - using (ClientCertPassphraseDialog clientCertPassphraseDialog = new ClientCertPassphraseDialog(realm, maySave)) { - if (WorkbenchSingleton.SafeThreadFunction(clientCertPassphraseDialog.ShowDialog, WorkbenchSingleton.MainForm) == DialogResult.OK) { - return clientCertPassphraseDialog.Credential; - } - } - return null; - } - - SslClientCertificateCredential ClientCertificatePrompt(string realm, bool maySave) - { - using (ClientCertDialog clientCertDialog = new ClientCertDialog(realm, maySave)) { - if (WorkbenchSingleton.SafeThreadFunction(clientCertDialog.ShowDialog, WorkbenchSingleton.MainForm) == DialogResult.OK) { - return clientCertDialog.Credential; - } - } - return null; - } - } -} diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClientWrapper.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClientWrapper.cs new file mode 100644 index 0000000000..6dd535e90c --- /dev/null +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClientWrapper.cs @@ -0,0 +1,748 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Windows.Forms; +using System.Text; +using System.IO; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.Svn.Gui; +using PumaCode.SvnDotNet.SubversionSharp; +using PumaCode.SvnDotNet.AprSharp; +using System.Runtime.Serialization; + +namespace ICSharpCode.Svn +{ + using Svn = PumaCode.SvnDotNet.SubversionSharp.Svn; + + /// + /// A wrapper around the subversion library. + /// + public sealed class SvnClientWrapper : IDisposable + { + #region status->string conversion + static string GetKindString(Svn.NodeKind kind) + { + switch (kind) { + case Svn.NodeKind.Dir: + return "directory "; + case Svn.NodeKind.File: + return "file "; + } + return null; + } + + public static string GetActionString(char action) + { + switch (action) { + case 'A': + return GetActionString(SvnWcNotify.Actions.CommitAdded); + case 'D': + return GetActionString(SvnWcNotify.Actions.CommitDeleted); + case 'M': + return GetActionString(SvnWcNotify.Actions.CommitModified); + case 'R': + return GetActionString(SvnWcNotify.Actions.CommitReplaced); + default: + return "unknown"; + } + } + + public static string GetActionString(SvnWcNotify.Actions action) + { + switch (action) { + case SvnWcNotify.Actions.Add: + case SvnWcNotify.Actions.UpdateAdd: + case SvnWcNotify.Actions.CommitAdded: + return "added"; + case SvnWcNotify.Actions.Copy: + return "copied"; + case SvnWcNotify.Actions.Delete: + case SvnWcNotify.Actions.UpdateDelete: + case SvnWcNotify.Actions.CommitDeleted: + return "deleted"; + case SvnWcNotify.Actions.Restore: + return "restored"; + case SvnWcNotify.Actions.Revert: + return "reverted"; + case SvnWcNotify.Actions.FailedRevert: + return "revert failed"; + case SvnWcNotify.Actions.Resolved: + return "resolved"; + case SvnWcNotify.Actions.Skip: + return "skipped"; + case SvnWcNotify.Actions.UpdateUpdate: + return "updated"; + case SvnWcNotify.Actions.UpdateCompleted: + return ""; + case SvnWcNotify.Actions.UpdateExternal: + return "updated external"; + case SvnWcNotify.Actions.CommitModified: + return "modified"; + case SvnWcNotify.Actions.CommitReplaced: + return "replaced"; + default: + return "unknown"; + } + } + #endregion + + #region stuff that does not belong here + /* + void ReceiveNotification(object sender, SvnWcNotify e) + { + if (e.Action == NotifyAction.UpdateCompleted) { + SvnCategory.AppendText(Environment.NewLine + "Updated " + e.Path.ToString() + " to revision " + e.Revision + "."); + return; + } + + string kind = GetKindString(e.NodeKind); + string action = GetActionString(e.Action); + SvnCategory.AppendText(Environment.NewLine + kind + action + " : " + e.Path); + } + + void WriteMid(string str) + { + const int max = 40; + string filler = new String('-', max - str.Length / 2); + SvnCategory.AppendText(Environment.NewLine + filler + " " + str + " " + filler); + if (str.Length % 2 == 0) { + SvnCategory.AppendText("-"); + } + } + */ + + /* + class ThreadStartWrapper + { + ThreadStart innerDelegate; + + public ThreadStartWrapper(ThreadStart innerDelegate) + { + this.innerDelegate = innerDelegate; + } + + public void Start() + { + try { + innerDelegate(); + } catch (ThreadAbortException) { + // don't show error message, silently cancel thread + } catch (Exception e) { + SvnClient.Instance.OperationDone(); + + MessageService.ShowError(e); + } finally { + SvnClient.Instance.OperationDone(); + } + } + } + + InOperationDialog inOperationForm; + bool done = false; + public void OperationStart(string operationName, ThreadStart threadStart) + { + done = false; + WriteMid(operationName); + + Thread thread = new Thread(new ThreadStart(new ThreadStartWrapper(threadStart).Start)); + thread.Name = "SvnOperation"; + thread.IsBackground = true; + inOperationForm = new InOperationDialog(operationName, thread); + inOperationForm.Owner = WorkbenchSingleton.MainForm; + inOperationForm.Show(); + thread.Start(); + } + + void OperationDone() + { + if (done) { + return; + } + WorkbenchSingleton.SafeThreadCall(WriteMid, "Done"); + try { + if (inOperationForm != null) { + inOperationForm.Operation = null; + WorkbenchSingleton.SafeThreadCall(inOperationForm.Close); + inOperationForm = null; + } + } catch (Exception e) { + MessageService.ShowError(e); + } finally { + done = true; + } + } + + public void WaitForOperationEnd() + { + while (!done) { + Application.DoEvents(); + } + } + */ + #endregion + + #region AprPoolHandle + sealed class AprPoolHandle : IDisposable + { + AprPool pool; + + public AprPool Pool { + get { return pool; } + } + + public AprPoolHandle() + { + pool = Svn.PoolCreate(); + } + + public void Dispose() + { + if (!pool.IsNull) { + pool.Destroy(); + } + GC.SuppressFinalize(this); + } + + ~AprPoolHandle() + { + if (!pool.IsNull) { + pool.Destroy(); + } + } + } + #endregion + + AprPoolHandle memoryPool; + SvnClient client; + Dictionary statusCache = new Dictionary(); + + public SvnClientWrapper() + { + Debug("SVN: Create SvnClient instance"); + + memoryPool = new AprPoolHandle(); + client = new SvnClient(memoryPool.Pool); + //client.LogMessage += new LogMessageDelegate(SetLogMessage); + //client.Notification += new NotificationDelegate(ReceiveNotification); + } + + public void Dispose() + { + if (memoryPool != null) { + Debug("SVN: Dispose SvnClient"); + memoryPool.Dispose(); + memoryPool = null; + } + client = null; + statusCache = null; + } + + #region Authorization + bool authorizationEnabled; + bool allowInteractiveAuthorization; + + public bool AllowInteractiveAuthorization { + get { + return allowInteractiveAuthorization; + } + set { + CheckNotDisposed(); + if (allowInteractiveAuthorization != value) { + if (authorizationEnabled) + throw new InvalidOperationException("Cannot change AllowInteractiveAuthorization after an operation was done."); + allowInteractiveAuthorization = value; + } + } + } + + void OpenAuth() + { + if (authorizationEnabled) + return; + authorizationEnabled = true; + + const int retryLimit = 3; + client.AddUsernameProvider(); + client.AddSimpleProvider(); + if (allowInteractiveAuthorization) { + client.AddPromptProvider(PasswordPrompt, IntPtr.Zero, retryLimit); + } + client.AddSslServerTrustFileProvider(); + if (allowInteractiveAuthorization) { + client.AddPromptProvider(SslServerTrustPrompt, IntPtr.Zero); + } + client.AddSslClientCertPwFileProvider(); + if (allowInteractiveAuthorization) { + client.AddPromptProvider(ClientCertificatePasswordPrompt, IntPtr.Zero, retryLimit); + } + client.AddSslClientCertFileProvider(); + if (allowInteractiveAuthorization) { + client.AddPromptProvider(ClientCertificatePrompt, IntPtr.Zero, retryLimit); + } + client.OpenAuth(); + } + + SvnError PasswordPrompt(out SvnAuthCredSimple cred, IntPtr baton, AprString realm, AprString username, bool maySave, AprPool pool) + { + cred = IntPtr.Zero; + LoggingService.Debug("PasswordPrompt"); + try { + using (LoginDialog loginDialog = new LoginDialog(realm.Value, username.Value, maySave)) { + if (WorkbenchSingleton.SafeThreadFunction(loginDialog.ShowDialog, WorkbenchSingleton.MainForm) == DialogResult.OK) { + cred = loginDialog.CreateCredential(pool); + } + } + } catch (Exception ex) { + MessageService.ShowError(ex); + } + return SvnError.NoError; + } + + SvnError SslServerTrustPrompt(out SvnAuthCredSslServerTrust cred, IntPtr baton, AprString realm, SvnAuthCredSslServerTrust.CertFailures failures, SvnAuthSslServerCertInfo certInfo, bool maySave, IntPtr pool) + { + cred = IntPtr.Zero; + LoggingService.Debug("SslServerTrustPrompt"); + try { + using (SslServerTrustDialog sslServerTrustDialog = new SslServerTrustDialog(certInfo, failures, maySave)) { + if (WorkbenchSingleton.SafeThreadFunction(sslServerTrustDialog.ShowDialog, WorkbenchSingleton.MainForm) == DialogResult.OK) { + cred = sslServerTrustDialog.CreateCredential(pool); + } + } + } catch (Exception ex) { + MessageService.ShowError(ex); + } + return SvnError.NoError; + } + + SvnError ClientCertificatePasswordPrompt(out SvnAuthCredSslClientCertPw cred, IntPtr baton, AprString realm, bool maySave, IntPtr pool) + { + cred = IntPtr.Zero; + LoggingService.Debug("SslServerTrustPrompt"); + try { + using (ClientCertPassphraseDialog clientCertPassphraseDialog = new ClientCertPassphraseDialog(realm.Value, maySave)) { + if (WorkbenchSingleton.SafeThreadFunction(clientCertPassphraseDialog.ShowDialog, WorkbenchSingleton.MainForm) == DialogResult.OK) { + cred = clientCertPassphraseDialog.CreateCredential(pool); + } + } + } catch (Exception ex) { + MessageService.ShowError(ex); + } + return SvnError.NoError; + } + + SvnError ClientCertificatePrompt(out SvnAuthCredSslClientCert cred, IntPtr baton, AprString realm, bool maySave, IntPtr pool) + { + cred = IntPtr.Zero; + LoggingService.Debug("SslServerTrustPrompt"); + try { + using (ClientCertDialog clientCertDialog = new ClientCertDialog(realm.Value, maySave)) { + if (WorkbenchSingleton.SafeThreadFunction(clientCertDialog.ShowDialog, WorkbenchSingleton.MainForm) == DialogResult.OK) { + cred = clientCertDialog.CreateCredential(pool); + } + } + } catch (Exception ex) { + MessageService.ShowError(ex); + } + return SvnError.NoError; + } + #endregion + + [System.Diagnostics.ConditionalAttribute("DEBUG")] + void Debug(string text) + { + LoggingService.Debug(text); + } + + void CheckNotDisposed() + { + if (client == null) + throw new ObjectDisposedException("SvnClientWrapper"); + } + + void BeforeOperation() + { + // before any subversion operation, ensure the object is not disposed + // and register authorization if necessary + CheckNotDisposed(); + OpenAuth(); + } + + void AfterOperation() + { + // after any subversion operation, clear the memory pool + client.Clear(); + } + + public void ClearStatusCache() + { + CheckNotDisposed(); + statusCache.Clear(); + } + + public Status SingleStatus(string filename) + { + Debug("SVN: SingleStatus(" + filename + ")"); + BeforeOperation(); + try { + filename = FileUtility.NormalizePath(filename); + Status result; + if (statusCache.TryGetValue(filename, out result)) { + Debug("SVN: SingleStatus retrieved from cache " + result.TextStatus); + return result; + } + client.Status2( + filename, Svn.Revision.Working, + delegate (IntPtr baton, SvnPath path, SvnWcStatus2 status) { + string dir = path.Value; + Debug("SVN: SingleStatus.callback(" + dir + "," + status.TextStatus + ")"); + Status s = new Status { + Copied = status.Copied, + TextStatus = ToStatusKind(status.TextStatus) + }; + statusCache[dir] = s; + if (StringComparer.InvariantCultureIgnoreCase.Equals(filename, dir)) { + result = s; + } + }, + IntPtr.Zero, + false, true, false, false, false + ); + return result; + } catch (SvnException ex) { + throw new SvnClientException(ex); + } finally { + AfterOperation(); + } + } + + public void Add(string filename, Recurse recurse) + { + Debug("SVN: Add(" + filename + ", " + recurse + ")"); + BeforeOperation(); + try { + client.Add3(filename, recurse == Recurse.Full, false, false); + } catch (SvnException ex) { + throw new SvnClientException(ex); + } finally { + AfterOperation(); + } + } + + public string GetPropertyValue(string fileName, string propertyName) + { + Debug("SVN: GetPropertyValue(" + fileName + ", " + propertyName + ")"); + BeforeOperation(); + try { + AprHash hash = client.PropGet2(propertyName, fileName, + Svn.Revision.Working, Svn.Revision.Working, + false); + foreach (AprHashEntry entry in hash) { + // entry.ValueAsString treats the value as const char*, but it is a svn_string_t* + SvnString value = entry.Value; + Debug("SVN: GetPropertyValue hash entry: (" + entry.KeyAsString + ", " + value + ")"); + return value.Data.Value; + } + Debug("SVN: GetPropertyValue did not find any entries"); + return null; + } catch (SvnException ex) { + throw new SvnClientException(ex); + } finally { + AfterOperation(); + } + } + + public void SetPropertyValue(string fileName, string propertyName, string newPropertyValue) + { + Debug("SVN: SetPropertyValue(" + fileName + ", " + propertyName + ", " + newPropertyValue + ")"); + BeforeOperation(); + try { + SvnString npv; + if (newPropertyValue != null) + npv = new SvnString(newPropertyValue, client.Pool); + else + npv = IntPtr.Zero; + client.PropSet2(propertyName, npv, fileName, false, false); + } catch (SvnException ex) { + throw new SvnClientException(ex); + } finally { + AfterOperation(); + } + } + + SvnPath[] ToSvnPaths(string[] files) + { + SvnPath[] paths = new SvnPath[files.Length]; + for (int i = 0; i < files.Length; i++) { + paths[i] = new SvnPath(files[i], client.Pool); + } + return paths; + } + + public void Delete(string[] files, bool force) + { + Debug("SVN: Delete(" + string.Join(",", files) + ", " + force + ")"); + BeforeOperation(); + try { + client.Delete2(ToSvnPaths(files), force); + } catch (SvnException ex) { + throw new SvnClientException(ex); + } finally { + AfterOperation(); + } + } + + public void Revert(string[] files, Recurse recurse) + { + Debug("SVN: Revert(" + string.Join(",", files) + ", " + recurse + ")"); + BeforeOperation(); + try { + client.Revert(ToSvnPaths(files), recurse == Recurse.Full); + } catch (SvnException ex) { + throw new SvnClientException(ex); + } finally { + AfterOperation(); + } + } + + public void Move(string from, string to, bool force) + { + Debug("SVN: Move(" + from + ", " + to + ", " + force + ")"); + BeforeOperation(); + try { + client.Move3(from, to, force); + } catch (SvnException ex) { + throw new SvnClientException(ex); + } finally { + AfterOperation(); + } + } + + public void AddToIgnoreList(string directory, params string[] filesToIgnore) + { + Debug("SVN: AddToIgnoreList(" + directory + ", " + string.Join(",", filesToIgnore) + ")"); + string propertyValue = GetPropertyValue(directory, "svn:ignore"); + StringBuilder b = new StringBuilder(); + if (propertyValue != null) { + using (StringReader r = new StringReader(propertyValue)) { + string line; + while ((line = r.ReadLine()) != null) { + if (line.Length > 0) { + b.AppendLine(line); + } + } + } + } + foreach (string file in filesToIgnore) + b.AppendLine(file); + SetPropertyValue(directory, "svn:ignore", b.ToString()); + } + + public void Log(string[] paths, Revision start, Revision end, + int limit, bool discoverChangePaths, bool strictNodeHistory, + Action logMessageReceiver) + { + Debug("SVN: Log({" + string.Join(",", paths) + "}, " + start + ", " + end + + ", " + limit + ", " + discoverChangePaths + ", " + strictNodeHistory + ")"); + BeforeOperation(); + try { + client.Log2( + ToSvnPaths(paths), + start, end, limit, discoverChangePaths, strictNodeHistory, + delegate (IntPtr baton, AprHash changed_paths, int revision, AprString author, AprString date, AprString message, AprPool pool) { + Debug("SVN: Log: Got revision " + revision); + DateTime dateTime = DateTime.MinValue; + DateTime.TryParse(date.Value, out dateTime); + LogMessage msg = new LogMessage() { + Revision = revision, + Author = author.Value, + Date = dateTime, + Message = message.Value + }; + if (discoverChangePaths) { + msg.ChangedPaths = new List(); + foreach (AprHashEntry entry in changed_paths) { + SvnLogChangedPath changedPath = entry.Value; + msg.ChangedPaths.Add(new ChangedPath { + Path = entry.KeyAsString, + CopyFromPath = changedPath.CopyFromPath.Value, + CopyFromRevision = changedPath.CopyFromRev, + Action = changedPath.Action + }); + } + } + logMessageReceiver(msg); + return SvnError.NoError; + }, + IntPtr.Zero + ); + Debug("SVN: Log finished"); + } catch (SvnException ex) { + throw new SvnClientException(ex); + } finally { + AfterOperation(); + } + } + + static StatusKind ToStatusKind(SvnWcStatus.Kind kind) + { + switch (kind) { + case SvnWcStatus.Kind.Added: + return StatusKind.Added; + case SvnWcStatus.Kind.Conflicted: + return StatusKind.Conflicted; + case SvnWcStatus.Kind.Deleted: + return StatusKind.Deleted; + case SvnWcStatus.Kind.External: + return StatusKind.External; + case SvnWcStatus.Kind.Ignored: + return StatusKind.Ignored; + case SvnWcStatus.Kind.Incomplete: + return StatusKind.Incomplete; + case SvnWcStatus.Kind.Merged: + return StatusKind.Merged; + case SvnWcStatus.Kind.Missing: + return StatusKind.Missing; + case SvnWcStatus.Kind.Modified: + return StatusKind.Modified; + case SvnWcStatus.Kind.Normal: + return StatusKind.Normal; + case SvnWcStatus.Kind.Obstructed: + return StatusKind.Obstructed; + case SvnWcStatus.Kind.Replaced: + return StatusKind.Replaced; + case SvnWcStatus.Kind.Unversioned: + return StatusKind.Unversioned; + default: + return StatusKind.None; + } + } + } + + public class LogMessage + { + public int Revision; + public string Author; + public DateTime Date; + public string Message; + + public List ChangedPaths; + } + + public class ChangedPath + { + public string Path; + public string CopyFromPath; + public int CopyFromRevision; + /// + /// change action ('A','D','R' or 'M') + /// + public char Action; + } + + public class Revision + { + SvnRevision revision; + + public static readonly Revision Base = new SvnRevision(Svn.Revision.Base); + public static readonly Revision Committed = new SvnRevision(Svn.Revision.Committed); + public static readonly Revision Head = new SvnRevision(Svn.Revision.Head); + public static readonly Revision Working = new SvnRevision(Svn.Revision.Working); + public static readonly Revision Unspecified = new SvnRevision(Svn.Revision.Unspecified); + + public static Revision FromNumber(int number) + { + return new SvnRevision(number); + } + + public static implicit operator SvnRevision(Revision r) + { + return r.revision; + } + + public static implicit operator Revision(SvnRevision r) + { + return new Revision() { revision = r }; + } + + public override string ToString() + { + switch (revision.Kind) { + case Svn.Revision.Base: + return "base"; + case Svn.Revision.Committed: + return "committed"; + case Svn.Revision.Date: + return AprTime.ToDateTime(revision.Date).ToString(); + case Svn.Revision.Head: + return "head"; + case Svn.Revision.Number: + return revision.Number.ToString(); + case Svn.Revision.Previous: + return "previous"; + case Svn.Revision.Unspecified: + return "unspecified"; + case Svn.Revision.Working: + return "working"; + default: + return "unknown"; + } + } + } + + public class Status + { + public bool Copied { get; set; } + public StatusKind TextStatus { get; set; } + } + + public enum Recurse + { + None, + Full + } + + public class SvnClientException : Exception + { + public readonly int ErrorCode; + + internal SvnClientException(SvnException ex) : base(ex.Message, ex) + { + LoggingService.Debug(ex); + ErrorCode = ex.AprErr; + } + + /// + /// Gets the inner exception of the exception being wrapped. + /// + public Exception GetInnerException() + { + return InnerException.InnerException; + } + } + + public enum StatusKind + { + None, + Added, + Conflicted, + Deleted, + Modified, + Replaced, + External, + Ignored, + Incomplete, + Merged, + Missing, + Obstructed, + Normal, + Unversioned + } +} diff --git a/src/AddIns/Misc/SubversionAddIn/Project/SubversionAddIn.csproj b/src/AddIns/Misc/SubversionAddIn/Project/SubversionAddIn.csproj index 31c6f8ca5a..79d1935ff3 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/SubversionAddIn.csproj +++ b/src/AddIns/Misc/SubversionAddIn/Project/SubversionAddIn.csproj @@ -1,4 +1,4 @@ - + Library ICSharpCode.Svn @@ -9,6 +9,7 @@ 8.0.50215 2.0 Always + v2.0 True @@ -24,25 +25,52 @@ TRACE + + ..\RequiredLibraries\AprSharp.dll + + + ..\RequiredLibraries\SubversionSharp.dll + - - ..\RequiredLibraries\NSvn.Core.dll - False - True - - - ..\RequiredLibraries\NSvn.Common.dll - False - True - - + + intl3_svn.dll + PreserveNewest + + + libapr.dll + PreserveNewest + + + libapriconv.dll + PreserveNewest + + + libaprutil.dll + PreserveNewest + + + libdb44.dll + PreserveNewest + + + libeay32.dll + PreserveNewest + + + ssleay32.dll + PreserveNewest + + + svn_client-1.dll + PreserveNewest + Always @@ -50,7 +78,6 @@ InfoPanel.cs - Form @@ -97,6 +124,7 @@ DiffPanel.cs + DiffPanel.cs @@ -115,35 +143,11 @@ ICSharpCode.Core False - - msvcp70.dll - PreserveNewest - - - msvcr70.dll - PreserveNewest - - - LIBAPR.DLL - PreserveNewest - - - LibAprIconv.Dll - PreserveNewest - - - LibAprUtil.Dll - PreserveNewest - {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} ICSharpCode.SharpDevelop.Dom False - - LibDB44.dll - PreserveNewest - {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} ICSharpCode.TextEditor diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs index efea852d50..1ac7c69aa2 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs @@ -208,6 +208,7 @@ namespace ICSharpCode.SharpDevelop.Sda Project.ProjectService.LoadSolutionOrProject(fileName); } + [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] public bool IsSolutionOrProject(string fileName) { return Project.ProjectService.HasProjectLoader(fileName); @@ -232,6 +233,7 @@ namespace ICSharpCode.SharpDevelop.Sda return WorkbenchSingleton.MainForm.IsDisposed; } + [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] public void KillWorkbench() { System.Windows.Forms.Application.Exit(); diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/ExceptionBox.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/ExceptionBox.cs index c14d6eb1b3..896442c97f 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/ExceptionBox.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/ExceptionBox.cs @@ -83,14 +83,14 @@ namespace ICSharpCode.SharpDevelop.Sda /// /// Creates a new ExceptionBox instance. /// - /// The exception to display + /// The exception to display /// An additional message to display /// If is true, the /// continue button is not available. [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - public ExceptionBox(Exception e, string message, bool mustTerminate) + public ExceptionBox(Exception exception, string message, bool mustTerminate) { - this.exceptionThrown = e; + this.exceptionThrown = exception; this.message = message; InitializeComponent(); if (mustTerminate) { diff --git a/src/Setup/Files.wxs b/src/Setup/Files.wxs index dc38dbf2dd..d834f4af2b 100644 --- a/src/Setup/Files.wxs +++ b/src/Setup/Files.wxs @@ -1037,7 +1037,7 @@ - + @@ -1048,6 +1048,7 @@ + @@ -1383,36 +1384,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + diff --git a/src/Setup/Setup.wxs b/src/Setup/Setup.wxs index e3132fb7e9..d3d729358d 100644 --- a/src/Setup/Setup.wxs +++ b/src/Setup/Setup.wxs @@ -354,15 +354,6 @@ --> - - - - - - - - - diff --git a/src/Tools/UpdateAssemblyInfo/Main.cs b/src/Tools/UpdateAssemblyInfo/Main.cs index 733bd55a70..3e149a7a9b 100644 --- a/src/Tools/UpdateAssemblyInfo/Main.cs +++ b/src/Tools/UpdateAssemblyInfo/Main.cs @@ -11,6 +11,9 @@ using System.Reflection; using System.Text; using System.Text.RegularExpressions; using System.Collections.Specialized; +using System.Runtime.CompilerServices; +using PumaCode.SvnDotNet.AprSharp; +using PumaCode.SvnDotNet.SubversionSharp; namespace UpdateAssemblyInfo { @@ -161,33 +164,25 @@ namespace UpdateAssemblyInfo } static void RetrieveRevisionNumber() { - // we use NSvn to be independent from the installed subversion client - // NSvn is a quite big library (>1 MB). - // We don't want to have it twice in the repository, so we must use the version in the - // subversion addin directory without copying it to the UpdateAssemblyInfo directory. - // That means we have to use reflection on the library. + string oldWorkingDir = Environment.CurrentDirectory; try { - // Set working directory so msvcp70.dll and msvcr70.dll can be found + // Change working dir so that the subversion libraries can be found Environment.CurrentDirectory = Path.Combine(oldWorkingDir, "AddIns\\Misc\\SubversionAddIn\\RequiredLibraries"); - Assembly asm = Assembly.LoadFrom(Path.Combine(Environment.CurrentDirectory, "NSvn.Core.dll")); - Type clientType = asm.GetType("NSvn.Core.Client"); - object clientInstance = Activator.CreateInstance(clientType); - object statusInstance = clientType.InvokeMember("SingleStatus", - BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, - null, clientInstance, - new object[] { oldWorkingDir }); - Type statusType = statusInstance.GetType(); - object entryInstance = statusType.InvokeMember("Entry", - BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.Public, - null, statusInstance, new object[0]); - Type entryType = entryInstance.GetType(); - int revision = (int)entryType.InvokeMember("Revision", - BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.Public, - null, entryInstance, new object[0]); - revisionNumber = revision.ToString(); + + SvnClient client = new SvnClient(); + try { + client.Info(oldWorkingDir, new SvnRevision(Svn.Revision.Unspecified), new SvnRevision(Svn.Revision.Unspecified), + delegate(IntPtr baton, SvnPath path, SvnInfo info, AprPool pool) { + revisionNumber = info.Rev.ToString(); + return SvnError.NoError; + }, + IntPtr.Zero, false); + } finally { + client.Clear(); + } } catch (Exception e) { - Console.WriteLine("Reading revision number with NSvn failed: " + e.ToString()); + Console.WriteLine("Reading revision number with Svn.Net failed: " + e.ToString()); } finally { Environment.CurrentDirectory = oldWorkingDir; } diff --git a/src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.csproj b/src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.csproj index 2db550a1bd..7d9e1f6118 100644 --- a/src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.csproj +++ b/src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.csproj @@ -1,4 +1,4 @@ - + Exe UpdateAssemblyInfo @@ -19,6 +19,8 @@ false false 1607 + v2.0 + app.manifest bin\Debug\ @@ -31,18 +33,22 @@ TRACE + + ..\..\AddIns\Misc\SubversionAddIn\RequiredLibraries\AprSharp.dll + True + + + ..\..\AddIns\Misc\SubversionAddIn\RequiredLibraries\SubversionSharp.dll + True + + - - - Always - - \ No newline at end of file diff --git a/src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.exe.manifest b/src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.exe.manifest deleted file mode 100644 index 6bbf3ea0b3..0000000000 --- a/src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.exe.manifest +++ /dev/null @@ -1,15 +0,0 @@ - - - - Updates the assembly version in GlobalAssemblyInfo.cs - - - - - - - - - - - diff --git a/src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.sln b/src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.sln index 2f594bcdca..08414105f9 100644 --- a/src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.sln +++ b/src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.sln @@ -1,5 +1,7 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# SharpDevelop 2.0.0.1128 + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +# SharpDevelop 3.0.0.2967 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateAssemblyInfo", "UpdateAssemblyInfo.csproj", "{605C8CDB-F0AD-4A21-9F4A-959B8DECB0F3}" EndProject Global diff --git a/src/Tools/UpdateAssemblyInfo/app.manifest b/src/Tools/UpdateAssemblyInfo/app.manifest new file mode 100644 index 0000000000..81400d66f5 --- /dev/null +++ b/src/Tools/UpdateAssemblyInfo/app.manifest @@ -0,0 +1,21 @@ + + + + + + + + + + +