public void SomeGlobalTests()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Default);

            using (SvnClient client = NewSvnClient(false, false))
            {
                Assert.That(SvnClient.AdministrativeDirectoryName, Is.EqualTo(".svn"));
                Assert.That(SvnClient.Version, Is.GreaterThanOrEqualTo(new Version(1, 5, 0)));
                Assert.That(SvnClient.SharpSvnVersion, Is.GreaterThan(new Version(1, 5, 0)));
                Assert.That(client.GetRepositoryRoot(sbox.Uri), Is.EqualTo(sbox.RepositoryUri));
                Assert.That(client.GetRepositoryRoot(sbox.Wc), Is.EqualTo(sbox.RepositoryUri));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SvnOrigin"/> class from a SvnTarget
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="target">The target.</param>
        /// <param name="reposRoot">The repos root or <c>null</c> to retrieve the repository root from target</param>
        public SvnOrigin(IAnkhServiceProvider context, SvnTarget target, Uri reposRoot)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            else if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            SvnPathTarget pt = target as SvnPathTarget;

            if (pt != null)
            {
                SvnItem item = context.GetService <ISvnStatusCache>()[pt.FullPath];

                if (item == null || !item.IsVersioned)
                {
                    throw new InvalidOperationException("Can only create a SvnOrigin from versioned items");
                }

                _target    = target;
                _uri       = item.Status.Uri;
                _reposRoot = item.WorkingCopy.RepositoryRoot; // BH: Prefer the actual root over the provided
                return;
            }

            SvnUriTarget ut = target as SvnUriTarget;

            if (ut != null)
            {
                _target = ut;
                _uri    = ut.Uri;
                if (reposRoot != null)
                {
                    _reposRoot = reposRoot;
                }
                else
                {
                    using (SvnClient client = context.GetService <ISvnClientPool>().GetClient())
                    {
                        _reposRoot = client.GetRepositoryRoot(ut.Uri);

                        if (_reposRoot == null)
                        {
                            throw new InvalidOperationException("Can't retrieve the repository root of the UriTarget");
                        }

#if DEBUG
                        Debug.Assert(!_reposRoot.MakeRelativeUri(_uri).IsAbsoluteUri);
#endif
                    }
                }

                return;
            }

            throw new InvalidOperationException("Invalid target type");
        }
        private Uri GetRepositoryRoot()
        {
            SettingsCache cache = _cache;

            if (cache.SolutionFilename == null)
            {
                return(null);
            }

            using (SvnClient client = GetService <ISvnClientPool>().GetNoUIClient())
            {
                return(cache.RepositoryRoot = client.GetRepositoryRoot(cache.SolutionFilename));
            }
        }
Beispiel #4
0
        private Uri GetRepositoryRoot()
        {
            if (_checkedUri)
            {
                return(null);
            }


            _checkedUri = true;
            using (SvnClient client = _context.GetService <ISvnClientPool>().GetNoUIClient())
            {
                return(_repositoryRoot = client.GetRepositoryRoot(FullPath));
            }
        }
Beispiel #5
0
        private static long CommitNGetRevisionNumber(string source, string comment, SvnClient client)
        {
            SvnCommitArgs ca = new SvnCommitArgs();

            ca.LogMessage = comment;
            SvnCommitResult commitResults;
            long            revision;

            bool success = client.Commit(source, ca, out commitResults);

            if (ReferenceEquals(commitResults, null))
            {
                SvnInfoEventArgs svnInfo = GetLatestRevisionInfo(client, client.GetRepositoryRoot(source).AbsoluteUri);
                revision = svnInfo.LastChangeRevision;
            }
            else
            {
                revision = commitResults.Revision;
            }

            return(revision);
        }
