示例#1
0
        public void ChangeInfo_GetInfoCompare()
        {
            SvnSandBox sbox      = new SvnSandBox(this);
            Uri        reposUri  = sbox.CreateRepository(SandBoxRepository.MergeScenario);
            string     reposPath = reposUri.LocalPath;

            using (SvnClient cl = new SvnClient())
            {
                SvnSetPropertyArgs sa = new SvnSetPropertyArgs();
                sa.BaseRevision = 17;
                sa.LogMessage   = "Message";
                cl.RemoteSetProperty(reposUri, "MyProp", "Value", sa);
            }

            for (long ii = 1; ii < 19; ii++)
            {
                using (SvnLookClient lcl = new SvnLookClient())
                    using (SvnClient cl = new SvnClient())
                    {
                        SvnChangeInfoEventArgs r;
                        SvnChangeInfoArgs      ia     = new SvnChangeInfoArgs();
                        SvnLookOrigin          origin = new SvnLookOrigin(reposPath, ii);

                        SvnLogArgs la = new SvnLogArgs();
                        la.Start = la.End = ii;

                        Collection <SvnLogEventArgs> lrc;
                        //ia.RetrieveChangedPaths = false; // Will fail if true
                        Assert.That(lcl.GetChangeInfo(origin, ia, out r));
                        Assert.That(cl.GetLog(reposUri, la, out lrc));

                        Assert.That(r, Is.Not.Null);
                        Assert.That(lrc.Count, Is.EqualTo(1));

                        SvnLogEventArgs lr = lrc[0];

                        Assert.That(r.Author, Is.EqualTo(lr.Author));
                        Assert.That(r.Revision, Is.EqualTo(lr.Revision));
                        Assert.That(r.BaseRevision, Is.EqualTo(lr.Revision - 1));
                        Assert.That(r.LogMessage, Is.EqualTo(lr.LogMessage));
                        Assert.That(r.Time, Is.EqualTo(lr.Time));

                        Assert.That(r.ChangedPaths, Is.Not.Null, "r.ChangedPaths({0})", ii);
                        Assert.That(lr.ChangedPaths, Is.Not.Null, "lr.ChangedPaths({0})", ii);

                        Assert.That(r.ChangedPaths.Count, Is.EqualTo(lr.ChangedPaths.Count));

                        for (int i = 0; i < r.ChangedPaths.Count; i++)
                        {
                            SvnChangeItem c  = r.ChangedPaths[i];
                            SvnChangeItem lc = lr.ChangedPaths[c.Path];

                            Assert.That(c.Path, Is.EqualTo(lc.Path));
                            Assert.That(c.Action, Is.EqualTo(lc.Action));
                            Assert.That(c.CopyFromPath, Is.EqualTo(lc.CopyFromPath));
                            Assert.That(c.CopyFromRevision, Is.EqualTo(lc.CopyFromRevision));
                        }
                    }
            }
        }
示例#2
0
        public void ChangeInfo_GetInfo12()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoEventArgs r;
                SvnChangeInfoArgs      ia = new SvnChangeInfoArgs();

                SvnLookOrigin origin = new SvnLookOrigin(sbox.CreateRepository(SandBoxRepository.MergeScenario).LocalPath, 12);
                //ia.RetrieveChangedPaths = false; // Will fail if true

                Assert.That(cl.GetChangeInfo(origin, ia, out r));

                Assert.That(r, Is.Not.Null);
                Assert.That(r.Author, Is.EqualTo("merger"));
                Assert.That(r.Revision, Is.EqualTo(12L));
                Assert.That(r.BaseRevision, Is.EqualTo(11L));
                Assert.That(r.LogMessage, Is.EqualTo("Merge branch a - product roadmap"));

                // This is the exact time of the commit in microseconds
                DateTime shouldBe = new DateTime(2008, 1, 27, 15, 2, 26, 567, DateTimeKind.Utc).AddTicks(6830);

                Assert.That(r.Time, Is.EqualTo(shouldBe));
            }
        }
示例#3
0
        void OnPostCommit(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoArgs ia = new SvnChangeInfoArgs();

                SvnChangeInfoEventArgs i;
                Assert.That(cl.GetChangeInfo(e.HookArgs.LookOrigin, ia, out i));

                GC.KeepAlive(i);
                Assert.That(i.Revision, Is.GreaterThanOrEqualTo(0L));
                Assert.That(i.Author, Is.EqualTo(Environment.UserName));
            }
        }
