Browse Source

Auto-add new files to version control (part of SD2-1221)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2159 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
1276b5114e
  1. 26
      src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/AutostartCommands.cs
  2. 5
      src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs
  3. 9
      src/Main/Base/Project/Src/Services/File/FileService.cs
  4. 4
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs

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

@ -26,6 +26,7 @@ namespace ICSharpCode.Svn.Commands @@ -26,6 +26,7 @@ namespace ICSharpCode.Svn.Commands
{
FileService.FileRemoving += FileRemoving;
FileService.FileRenaming += FileRenaming;
FileService.FileCreated += FileCreated;
FileUtility.FileSaved += new FileNameEventHandler(FileSaved);
AbstractProjectBrowserTreeNode.AfterNodeInitialize += TreeNodeInitialized;
@ -73,6 +74,29 @@ namespace ICSharpCode.Svn.Commands @@ -73,6 +74,29 @@ namespace ICSharpCode.Svn.Commands
}
}
void FileCreated(object sender, FileEventArgs e)
{
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) {
case StatusKind.Unversioned:
case StatusKind.Deleted:
if (SvnClient.Instance.Client.IsIgnored(fullName))
return;
SvnClient.Instance.Client.Add(fullName, Recurse.None);
break;
}
} catch (Exception ex) {
MessageService.ShowError("File add exception: " + ex);
}
}
void FileRemoving(object sender, FileCancelEventArgs e)
{
if (e.Cancel) return;
@ -148,10 +172,10 @@ namespace ICSharpCode.Svn.Commands @@ -148,10 +172,10 @@ namespace ICSharpCode.Svn.Commands
return; // nothing to do
case StatusKind.Normal:
case StatusKind.Modified:
case StatusKind.Replaced:
// rename without problem
break;
case StatusKind.Added:
case StatusKind.Replaced:
if (status.Copied) {
MessageService.ShowError("The file was moved/copied and cannot be renamed without losing it's history.");
e.Cancel = true;

5
src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs

@ -495,6 +495,11 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -495,6 +495,11 @@ namespace ICSharpCode.SharpDevelop.Gui
}
}
DialogResult = DialogResult.OK;
// raise FileCreated event for the new files
foreach (KeyValuePair<string, FileDescriptionTemplate> entry in createdFiles) {
FileService.FireFileCreated(entry.Key);
}
}
}
}

9
src/Main/Base/Project/Src/Services/File/FileService.cs

@ -289,6 +289,15 @@ namespace ICSharpCode.SharpDevelop @@ -289,6 +289,15 @@ namespace ICSharpCode.SharpDevelop
}
}
public static void FireFileCreated(string fileName)
{
if (FileCreated != null) {
FileCreated(null, new FileEventArgs(fileName, false));
}
}
public static event EventHandler<FileEventArgs> FileCreated;
public static event EventHandler<FileRenamingEventArgs> FileRenaming;
public static event EventHandler<FileRenameEventArgs> FileRenamed;

4
src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs

@ -181,7 +181,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -181,7 +181,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
viewContent.Load(fileName);
if (File.Exists(fileName)) {
viewContent.Load(fileName);
}
} else {
viewContent.IsDirty = true;
}

Loading…
Cancel
Save