Beispiel #6
0
        private void CheckOutProject(CheckOutArguments arg)
        {
            using (SvnClient client = new SvnClient())
            {
                // Bind the SharpSvn UI to our client for SSL certificate and credentials
                SvnUIBindArgs bindArgs = new SvnUIBindArgs();
                SvnUI.Bind(client, bindArgs);

                if (arg.ShowMoreLogInformation)
                {
                    client.Notify += new EventHandler <SvnNotifyEventArgs>(client_Notify);
                }
                client.Cancel += new EventHandler <SvnCancelEventArgs>(client_Cancel);

                Uri rootUri = client.GetRepositoryRoot(arg.ProjectWorkspaceUri);

                myIfsSvn.CheckOut(client, arg.ProjectNbprojectUri, arg.CheckOutPathNbproject, new SvnCheckOutArgs()
                {
                    ThrowOnError = false, IgnoreExternals = true
                }, arg.CleanUpWhenLocked);

                myIfsSvn.CheckOut(client, arg.ProjectWorkspaceUri, arg.CheckOutPathWorkspace, new SvnCheckOutArgs()
                {
                    IgnoreExternals = true
                }, arg.CleanUpWhenLocked);
                myIfsSvn.CheckOut(client, arg.ProjectDocumentUri, arg.CheckOutPathDocument, new SvnCheckOutArgs()
                {
                    IgnoreExternals = true
                }, arg.CleanUpWhenLocked);

                this.Log("Starting Component Checkout [" + DateTime.Now.ToString() + "]", arg.ShowMoreLogInformation);

                Uri componentUri;
                if (arg.HasDocCompornents)
                {
                    componentUri = new Uri(Properties.Resources.ServerDocumentationOnlinedocframework.Replace("^/", rootUri.AbsoluteUri));

                    myIfsSvn.CheckOut(client, componentUri, arg.CheckOutPathDocumentEn, null, arg.CleanUpWhenLocked);
                }

                foreach (SvnComponent component in arg.CompornentArray)
                {
                    componentUri = new Uri(component.Path.Replace("^/", rootUri.AbsoluteUri));

                    this.Log(component.Name, arg.ShowMoreLogInformation);

                    if (component.Type == SvnComponent.SvnComponentType.Work)
                    {
                        myIfsSvn.CheckOut(client, componentUri, arg.CheckOutPathWorkspace + @"\" + component.Name, null, arg.CleanUpWhenLocked);
                    }
                    else if (component.Type == SvnComponent.SvnComponentType.Document)
                    {
                        List <SvnListEventArgs> folderList = myIfsSvn.GetFolderList(componentUri);
                        folderList.RemoveAt(0);
                        foreach (SvnListEventArgs folder in folderList)
                        {
                            myIfsSvn.CheckOut(client, folder.Uri, arg.CheckOutPathDocumentEn + @"\" + folder.Name, null, arg.CleanUpWhenLocked);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Determines all directories OR files at <url>
        /// </summary>
        /// <param name="url">URL of the SVN Repository</param>
        /// <returns>List of directories or files. Null if url is invalid.</returns>
        ///

        //TODO: Liste<string, string> mit lokalem pfad und tatsächlichem pfad (svn:external)
        //-> artifact to clean = lokales verzeichnis
        //-> watermark = tatsächliches verzeichnis



        public Dictionary <string, string> GetItems(string svnUrl, ItemType itemType, bool recursive, string versionSpec)
        {
            SvnNodeKind searchedItemType = SvnNodeKind.Unknown;

            if (itemType == ItemType.Directory)
            {
                searchedItemType = SvnNodeKind.Directory;
            }
            else if (itemType == ItemType.File)
            {
                searchedItemType = SvnNodeKind.File;
            }

            SvnListArgs args = new SvnListArgs();

            args.Revision         = ConvertToRevsion(versionSpec);
            args.IncludeExternals = true;

            if (recursive)
            {
                args.Depth = SvnDepth.Infinity;
            }
            else
            {
                args.Depth = SvnDepth.Children;
            }

            var svnRootPath = _svn.GetRepositoryRoot(new Uri(svnUrl));

            Collection <SvnListEventArgs> contents;
            Dictionary <string, string>   ret = new Dictionary <string, string>();

            try
            {
                if (_svn.GetList(new Uri(svnUrl), args, out contents))
                {
                    foreach (SvnListEventArgs item in contents)
                    {
                        //first entry is always empty
                        if (!string.IsNullOrEmpty(item.Path) && item.Entry.NodeKind == searchedItemType)
                        {
                            if (string.IsNullOrEmpty(item.ExternalTarget))
                            {
                                ret.Add(string.Format("{0}/{1}", svnUrl, item.Path), string.Format("{0}/{1}", svnUrl, item.Path));
                            }
                            else
                            {
                                //Substring cuts the obosolte / at beginning
                                //ret.Add(string.Format("{0}{1}/{2}", svnRootPath, item.BasePath.Substring(1), item.Path));
                                ret.Add(string.Format("{0}{1}/{2}", svnRootPath, item.BasePath.Substring(1), item.Path), string.Format("{0}/{1}/{2}", svnUrl, item.ExternalTarget, item.Path));
                            }
                        }
                    }
                }

                return(ret);
            }
            catch (SvnFileSystemException)
            {
                return(ret);
            }
        }
 private void EditButtonClick(object sender, EventArgs e)
 {
     if (listAddonsList.SelectedItems.Count > 1)
     {
         MessageBox.Show(Resources.editTooManySelected, Resources.editErrorHeader);
         return;
     }
     var addonDir = _installDir + "\\" + listAddonsList.SelectedItems[0].Text;
     var answer = Microsoft.VisualBasic.Interaction.InputBox("Give the new url of the repository");
     if (!string.IsNullOrEmpty(answer))
     {
         if (MessageBox.Show(@"Are you sure you want to relocate addon to " + answer, @"Continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
         {
             return;
         }
         if (Directory.Exists(addonDir + "\\.git"))
         {
             if (answer.IndexOf(".git") != 0)
             {
                 var process = Process.Start("git", "remote rm origin");
                 process.WaitForExit();
                 process.StartInfo.Arguments = "remote add origin " + answer;
                 process.Start();
             }
             else
             {
                 MessageBox.Show(@"Url cannot be resolved", @"Cannot resolve Url");
             }
         }
         else
         {
             Uri newUrl;
             try
             {
                 newUrl = new Uri(answer);
             }
             catch (Exception)
             {
                 MessageBox.Show(@"Url cannot be resolved", @"Cannot resolve Url");
                 return;
             }
             var svnClient = new SvnClient();
             var sourceUrl = svnClient.GetRepositoryRoot(addonDir);
             svnClient.Relocate(addonDir, sourceUrl, newUrl);
         }
     }
 }