Ejemplo n.º 1
0
 public SvnData(string str, AprPool pool)
 {
     byte[] utf8str = Encoder.GetBytes(str);
     mString = pool.Alloc(utf8str.Length + 1);
     Marshal.Copy(utf8str, 0, mString, utf8str.Length);
     Marshal.WriteByte(mString, utf8str.Length, 0);
 }
Ejemplo n.º 2
0
        public void TimeExpPoolTest()
        {
            AprPool p = AprPool.Create();

            Assert.IsFalse(p.IsNull, "#F01");

            AprTimeExp t = AprTimeExp.Alloc(p);

            Assert.IsFalse(t.IsNull, "#F02");

            TimeExpTest1(t, "#F");

            t.ClearPtr();
            t = AprTimeExp.Alloc(p);
            Assert.IsFalse(t.IsNull, "#F03");

            TimeExpTest2(t, "#F");

            t.ClearPtr();
            t = AprTimeExp.Alloc(p);
            Assert.IsFalse(t.IsNull, "#F04");

            TimeExpTest3(t, "#F");

            t.ClearPtr();
            t = AprTimeExp.Alloc(p);
            Assert.IsFalse(t.IsNull, "#F04");

            TimeExpTest4(t, "#F");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#F05");
        }
Ejemplo n.º 3
0
 internal void Detach(bool keepProperties)
 {
     try
     {
         if (keepProperties)
         {
             GC.KeepAlive(Name);
             GC.KeepAlive(Uri);
             GC.KeepAlive(RepositoryUri);
             GC.KeepAlive(RepositoryId);
             GC.KeepAlive(CopiedFrom);
             GC.KeepAlive(ConflictOldFile);
             GC.KeepAlive(ConflictNewFile);
             GC.KeepAlive(ConflictWorkFile);
             GC.KeepAlive(PropertyRejectFile);
             GC.KeepAlive(Checksum);
             GC.KeepAlive(LastChangeAuthor);
             GC.KeepAlive(LockToken);
             GC.KeepAlive(LockOwner);
             GC.KeepAlive(LockComment);
             GC.KeepAlive(ChangeList);
             GC.KeepAlive(FileExternalPath);
             GC.KeepAlive(FileExternalRevision);
             GC.KeepAlive(FileExternalOperationalRevision);
         }
     }
     finally
     {
         _client = null;
         _status = null;
         _entry  = null;
         _pool   = null;
     }
 }
Ejemplo n.º 4
0
        protected internal override unsafe void Detach(bool keepProperties)
        {
            try
            {
                if (keepProperties)
                {
                    // Use all properties to get them cached in .Net memory
                    GC.KeepAlive(ChangedPaths);
                    GC.KeepAlive(Author);
                    GC.KeepAlive(LogMessage);
                    GC.KeepAlive(RevisionProperties);
                }

                if (_changeItemsToDetach != null)
                {
                    foreach (SvnChangeItem i in _changeItemsToDetach)
                    {
                        i.Detach(keepProperties);
                    }
                }
            }
            finally
            {
                _entry               = null;
                _pool                = null;
                _pcMessage           = null;
                _pcAuthor            = null;
                _changeItemsToDetach = null;
                base.Detach(keepProperties);
            }
        }
Ejemplo n.º 5
0
        internal void Detach(bool keepProperties)
        {
            try
            {
                if (keepProperties)
                {
                    GC.KeepAlive(Name);
                    GC.KeepAlive(FullPath);
                    GC.KeepAlive(PropertyName);
                    GC.KeepAlive(MimeType);
                    GC.KeepAlive(BaseFile);
                    GC.KeepAlive(TheirFile);
                    GC.KeepAlive(MyFile);
                    GC.KeepAlive(MergedFile);
                    GC.KeepAlive(PropertyRejectFile);

                    GC.KeepAlive(LeftSource);
                    GC.KeepAlive(RightSource);
                }

                _leftOrigin?.Detach(keepProperties);
                _rightOrigin?.Detach(keepProperties);
            }
            finally
            {
                _description = null;
                _pool        = null;
            }
        }
