Пример #1
0
        private void CheckResult(Uri repositoryUri)
        {
            using (SvnPoolRemoteSession session = GetSession(repositoryUri))
            {
                SvnRemoteNodeKindArgs nka = new SvnRemoteNodeKindArgs();
                nka.ThrowOnError = true;

                SvnNodeKind kind;

                string path = session.MakeRelativePath(repositoryUri);

                if (session.GetNodeKind(path, nka, out kind))
                {
                    switch (kind)
                    {
                    case SvnNodeKind.Directory:
                    {
                        Uri parentUri = new Uri(repositoryUri, repositoryUri.PathAndQuery.EndsWith("/", StringComparison.Ordinal) ? "../" : "./");
                        return;
                    }

                    case SvnNodeKind.File:
                    {
                        SvnRemoteCommonArgs ca = new SvnRemoteCommonArgs();
                        ca.ThrowOnError = true;

                        Uri parentUri = new Uri(repositoryUri, "./");
                        Uri reposRoot;
                        if (!session.GetRepositoryRoot(ca, out reposRoot))
                        {
                            return;
                        }
                        return;
                    }
                    }
                }
            }
        }
Пример #2
0
        void OnFill(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException();
            }

            try
            {
                using (SvnPoolRemoteSession session = GetSession(uri))
                {
                    string path = session.MakeRelativePath(uri);

                    SvnRemoteListArgs la = new SvnRemoteListArgs();
                    la.ThrowOnError    = false;
                    la.RetrieveEntries = SvnDirEntryItems.Kind;

                    Uri repositoryRoot        = null;
                    List <ListViewItem> items = new List <ListViewItem>();

                    SvnRemoteNodeKindArgs commonArgs = new SvnRemoteNodeKindArgs();
                    commonArgs.ThrowOnError = false;
                    SvnNodeKind kind;

                    session.GetNodeKind(path, commonArgs, out kind);

                    session.GetRepositoryRoot(out repositoryRoot);

                    bool ok = (kind == SvnNodeKind.File) || session.List(path, la,
                                                                         delegate(object sender, SvnRemoteListEventArgs e)
                    {
                        if (string.IsNullOrEmpty(e.Path))
                        {
                            return;
                        }

                        ListViewItem lvi = new ListViewItem();
                        lvi.Tag          = e.Uri;
                        lvi.Text         = SvnTools.GetFileName(e.Uri);
                        lvi.ImageIndex   = (e.Entry.NodeKind == SvnNodeKind.Directory) ? _dirOffset : _fileOffset;
                        items.Add(lvi);
                    });


                    if (IsHandleCreated)
                    {
                        Invoke((AnkhAction) delegate()
                        {
                            if (uri == _currentUri)
                            {
                                dirView.Items.Clear();

                                if (repositoryRoot != null && !_repositoryRoots.Contains(repositoryRoot))
                                {
                                    _repositoryRoots.Add(repositoryRoot);
                                }

                                if (ok)
                                {
                                    IFileIconMapper mapper = Context != null ? Context.GetService <IFileIconMapper>() : null;

                                    foreach (ListViewItem item in items)
                                    {
                                        if (item.ImageIndex == _fileOffset)
                                        {
                                            string ext = Path.GetExtension(item.Text);

                                            if (!string.IsNullOrEmpty(ext))
                                            {
                                                int n = mapper.GetIconForExtension(ext);

                                                if (n > 0)
                                                {
                                                    item.ImageIndex = n;
                                                }
                                            }
                                        }
                                    }

                                    SetView(items.ToArray());
                                    _walking[uri] = items;
                                }
                                else
                                {
                                    string message =
                                        string.Format("<{0}>",
                                                      la.LastException != null ? la.LastException.Message : "Nothing");
                                    dirView.Items.Add(message);
                                }
                            }
                        });
                    }
                }
            }
            catch (SvnException svnEx)
            {
                BeginInvoke((AnkhAction) delegate()
                {
                    dirView.Items.Clear();

                    string message =
                        string.Format("<{0}>", svnEx.Message);
                    dirView.Items.Add(message);
                });
            }
            finally
            {
                BeginInvoke((AnkhAction) delegate()
                {
                    lock (_running)
                    {
                        _running.Remove(uri);

                        if (_running.Count == 0)
                        {
                            if (_busy != null && _loading)
                            {
                                _loading = false;
                                _busy.Hide();
                            }
                        }
                    }
                });
                // Exception or something
            }
        }
Пример #3
0
        private void CheckResult(Uri combined, bool forceLoad)
        {
            using (SvnPoolRemoteSession session = GetSession(combined))
            {
                SvnRemoteCommonArgs ca = new SvnRemoteCommonArgs();
                ca.ThrowOnError = false;

                SvnRemoteNodeKindArgs nka = new SvnRemoteNodeKindArgs();
                nka.ThrowOnError = false;

                SvnRemoteStatArgs sa = new SvnRemoteStatArgs();
                sa.ThrowOnError = false;
                SvnNodeKind kind;

                string path = session.MakeRelativePath(combined);

                if (session.GetNodeKind(path, nka, out kind))
                {
                    Invoke((AnkhAction) delegate
                    {
                        switch (kind)
                        {
                        case SvnNodeKind.Directory:
                            {
                                Uri parentUri = new Uri(combined, combined.PathAndQuery.EndsWith("/", StringComparison.Ordinal) ? "../" : "./");

                                if (!forceLoad && parentUri.ToString() != urlBox.Text)
                                {
                                    return;     // The user selected something else while we where busy
                                }
                                // The user typed a directory Url without ending '/'
                                fileNameBox.Text = combined.ToString().TrimEnd('/') + '/';
                                UpdateDirectories();
                                return;
                            }

                        case SvnNodeKind.File:
                            {
                                Uri parentUri = new Uri(combined, "./");

                                if (parentUri.ToString() != urlBox.Text)
                                {
                                    return;     // The user selected something else while we where busy
                                }
                                SelectedUri = combined;

                                Uri reposRoot;
                                if (!session.GetRepositoryRoot(ca, out reposRoot))
                                {
                                    return;
                                }

                                SelectedRepositoryRoot = reposRoot;
                                DialogResult           = DialogResult.OK;
                                return;
                            }
                        }
                    });
                }
            }
        }