示例#4
0
        public void ChangeInfo_BigWrite()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri        uri  = sbox.CreateRepository(SandBoxRepository.Empty);
            string     dir  = sbox.Wc;

            Client.CheckOut(uri, dir);

            string file = Path.Combine(dir, "bigfile");

            WriteBigFile(file);
            Client.Add(file);
            Client.SetProperty(file, "a", "b");
            using (InstallHook(uri, SvnHookType.PreCommit, OnPreCommitBigFile))
            {
                Client.Commit(dir);
            }

            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoArgs ia = new SvnChangeInfoArgs();

                SvnLookOrigin lo = new SvnLookOrigin(uri.LocalPath);

                using (MemoryStream ms = new MemoryStream())
                {
                    cl.Write(lo, "/bigfile", ms);
                }

                string b_p;
                Assert.That(cl.GetProperty(lo, "/bigfile", "a", out b_p));
                Assert.That(b_p, Is.EqualTo("b"));

                Collection <SvnLookListEventArgs> lst;
                cl.GetList(lo, "", out lst);

                Assert.That(lst, Is.Not.Null);
                Assert.That(lst.Count, Is.EqualTo(1));
                SvnLookListEventArgs r = lst[0];

                Assert.That(r, Is.Not.Null);
                Assert.That(r.Name, Is.EqualTo("bigfile"));
                Assert.That(r.NodeKind, Is.EqualTo(SvnNodeKind.File));
                Assert.That(r.Path, Is.EqualTo("bigfile"));
            }
        }
示例#5
0
        public void ChangeInfo_BigWrite()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri uri = sbox.CreateRepository(SandBoxRepository.Empty);
            string dir = sbox.Wc;
            Client.CheckOut(uri, dir);

            string file = Path.Combine(dir, "bigfile");
            WriteBigFile(file);
            Client.Add(file);
            Client.SetProperty(file, "a", "b");
            using (InstallHook(uri, SvnHookType.PreCommit, OnPreCommitBigFile))
            {
                Client.Commit(dir);
            }

            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoArgs ia = new SvnChangeInfoArgs();

                SvnLookOrigin lo = new SvnLookOrigin(uri.LocalPath);

                using (MemoryStream ms = new MemoryStream())
                {
                    cl.Write(lo, "/bigfile", ms);
                }

                string b_p;
                Assert.That(cl.GetProperty(lo, "/bigfile", "a", out b_p));
                Assert.That(b_p, Is.EqualTo("b"));

                Collection<SvnLookListEventArgs> lst;
                cl.GetList(lo, "", out lst);

                Assert.That(lst, Is.Not.Null);
                Assert.That(lst.Count, Is.EqualTo(1));
                SvnLookListEventArgs r = lst[0];

                Assert.That(r, Is.Not.Null);
                Assert.That(r.Name, Is.EqualTo("bigfile"));
                Assert.That(r.NodeKind, Is.EqualTo(SvnNodeKind.File));
                Assert.That(r.Path, Is.EqualTo("bigfile"));
            }
        }
示例#6
0
        void OnPreCommit(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoArgs ia = new SvnChangeInfoArgs();

                SvnChangeInfoEventArgs i;
                Assert.That(cl.GetChangeInfo(e.HookArgs.LookOrigin, ia, out i));

                Assert.That(i.Revision, Is.LessThan(0L));
                Assert.That(i.Author, Is.EqualTo(Environment.UserName));
                Assert.That(i.LogMessage, Is.EqualTo("Blaat!\r\nQWQQ\r\n"));

                using (MemoryStream ms = new MemoryStream())
                {
                    SvnLookWriteArgs wa = new SvnLookWriteArgs();

                    cl.Write(e.HookArgs.LookOrigin, "trunk/Pre.txt", ms, wa);
                    ms.Position = 0;

                    using (StreamReader sr = new StreamReader(ms))
                    {
                        Assert.That(sr.ReadToEnd(), Is.EqualTo("AllTheData"));
                    }

                    string v;
                    cl.GetProperty(e.HookArgs.LookOrigin, "trunk/Pre.txt", "boe", out v);

                    Assert.That(v, Is.EqualTo("blaat"));

                    SvnPropertyCollection props;
                    cl.GetPropertyList(e.HookArgs.LookOrigin, "trunk/Pre.txt", out props);

                    Assert.That(props, Is.Not.Null);
                    Assert.That(props.Count, Is.EqualTo(1));
                }

                Guid id;
                Assert.That(cl.TryGetRepositoryId(e.HookArgs.LookOrigin, out id));
                Assert.That(id, Is.Not.EqualTo(Guid.Empty));
            }
        }
