Ejemplo n.º 1
0
        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;
                }
            }
        }
Ejemplo n.º 2
0
        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;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        // 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;
        }
Ejemplo n.º 4
0
            /// <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);
                }
            }
Ejemplo n.º 5
0
        private SvnPoolRemoteSession GetSession(Uri uri)
        {
            ISvnClientPool pool = (Context != null) ? Context.GetService <ISvnClientPool>() : null;

            if (pool != null)
            {
                return(pool.GetRemoteSession(uri, true));
            }

            throw new InvalidOperationException();
        }
Ejemplo n.º 6
0
        protected SvnClient GetClient()
        {
            ISvnClientPool pool = (Context != null) ? Context.GetService <ISvnClientPool>() : null;

            if (pool != null)
            {
                return(pool.GetClient());
            }
            else
            {
                return(new SvnClient());
            }
        }
Ejemplo n.º 7
0
        public SvnWorkingCopyClient GetWcClient()
        {
            ISvnClientPool pool = (Context != null) ? Context.GetService <ISvnClientPool>() : null;

            if (pool != null)
            {
                return(pool.GetWcClient());
            }
            else
            {
                return(new SvnWorkingCopyClient());
            }
        }
Ejemplo n.º 8
0
            private void MarkResolved()
            {
                ISvnClientPool pool = GetService <ISvnClientPool>();

                if (pool == null)
                {
                    return;
                }

                using (SvnClient client = pool.GetClient())
                {
                    client.Resolved(_toMonitor);
                }
            }
Ejemplo n.º 9
0
        /// <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();
            }
        }
Ejemplo n.º 10
0
        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();
            }
        }
Ejemplo n.º 11
0
        /// <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();
            }
        }
Ejemplo n.º 12
0
        // 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;
        }