Пример #1
0
        public void GetIgnoredFiles(String refID, String directoryName, bool recursive)
        {
            if (!this.Project.DataTypeReferences.Contains(refID))
            {
                throw new BuildException(String.Format("The refid {0} is not defined.", refID));
            }

            FileSet RefFileSet = (FileSet)this.Project.DataTypeReferences[refID];

            try
            {
                AprPool          p   = Svn.PoolCreate();
                SvnClientContext ctx = SvnClientContext.Create(p);
                ctx.Config  = SvnConfig.GetConfig(p);
                this.Client = new SvnClient(ctx, p);

                String AdminDir = ".svn";
                if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("SVN_ASP_DOT_NET_HACK")))
                {
                    AdminDir = "_svn";
                }

                this.Client.SetWcAdmDir(AdminDir);
                this.Client.AddSimpleProvider();
                this.Client.AddUsernameProvider();
                this.Client.AddSslServerTrustFileProvider();
                this.Client.AddSslClientCertFileProvider();
                this.Client.AddSslClientCertPwFileProvider();
                this.Client.OpenAuth();
                AprArray crapList = this.Client.PropList(directoryName, new SvnRevision(Svn.Revision.Working), recursive);
                crapList.ElementType = typeof(SvnClientPropListItem);
                SvnClientPropListItem[] props = new SvnClientPropListItem[crapList.Count];
                crapList.CopyTo(props, 0);

                foreach (SvnClientPropListItem property in props)
                {
                    foreach (AprHashEntry entry in property.PropHash)
                    {
                        if (entry.KeyAsString == "svn:ignore")
                        {
                            foreach (String ignored in new SvnString(entry.Value).Data.Value.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
                            {
                                string FullPath = Path.Combine(property.NodeName.ToString(), ignored);

                                RefFileSet.Includes.Add(FullPath);
                            }
                        }
                    }
                }
            }
            finally
            {
                if (this.Client != null)
                {
                    this.Client.Pool.Destroy();
                }
            }
        }
Пример #2
0
        private void DeleteIgnoredFiles()
        {
            AprArray crapList = this.Client.PropList(this.Directory, new SvnRevision(Svn.Revision.Working), this.Recurse);

            crapList.ElementType = typeof(SvnClientPropListItem);
            SvnClientPropListItem[] props = new SvnClientPropListItem[crapList.Count];
            crapList.CopyTo(props, 0);

            foreach (SvnClientPropListItem property in props)
            {
                foreach (AprHashEntry entry in property.PropHash)
                {
                    if (entry.KeyAsString == "svn:ignore")
                    {
                        foreach (String ignored in new SvnString(entry.Value).Data.Value.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            string FullPath = Path.Combine(property.NodeName.ToString(), ignored);

                            try
                            {
                                if (File.Exists(FullPath))
                                {
                                    if (OkayToDelete(FullPath))
                                    {
                                        File.Delete(FullPath);
                                    }
                                }
                                else if (System.IO.Directory.Exists(FullPath))
                                {
                                    if (OkayToDelete(FullPath))
                                    {
                                        That.Computer.FileSystem.DeleteDirectory(FullPath, Microsoft.VisualBasic.FileIO.DeleteDirectoryOption.DeleteAllContents);
                                    }
                                }
                            }
                            catch (IOException ex)
                            {
                                throw new BuildException(String.Format("Error trying to delete: '{0}'.", FullPath), this.Location);
                            }
                        }
                    }
                }
            }
        }