示例#7
0
        public void ChangeInfo_GetInfoHead()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoEventArgs r;
                SvnChangeInfoArgs      ia = new SvnChangeInfoArgs();

                SvnLookOrigin lo = new SvnLookOrigin(sbox.CreateRepository(SandBoxRepository.MergeScenario).LocalPath);
                Assert.That(cl.GetChangeInfo(lo, ia, out r));

                Assert.That(r, Is.Not.Null);
                Assert.That(r.Author, Is.EqualTo("merger"));
                Assert.That(r.Revision, Is.EqualTo(17L));
                Assert.That(r.BaseRevision, Is.EqualTo(16L));
                Assert.That(r.LogMessage, Is.EqualTo("Merged branch c back to trunk"));

                // This is the exact time of the commit in microseconds
                DateTime shouldBe = new DateTime(2008, 1, 27, 15, 7, 57, 9, DateTimeKind.Utc).AddTicks(4750);

                Assert.That(r.Time, Is.EqualTo(shouldBe));

                foreach (SvnChangeItem i in r.ChangedPaths)
                {
                    if (i.NodeKind != SvnNodeKind.File)
                    {
                        continue;
                    }
                    using (MemoryStream ms = new MemoryStream())
                    {
                        cl.Write(lo, i.Path, ms);
                    }
                }
            }
        }
示例#8
0
        public void ChangeInfo_GetInfo12()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoEventArgs r;
                SvnChangeInfoArgs ia = new SvnChangeInfoArgs();

                SvnLookOrigin origin = new SvnLookOrigin(sbox.CreateRepository(SandBoxRepository.MergeScenario).LocalPath, 12);
                //ia.RetrieveChangedPaths = false; // Will fail if true

                Assert.That(cl.GetChangeInfo(origin, ia, out r));

                Assert.That(r, Is.Not.Null);
                Assert.That(r.Author, Is.EqualTo("merger"));
                Assert.That(r.Revision, Is.EqualTo(12L));
                Assert.That(r.BaseRevision, Is.EqualTo(11L));
                Assert.That(r.LogMessage, Is.EqualTo("Merge branch a - product roadmap"));

                // This is the exact time of the commit in microseconds
                DateTime shouldBe = new DateTime(2008, 1, 27, 15, 2, 26, 567, DateTimeKind.Utc).AddTicks(6830);

                Assert.That(r.Time, Is.EqualTo(shouldBe));
            }
        }
示例#9
0
        public void ChangeInfo_GetInfoHead()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoEventArgs r;
                SvnChangeInfoArgs ia = new SvnChangeInfoArgs();

                SvnLookOrigin lo = new SvnLookOrigin(sbox.CreateRepository(SandBoxRepository.MergeScenario).LocalPath);
                Assert.That(cl.GetChangeInfo(lo, ia, out r));

                Assert.That(r, Is.Not.Null);
                Assert.That(r.Author, Is.EqualTo("merger"));
                Assert.That(r.Revision, Is.EqualTo(17L));
                Assert.That(r.BaseRevision, Is.EqualTo(16L));
                Assert.That(r.LogMessage, Is.EqualTo("Merged branch c back to trunk"));

                // This is the exact time of the commit in microseconds
                DateTime shouldBe = new DateTime(2008, 1, 27, 15, 7, 57, 9, DateTimeKind.Utc).AddTicks(4750);

                Assert.That(r.Time, Is.EqualTo(shouldBe));

                foreach (SvnChangeItem i in r.ChangedPaths)
                {
                    if (i.NodeKind != SvnNodeKind.File)
                        continue;
                    using (MemoryStream ms = new MemoryStream())
                    {
                        cl.Write(lo, i.Path, ms);
                    }
                }
            }
        }
