Browse Source

Implemented reloading solution when it was changed by version control operation (SD2-1221)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2163 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
80abc20f76
  1. 4
      src/AddIns/Misc/SubversionAddIn/Project/ICSharpCode.Svn.addin
  2. 54
      src/AddIns/Misc/SubversionAddIn/Project/Resources/SubversionOptionsPanel.xfrm
  3. 29
      src/AddIns/Misc/SubversionAddIn/Project/Src/AddInOptions.cs
  4. 24
      src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs
  5. 139
      src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/ProjectBrowserCommands.cs
  6. 2
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryView.cs
  7. 3
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewDisplayBinding.cs
  8. 8
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/SubversionOptionsPanel.cs

4
src/AddIns/Misc/SubversionAddIn/Project/ICSharpCode.Svn.addin

@ -135,12 +135,12 @@ @@ -135,12 +135,12 @@
icon = "Svn.CreatePatch"
class = "ICSharpCode.Svn.Commands.CreatePatchCommand"/>
</Condition>
<Condition name = "SubversionState" state = "Modified;Normal" item = "Folder">
<!--<Condition name = "SubversionState" state = "Modified;Normal" item = "Folder">
<MenuItem id = "SvnApplyPatch"
label = "Apply patch..."
icon = "Svn.ApplyPatch"
class = "ICSharpCode.Svn.Commands.ApplyPatchCommand"/>
</Condition>
</Condition>-->
<MenuItem id = "Sep4" type = "Separator"/>
<MenuItem id = "SvnHelp"
label = "Help"

54
src/AddIns/Misc/SubversionAddIn/Project/Resources/SubversionOptionsPanel.xfrm

@ -3,52 +3,48 @@ @@ -3,52 +3,48 @@
<Name value="XmlUserControl1" />
<ClientSize value="{Width=296, Height=240}" />
<Controls>
<System.Windows.Forms.CheckBox>
<Name value="useHistoryDisplayBindingCheckBox" />
<Location value="8, 135" />
<Text value="Add &amp;history tab to version-controlled files" />
<TabIndex value="6" />
<Size value="280, 24" />
<UseVisualStyleBackColor value="True" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="autoRenameFilesCheckBox" />
<Location value="8, 63" />
<Text value="&amp;Keep history for renamed files (rename in Subversion)" />
<TabIndex value="5" />
<Size value="280, 24" />
<Anchor value="Top, Left, Right" />
<UseVisualStyleBackColor value="True" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="autoDeleteFilesCheckBox" />
<Location value="{X=8,Y=172}" />
<FlatAppearance value="System.Windows.Forms.FlatButtonAppearance" />
<Location value="8, 33" />
<Text value="Automatically &amp;delete removed files" />
<TabIndex value="3" />
<Size value="{Width=280, Height=24}" />
<Size value="280, 24" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="autoReloadProjectCheckBox" />
<Location value="{X=8,Y=192}" />
<FlatAppearance value="System.Windows.Forms.FlatButtonAppearance" />
<Location value="8, 105" />
<Text value="&amp;Re-load project after projectfile change" />
<TabIndex value="4" />
<Size value="{Width=280, Height=24}" />
<Size value="280, 24" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.CheckBox>
<Name value="autoAddFilesCheckBox" />
<Location value="{X=8,Y=152}" />
<FlatAppearance value="System.Windows.Forms.FlatButtonAppearance" />
<Location value="8, 3" />
<Text value="Automatically &amp;add new files" />
<TabIndex value="2" />
<Size value="{Width=280, Height=24}" />
<Size value="280, 24" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.TextBox>
<Name value="logMessageTextBox" />
<TabIndex value="1" />
<Multiline value="True" />
<AcceptsReturn value="True" />
<WordWrap value="False" />
<Anchor value="Top, Left, Right" />
<Size value="{Width=280, Height=112}" />
<AcceptsTab value="True" />
<Location value="{X=8,Y=32}" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="label1" />
<Location value="{X=8,Y=8}" />
<Text value="&amp;Standard commit message:" />
<TextAlign value="BottomLeft" />
<Size value="{Width=280, Height=23}" />
<TabIndex value="0" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.Label>
</Controls>
</System.Windows.Forms.UserControl>
</Components>

29
src/AddIns/Misc/SubversionAddIn/Project/Src/AddInOptions.cs

@ -22,17 +22,6 @@ namespace ICSharpCode.Svn @@ -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 @@ -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 @@ -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
}
}

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

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="none" email=""/>
// <owner name="Daniel Grunwald" email=""/>
// <version>$Revision$</version>
// </file>
@ -18,9 +18,10 @@ using NSvn.Core; @@ -18,9 +18,10 @@ using NSvn.Core;
namespace ICSharpCode.Svn.Commands
{
/// <summary>
/// Description of AutostartCommands.
/// Registers event handlers for file added, removed, renamed etc. and
/// executes the appropriate Subversion commands.
/// </summary>
public class RegisterEventsCommand : AbstractCommand
public sealed class RegisterEventsCommand : AbstractCommand
{
public override void Run()
{
@ -62,26 +63,14 @@ namespace ICSharpCode.Svn.Commands @@ -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 @@ -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 @@ -201,7 +191,7 @@ namespace ICSharpCode.Svn.Commands
}
}
class AutoAddAfterRenameHelper
sealed class AutoAddAfterRenameHelper
{
FileRenamingEventArgs args;

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

@ -1,11 +1,12 @@ @@ -1,11 +1,12 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="none" email=""/>
// <owner name="Daniel Grunwald" email=""/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@ -33,12 +34,12 @@ namespace ICSharpCode.Svn.Commands @@ -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 @@ -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;
}
}
/// <summary>
/// Remembers a list of file sizes and last write times. If a project
/// changed during the operation, suggest that the user reloads the solution.
/// </summary>
protected sealed class ProjectWatcher
{
List<ProjectEntry> list = new List<ProjectEntry>();
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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -272,7 +359,7 @@ namespace ICSharpCode.Svn.Commands
{
protected override void Run(string filename)
{
SvnGuiWrapper.Relocate(filename, Callback);
SvnGuiWrapper.Relocate(filename, WatchProjects().Callback);
}
}
}

2
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryView.cs

@ -24,7 +24,7 @@ namespace ICSharpCode.Svn @@ -24,7 +24,7 @@ namespace ICSharpCode.Svn
public override string TabPageText {
get {
return "History";
return "History"; // TODO: Translate
}
}
#endregion

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

@ -62,6 +62,9 @@ namespace ICSharpCode.Svn @@ -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;
}

8
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/SubversionOptionsPanel.cs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="none" email=""/>
// <owner name="Daniel Grunwald" email=""/>
// <version>$Revision$</version>
// </file>
@ -23,18 +23,20 @@ namespace ICSharpCode.Svn.Gui @@ -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;
}

Loading…
Cancel
Save