Ejemplo n.º 6
0
        /// <summary>Adds the specified path</summary>
        /// <returns>true if the operation succeeded; false if it did not</returns>
        /// <exception type="SvnException">Operation failed and args.ThrowOnError = true</exception>
        /// <exception type="ArgumentException">Parameters invalid</exception>
        public unsafe bool Add(string path, SvnAddArgs args)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            EnsureState(SvnContextState.ConfigLoaded, SvnExtendedState.MimeTypesLoaded);
            using var pool  = new AprPool(_pool);
            using var store = new ArgsStore(this, args, pool);

            svn_error_t r = svn_client.svn_client_add5(
                pool.AllocDirent(path),
                (svn_depth_t)args.Depth,
                args.Force,
                args.NoIgnore,
                args.NoAutoProps,
                args.AddParents,
                CtxHandle,
                pool.Handle);

            return(args.HandleResult(this, r, path));
        }
Ejemplo n.º 7
0
        public void CountCopy()
        {
            AprPool p = AprPool.Create();

            Assert.IsFalse(p.IsNull, "#C01");

            AprHash h = AprHash.Make(p);

            Assert.IsFalse(h.IsNull, "#C02");
            Assert.AreEqual(0, h.Count, "#C03");

            h.Set("A", "A1");
            h.Set("B", "B2");
            h.Set("C", "C3");
            h.Set("D", "D4");
            h.Set("E", "E5");
            Assert.AreEqual(5, h.Count, "#C04");

            AprHash ch = h.Copy(p);

            Assert.IsTrue(((IntPtr)h).ToInt32() != ((IntPtr)ch).ToInt32(), "#C05");
            Assert.AreEqual(h.Count, ch.Count, "#C06");
            Assert.AreEqual("A1", ch.GetAsString("A"), "#C07");
            Assert.AreEqual("B2", ch.GetAsString("B"), "#C08");
            Assert.AreEqual("C3", ch.GetAsString("C"), "#C09");
            Assert.AreEqual("D4", ch.GetAsString("D"), "#C10");
            Assert.AreEqual("E5", ch.GetAsString("E"), "#C11");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#C12");
        }