示例#10
0
        public void ChangeInfo_GetInfoCompare()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri reposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);
            string reposPath = reposUri.LocalPath;

            using (SvnClient cl = new SvnClient())
            {
                SvnSetPropertyArgs sa = new SvnSetPropertyArgs();
                sa.BaseRevision = 17;
                sa.LogMessage = "Message";
                cl.RemoteSetProperty(reposUri, "MyProp", "Value", sa);
            }

            for (long ii = 1; ii < 19; ii++)
            {
                using (SvnLookClient lcl = new SvnLookClient())
                using (SvnClient cl = new SvnClient())
                {
                    SvnChangeInfoEventArgs r;
                    SvnChangeInfoArgs ia = new SvnChangeInfoArgs();
                    SvnLookOrigin origin = new SvnLookOrigin(reposPath, ii);

                    SvnLogArgs la = new SvnLogArgs();
                    la.Start = la.End = ii;

                    Collection<SvnLogEventArgs> lrc;
                    //ia.RetrieveChangedPaths = false; // Will fail if true
                    Assert.That(lcl.GetChangeInfo(origin, ia, out r));
                    Assert.That(cl.GetLog(reposUri, la, out lrc));

                    Assert.That(r, Is.Not.Null);
                    Assert.That(lrc.Count, Is.EqualTo(1));

                    SvnLogEventArgs lr = lrc[0];

                    Assert.That(r.Author, Is.EqualTo(lr.Author));
                    Assert.That(r.Revision, Is.EqualTo(lr.Revision));
                    Assert.That(r.BaseRevision, Is.EqualTo(lr.Revision - 1));
                    Assert.That(r.LogMessage, Is.EqualTo(lr.LogMessage));
                    Assert.That(r.Time, Is.EqualTo(lr.Time));

                    Assert.That(r.ChangedPaths, Is.Not.Null, "r.ChangedPaths({0})", ii);
                    Assert.That(lr.ChangedPaths, Is.Not.Null, "lr.ChangedPaths({0})", ii);

                    Assert.That(r.ChangedPaths.Count, Is.EqualTo(lr.ChangedPaths.Count));

                    for (int i = 0; i < r.ChangedPaths.Count; i++)
                    {
                        SvnChangeItem c = r.ChangedPaths[i];
                        SvnChangeItem lc = lr.ChangedPaths[c.Path];

                        Assert.That(c.Path, Is.EqualTo(lc.Path));
                        Assert.That(c.Action, Is.EqualTo(lc.Action));
                        Assert.That(c.CopyFromPath, Is.EqualTo(lc.CopyFromPath));
                        Assert.That(c.CopyFromRevision, Is.EqualTo(lc.CopyFromRevision));
                    }
                }
            }
        }
示例#11
0
        void OnPostCommit(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoArgs ia = new SvnChangeInfoArgs();

                SvnChangeInfoEventArgs i;
                Assert.That(cl.GetChangeInfo(e.HookArgs.LookOrigin, ia, out i));

                GC.KeepAlive(i);
                Assert.That(i.Revision, Is.GreaterThanOrEqualTo(0L));
                Assert.That(i.Author, Is.EqualTo(Environment.UserName));
            }
        }
示例#12
0
        void OnPreCommit(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoArgs ia = new SvnChangeInfoArgs();

                SvnChangeInfoEventArgs i;
                Assert.That(cl.GetChangeInfo(e.HookArgs.LookOrigin, ia, out i));

                Assert.That(i.Revision, Is.LessThan(0L));
                Assert.That(i.Author, Is.EqualTo(Environment.UserName));
                Assert.That(i.LogMessage, Is.EqualTo("Blaat!\r\nQWQQ\r\n"));

                using (MemoryStream ms = new MemoryStream())
                {
                    SvnLookWriteArgs wa = new SvnLookWriteArgs();

                    cl.Write(e.HookArgs.LookOrigin, "trunk/Pre.txt", ms, wa);
                    ms.Position = 0;

                    using (StreamReader sr = new StreamReader(ms))
                    {
                        Assert.That(sr.ReadToEnd(), Is.EqualTo("AllTheData"));
                    }

                    string v;
                    cl.GetProperty(e.HookArgs.LookOrigin, "trunk/Pre.txt", "boe", out v);

                    Assert.That(v, Is.EqualTo("blaat"));

                    SvnPropertyCollection props;
                    cl.GetPropertyList(e.HookArgs.LookOrigin, "trunk/Pre.txt", out props);

                    Assert.That(props, Is.Not.Null);
                    Assert.That(props.Count, Is.EqualTo(1));
                }

                Guid id;
                Assert.That(cl.TryGetRepositoryId(e.HookArgs.LookOrigin, out id));
                Assert.That(id, Is.Not.EqualTo(Guid.Empty));
            }
        }