protected virtual void ValidateAdd(object sender, CancelEventArgs e) { ISvnClientPool clientPool = Context.GetService <ISvnClientPool>(); if (localFolder.SelectedItem == null) { errorProvider1.SetError(localFolder, "Please select a working copy path"); e.Cancel = true; return; } if (RepositoryAddUrl == null) { errorProvider1.SetError(repositoryTree, "Please select a location in the repository to add to"); e.Cancel = true; return; } using (SvnClient sc = clientPool.GetClient()) { SvnInfoArgs ia = new SvnInfoArgs(); ia.ThrowOnError = false; Collection <SvnInfoEventArgs> info; bool result = sc.GetInfo(RepositoryUri, ia, out info); if (!result) { errorProvider1.SetError(repositoryTree, "Please select a valid location in the repository to add to"); e.Cancel = true; return; } } }
private void EnsureCredentials(ScmUserNamePasswordEventArgs e) { ISvnClientPool pool = (Context != null) ? Context.GetService <ISvnClientPool>() : null; if (pool != null) { using (SvnPoolClient client = pool.GetNoUIClient()) { EventHandler <SvnUserNamePasswordEventArgs> handler = delegate(object sender, SvnUserNamePasswordEventArgs args) { args.Save = true; args.UserName = e.UserName; args.Password = e.Password; }; client.Authentication.UserNamePasswordHandlers += handler; try { SvnInfoArgs infoArgs = new SvnInfoArgs(); infoArgs.ThrowOnError = false; System.Collections.ObjectModel.Collection <SvnInfoEventArgs> info; if (client.GetInfo(SvnUriTarget.FromString(e.RepositoryUri), infoArgs, out info)) { } } finally { client.Authentication.UserNamePasswordHandlers -= handler; } } } }
// Note: We can only implement our own Dispose over the existing // As VC++ unconditionally calls GC.SuppressFinalize() just before returning // Luckily the using construct uses the last defined or IDisposable methods which we can override protected SvnPoolRemoteSession(ISvnClientPool pool) { if (pool == null) { throw new ArgumentNullException("pool"); } _pool = pool; }
/// <summary> /// Call this to start the operation. /// </summary> /// <param name="caption">The caption to use in the progress dialog.</param> public void Start(string caption) { Thread thread = new Thread(new ParameterizedThreadStart(this.Run)); ISvnClientPool pool = GetService <ISvnClientPool>(); IAnkhDialogOwner dialogOwner = GetService <IAnkhDialogOwner>(); using (ProgressDialog dialog = new ProgressDialog()) using (SvnClient client = pool.GetClient()) using (CreateUpdateReport ? BindOutputPane(client) : null) using (dialog.Bind(client)) { _sync = dialog; dialog.Caption = caption; dialog.Context = this; thread.Name = "AnkhSVN Worker"; bool threadStarted = false; dialog.HandleCreated += delegate { if (!threadStarted) { threadStarted = true; thread.Start(client); } }; _invoker = dialog; do { if (!_closed) { dialog.ShowDialog(this); } else { Application.DoEvents(); } // Show the dialog again if the thread join times out // Do this to handle the acase where the service wants to // pop up a dialog before canceling. // BH: Experienced this 2008-09-29 when our repository server // accepted http connections but didn't handle them in time }while (!thread.Join(2500)); } if (_cancelled) { // NOOP } else if (_exception != null) { throw new ProgressRunnerException(this._exception); } }
private SvnPoolRemoteSession GetSession(Uri uri) { ISvnClientPool pool = (Context != null) ? Context.GetService <ISvnClientPool>() : null; if (pool != null) { return(pool.GetRemoteSession(uri, true)); } throw new InvalidOperationException(); }
protected SvnClient GetClient() { ISvnClientPool pool = (Context != null) ? Context.GetService <ISvnClientPool>() : null; if (pool != null) { return(pool.GetClient()); } else { return(new SvnClient()); } }
public SvnWorkingCopyClient GetWcClient() { ISvnClientPool pool = (Context != null) ? Context.GetService <ISvnClientPool>() : null; if (pool != null) { return(pool.GetWcClient()); } else { return(new SvnWorkingCopyClient()); } }
private void MarkResolved() { ISvnClientPool pool = GetService <ISvnClientPool>(); if (pool == null) { return; } using (SvnClient client = pool.GetClient()) { client.Resolved(_toMonitor); } }
/// <summary> /// Returns the client to the threadpool, or disposes the cleint /// </summary> protected virtual void ReturnClient() { // In our common implementation this code is not used // Update AnkhSvnClientPool.AnkhSvnPoolClient if (_shouldDispose || _nReturns++ > 1024 || IsCommandRunning || !_pool.ReturnClient(this)) { // Recycle the SvnPoolRemoteSession if at least one of the following is true // * A command is still active in it (User error) // * The pool doesn't accept the client (Pool error) // * The client has handled 1024 sessions (Garbage collection of apr memory) _pool = null; InnerDispose(); } }
protected override void SaveSettingsCore() { Config.InteractiveMergeOnConflict = interactiveMergeOnConflict.Checked; Config.AutoAddEnabled = autoAddFiles.Checked; Config.SuppressLockingUI = autoLockFiles.Checked; Config.FlashWindowWhenOperationCompletes = flashWindowAfterOperation.Checked; Config.PCDoubleClickShowsChanges = pcDefaultDoubleClick.SelectedIndex == 1; Config.EnableTortoiseSvnHooks = clientSideHooks.Checked; Config.PreferPuttyAsSSH = preferPutty.Checked; if (Context != null) { ISvnClientPool pool = Context.GetService <ISvnClientPool>(); pool.FlushAllClients(); } }
/// <summary> /// Returns the client to the threadpool, or disposes the cleint /// </summary> protected virtual void ReturnClient() { // In our common implementation this code is not used // Update AnkhSvnClientPool.AnkhSvnPoolClient if (_shouldDispose || _nReturns++ > 1024 || IsCommandRunning || !_pool.ReturnClient(this)) { // Recycle the SvnPoolRemoteSession if at least one of the following is true // * A command is still active in it (User error) // * The pool doesn't accept the client (Pool error) // * The client has handled 1024 sessions (Garbage collection of apr memory) _pool = null; InnerDispose(); } }
// Note: We can only implement our own Dispose over the existing // As VC++ unconditionally calls GC.SuppressFinalize() just before returning // Luckily the using construct uses the last defined or IDisposable methods which we can override protected SvnPoolRemoteSession(ISvnClientPool pool) { if (pool == null) throw new ArgumentNullException("pool"); _pool = pool; }