Ejemplo n.º 8
0
        /// <summary>Updates the specified paths to the specified revision</summary>
        /// <exception type="SvnException">Operation failed and args.ThrowOnError = true</exception>
        /// <exception type="ArgumentException">Parameters invalid</exception>
        /// <returns>true if the operation succeeded; false if it did not</returns>
        public unsafe bool Update(ICollection <string> paths, SvnUpdateArgs args, out SvnUpdateResult updateResult)
        {
            if (paths == null)
            {
                throw new ArgumentNullException(nameof(paths));
            }
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            updateResult = null;

            foreach (string s in paths)
            {
                if (string.IsNullOrEmpty(s))
                {
                    throw new ArgumentException(SharpSvnStrings.ItemInListIsNull, nameof(paths));
                }
                if (!IsNotUri(s))
                {
                    throw new ArgumentException(SharpSvnStrings.ArgumentMustBeAPathNotAUri, nameof(paths));
                }
            }

            EnsureState(SvnContextState.AuthorizationInitialized);
            using var pool  = new AprPool(_pool);
            using var store = new ArgsStore(this, args, pool);

            var aprPaths = new AprArray <string, AprCStrDirentMarshaller>(paths, pool);

            apr_array_header_t.__Internal *revs_ptr = null;
            svn_opt_revision_t             uRev     = args.Revision.Or(SvnRevision.Head).AllocSvnRevision(pool);

            svn_error_t r = svn_client.svn_client_update4(
                (void **)&revs_ptr,
                aprPaths.Handle,
                uRev,
                (svn_depth_t)args.Depth,
                args.KeepDepth,
                args.IgnoreExternals,
                args.AllowObstructions,
                args.AddsAsModifications,
                args.UpdateParents,
                CtxHandle,
                pool.Handle);

            if (args.HandleResult(this, r, paths))
            {
                var revs = apr_array_header_t.__CreateInstance(new IntPtr(revs_ptr));

                var aprRevs = new AprArray <long, AprSvnRevNumMarshaller>(revs, pool);

                updateResult = new SvnUpdateResult(paths, aprRevs.ToArray(), (paths.Count >= 1) ? aprRevs[0] : -1);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 9
0
        public void CopyTo()
        {
            AprPool p = AprPool.Create();

            Assert.IsFalse(p.IsNull, "#C01");

            AprHash h = AprHash.Make(p);

            Assert.IsFalse(h.IsNull, "#C02");

            h.Set("A", "A1");
            h.Set("B", "B2");
            h.Set("C", "C3");
            h.Set("D", "D4");
            h.Set("E", "E5");

            AprHashEntry[] a = new AprHashEntry[5];
            h.CopyTo(a, 0);
            Assert.AreEqual("A", a[0].KeyAsString, "#C03");
            Assert.AreEqual("A1", a[0].ValueAsString, "#C04");
            Assert.AreEqual("B", a[1].KeyAsString, "#C05");
            Assert.AreEqual("B2", a[1].ValueAsString, "#C06");
            Assert.AreEqual("C", a[2].KeyAsString, "#C07");
            Assert.AreEqual("C3", a[2].ValueAsString, "#C08");
            Assert.AreEqual("D", a[3].KeyAsString, "#C09");
            Assert.AreEqual("D4", a[3].ValueAsString, "#C10");
            Assert.AreEqual("E", a[4].KeyAsString, "#C11");
            Assert.AreEqual("E5", a[4].ValueAsString, "#C12");


            p.Destroy();
            Assert.IsTrue(p.IsNull, "#C13");
        }
Ejemplo n.º 10
0
        public void SetGet()
        {
            AprPool p = AprPool.Create();

            Assert.IsFalse(p.IsNull, "#B01");

            AprHash h = AprHash.Make(p);

            Assert.IsFalse(h.IsNull, "#B02");

            h.Set("A", "A1");
            h.Set("B", "B2");
            h.Set("C", "C3");
            h.Set("D", "D4");
            h.Set("E", "E5");

            Assert.AreEqual("A1", h.GetAsString("A"), "#B03");
            Assert.AreEqual("B2", h.GetAsString("B"), "#B04");
            Assert.AreEqual("C3", h.GetAsString("C"), "#B05");
            Assert.AreEqual("D4", h.GetAsString("D"), "#B06");
            Assert.AreEqual("E5", h.GetAsString("E"), "#B07");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#B08");
        }
Ejemplo n.º 11
0
        /// <summary>Detaches the SvnEventArgs from the unmanaged storage; optionally keeping the property values for later use</summary>
        /// <description>After this method is called all properties are either stored managed, or are no longer readable</description>
        protected internal override void Detach(bool keepProperties)
        {
            try
            {
                if (keepProperties)
                {
                    // Use all properties to get them cached in .Net memory
                    GC.KeepAlive(Path);
                    GC.KeepAlive(FullPath);
                    GC.KeepAlive(Uri);
                    GC.KeepAlive(MimeType);
                    GC.KeepAlive(Error);
                    GC.KeepAlive(Lock);
                    GC.KeepAlive(ChangeListName);
                    GC.KeepAlive(MergeRange);
                    GC.KeepAlive(PropertyName);
                    GC.KeepAlive(RevisionProperties);
                }

                _lock?.Detach(keepProperties);
            }
            finally
            {
                _notify = null;
                _pool   = null;
                base.Detach(keepProperties);
            }
        }
Ejemplo n.º 12
0
        /// <summary>Writes the content of specified files or URLs to a stream. (<c>svn cat</c>)</summary>
        public unsafe bool Write(SvnTarget target, Stream output, SvnWriteArgs args, out SvnPropertyCollection properties)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }
            if (args == null)
            {
                throw new ObjectDisposedException(nameof(args));
            }

            using var pool = new AprPool(_pool);
            apr_hash_t.__Internal *props_ptr = null;

            properties = null;

            if (InternalWrite(target, output, args, &props_ptr, pool))
            {
                var props = apr_hash_t.__CreateInstance(new IntPtr(props_ptr));
                properties = CreatePropertyDictionary(props, pool);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 13
0
 public SvnStream(IntPtr baton, AprPool pool)
 {
     mStream        = Svn.svn_stream_create(baton, pool);
     mReadDelegate  = null;
     mWriteDelegate = null;
     mCloseDelegate = null;
 }
Ejemplo n.º 14
0
 public static void Blame(SvnUrl pathOrUrl,
                          SvnOptRevision start, SvnOptRevision end,
                          BlameReceiver receiver, IntPtr baton,
                          SvnClientContext ctx, AprPool pool)
 {
     InternalBlame(pathOrUrl, start, end, receiver, baton, ctx, pool);
 }
Ejemplo n.º 15
0
        /// <summary>Retrieves an authorization baton allocated in the specified pool; containing the current authorization settings</summary>
        internal unsafe svn_auth_baton_t GetAuthorizationBaton(ref int cookie)
        {
            if (_currentBaton != null && _cookie == cookie)
            {
                return(_currentBaton);
            }

            using var tmpPool = new AprPool(_parentPool);

            apr_hash_t creds = null;

            if (_currentBaton != null)
            {
                creds = clone_credentials(get_cache(_currentBaton), null, tmpPool);
            }

            _authPool.Clear();

            var authArray = new AprArray <ISvnAuthWrapper, SvnAuthProviderMarshaller>(_handlers, _authPool);

            svn_auth_baton_t.__Internal *rsltPtr = null;

            svn_auth.svn_auth_open((void **)&rsltPtr, authArray.Handle, _authPool.Handle);

            var rslt = svn_auth_baton_t.__CreateInstance(new IntPtr(rsltPtr));

            if (creds != null)
            {
                clone_credentials(creds, get_cache(rslt), _authPool);
            }

            if (_clientContext._configPath != null)
            {
                svn_auth.svn_auth_set_parameter(
                    rslt,
                    tmpPool.AllocString(Constants.SVN_AUTH_PARAM_CONFIG_DIR),
                    new IntPtr(_authPool.AllocDirent(_clientContext._configPath)));
            }

            if (_forcedUser != null)
            {
                svn_auth.svn_auth_set_parameter(
                    rslt,
                    tmpPool.AllocString(Constants.SVN_AUTH_PARAM_DEFAULT_USERNAME),
                    new IntPtr(_authPool.AllocString(_forcedUser)));
            }

            if (_forcedPassword != null)
            {
                svn_auth.svn_auth_set_parameter(
                    rslt,
                    tmpPool.AllocString(Constants.SVN_AUTH_PARAM_DEFAULT_PASSWORD),
                    new IntPtr(_authPool.AllocString(_forcedPassword)));
            }

            _currentBaton = rslt;

            cookie = _cookie;
            return(rslt);
        }
Ejemplo n.º 16
0
        public static int Status(SvnPath path,
                                 SvnOptRevision revision,
                                 SvnWcStatus.Func statusFunc, IntPtr statusBaton,
                                 bool descend, bool getAll, bool update, bool noIgnore,
                                 SvnClientContext ctx, AprPool pool)
        {
            int         rev;
            SvnDelegate statusDelegate = new SvnDelegate(statusFunc);

            Debug.Write(String.Format("svn_client_status({0},{1},{2},{3},{4:X},{5},{6},{7},{8},{9})...", path, revision, statusFunc.Method.Name, statusBaton.ToInt32(), descend, getAll, update, noIgnore, ctx, pool));
            SvnError err = Svn.svn_client_status(out rev, path, revision,
                                                 (Svn.svn_wc_status_func_t)statusDelegate.Wrapper,
                                                 statusBaton,
                                                 (descend ? 1 : 0), (getAll ? 1 : 0),
                                                 (update ? 1 : 0), (noIgnore ? 1 : 0),
                                                 ctx, pool);

            if (!err.IsNoError)
            {
                throw new SvnException(err);
            }
            Debug.WriteLine(String.Format("Done({0})", rev));
            if (update)
            {
                return(rev);
            }
            else
            {
                return(-1);
            }
        }
Ejemplo n.º 17
0
        public void CreateDestroy()
        {
            AprPool p = AprPool.Create();

            Assert.IsFalse(p.IsNull, "#A01");

            AprThreadMutex m = new AprThreadMutex();

            Assert.IsTrue(m.IsNull, "#A02");

            m = AprThreadMutex.Create(p);
            Assert.IsFalse(m.IsNull, "#A03");
            Assert.AreEqual(((IntPtr)p).ToInt32(), ((IntPtr)(m.Pool)).ToInt32(), "#A04");

            m.Destroy();
            Assert.IsTrue(m.IsNull, "#A05");

            m = AprThreadMutex.Create(AprThreadMutex.AprThreadMutexFlags.Unnested, p);
            Assert.IsFalse(m.IsNull, "#A06");
            Assert.AreEqual(((IntPtr)p).ToInt32(), ((IntPtr)(m.Pool)).ToInt32(), "#A04");

            m.Destroy();
            Assert.IsTrue(m.IsNull, "#A07");

            m = AprThreadMutex.Create(AprThreadMutex.AprThreadMutexFlags.Nested, p);
            Assert.IsFalse(m.IsNull, "#A08");
            Assert.AreEqual(((IntPtr)p).ToInt32(), ((IntPtr)(m.Pool)).ToInt32(), "#A04");

            m.Destroy();
            Assert.IsTrue(m.IsNull, "#A09");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#A10");
        }
Ejemplo n.º 18
0
 protected override void ExecuteTask()
 {
     try
     {
         try
         {
             AprPool          p   = Svn.PoolCreate();
             SvnClientContext ctx = SvnClientContext.Create(p);
             ctx.Config  = SvnConfig.GetConfig(p);
             this.Client = new SvnClient(ctx, p);
             this.Client.AddSimpleProvider();
             this.Client.AddUsernameProvider();
             this.Client.AddSslServerTrustFileProvider();
             this.Client.AddSslClientCertFileProvider();
             this.Client.AddSslClientCertPwFileProvider();
             this.Client.OpenAuth();
             this.Client.Status2(this.Directory, new SvnRevision(Svn.Revision.Head), new SvnWcStatus2.Func(this.Clean), IntPtr.Zero, this.Recurse, true, false, false, false);
         }
         catch (Exception ex)
         {
             throw new BuildException(ex.Message, this.Location, ex);
         }
     }
     finally
     {
         if (this.Client != null)
         {
             this.Client.Pool.Destroy();
         }
     }
 }
Ejemplo n.º 19
0
        public void Duplicate()
        {
            AprPool p = AprPool.Create();

            Assert.IsFalse(p.IsNull, "#A01");

            AprString s = new AprString();

            Assert.IsTrue(s.IsNull, "#A02");

            s = AprString.Duplicate(p, "This is a test of string duplication");
            Assert.IsFalse(s.IsNull, "#A03");
            Assert.AreEqual("This is a test of string duplication", s.ToString(), "#A04");

            AprString s2 = AprString.Duplicate(p, s);

            Assert.IsFalse(s2.IsNull, "#A05");
            Assert.AreEqual("This is a test of string duplication", s2.ToString(), "#A06");

            s2 = AprString.Duplicate(p, s, 14);
            Assert.IsFalse(s2.IsNull, "#A07");
            Assert.AreEqual("This is a test", s2.ToString(), "#A08");

            s = AprString.Duplicate(p, "This is a test of string duplication", 14);
            Assert.IsFalse(s.IsNull, "#A09");
            Assert.AreEqual("This is a test", s.ToString(), "#A10");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#A11");
        }
Ejemplo n.º 20
0
        public void AllocatorMutex()
        {
            AprAllocator a = AprAllocator.Create();

            Assert.IsFalse(a.IsNull, "#C01");

            AprPool p = AprPool.Create(a);

            Assert.IsFalse(p.IsNull, "#C02");
            Assert.AreEqual(((IntPtr)a).ToInt32(), ((IntPtr)(p.Allocator)).ToInt32(), "#C03");

            a.Owner = p;
            Assert.AreEqual(((IntPtr)p).ToInt32(), ((IntPtr)(a.Owner)).ToInt32(), "#C04");

            AprThreadMutex m = AprThreadMutex.Create(p);

            Assert.IsFalse(m.IsNull, "#C05");
            Assert.AreEqual(((IntPtr)p).ToInt32(), ((IntPtr)(m.Pool)).ToInt32(), "#C06");

            a.Mutex = m;
            Assert.AreEqual(((IntPtr)m).ToInt32(), ((IntPtr)(a.Mutex)).ToInt32(), "#C07");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#C08");
        }
Ejemplo n.º 21
0
        public static AprPool PoolCreate(AprPool pool, AprAllocator allocator)
        {
            AprPool newpool = AprPool.Create(pool, allocator);

            allocator.Owner = pool;
            return(newpool);
        }
Ejemplo n.º 22
0
        public SvnError UsernameAuth(out SvnAuthCredUsername cred, IntPtr baton,
                                     AprString realm, bool maySave, AprPool pool)
        {
            Console.WriteLine("Username Authentication:");
            Console.WriteLine("------------------------");
            Console.WriteLine("Realm: {0}", realm);
            Console.WriteLine("");

            bool   valid = false;
            string line  = "";

            while (!valid)
            {
                Console.Write("Enter Username: ");

                line = Console.ReadLine();

                if (line.Trim().Length > 0)
                {
                    valid = true;
                }
            }

            cred          = SvnAuthCredUsername.Alloc(pool);
            cred.Username = new AprString(line, pool);
            cred.MaySave  = maySave;
            return(SvnError.NoError);
        }
Ejemplo n.º 23
0
        public void CreateDestroySubPoolWithCustomAllocator()
        {
            AprPool p = new AprPool();

            Assert.IsTrue(p.IsNull, "#D01");

            p = AprPool.Create();
            Assert.IsFalse(p.IsNull, "#D02");

            AprAllocator a = AprAllocator.Create();

            Assert.IsFalse(a.IsNull, "#D03");

            AprPool sp = AprPool.Create(p, a);

            Assert.IsFalse(sp.IsNull, "#D04");
            Assert.AreEqual(((IntPtr)p).ToInt32(), ((IntPtr)(sp.Parent)).ToInt32(), "#D05");
            Assert.AreEqual(((IntPtr)a).ToInt32(), ((IntPtr)(sp.Allocator)).ToInt32(), "#D06");

            a.Owner = p;
            Assert.AreEqual(((IntPtr)p).ToInt32(), ((IntPtr)(a.Owner)).ToInt32(), "#D07");

            sp.Destroy();
            Assert.IsTrue(sp.IsNull, "#D08");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#D09");
        }
Ejemplo n.º 24
0
        public void Parentship()
        {
            AprPool p = AprPool.Create();

            Assert.IsFalse(p.IsNull, "#I01");

            AprPool sp = AprPool.Create(p);

            Assert.IsFalse(sp.IsNull, "#I02");
            Assert.AreEqual(((IntPtr)p).ToInt32(), ((IntPtr)(sp.Parent)).ToInt32(), "#I03");

            AprPool ssp = AprPool.Create(sp);

            Assert.IsFalse(ssp.IsNull, "#I05");
            Assert.AreEqual(((IntPtr)sp).ToInt32(), ((IntPtr)(ssp.Parent)).ToInt32(), "#I06");

            Assert.IsTrue(p.IsAncestor(sp), "#I08");
            Assert.IsTrue(sp.IsAncestor(ssp), "#I09");
            Assert.IsTrue(p.IsAncestor(ssp), "#I10");
            Assert.IsFalse(sp.IsAncestor(p), "#I11");
            Assert.IsFalse(ssp.IsAncestor(p), "#I12");
            Assert.IsFalse(ssp.IsAncestor(sp), "#I13");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#I14");
        }
Ejemplo n.º 25
0
        public void Cat()
        {
            AprPool p = AprPool.Create();

            Assert.IsFalse(p.IsNull, "#D01");

            AprArray a = AprArray.Make(p, 2, Marshal.SizeOf(typeof(int)));

            Assert.IsFalse(a.IsNull, "#D02");

            Marshal.WriteInt32(a.Push(), 1);
            Marshal.WriteInt32(a.Push(), 2);

            AprArray a2 = AprArray.Make(p, 3, Marshal.SizeOf(typeof(int)));

            Assert.IsFalse(a2.IsNull, "#D03");

            Marshal.WriteInt32(a2.Push(), 3);
            Marshal.WriteInt32(a2.Push(), 4);
            Marshal.WriteInt32(a2.Push(), 5);

            a.Cat(a2);
            Assert.AreEqual(5, Marshal.ReadInt32(a.Pop()), "#D05");
            Assert.AreEqual(4, Marshal.ReadInt32(a.Pop()), "#DO6");
            Assert.AreEqual(3, Marshal.ReadInt32(a.Pop()), "#DO7");
            Assert.AreEqual(2, Marshal.ReadInt32(a.Pop()), "#DO8");
            Assert.AreEqual(1, Marshal.ReadInt32(a.Pop()), "#DO9");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#D10");
        }
Ejemplo n.º 26
0
        public void Copy()
        {
            AprPool p = AprPool.Create();

            Assert.IsFalse(p.IsNull, "#C01");

            AprArray a = AprArray.Make(p, 5, Marshal.SizeOf(typeof(int)));

            Assert.IsFalse(a.IsNull, "#C02");

            Marshal.WriteInt32(a.Push(), 1);
            Marshal.WriteInt32(a.Push(), 2);
            Marshal.WriteInt32(a.Push(), 3);
            Marshal.WriteInt32(a.Push(), 4);
            Marshal.WriteInt32(a.Push(), 5);

            AprArray ca = a.Copy(p);

            Assert.IsTrue(((IntPtr)a).ToInt32() != ((IntPtr)ca).ToInt32(), "#C03");
            Assert.AreEqual(a.Count, ca.Count, "#C04");
            Assert.AreEqual(5, Marshal.ReadInt32(ca.Pop()), "#C05");
            Assert.AreEqual(4, Marshal.ReadInt32(ca.Pop()), "#CO6");
            Assert.AreEqual(3, Marshal.ReadInt32(ca.Pop()), "#CO7");
            Assert.AreEqual(2, Marshal.ReadInt32(ca.Pop()), "#CO8");
            Assert.AreEqual(1, Marshal.ReadInt32(ca.Pop()), "#CO9");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#C10");
        }
Ejemplo n.º 27
0
        /// <summary>Sets the specified property on the specfied path to value</summary>
        /// <remarks>Use <see cref="DeleteProperty(string,string, SvnSetPropertyArgs)" /> to remove an existing property</remarks>
        public bool SetProperty(string target, string propertyName, string value, SvnSetPropertyArgs args)
        {
            if (string.IsNullOrEmpty(target))
            {
                throw new ArgumentNullException(nameof(target));
            }
            if (string.IsNullOrEmpty(propertyName))
            {
                throw new ArgumentNullException(nameof(propertyName));
            }
            if (!IsNotUri(target))
            {
                throw new ArgumentException(SharpSvnStrings.ArgumentMustBeAPathNotAUri, nameof(target));
            }
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            using var pool = new AprPool(_pool);

            return(InternalSetProperty(
                       target,
                       propertyName,
                       pool.AllocPropertyValue(value, propertyName),
                       args,
                       pool));
        }
Ejemplo n.º 28
0
 public SvnClient(SvnClientContext ctx, AprPool pool)
 {
     mGlobalPool = pool;
     mPool       = Svn.PoolCreate(mGlobalPool);
     mContext    = ctx;
     mAuthObjs   = null;
 }
Ejemplo n.º 29
0
        internal SvnInfoEventArgs(string path, svn_client_info2_t info, AprPool pool)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }
            if (pool == null)
            {
                throw new ArgumentNullException(nameof(pool));
            }

            _info = info;
            _pool = pool;

            Path               = path;
            Revision           = info.rev;
            NodeKind           = (SvnNodeKind)info.kind;
            LastChangeRevision = info.last_changed_rev;
            LastChangeTime     = SvnBase.DateTimeFromAprTime(info.last_changed_date);
            HasLocalInfo       = (info.wc_info != null);

            if (info.wc_info != null)
            {
                _wcSchedule      = (SvnSchedule)info.wc_info.schedule;
                CopyFromRevision = info.wc_info.copyfrom_rev;
                Depth            = (SvnDepth)info.wc_info.depth;

                ContentTime = SvnBase.DateTimeFromAprTime(info.wc_info.recorded_time);
                if (info.wc_info.recorded_size == -1)
                {
                    WorkingCopySize = -1;
                }
                else
                {
                    WorkingCopySize = info.wc_info.recorded_size;
                }

                Conflicted = info.wc_info.conflicts != null && (info.wc_info.conflicts.nelts > 0);
            }
            else
            {
                Depth            = SvnDepth.Unknown;
                WorkingCopySize  = -1;
                CopyFromRevision = -1;
            }

            if (info.size == -1)
            {
                RepositorySize = -1;
            }
            else
            {
                RepositorySize = info.size;
            }
        }
