Browse Source

Replace NSvn with Svn.Net.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2971 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
f80658d15f
  1. 278
      src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs
  2. 24
      src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/ProjectBrowserCommands.cs
  3. 18
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/ClientCertDialog.cs
  4. 16
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/ClientCertPassphraseDialog.cs
  5. 16
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/LoginDialog.cs
  6. 47
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/SslServerTrustDialog.cs
  7. 24
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/DiffPanel.cs
  8. 38
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs
  9. 36
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs
  10. 57
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/InfoPanel.cs
  11. 86
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs
  12. 16
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/SvnGuiWrapper.cs
  13. 52
      src/AddIns/Misc/SubversionAddIn/Project/Src/SubversionStateCondition.cs
  14. 282
      src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClient.cs
  15. 748
      src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClientWrapper.cs
  16. 78
      src/AddIns/Misc/SubversionAddIn/Project/SubversionAddIn.csproj
  17. 2
      src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs
  18. 6
      src/Main/ICSharpCode.SharpDevelop.Sda/Src/ExceptionBox.cs
  19. 40
      src/Setup/Files.wxs
  20. 9
      src/Setup/Setup.wxs
  21. 41
      src/Tools/UpdateAssemblyInfo/Main.cs
  22. 18
      src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.csproj
  23. 15
      src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.exe.manifest
  24. 6
      src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.sln
  25. 21
      src/Tools/UpdateAssemblyInfo/app.manifest

278
src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs

@ -13,8 +13,6 @@ using System.Windows.Forms; @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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);
}
}
}
}

24
src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/ProjectBrowserCommands.cs

@ -14,8 +14,6 @@ using ICSharpCode.Core; @@ -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 @@ -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 @@ -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 @@ -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 @@ -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();
}
}
}

18
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/ClientCertDialog.cs

@ -10,7 +10,8 @@ using System.Reflection; @@ -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 @@ -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"));

16
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/ClientCertPassphraseDialog.cs

@ -10,7 +10,8 @@ using System.Reflection; @@ -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 @@ -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)

16
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/LoginDialog.cs

@ -10,7 +10,8 @@ using System.Reflection; @@ -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 @@ -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 {

47
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/AuthentificationDialogs/SslServerTrustDialog.cs

@ -11,7 +11,8 @@ using System.Reflection; @@ -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 @@ -20,10 +21,10 @@ namespace ICSharpCode.Svn.Gui
/// </summary>
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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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;
}
}
}
}

24
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/DiffPanel.cs

@ -14,8 +14,6 @@ using ICSharpCode.TextEditor.Document; @@ -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 @@ -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 @@ -127,7 +125,7 @@ namespace ICSharpCode.Svn
if (fromRevision.ToString() == toRevision.ToString()) {
output = "";
} else {
SvnClient.Instance.OperationStart("Diff", DoDiffOperation);
//SvnClient.Instance.OperationStart("Diff", DoDiffOperation);
}
}

38
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs

@ -9,7 +9,6 @@ using System; @@ -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 @@ -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 @@ -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;
}

36
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs

@ -12,7 +12,6 @@ using System.Windows.Forms; @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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);
}
}
}
}

57
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/InfoPanel.cs

@ -7,6 +7,7 @@ @@ -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; @@ -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 @@ -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 @@ -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<ChangedPath> changes = logMessage.ChangedPaths;
if (changes == null) {
changesListView.Items.Add("Loading...");
if (!isLoadingChangedPaths) {
@ -95,13 +95,12 @@ namespace ICSharpCode.Svn @@ -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 @@ -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 @@ -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;

86
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/ProjectBrowserVisitor/OverlayIconManager.cs

@ -13,8 +13,6 @@ using System.Windows.Forms; @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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);

16
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/SvnGuiWrapper.cs

@ -66,20 +66,20 @@ namespace ICSharpCode.Svn @@ -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);

52
src/AddIns/Misc/SubversionAddIn/Project/Src/SubversionStateCondition.cs

