Author: lluis
Date: 2006-12-17 12:43:16 -0500 (Sun, 17 Dec 2006)
New Revision: 69622
Added:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlFileSystemExtension.cs
Modified:
trunk/monodevelop/Extras/VersionControl/ChangeLog
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionVersionControl.cs
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SvnClient.cs
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/Makefile.am
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.mdp
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/AddRemoveMoveCommand.cs
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/ChangeSet.cs
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Repository.cs
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/UnknownRepository.cs
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlProjectService.cs
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml
Log:
*
MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs:
Improved implementation of Move.
*
MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SvnClient.cs:
Removed debug code.
*
MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionVersionControl.cs:
Minor fixes.
* MonoDevelop.VersionControl/MonoDevelop.VersionControl.mdp,
MonoDevelop.VersionControl/Makefile.am: Added new file.
* MonoDevelop.VersionControl/VersionControl.addin.xml: Registered new
file system extension.
* MonoDevelop.VersionControl/MonoDevelop.VersionControl/Repository.cs:
Split Move method into MoveFile and MoveDirectory. The same for
Delete. Added some other useful overridable methods.
*
MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlFileSystemExtension.cs:
New file system extension which supports version control systems.
*
MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs,
MonoDevelop.VersionControl/MonoDevelop.VersionControl/AddRemoveMoveCommand.cs,
MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlProjectService.cs,
MonoDevelop.VersionControl/MonoDevelop.VersionControl/UnknownRepository.cs:
Track api changes.
* MonoDevelop.VersionControl/MonoDevelop.VersionControl/ChangeSet.cs:
Removed unused field.
Modified: trunk/monodevelop/Extras/VersionControl/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/VersionControl/ChangeLog 2006-12-17 17:42:07 UTC
(rev 69621)
+++ trunk/monodevelop/Extras/VersionControl/ChangeLog 2006-12-17 17:43:16 UTC
(rev 69622)
@@ -1,3 +1,28 @@
+2006-12-17 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ *
MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs:
+ Improved implementation of Move.
+ *
MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SvnClient.cs:
+ Removed debug code.
+ *
MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionVersionControl.cs:
+ Minor fixes.
+ * MonoDevelop.VersionControl/MonoDevelop.VersionControl.mdp,
+ MonoDevelop.VersionControl/Makefile.am: Added new file.
+ * MonoDevelop.VersionControl/VersionControl.addin.xml: Registered new
+ file system extension.
+ * MonoDevelop.VersionControl/MonoDevelop.VersionControl/Repository.cs:
+ Split Move method into MoveFile and MoveDirectory. The same for
+ Delete. Added some other useful overridable methods.
+ *
MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlFileSystemExtension.cs:
+ New file system extension which supports version control systems.
+ *
MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs,
+
MonoDevelop.VersionControl/MonoDevelop.VersionControl/AddRemoveMoveCommand.cs,
+
MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlProjectService.cs,
+
MonoDevelop.VersionControl/MonoDevelop.VersionControl/UnknownRepository.cs:
+ Track api changes.
+ * MonoDevelop.VersionControl/MonoDevelop.VersionControl/ChangeSet.cs:
+ Removed unused field.
+
2006-12-14 Lluis Sanchez Gual <[EMAIL PROTECTED]>
*
MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlProjectService.cs,
Modified:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/Makefile.am
===================================================================
---
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/Makefile.am
2006-12-17 17:42:07 UTC (rev 69621)
+++
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/Makefile.am
2006-12-17 17:43:16 UTC (rev 69622)
@@ -23,6 +23,7 @@
MonoDevelop.VersionControl/CommitDialogExtension.cs \
MonoDevelop.VersionControl/VersionControlNodeExtension.cs \
MonoDevelop.VersionControl/VersionControlProjectService.cs \
+
MonoDevelop.VersionControl/VersionControlFileSystemExtension.cs \
MonoDevelop.VersionControl.Dialogs/CommitDialog.cs \
MonoDevelop.VersionControl.Dialogs/EditRepositoryDialog.cs \
MonoDevelop.VersionControl.Dialogs/SelectRepositoryDialog.cs \
Modified:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/AddRemoveMoveCommand.cs
===================================================================
---
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/AddRemoveMoveCommand.cs
2006-12-17 17:42:07 UTC (rev 69621)
+++
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/AddRemoveMoveCommand.cs
2006-12-17 17:43:16 UTC (rev 69622)
@@ -107,11 +107,11 @@
public class RemoveCommand
{
- public static bool Remove (Repository vc, string path, bool
test)
+ public static bool Remove (Repository vc, string path, bool
isDir, bool test)
{
if (vc.CanRemove(path)) {
if (test) return true;
- new RemoveWorker(vc, path).Start();
+ new RemoveWorker(vc, path, isDir).Start();
return true;
}
return false;
@@ -127,10 +127,12 @@
private class RemoveWorker : Task {
Repository vc;
string path;
+ bool isDir;
- public RemoveWorker(Repository vc, string path) {
+ public RemoveWorker(Repository vc, string path, bool
isDir) {
this.vc = vc;
this.path = path;
+ this.isDir = isDir;
}
protected override string GetDescription() {
@@ -139,7 +141,10 @@
protected override void Run() {
bool isDir = Directory.Exists (path);
- vc.Delete(path, true, GetProgressMonitor ());
+ if (isDir)
+ vc.DeleteDirectory (path, true,
GetProgressMonitor ());
+ else
+ vc.DeleteFile (path, true,
GetProgressMonitor ());
Gtk.Application.Invoke (delegate {
VersionControlProjectService.NotifyFileStatusChanged (vc, path, isDir);
});
Modified:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/ChangeSet.cs
===================================================================
---
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/ChangeSet.cs
2006-12-17 17:42:07 UTC (rev 69621)
+++
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/ChangeSet.cs
2006-12-17 17:43:16 UTC (rev 69622)
@@ -155,7 +155,6 @@
public class ChangeSetItem
{
VersionInfo versionInfo;
- string comment = string.Empty;
internal ChangeSetItem (VersionInfo versionInfo)
{
Modified:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Repository.cs
===================================================================
---
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Repository.cs
2006-12-17 17:42:07 UTC (rev 69621)
+++
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Repository.cs
2006-12-17 17:43:16 UTC (rev 69622)
@@ -201,12 +201,63 @@
// Adds a file or directory to the repository
public abstract void Add (string localPath, bool recurse,
IProgressMonitor monitor);
- // Moves a file or directory
- public abstract void Move (string localSrcPath, string
localDestPath, Revision revision, bool force, IProgressMonitor monitor);
+
+ // Moves a file. This method may be called for versioned and
unversioned
+ // files. The default implementetions performs a system file
move.
+ // It's up to the implementation to decide how smart the
MoveFile method is.
+ // For example, when moving a file to an unversioned directory,
the implementation
+ // might just throw an exception, or it could version the
directory, or it could
+ // ask the user what to do.
+ public virtual void MoveFile (string localSrcPath, string
localDestPath, bool force, IProgressMonitor monitor)
+ {
+ File.Move (localSrcPath, localDestPath);
+ }
- // Deletes a file or directory
- public abstract void Delete (string localPath, bool force,
IProgressMonitor monitor);
+ // Moves a directory. This method may be called for versioned
and unversioned
+ // files. The default implementetions performs a system file
move.
+ public virtual void MoveDirectory (string localSrcPath, string
localDestPath, bool force, IProgressMonitor monitor)
+ {
+ Directory.Move (localSrcPath, localDestPath);
+ }
+ // Deletes a file or directory. This method may be called for
versioned and unversioned
+ // files. The default implementetions performs a system file
delete.
+ public virtual void DeleteFile (string localPath, bool force,
IProgressMonitor monitor)
+ {
+ if (Directory.Exists (localPath))
+ Directory.Delete (localPath, true);
+ else
+ File.Delete (localPath);
+ }
+
+ public virtual void DeleteDirectory (string localPath, bool
force, IProgressMonitor monitor)
+ {
+ if (Directory.Exists (localPath))
+ Directory.Delete (localPath, true);
+ else
+ File.Delete (localPath);
+ }
+
+ // Creates a local directory.
+ public virtual void CreateLocalDirectory (string path)
+ {
+ Directory.CreateDirectory (path);
+ }
+
+ // Called to request write permission for a file. The file may
not yet exist.
+ // After the file is modified or created, NotifyFileChanged is
called.
+ // This method is allways called for versioned and unversioned
files.
+ public virtual bool RequestFileWritePermission (string path)
+ {
+ return true;
+ }
+
+ // Called after a file has been modified.
+ // This method is allways called for versioned and unversioned
files.
+ public virtual void NotifyFileChanged (string path)
+ {
+ }
+
// Locks a file in the repository so no other users can change
it
public virtual void Lock (string localPath)
{
Modified:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/UnknownRepository.cs
===================================================================
---
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/UnknownRepository.cs
2006-12-17 17:42:07 UTC (rev 69621)
+++
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/UnknownRepository.cs
2006-12-17 17:43:16 UTC (rev 69622)
@@ -68,12 +68,20 @@
{
}
- public override void Move (string srcPath, string destPath,
Revision revision, bool force, IProgressMonitor monitor)
+ public override void MoveFile (string srcPath, string destPath,
bool force, IProgressMonitor monitor)
{
}
- public override void Delete (string path, bool force,
IProgressMonitor monitor)
+ public override void MoveDirectory (string srcPath, string
destPath, bool force, IProgressMonitor monitor)
{
}
+
+ public override void DeleteFile (string path, bool force,
IProgressMonitor monitor)
+ {
+ }
+
+ public override void DeleteDirectory (string path, bool force,
IProgressMonitor monitor)
+ {
+ }
}
}
Added:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlFileSystemExtension.cs
===================================================================
---
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlFileSystemExtension.cs
2006-12-17 17:42:07 UTC (rev 69621)
+++
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlFileSystemExtension.cs
2006-12-17 17:43:16 UTC (rev 69622)
@@ -0,0 +1,97 @@
+
+using System;
+using MonoDevelop.Core;
+using MonoDevelop.Ide.Gui;
+using MonoDevelop.Projects;
+using MonoDevelop.Core.ProgressMonitoring;
+using MonoDevelop.Core.FileSystem;
+
+namespace MonoDevelop.VersionControl
+{
+ public class VersionControlFileSystemExtension: FileSystemExtension
+ {
+ public override bool CanHandlePath (string path, bool
isDirectory)
+ {
+ if (IdeApp.ProjectOperations.CurrentOpenCombine == null)
+ return false;
+ else
+ return GetRepository (path) != null;
+ }
+
+ Repository GetRepository (string path)
+ {
+ // FIXME: Optimize
+ foreach (Project prj in
IdeApp.ProjectOperations.CurrentOpenCombine.GetAllProjects ()) {
+ if (path.StartsWith (prj.BaseDirectory)) {
+ return
VersionControlProjectService.GetRepository (prj, path);
+ }
+ }
+ return null;
+ }
+
+ public override void CopyFile (string source, string dest, bool
overwrite)
+ {
+ Repository repo = GetRepository (dest);
+ if (repo.RequestFileWritePermission (dest)) {
+ base.CopyFile (source, dest, overwrite);
+ repo.NotifyFileChanged (dest);
+ }
+ else
+ throw new System.IO.IOException ("Write
permission denied");
+ }
+
+ public override void MoveFile (string source, string dest)
+ {
+ IProgressMonitor monitor = new NullProgressMonitor ();
+
+ Repository srcRepo = GetRepository (source);
+ Repository dstRepo = GetRepository (dest);
+
+ if (srcRepo == dstRepo)
+ srcRepo.MoveFile (source, dest, true, monitor);
+ else {
+ CopyFile (source, dest, true);
+ srcRepo.DeleteFile (source, true, monitor);
+ }
+ }
+
+ public override void DeleteFile (string file)
+ {
+ Repository repo = GetRepository (file);
+ repo.DeleteFile (file, true, new NullProgressMonitor
());
+ }
+
+ public override void CreateDirectory (string path)
+ {
+ Repository repo = GetRepository (path);
+ repo.CreateLocalDirectory (path);
+ }
+
+ public override void MoveDirectory (string sourcePath, string
destPath)
+ {
+ IProgressMonitor monitor = new NullProgressMonitor ();
+
+ Repository srcRepo = GetRepository (sourcePath);
+ Repository dstRepo = GetRepository (destPath);
+
+ if (srcRepo == dstRepo)
+ srcRepo.MoveDirectory (sourcePath, destPath,
true, monitor);
+ else {
+ CopyDirectory (sourcePath, destPath);
+ srcRepo.DeleteDirectory (sourcePath, true,
monitor);
+ }
+ }
+
+ public override void DeleteDirectory (string path)
+ {
+ Repository repo = GetRepository (path);
+ repo.DeleteDirectory (path, true, new
NullProgressMonitor ());
+ }
+
+ public override bool RequestFileEdit (string file)
+ {
+ Repository repo = GetRepository (file);
+ return repo.RequestFileWritePermission (file);
+ }
+ }
+}
Modified:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs
===================================================================
---
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs
2006-12-17 17:42:07 UTC (rev 69621)
+++
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs
2006-12-17 17:43:16 UTC (rev 69622)
@@ -328,7 +328,7 @@
case Commands.Add:
return AddCommand.Add (repo, path,
test);
case Commands.Remove:
- return RemoveCommand.Remove (repo,
path, test);
+ return RemoveCommand.Remove (repo,
path, isDir, test);
case Commands.Revert:
return RevertCommand.Revert (repo,
path, test);
case Commands.Publish:
Modified:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlProjectService.cs
===================================================================
---
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlProjectService.cs
2006-12-17 17:42:07 UTC (rev 69621)
+++
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlProjectService.cs
2006-12-17 17:43:16 UTC (rev 69622)
@@ -23,7 +23,7 @@
internal static Gdk.Pixbuf overlay_controled;
static Gdk.Pixbuf overlay_unversioned;
static Gdk.Pixbuf overlay_protected;
- static Gdk.Pixbuf overlay_normal;
+// static Gdk.Pixbuf overlay_normal;
static Gdk.Pixbuf icon_modified;
static Gdk.Pixbuf icon_removed;
@@ -42,7 +42,7 @@
overlay_controled =
Gdk.Pixbuf.LoadFromResource("overlay_controled.png");
overlay_unversioned =
Gdk.Pixbuf.LoadFromResource("overlay_unversioned.png");
overlay_protected =
Gdk.Pixbuf.LoadFromResource("overlay_locked.png");
- overlay_normal =
Gdk.Pixbuf.LoadFromResource("overlay_normal.png");
+// overlay_normal =
Gdk.Pixbuf.LoadFromResource("overlay_normal.png");
icon_modified =
MonoDevelop.Core.Gui.Services.Resources.GetIcon ("gtk-edit", Gtk.IconSize.Menu);
icon_removed =
MonoDevelop.Core.Gui.Services.Resources.GetIcon (Gtk.Stock.Remove,
Gtk.IconSize.Menu);
@@ -50,11 +50,11 @@
icon_added =
MonoDevelop.Core.Gui.Services.Resources.GetIcon (Gtk.Stock.Add,
Gtk.IconSize.Menu);
icon_controled =
Gdk.Pixbuf.LoadFromResource("overlay_controled.png");
- IdeApp.ProjectOperations.FileChangedInProject +=
OnFileChanged;
+/* IdeApp.ProjectOperations.FileChangedInProject +=
OnFileChanged;
IdeApp.ProjectOperations.FileAddedToProject +=
OnFileAdded;
IdeApp.ProjectOperations.FileRemovedFromProject +=
OnFileRemoved;
IdeApp.ProjectOperations.FileRenamedInProject +=
OnFileRenamed;
- }
+*/ }
public static Gdk.Pixbuf LoadOverlayIconForStatus(VersionStatus
status)
{
@@ -211,7 +211,7 @@
string file = Path.Combine
(Runtime.Properties.ConfigDirectory, "version-control-commit-msg");
if (comments.Count == 0) {
if (File.Exists (file))
- File.Delete (file);
+ Runtime.FileService.DeleteFile
(file);
return;
}
@@ -304,7 +304,7 @@
Repository repo = GetRepository (args.Project, path);
if (repo != null && repo.IsVersioned (path) &&
repo.CanRemove (path)) {
using (IProgressMonitor monitor =
GetStatusMonitor ()) {
- repo.Delete (path, true, monitor);
+ repo.DeleteFile (path, true, monitor);
}
NotifyFileStatusChanged (repo, path,
args.ProjectFile.Subtype == Subtype.Directory);
}
Modified:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.mdp
===================================================================
---
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.mdp
2006-12-17 17:42:07 UTC (rev 69621)
+++
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.mdp
2006-12-17 17:43:16 UTC (rev 69622)
@@ -71,6 +71,7 @@
<File name="./MonoDevelop.VersionControl/VersionInfo.cs" subtype="Code"
buildaction="Compile" />
<File name="./MonoDevelop.VersionControl/VersionStatus.cs" subtype="Code"
buildaction="Compile" />
<File name="./MonoDevelop.VersionControl/FileUpdateEventHandler.cs"
subtype="Code" buildaction="Compile" />
+ <File
name="./MonoDevelop.VersionControl/VersionControlFileSystemExtension.cs"
subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Project" localcopy="True" refto="Diff" />
Modified:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml
===================================================================
---
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml
2006-12-17 17:42:07 UTC (rev 69621)
+++
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml
2006-12-17 17:43:16 UTC (rev 69622)
@@ -26,6 +26,10 @@
<Extension path = "/MonoDevelop/VersionControl/CommitDialogExtensions">
</Extension>
+
+ <Extension path = "/Workspace/FileSystemExtensions"
extension-nodes="Class" description="File system extensions|File system
extensions which can provide specific behavior when handling files. Specified
classes must implement MonoDevelop.Core.FileSystem.FileSystemExtension.">
+ <Class class =
"MonoDevelop.VersionControl.VersionControlFileSystemExtension" />
+ </Extension>
<Extension path =
"/SharpDevelop/Workbench/Pads/MonoDevelop.Ide.Gui.Pads.ProjectPad">
<PadOption id = "ShowVersionControlOverlays" _label = "Show
version control overlay icons" defaultValue = "True" />
Modified:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs
===================================================================
---
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs
2006-12-17 17:42:07 UTC (rev 69621)
+++
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs
2006-12-17 17:43:16 UTC (rev 69622)
@@ -164,16 +164,174 @@
Svn.Add (path, recurse, monitor);
}
- public override void Move (string srcPath, string destPath,
Revision revision, bool force, IProgressMonitor monitor)
+ public override void MoveFile (string srcPath, string destPath,
bool force, IProgressMonitor monitor)
{
- Svn.Move (srcPath, destPath, revision, force, monitor);
+ bool destIsVersioned = false;
+
+ if (File.Exists (destPath))
+ throw new InvalidOperationException ("Cannot
move file. Destination file already exist.");
+
+ if (IsVersioned (destPath)) {
+ // Revert to the original status
+ Revert (destPath, false, monitor);
+ if (File.Exists (destPath))
+ File.Delete (destPath);
+ destIsVersioned = true;
+ }
+
+ VersionInfo srcInfo = GetVersionInfo (srcPath, false);
+ if (srcInfo != null && srcInfo.Status ==
VersionStatus.ScheduledAdd) {
+ // If the file is scheduled to add, cancel it,
move the file, and schedule to add again
+ Revert (srcPath, false, monitor);
+ if (!destIsVersioned)
+ MakeDirVersioned (Path.GetDirectoryName
(destPath), monitor);
+ base.MoveFile (srcPath, destPath, force,
monitor);
+ if (!destIsVersioned)
+ Add (destPath, false, monitor);
+ } else {
+ if (!destIsVersioned && IsVersioned (srcPath)) {
+ MakeDirVersioned (Path.GetDirectoryName
(destPath), monitor);
+ Svn.Move (srcPath, destPath, force,
monitor);
+ } else
+ base.MoveFile (srcPath, destPath,
force, monitor);
+ }
}
- public override void Delete (string path, bool force,
IProgressMonitor monitor)
+ public override void MoveDirectory (string srcPath, string
destPath, bool force, IProgressMonitor monitor)
{
- Svn.Delete (path, force, monitor);
+ if (IsVersioned (destPath))
+ {
+ VersionInfo vinfo = GetVersionInfo (destPath,
false);
+ if (vinfo.Status !=
VersionStatus.ScheduledDelete && Directory.Exists (destPath))
+ throw new InvalidOperationException
("Cannot move directory. Destination directory already exist.");
+
+ srcPath = Path.GetFullPath (srcPath);
+
+ // The target directory does not exist, but it
is versioned. It may be because
+ // it is scheduled to delete, or maybe it has
been physicaly deleted. In any
+ // case we are going to replace the old
directory by the new directory.
+
+ // Revert the old directory, so we can see
which files were there so
+ // we can delete or replace them
+ Revert (destPath, true, monitor);
+
+ // Get the list of files in the directory to be
replaced
+ ArrayList oldFiles = new ArrayList ();
+ GetDirectoryFiles (destPath, oldFiles);
+
+ // Get the list of files to move
+ ArrayList newFiles = new ArrayList ();
+ GetDirectoryFiles (srcPath, newFiles);
+
+ // Move all new files to the new destination
+ Hashtable copiedFiles = new Hashtable ();
+ Hashtable copiedFolders = new Hashtable ();
+ foreach (string file in newFiles) {
+ string src = Path.GetFullPath (file);
+ string dst = Path.Combine (destPath,
src.Substring (srcPath.Length + 1));
+ if (File.Exists (dst))
+ File.Delete (dst);
+
+ // Make sure the target directory exists
+ string destDir = Path.GetDirectoryName
(dst);
+ if (!Directory.Exists (destDir))
+ Directory.CreateDirectory
(destDir);
+
+ // If the source file is versioned,
make sure the target directory
+ // is also versioned.
+ if (IsVersioned (src))
+ MakeDirVersioned (destDir,
monitor);
+
+ MoveFile (src, dst, true, monitor);
+ copiedFiles [dst] = dst;
+ string df = Path.GetDirectoryName (dst);
+ copiedFolders [df] = df;
+ }
+
+ // Delete all old files which have not been
replaced
+ ArrayList foldersToDelete = new ArrayList ();
+ foreach (string oldFile in oldFiles) {
+ if (!copiedFiles.Contains (oldFile)) {
+ DeleteFile (oldFile, true,
monitor);
+ string fd =
Path.GetDirectoryName (oldFile);
+ if (!copiedFolders.Contains
(fd) && !foldersToDelete.Contains (fd))
+ foldersToDelete.Add
(fd);
+ }
+ }
+
+ // Delete old folders
+ foreach (string folder in foldersToDelete) {
+ Svn.Delete (folder, true, monitor);
+ }
+
+ // Delete the source directory
+ DeleteDirectory (srcPath, true, monitor);
+ }
+ else {
+ if (Directory.Exists (destPath))
+ throw new InvalidOperationException
("Cannot move directory. Destination directory already exist.");
+
+ VersionInfo srcInfo = GetVersionInfo (srcPath,
false);
+ if (srcInfo != null && srcInfo.Status ==
VersionStatus.ScheduledAdd) {
+ // If the directory is scheduled to
add, cancel it, move the directory, and schedule to add it again
+ MakeDirVersioned (Path.GetDirectoryName
(destPath), monitor);
+ Revert (srcPath, true, monitor);
+ base.MoveDirectory (srcPath, destPath,
force, monitor);
+ Add (destPath, true, monitor);
+ } else {
+ if (IsVersioned (srcPath)) {
+ MakeDirVersioned
(Path.GetDirectoryName (destPath), monitor);
+ Svn.Move (srcPath, destPath,
force, monitor);
+ } else
+ base.MoveDirectory (srcPath,
destPath, force, monitor);
+ }
+ }
}
+ void MakeDirVersioned (string dir, IProgressMonitor monitor)
+ {
+ if (Directory.Exists (Path.Combine (dir, ".svn")))
+ return;
+
+ // Make the parent versioned
+ string parentDir = Path.GetDirectoryName (dir);
+ if (parentDir == dir || parentDir == "")
+ throw new InvalidOperationException ("Could not
create versioned directory.");
+ MakeDirVersioned (parentDir, monitor);
+
+ Add (dir, false, monitor);
+ }
+
+ void GetDirectoryFiles (string directory, ArrayList collection)
+ {
+ string[] dir = Directory.GetDirectories(directory);
+ foreach (string d in dir) {
+ // Get all files ignoring the .svn directory
+ if (Path.GetFileName (d) != ".svn")
+ GetDirectoryFiles (d, collection);
+ }
+ string[] file = Directory.GetFiles (directory);
+ foreach (string f in file)
+ collection.Add(f);
+ }
+
+
+ public override void DeleteFile (string path, bool force,
IProgressMonitor monitor)
+ {
+ if (IsVersioned (path))
+ Svn.Delete (path, force, monitor);
+ else
+ base.DeleteFile (path, force, monitor);
+ }
+
+ public override void DeleteDirectory (string path, bool force,
IProgressMonitor monitor)
+ {
+ if (IsVersioned (path))
+ Svn.Delete (path, force, monitor);
+ else
+ base.DeleteDirectory (path, force, monitor);
+ }
+
public override DiffInfo[] PathDiff (string baseLocalPath,
string[] localPaths)
{
if (localPaths != null) {
@@ -185,7 +343,7 @@
try {
list.AddRange
(GenerateUnifiedDiffInfo (diff, path, new string [] { path }));
} finally {
- File.Delete (diff);
+ Runtime.FileService.DeleteFile
(diff);
}
}
return (DiffInfo[]) list.ToArray
(typeof(DiffInfo));
@@ -194,7 +352,7 @@
try {
return GenerateUnifiedDiffInfo (diff,
baseLocalPath, null);
} finally {
- File.Delete (diff);
+ Runtime.FileService.DeleteFile (diff);
}
}
}
Modified:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionVersionControl.cs
===================================================================
---
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionVersionControl.cs
2006-12-17 17:42:07 UTC (rev 69621)
+++
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionVersionControl.cs
2006-12-17 17:43:16 UTC (rev 69622)
@@ -59,7 +59,7 @@
Path.GetFileName(sourcefile) + ".svn-base");
}
- string GetDirectoryDotSvn(string sourcepath) {
+ internal static string GetDirectoryDotSvn (string sourcepath) {
return Path.Combine(sourcepath, ".svn");
}
@@ -248,8 +248,8 @@
return Client.List(path, recurse, SvnClient.Rev.Head);
}
- public void Move(string srcPath, string destPath, Revision
revision, bool force, IProgressMonitor monitor) {
-
+ public void Move(string srcPath, string destPath, bool force,
IProgressMonitor monitor) {
+ Client.Move (srcPath, destPath, SvnClient.Rev.Head,
force, monitor);
}
public string PathDiff (string path, bool recursive)
Modified:
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SvnClient.cs
===================================================================
---
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SvnClient.cs
2006-12-17 17:42:07 UTC (rev 69621)
+++
trunk/monodevelop/Extras/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SvnClient.cs
2006-12-17 17:43:16 UTC (rev 69622)
@@ -457,7 +457,7 @@
if (outfile != IntPtr.Zero)
apr.file_close (outfile);
if (fout != null)
- File.Delete (fout);
+ Runtime.FileService.DeleteFile
(fout);
outfile = IntPtr.Zero;
fout = null;
} catch {}
@@ -471,7 +471,7 @@
if (errfile != IntPtr.Zero)
apr.file_close (errfile);
if (ferr != null)
- File.Delete (ferr);
+ Runtime.FileService.DeleteFile
(ferr);
} catch {}
}
}
@@ -574,7 +574,6 @@
Stream buf;
public StreamCollector(Stream buf) { this.buf = buf; }
public IntPtr Func(IntPtr baton, IntPtr data, ref int
len) {
- Console.WriteLine(len);
for (int i = 0; i < len; i++)
buf.WriteByte(Marshal.ReadByte((IntPtr)((int)data+i)));
return IntPtr.Zero;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches