Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTherzok <teromario@yahoo.com>2013-08-23 19:04:18 +0400
committerTherzok <teromario@yahoo.com>2013-08-23 19:04:18 +0400
commitc7e3b6c2918a3da14b82e057c6070bbbbc449b4a (patch)
tree75c53216b3cfebb479b22e681d9a02c74b180555 /main/src/addins/VersionControl/Subversion.Win32
parentc52dd734abd5c20756042b4d9e3c59f3790b3272 (diff)
[Subversion] Implemented Progress Monitoring for Subversion commands.
TODO: Prettify text output and make progress bar indefinite.
Diffstat (limited to 'main/src/addins/VersionControl/Subversion.Win32')
-rw-r--r--main/src/addins/VersionControl/Subversion.Win32/SvnSharpClient.cs52
1 files changed, 46 insertions, 6 deletions
diff --git a/main/src/addins/VersionControl/Subversion.Win32/SvnSharpClient.cs b/main/src/addins/VersionControl/Subversion.Win32/SvnSharpClient.cs
index 7e63a392b3..f0de966632 100644
--- a/main/src/addins/VersionControl/Subversion.Win32/SvnSharpClient.cs
+++ b/main/src/addins/VersionControl/Subversion.Win32/SvnSharpClient.cs
@@ -9,6 +9,7 @@ using SharpSvn.Security;
using SvnRevision = MonoDevelop.VersionControl.Subversion.SvnRevision;
using MonoDevelop.Ide;
using MonoDevelop.Projects.Text;
+using System.Timers;
namespace SubversionAddinWindows
{
@@ -77,6 +78,8 @@ namespace SubversionAddinWindows
public class SvnSharpBackend: SubversionBackend
{
SvnClient client;
+ IProgressMonitor updateMonitor;
+ ProgressData progressData;
public override string GetTextBase (string file)
{
@@ -109,6 +112,9 @@ namespace SubversionAddinWindows
client.Authentication.SslServerTrustHandlers += new EventHandler<SvnSslServerTrustEventArgs> (AuthenticationSslServerTrustHandlers);
client.Authentication.UserNameHandlers += new EventHandler<SvnUserNameEventArgs> (AuthenticationUserNameHandlers);
client.Authentication.UserNamePasswordHandlers += new EventHandler<SvnUserNamePasswordEventArgs> (AuthenticationUserNamePasswordHandlers);
+ client.Progress += delegate (object sender, SvnProgressEventArgs e) {
+ ProgressWork (e, progressData, updateMonitor);
+ };
}
void AuthenticationUserNamePasswordHandlers (object sender, SvnUserNamePasswordEventArgs e)
@@ -217,7 +223,7 @@ namespace SubversionAddinWindows
// Redo path link.
repositoryPath = repositoryPath.TrimStart (new char[] { '/' });
foreach (var segment in target.Uri.Segments) {
- if (repositoryPath.StartsWith (segment))
+ if (repositoryPath.StartsWith (segment, StringComparison.Ordinal))
repositoryPath = repositoryPath.Remove (0, segment.Length);
}
@@ -294,7 +300,7 @@ namespace SubversionAddinWindows
return list;
}
- private RevisionAction ConvertRevisionAction (SvnChangeAction svnChangeAction)
+ static RevisionAction ConvertRevisionAction (SvnChangeAction svnChangeAction)
{
switch (svnChangeAction) {
case SvnChangeAction.Add: return RevisionAction.Add;
@@ -394,7 +400,7 @@ namespace SubversionAddinWindows
return list;
}
- VersionInfo CreateVersionInfo (Repository repo, SvnStatusEventArgs ent)
+ static VersionInfo CreateVersionInfo (Repository repo, SvnStatusEventArgs ent)
{
VersionStatus rs = VersionStatus.Unversioned;
Revision rr = null;
@@ -434,7 +440,7 @@ namespace SubversionAddinWindows
return ret;
}
- private VersionStatus ConvertStatus (SvnSchedule schedule, SvnStatus status)
+ static VersionStatus ConvertStatus (SvnSchedule schedule, SvnStatus status)
{
switch (schedule) {
case SvnSchedule.Add: return VersionStatus.Versioned | VersionStatus.ScheduledAdd;
@@ -504,7 +510,7 @@ namespace SubversionAddinWindows
lock (client) {
foreach (var path in paths) {
if (client.GetProperty (new SvnPathTarget (path.ParentDirectory), SvnPropertyNames.SvnIgnore, out result)) {
- int index = result.IndexOf (path.FileName + Environment.NewLine);
+ int index = result.IndexOf (path.FileName + Environment.NewLine, StringComparison.Ordinal);
result = (index < 0) ? result : result.Remove (index, path.FileName.Length+Environment.NewLine.Length);
client.SetProperty (path.ParentDirectory, SvnPropertyNames.SvnIgnore, result);
}
@@ -585,9 +591,17 @@ namespace SubversionAddinWindows
public bool SendingData;
}
+ class ProgressData
+ {
+ public int Bytes;
+ public Timer LogTimer = new Timer ();
+ public int Seconds;
+ }
+
void BindMonitor (SvnClientArgs args, IProgressMonitor monitor)
{
NotifData data = new NotifData ();
+ progressData = new ProgressData ();
args.Notify += delegate (object o, SvnNotifyEventArgs e) {
Notify (e, data, monitor);
@@ -598,9 +612,35 @@ namespace SubversionAddinWindows
args.SvnError += delegate (object o, SvnErrorEventArgs a) {
monitor.ReportError (a.Exception.Message, a.Exception.RootCause);
};
+
+ updateMonitor = monitor;
+ }
+
+ static void ProgressWork (SvnProgressEventArgs e, ProgressData data, IProgressMonitor monitor)
+ {
+ if (monitor == null)
+ return;
+
+ int currentProgress = (int)e.Progress;
+ int totalProgress = (int)e.TotalProgress;
+ if (totalProgress != -1 && currentProgress >= totalProgress) {
+ data.LogTimer.Close ();
+ return;
+ }
+
+ data.Bytes = currentProgress;
+ if (data.LogTimer.Enabled)
+ return;
+
+ data.LogTimer.Interval = 1000;
+ data.LogTimer.Elapsed += delegate (object sender, ElapsedEventArgs eea) {
+ data.Seconds += 1;
+ monitor.Log.WriteLine ("{0} bytes in {1} seconds", data.Bytes, data.Seconds);
+ };
+ data.LogTimer.Start ();
}
- void Notify (SvnNotifyEventArgs e, NotifData notifData, IProgressMonitor monitor)
+ static void Notify (SvnNotifyEventArgs e, NotifData notifData, IProgressMonitor monitor)
{
string actiondesc;
string file = e.Path;