@ -10,8 +10,8 @@ using System.IO; @@ -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 @@ -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;
}
}

282
src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClient.cs

@ -1,282 +0,0 @@ @@ -1,282 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version>$Revision$</version>
// </file>
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
{
/// <summary>
/// Description of SvnClient.
/// </summary>
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<Form, DialogResult>(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<Form, DialogResult>(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<Form, DialogResult>(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<Form, DialogResult>(clientCertDialog.ShowDialog, WorkbenchSingleton.MainForm) == DialogResult.OK) {
return clientCertDialog.Credential;
}
}
return null;
}
}
}

748
src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClientWrapper.cs

@ -0,0 +1,748 @@ @@ -0,0 +1,748 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
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;
/// <summary>
/// A wrapper around the subversion library.
/// </summary>
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<string, Status> statusCache = new Dictionary<string, Status>();
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<Form, DialogResult>(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<Form, DialogResult>(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<Form, DialogResult>(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<Form, DialogResult>(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<LogMessage> 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<ChangedPath>();
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<ChangedPath> ChangedPaths;
}
public class ChangedPath
{
public string Path;
public string CopyFromPath;
public int CopyFromRevision;
/// <summary>
/// change action ('A','D','R' or 'M')
/// </summary>
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;
}
/// <summary>
/// Gets the inner exception of the exception being wrapped.
/// </summary>
public Exception GetInnerException()
{
return InnerException.InnerException;
}
}
public enum StatusKind
{
None,
Added,
Conflicted,
Deleted,
Modified,
Replaced,
External,
Ignored,
Incomplete,
Merged,
Missing,
Obstructed,
Normal,
Unversioned
}
}

78
src/AddIns/Misc/SubversionAddIn/Project/SubversionAddIn.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.Svn</RootNamespace>
@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
<ProductVersion>8.0.50215</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<RunPostBuildEvent>Always</RunPostBuildEvent>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@ -24,25 +25,52 @@ @@ -24,25 +25,52 @@
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="AprSharp">
<HintPath>..\RequiredLibraries\AprSharp.dll</HintPath>
</Reference>
<Reference Include="SubversionSharp">
<HintPath>..\RequiredLibraries\SubversionSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="NSvn.Core">
<HintPath>..\RequiredLibraries\NSvn.Core.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>True</Private>
</Reference>
<Reference Include="NSvn.Common">
<HintPath>..\RequiredLibraries\NSvn.Common.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>True</Private>
</Reference>
<Reference Include="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</ItemGroup>
<ItemGroup>
<None Include="..\RequiredLibraries\intl3_svn.dll">
<Link>intl3_svn.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RequiredLibraries\libapr.dll">
<Link>libapr.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RequiredLibraries\libapriconv.dll">
<Link>libapriconv.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RequiredLibraries\libaprutil.dll">
<Link>libaprutil.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RequiredLibraries\libdb44.dll">
<Link>libdb44.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RequiredLibraries\libeay32.dll">
<Link>libeay32.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RequiredLibraries\ssleay32.dll">
<Link>ssleay32.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\RequiredLibraries\svn_client-1.dll">
<Link>svn_client-1.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ICSharpCode.Svn.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@ -50,7 +78,6 @@ @@ -50,7 +78,6 @@
<Compile Include="Src\Gui\HistoryViewDisplayBinding\InfoPanel.Designer.cs">
<DependentUpon>InfoPanel.cs</DependentUpon>
</Compile>
<Compile Include="Src\SvnClient.cs" />
<Compile Include="Src\InOperationDialog.cs">
<SubType>Form</SubType>
</Compile>
@ -97,6 +124,7 @@ @@ -97,6 +124,7 @@
<DependentUpon>DiffPanel.cs</DependentUpon>
</Compile>
<Compile Include="Src\Gui\HistoryViewDisplayBinding\DiffPanel.cs" />
<Compile Include="Src\SvnClientWrapper.cs" />
<EmbeddedResource Include="Src\Gui\HistoryViewDisplayBinding\DiffPanel.resx">
<DependentUpon>DiffPanel.cs</DependentUpon>
</EmbeddedResource>
@ -115,35 +143,11 @@ @@ -115,35 +143,11 @@
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<Content Include="..\RequiredLibraries\msvcp70.dll">
<Link>msvcp70.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\RequiredLibraries\msvcr70.dll">
<Link>msvcr70.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\RequiredLibraries\LIBAPR.DLL">
<Link>LIBAPR.DLL</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\RequiredLibraries\LibAprIconv.Dll">
<Link>LibAprIconv.Dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\RequiredLibraries\LibAprUtil.Dll">
<Link>LibAprUtil.Dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
<Private>False</Private>
</ProjectReference>
<Content Include="..\RequiredLibraries\LibDB44.dll">
<Link>LibDB44.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<ProjectReference Include="..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project>
<Name>ICSharpCode.TextEditor</Name>

2
src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs

@ -208,6 +208,7 @@ namespace ICSharpCode.SharpDevelop.Sda @@ -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 @@ -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();

6
src/Main/ICSharpCode.SharpDevelop.Sda/Src/ExceptionBox.cs

@ -83,14 +83,14 @@ namespace ICSharpCode.SharpDevelop.Sda @@ -83,14 +83,14 @@ namespace ICSharpCode.SharpDevelop.Sda
/// <summary>
/// Creates a new ExceptionBox instance.
/// </summary>
/// <param name="e">The exception to display</param>
/// <param name="exception">The exception to display</param>
/// <param name="message">An additional message to display</param>
/// <param name="mustTerminate">If <paramref name="mustTerminate"/> is true, the
/// continue button is not available.</param>
[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) {

40
src/Setup/Files.wxs

@ -1037,7 +1037,7 @@ @@ -1037,7 +1037,7 @@
<Component Guid="2E711769-201C-4C5F-A97A-179C852B023F" Id="BooBindingFiles" DiskId="1">
<File Source="..\..\AddIns\AddIns\BackendBindings\BooBinding\Boo.Lang.CodeDom.dll" Id="Boo.Lang.CodeDom.dll" Name="Boo.Lang.CodeDom.dll" />
<File Source="..\..\AddIns\AddIns\BackendBindings\BooBinding\Boo.Lang.Compiler.dll" Id="Boo.Lang.Compiler.dll" Name="Boo.Lang.Compiler.dll" />
<File Source="..\..\AddIns\AddIns\BackendBindings\BooBinding\Boo.Lang.dll" Id="Boo.Lang.dll" />
<File Source="..\..\AddIns\AddIns\BackendBindings\BooBinding\Boo.Lang.dll" Id="Boo.Lang.dll" Name="Boo.Lang.dll" />
<File Source="..\..\AddIns\AddIns\BackendBindings\BooBinding\Boo.Lang.Parser.dll" Id="Boo.Lang.Parser.dll" Name="Boo.Lang.Parser.dll" />
<File Source="..\..\AddIns\AddIns\BackendBindings\BooBinding\Boo.Lang.Useful.dll" Id="Boo.Lang.Useful.dll" Name="Boo.Lang.Useful.dll" />
<File Source="..\..\AddIns\AddIns\BackendBindings\BooBinding\Boo.Microsoft.Build.targets" Id="Boo.Microsoft.Build.targets" Name="Boo.Microsoft.Build.targets" />
@ -1048,6 +1048,7 @@ @@ -1048,6 +1048,7 @@
<File Source="..\..\AddIns\AddIns\BackendBindings\BooBinding\booc.exe.config" Id="booc.exe.config" Name="booc.exe.config" />
<File Source="..\..\AddIns\AddIns\BackendBindings\BooBinding\booc.rsp" Name="booc.rsp" Id="booc.rsp" />
<File Source="..\..\AddIns\AddIns\BackendBindings\BooBinding\NRefactoryToBooConverter.dll" Id="NRefactoryToBooConverter.dll" Name="NRefactoryToBooConverter.dll" />
<File Source="..\..\AddIns\AddIns\BackendBindings\BooBinding\Boo.Lang.Extensions.dll" Name="Boo.Lang.Extensions.dll" Id="Boo.Lang.Extensions.dll" />
</Component>
</Directory>
<Directory Id="CSharpBindingFolder" Name="CSharpBinding">
@ -1383,36 +1384,19 @@ @@ -1383,36 +1384,19 @@
</Component>
</Directory>
<Directory Id="SubversionAddInFolder" Name="SubversionAddIn">
<Component Id="SubversionUtilsDll" Guid="0FEF5BBC-A97C-4BB9-BEC2-759388E5572D" DiskId="1">
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\Utils.dll" Id="Utils.dll" Assembly=".net" AssemblyApplication="NSvn.Common.dll" AssemblyManifest="NSvn.Common.dll" KeyPath="yes" />
</Component>
<Component Id="SubversionLibAprDll" Guid="E4EE12A6-0766-4C85-8E28-7D7DEFC3AFEE" DiskId="1">
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\LIBAPR.DLL" Id="LIBAPR.DLL" />
</Component>
<Component Id="SubversionAprIconvDll" Guid="1494C120-502D-4108-897F-14BD0D601DD1" DiskId="1">
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\LibAprIconv.Dll" Id="LibAprIconv.Dll" Name="LibAprIconv.Dll" />
</Component>
<Component Id="SubversionLibAprUtilDll" Guid="7F963E06-7BF6-4D95-B6C7-443A5A8FC739" DiskId="1">
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\LibAprUtil.Dll" Id="LibAprUtil.Dll" Name="LibAprUtil.Dll" />
</Component>
<Component Id="SubversionLibDb44Dll" Guid="6A86A5F7-1E80-465D-82F4-B8064663F83A" DiskId="1">
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\LibDB44.dll" Name="LibDB44.dll" Id="LibDB44.dll" />
</Component>
<Component Id="SubversionMsvcp70Dll" Guid="E4612BC7-DA35-403D-BCFE-BC04D797D801" DiskId="1">
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\msvcp70.dll" Name="msvcp70.dll" Id="msvcp70.dll" />
</Component>
<Component Id="SubversionMsvcr70Dll" Guid="993F3D8A-DB4E-433E-92E4-FB46AF71488D" DiskId="1">
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\msvcr70.dll" Name="msvcr70.dll" Id="msvcr70.dll" />
</Component>
<Component Id="NSvnCommonDll" Guid="53B4D3C6-5A80-496E-8926-3A7060766068" DiskId="1">
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\NSvn.Common.dll" Id="NSvn.Common.dll" Name="NSvn.Common.dll" Assembly=".net" AssemblyApplication="NSvn.Common.dll" AssemblyManifest="NSvn.Common.dll" KeyPath="yes" />
</Component>
<Component Id="NSvnCoreDll" Guid="5989C307-D92E-4973-89E0-2509E3306C09" DiskId="1">
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\NSvn.Core.dll" Id="NSvn.Core.dll" Name="NSvn.Core.dll" Assembly=".net" AssemblyApplication="NSvn.Core.dll" AssemblyManifest="NSvn.Core.dll" KeyPath="yes" />
</Component>
<Component Guid="C9B1D523-5674-4398-9073-20F57B45DD46" Id="SubversionAddInDll" DiskId="1">
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\SubversionAddIn.dll" Id="SubversionAddIn.dll" Name="SubversionAddIn.dll" Assembly=".net" AssemblyApplication="SubversionAddIn.dll" AssemblyManifest="SubversionAddIn.dll" KeyPath="yes" />
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\ICSharpCode.Svn.addin" Id="ICSharpCode.Svn.addin" Name="ICSharpCode.Svn.addin" />
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\AprSharp.dll" Name="AprSharp.dll" Id="AprSharp.dll" />
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\intl3_svn.dll" Name="intl3_svn.dll" Id="intl3_svn.dll" />
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\libapr.dll" Name="libapr.dll" Id="libapr.dll" />
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\libapriconv.dll" Name="libapriconv.dll" Id="libapriconv.dll" />
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\libaprutil.dll" Name="libaprutil.dll" Id="libaprutil.dll" />
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\libdb44.dll" Name="libdb44.dll" Id="libdb44.dll" />
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\libeay32.dll" Name="libeay32.dll" Id="libeay32.dll" />
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\ssleay32.dll" Name="ssleay32.dll" Id="ssleay32.dll" />
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\SubversionSharp.dll" Name="SubversionSharp.dll" Id="SubversionSharp.dll" />
<File Source="..\..\AddIns\AddIns\Misc\SubversionAddin\svn_client-1.dll" Name="svn_client-1.dll" Id="svn_client_1.dll" />
</Component>
</Directory>
<Directory Id="UnitTestingFolder" Name="UnitTesting">

9
src/Setup/Setup.wxs

@ -354,15 +354,6 @@ @@ -354,15 +354,6 @@
-->
<ComponentRef Id="StartPageAddInFiles"/>
<ComponentRef Id="SubversionAddInDll"/>
<ComponentRef Id="SubversionUtilsDll"/>
<ComponentRef Id="SubversionLibAprDll"/>
<ComponentRef Id="SubversionAprIconvDll"/>
<ComponentRef Id="SubversionLibAprUtilDll"/>
<ComponentRef Id="SubversionLibDb44Dll"/>
<ComponentRef Id="SubversionMsvcp70Dll"/>
<ComponentRef Id="SubversionMsvcr70Dll"/>
<ComponentRef Id="NSvnCommonDll"/>
<ComponentRef Id="NSvnCoreDll"/>
<ComponentRef Id="UnitTestingAddInFiles"/>
<ComponentRef Id="SyntaxModesFiles"/>
<ComponentRef Id="SharpDevelopWebsiteShortcut"/>

41
src/Tools/UpdateAssemblyInfo/Main.cs

@ -11,6 +11,9 @@ using System.Reflection; @@ -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 @@ -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;
}

18
src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>UpdateAssemblyInfo</RootNamespace>
@ -19,6 +19,8 @@ @@ -19,6 +19,8 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<DebugSymbols>false</DebugSymbols>
<NoWarn>1607</NoWarn>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
@ -31,18 +33,22 @@ @@ -31,18 +33,22 @@
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="AprSharp">
<HintPath>..\..\AddIns\Misc\SubversionAddIn\RequiredLibraries\AprSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SubversionSharp">
<HintPath>..\..\AddIns\Misc\SubversionAddIn\RequiredLibraries\SubversionSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<None Include="app.manifest" />
<None Include="Readme.txt" />
</ItemGroup>
<ItemGroup>
<Content Include="UpdateAssemblyInfo.exe.manifest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>

15
src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.exe.manifest

@ -1,15 +0,0 @@ @@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<description>Updates the assembly version in GlobalAssemblyInfo.cs</description>
<!-- required because Vista otherwise thinks UpdateAssemblyInfo requires admin rights -->
<!-- because it contains the word "Update" -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

6
src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.sln

@ -1,5 +1,7 @@ @@ -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

21
src/Tools/UpdateAssemblyInfo/app.manifest

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!--
The presence of the "requestedExecutionLevel" node will disable
file and registry virtualization on Vista.
Use the "level" attribute to specify the User Account Control level:
asInvoker = Never prompt for elevation
requireAdministrator = Always prompt for elevation
highestAvailable = Prompt for elevation when started by administrator,
but do not prompt for administrator password when started by
standard user.
-->
<requestedExecutionLevel level="asInvoker"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
Loading…
Cancel
Save