diff --git a/src/AddIns/Misc/SubversionAddIn/Project/ICSharpCode.Svn.addin b/src/AddIns/Misc/SubversionAddIn/Project/ICSharpCode.Svn.addin index baacf4bf6a..6ea641c70b 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/ICSharpCode.Svn.addin +++ b/src/AddIns/Misc/SubversionAddIn/Project/ICSharpCode.Svn.addin @@ -135,12 +135,12 @@ icon = "Svn.CreatePatch" class = "ICSharpCode.Svn.Commands.CreatePatchCommand"/> - + + + + + + + + + + + + + + + + + + + - - + - + + - - + - + - - + - + - - - - - - - - - - - - - - - - - - - - diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/AddInOptions.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/AddInOptions.cs index 8935d35b2e..9d403cbbfa 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/AddInOptions.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/AddInOptions.cs @@ -22,17 +22,6 @@ namespace ICSharpCode.Svn } #region Properties - public static string DefaultLogMessage { - get { - return properties.Get("DefaultLogMessage", - "# All lines starting with a # will be ignored" + Environment.NewLine + - "# This template can be modified by using the 'Tools->IDE Options->Source Control->Subversion' panel"); - } - set { - properties.Set("DefaultLogMessage", value); - } - } - public static bool AutomaticallyAddFiles { get { return properties.Get("AutomaticallyAddFiles", true); @@ -51,6 +40,15 @@ namespace ICSharpCode.Svn } } + public static bool AutomaticallyRenameFiles { + get { + return properties.Get("AutomaticallyRenameFiles", true); + } + set { + properties.Set("AutomaticallyRenameFiles", value); + } + } + public static bool AutomaticallyReloadProject { get { return properties.Get("AutomaticallyReloadProject", true); @@ -59,6 +57,15 @@ namespace ICSharpCode.Svn properties.Set("AutomaticallyReloadProject", value); } } + + public static bool UseHistoryDisplayBinding { + get { + return properties.Get("UseHistoryDisplayBinding", true); + } + set { + properties.Set("UseHistoryDisplayBinding", value); + } + } #endregion } } diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs index a6e06b9614..afb5a65cc3 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs @@ -1,7 +1,7 @@ // // // -// +// // $Revision$ // @@ -18,9 +18,10 @@ using NSvn.Core; namespace ICSharpCode.Svn.Commands { /// - /// Description of AutostartCommands. + /// Registers event handlers for file added, removed, renamed etc. and + /// executes the appropriate Subversion commands. /// - public class RegisterEventsCommand : AbstractCommand + public sealed class RegisterEventsCommand : AbstractCommand { public override void Run() { @@ -62,26 +63,14 @@ namespace ICSharpCode.Svn.Commands SubversionStateCondition.ResetCache(); } - void FileAdded(object sender, FileEventArgs e) - { - try { - if (AddInOptions.AutomaticallyAddFiles) { - if (!CanBeVersionControlledFile(e.FileName)) return; - SvnClient.Instance.Client.Add(Path.GetFullPath(e.FileName), Recurse.None); - } - } catch (Exception ex) { - MessageService.ShowError("File added exception: " + ex); - } - } - void FileCreated(object sender, FileEventArgs e) { + if (!AddInOptions.AutomaticallyAddFiles) return; if (!Path.IsPathRooted(e.FileName)) return; string fullName = Path.GetFullPath(e.FileName); if (!CanBeVersionControlledFile(fullName)) return; if (e.IsDirectory) return; - if (!AddInOptions.AutomaticallyAddFiles) return; try { Status status = SvnClient.Instance.Client.SingleStatus(fullName); switch (status.TextStatus) { @@ -162,6 +151,7 @@ namespace ICSharpCode.Svn.Commands void FileRenaming(object sender, FileRenamingEventArgs e) { if (e.Cancel) return; + if (!AddInOptions.AutomaticallyRenameFiles) return; string fullSource = Path.GetFullPath(e.SourceFile); if (!CanBeVersionControlledFile(fullSource)) return; try { @@ -201,7 +191,7 @@ namespace ICSharpCode.Svn.Commands } } - class AutoAddAfterRenameHelper + sealed class AutoAddAfterRenameHelper { FileRenamingEventArgs args; diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/ProjectBrowserCommands.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/ProjectBrowserCommands.cs index 9e2cec4add..3f319edf34 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/ProjectBrowserCommands.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/ProjectBrowserCommands.cs @@ -1,11 +1,12 @@ // // // -// +// // $Revision$ // using System; +using System.Collections.Generic; using System.IO; using System.Text; @@ -33,12 +34,12 @@ namespace ICSharpCode.Svn.Commands } } - protected void Callback() + protected ProjectWatcher WatchProjects() { - WorkbenchSingleton.SafeThreadAsyncCall(CallbackInvoked); + return new ProjectWatcher(ProjectService.OpenSolution); } - void CallbackInvoked() + static void CallbackInvoked() { SubversionStateCondition.ResetCache(); AbstractProjectBrowserTreeNode node = ProjectBrowserPad.Instance.SelectedNode; @@ -48,13 +49,98 @@ namespace ICSharpCode.Svn.Commands } protected abstract void Run(string filename); + + struct ProjectEntry + { + string fileName; + long size; + DateTime writeTime; + + public ProjectEntry(FileInfo file) + { + fileName = file.FullName; + if (file.Exists) { + size = file.Length; + writeTime = file.LastWriteTime; + } else { + size = -1; + writeTime = DateTime.MinValue; + } + } + + public bool HasFileChanged() + { + FileInfo file = new FileInfo(fileName); + long newSize; + DateTime newWriteTime; + if (file.Exists) { + newSize = file.Length; + newWriteTime = file.LastWriteTime; + } else { + newSize = -1; + newWriteTime = DateTime.MinValue; + } + return size != newSize || writeTime != newWriteTime; + } + } + + /// + /// Remembers a list of file sizes and last write times. If a project + /// changed during the operation, suggest that the user reloads the solution. + /// + protected sealed class ProjectWatcher + { + List list = new List(); + Solution solution; + + internal ProjectWatcher(Solution solution) + { + this.solution = solution; + if (AddInOptions.AutomaticallyReloadProject && solution != null) + { + list.Add(new ProjectEntry(new FileInfo(solution.FileName))); + foreach (IProject p in solution.Projects) { + list.Add(new ProjectEntry(new FileInfo(p.FileName))); + } + } + } + + public void Callback() + { + WorkbenchSingleton.SafeThreadAsyncCall(CallbackInvoked); + } + + void CallbackInvoked() + { + SubversionCommand.CallbackInvoked(); + if (ProjectService.OpenSolution != solution) + return; + if (!list.TrueForAll(delegate (ProjectEntry pe) { + return !pe.HasFileChanged(); + })) + { + // if at least one project was changed: + if (MessageService.ShowCustomDialog( + MessageService.DefaultMessageBoxTitle, + "SharpDevelop detected that the version control operation changed " + + "project files.\n" + + "You should reload the solution.", + 0, 1, + "Reload solution", "Keep old solution open") + == 0) + { + ProjectService.LoadSolution(solution.FileName); + } + } + } + } } public class UpdateCommand : SubversionCommand { protected override void Run(string filename) { - SvnGuiWrapper.Update(filename, Callback); + SvnGuiWrapper.Update(filename, WatchProjects().Callback); } } @@ -62,7 +148,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.UpdateToRevision(filename, Callback); + SvnGuiWrapper.UpdateToRevision(filename, WatchProjects().Callback); } } @@ -70,7 +156,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.Revert(filename, Callback); + SvnGuiWrapper.Revert(filename, WatchProjects().Callback); } } @@ -86,7 +172,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.ApplyPatch(filename, null); + SvnGuiWrapper.ApplyPatch(filename, WatchProjects().Callback); } } @@ -94,7 +180,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.Commit(filename, Callback); + SvnGuiWrapper.Commit(filename, WatchProjects().Callback); } } @@ -102,7 +188,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.Add(filename, Callback); + SvnGuiWrapper.Add(filename, WatchProjects().Callback); } } @@ -110,7 +196,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.Ignore(filename, Callback); + SvnGuiWrapper.Ignore(filename, WatchProjects().Callback); } } @@ -118,7 +204,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.Blame(filename, Callback); + SvnGuiWrapper.Blame(filename, null); } } @@ -128,6 +214,7 @@ namespace ICSharpCode.Svn.Commands { 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) { StringBuilder b = new StringBuilder(); @@ -143,7 +230,7 @@ namespace ICSharpCode.Svn.Commands Path.GetDirectoryName(filename), Recurse.None); } MessageService.ShowMessage(shortFileName + " was removed from the ignore list."); - Callback(); + watcher.Callback(); } } } @@ -176,7 +263,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.Diff(filename, Callback); + SvnGuiWrapper.Diff(filename, WatchProjects().Callback); } } @@ -184,7 +271,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.ConflictEditor(filename, Callback); + SvnGuiWrapper.ConflictEditor(filename, WatchProjects().Callback); } } @@ -192,7 +279,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.ResolveConflict(filename, Callback); + SvnGuiWrapper.ResolveConflict(filename, WatchProjects().Callback); } } @@ -200,7 +287,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.ShowLog(filename, Callback); + SvnGuiWrapper.ShowLog(filename, WatchProjects().Callback); } } @@ -208,7 +295,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.Cleanup(filename, Callback); + SvnGuiWrapper.Cleanup(filename, null); } } @@ -216,7 +303,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.RepoBrowser(filename, Callback); + SvnGuiWrapper.RepoBrowser(filename, null); } } @@ -224,7 +311,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.RepoStatus(filename, Callback); + SvnGuiWrapper.RepoStatus(filename, null); } } @@ -232,7 +319,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.RevisionGraph(filename, Callback); + SvnGuiWrapper.RevisionGraph(filename, null); } } @@ -240,7 +327,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.Branch(filename, Callback); + SvnGuiWrapper.Branch(filename, WatchProjects().Callback); } } @@ -248,7 +335,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.Switch(filename, Callback); + SvnGuiWrapper.Switch(filename, WatchProjects().Callback); } } @@ -256,7 +343,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.Merge(filename, Callback); + SvnGuiWrapper.Merge(filename, WatchProjects().Callback); } } @@ -264,7 +351,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.Export(filename, Callback); + SvnGuiWrapper.Export(filename, null); } } @@ -272,7 +359,7 @@ namespace ICSharpCode.Svn.Commands { protected override void Run(string filename) { - SvnGuiWrapper.Relocate(filename, Callback); + SvnGuiWrapper.Relocate(filename, WatchProjects().Callback); } } } diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryView.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryView.cs index 3317a1ef4e..af301e9548 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryView.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryView.cs @@ -24,7 +24,7 @@ namespace ICSharpCode.Svn public override string TabPageText { get { - return "History"; + return "History"; // TODO: Translate } } #endregion 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 9622b203b9..ede1ff9a2c 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs @@ -62,6 +62,9 @@ namespace ICSharpCode.Svn public bool CanAttachTo(ICSharpCode.SharpDevelop.Gui.IViewContent content) { + if (!AddInOptions.UseHistoryDisplayBinding) { + return false; + } if (content.IsUntitled || content.FileName == null || !File.Exists(content.FileName)) { return false; } diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/SubversionOptionsPanel.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/SubversionOptionsPanel.cs index 7cb856bf63..ad7ed99a8c 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/SubversionOptionsPanel.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/SubversionOptionsPanel.cs @@ -1,7 +1,7 @@ // // // -// +// // $Revision$ // @@ -23,18 +23,20 @@ namespace ICSharpCode.Svn.Gui public override void LoadPanelContents() { SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("ICSharpCode.Svn.Resources.SubversionOptionsPanel.xfrm")); - ControlDictionary["logMessageTextBox"].Text = AddInOptions.DefaultLogMessage; ((CheckBox)ControlDictionary["autoAddFilesCheckBox"]).Checked = AddInOptions.AutomaticallyAddFiles; ((CheckBox)ControlDictionary["autoDeleteFilesCheckBox"]).Checked = AddInOptions.AutomaticallyDeleteFiles; + ((CheckBox)ControlDictionary["autoRenameFilesCheckBox"]).Checked = AddInOptions.AutomaticallyRenameFiles; ((CheckBox)ControlDictionary["autoReloadProjectCheckBox"]).Checked = AddInOptions.AutomaticallyReloadProject; + ((CheckBox)ControlDictionary["useHistoryDisplayBindingCheckBox"]).Checked = AddInOptions.UseHistoryDisplayBinding; } public override bool StorePanelContents() { - AddInOptions.DefaultLogMessage = ControlDictionary["logMessageTextBox"].Text; AddInOptions.AutomaticallyAddFiles = ((CheckBox)ControlDictionary["autoAddFilesCheckBox"]).Checked; AddInOptions.AutomaticallyDeleteFiles = ((CheckBox)ControlDictionary["autoDeleteFilesCheckBox"]).Checked; + AddInOptions.AutomaticallyRenameFiles = ((CheckBox)ControlDictionary["autoRenameFilesCheckBox"]).Checked; AddInOptions.AutomaticallyReloadProject = ((CheckBox)ControlDictionary["autoReloadProjectCheckBox"]).Checked; + AddInOptions.UseHistoryDisplayBinding = ((CheckBox)ControlDictionary["useHistoryDisplayBindingCheckBox"]).Checked; return true; }