Ejemplo n.º 30
0
 public SvnClient(AprPool pool)
 {
     mGlobalPool     = pool;
     mPool           = Svn.PoolCreate(mGlobalPool);
     mContext        = SvnClientContext.Create(mGlobalPool);
     mContext.Config = SvnConfig.GetConfig(mGlobalPool);
     mAuthObjs       = null;
 }
Ejemplo n.º 31
0
        private SvnError GetCommitLogCallback(out AprString logMessage, out SvnPath tmpFile, AprArray commitItems, IntPtr baton, AprPool pool)
        {
            if (!commitItems.IsNull)
            {
                foreach (SvnClientCommitItem2 item in commitItems)
                {
                    m_log.Debug("[SVNBACKUP]: ... " + Path.GetFileName(item.Path.ToString()) + " (" + item.Kind.ToString() + ") r" + item.Revision.ToString());
                }
            }

            string msg = "Region Backup (" + System.Environment.MachineName + " at " + DateTime.UtcNow + " UTC)";

            m_log.Debug("[SVNBACKUP]: Saved with message: " + msg);

            logMessage = new AprString(msg, pool);
            tmpFile = new SvnPath(pool);

            return (SvnError.NoError);
        }
Ejemplo n.º 32
0
        // private void CheckoutSvnPartial(string subdir)
        // {
        //     if (!Directory.Exists(m_svndir + Slash.DirectorySeparatorChar + subdir))
        //         Directory.CreateDirectory(m_svndir + Slash.DirectorySeparatorChar + subdir);

        //     m_svnClient.Checkout2(m_svnurl + "/" + subdir, m_svndir, Svn.Revision.Head, Svn.Revision.Head, true, false);
        // }

        // private void CheckoutSvnPartial(string subdir, SvnRevision revision)
        // {
        //     if (!Directory.Exists(m_svndir + Slash.DirectorySeparatorChar + subdir))
        //         Directory.CreateDirectory(m_svndir + Slash.DirectorySeparatorChar + subdir);

        //     m_svnClient.Checkout2(m_svnurl + "/" + subdir, m_svndir, revision, revision, true, false);
        // }

        #endregion

        #region SvnDotNet Callbacks

        private SvnError SimpleAuth(out SvnAuthCredSimple svnCredentials, IntPtr baton,
                                    AprString realm, AprString username, bool maySave, AprPool pool)
        {
            svnCredentials = SvnAuthCredSimple.Alloc(pool);
            svnCredentials.Username = new AprString(m_svnuser, pool);
            svnCredentials.Password = new AprString(m_svnpass, pool);
            svnCredentials.MaySave = false;
            return SvnError.NoError;
        }