Example #1
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));
            }
        }
Example #2
0
        private void OnChangedProps(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient look = new SvnLookClient())
            {
                int i = 0;
                look.InheritedPropertyList(e.HookArgs.LookOrigin, "trunk/A/mu",
                                           delegate(object sender2, SvnLookInheritedPropertyListEventArgs ee)
                {
                    switch (i++)
                    {
                    case 0:
                        Assert.That(ee.Path, Is.EqualTo("trunk"));
                        Assert.That(ee.Properties.Contains("root-A"));
                        break;

                    case 1:
                        Assert.That(ee.Path, Is.EqualTo("trunk/A"));
                        Assert.That(ee.Properties.Contains("A-A"));
                        break;

                    case 2:
                        Assert.That(ee.Path, Is.EqualTo("trunk/A/mu"));
                        Assert.That(ee.Properties.Contains("mu-A"));
                        break;

                    default:
                        throw new InvalidOperationException("Too many invocations");
                    }
                });

                Assert.That(i, Is.GreaterThan(0), "No props listed");
            }
        }
        private void OnChangedProps(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient look = new SvnLookClient())
            {
                int i = 0;
                look.InheritedPropertyList(e.HookArgs.LookOrigin, "trunk/A/mu",
                    delegate(object sender2, SvnLookInheritedPropertyListEventArgs ee)
                    {
                        switch (i++)
                        {
                            case 0:
                                Assert.That(ee.Path, Is.EqualTo("trunk"));
                                Assert.That(ee.Properties.Contains("root-A"));
                                break;
                            case 1:
                                Assert.That(ee.Path, Is.EqualTo("trunk/A"));
                                Assert.That(ee.Properties.Contains("A-A"));
                                break;
                            case 2:
                                Assert.That(ee.Path, Is.EqualTo("trunk/A/mu"));
                                Assert.That(ee.Properties.Contains("mu-A"));
                                break;
                            default:
                                throw new InvalidOperationException("Too many invocations");
                        }
                    });

                Assert.That(i, Is.GreaterThan(0), "No props listed");
            }
        }
Example #4
0
        /// <summary>
        /// 検証を実施します。
        /// </summary>
        /// <returns>true:コミット可, false:コミット不可。</returns>
        public bool Validate()
        {
            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoEventArgs ci;
                cl.GetChangeInfo(hookArgs.LookOrigin, out ci);

                // ログメッセージに関する検証
                if (!CommonHook.Validate(ci))
                {
                    return(false);
                }

                // tagsに関する検証
                if (!TagsHook.Validate(ci))
                {
                    return(false);
                }

                // branchesに関する検証
                if (!BranchesHook.Validate(ci))
                {
                    return(false);
                }
            }
            return(true);
        }
Example #5
0
        static bool ShouldCommitHooksRun(SvnHookArguments ha)
        {
            // By default always run the commit hooks
            bool runCommitHooks = true;

            SvnLookOrigin slo = new SvnLookOrigin(ha.RepositoryPath, ha.TransactionName);
            SvnChangeInfoEventArgs sciea;
            using (SvnLookClient slc = new SvnLookClient())
            {
                bool gotLogInfo = slc.GetChangeInfo(slo, out sciea);
                Trace.WriteLineIf(!gotLogInfo, "Failed to GetLogInfo() for Commit, Commit Hooks NOT Ran");

                // If we fail to get the log we're going to play it safe
                // and not run these commit hooks
                runCommitHooks = gotLogInfo;
            }

            if (runCommitHooks)
            {
                // If the magic keywords [ignoreall] or [ignorefileformathooks]
                // are found don't run these commit hooks.
                string logMessage = sciea.LogMessage;
                if (!string.IsNullOrEmpty(logMessage))
                {
                    IEnumerable<string> magicIgnoreKeywords = new string[] { "[ignoreall]", "[ignorefileformathooks]" };
                    runCommitHooks = !logMessage.ContainsAny(magicIgnoreKeywords);
                }
            }

            return runCommitHooks;
        }
Example #6
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));
                        }
                    }
            }
        }
Example #7
0
        private static IRepoChangeInfo GetPreCommitRepoChangeInfo(string repositoryPath, string transactionName)
        {
            // SvnInfo ermitteln
              var svnLookClient = new SvnLookClient();
              var svnLookOrigin = new SvnLookOrigin(repositoryPath, transactionName);
              SvnChangeInfoEventArgs svnChangeInfoEventArgs;
              if (svnLookClient.GetChangeInfo(svnLookOrigin, out svnChangeInfoEventArgs))
              {
            return new SvnChangeInfoEventArgsWrapper(HookType.PreCommit, svnChangeInfoEventArgs);
              }

              return null;
        }
Example #8
0
        private static IRepoChangeInfo GetPostCommitRepoChangeInfo(string repositoryPath, long revision)
        {
            // SvnInfo ermitteln
              var svnLookClient = new SvnLookClient();
              var svnLookOrigin = new SvnLookOrigin(repositoryPath, revision);
              SvnChangeInfoEventArgs svnChangeInfoEventArgs;
              if (svnLookClient.GetChangeInfo(svnLookOrigin, out svnChangeInfoEventArgs))
              {
            return new SvnChangeInfoEventArgsWrapper(HookType.PostCommit, svnChangeInfoEventArgs);
              }

              return null;
        }
Example #9
0
        private void OnPreCommitBigFile(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient cl = new SvnLookClient())
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    cl.Write(e.HookArgs.LookOrigin, "/bigfile", ms);
                }

                string b_p;
                Assert.That(cl.GetProperty(e.HookArgs.LookOrigin, "/bigfile", "a", out b_p));
                Assert.That(b_p, Is.EqualTo("b"));
            }
        }
Example #10
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));
            }
        }
Example #11
0
        public void LookInheritedProps()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri        uri  = sbox.CreateRepository(SandBoxRepository.Greek);

            using (InstallHook(uri, SvnHookType.PreCommit, OnChangedProps))
            {
                Client.RepositoryOperation(new Uri(uri, "trunk"), delegate(SvnMultiCommandClient cl)
                {
                    cl.SetProperty("", "root-A", "B");
                    cl.SetProperty("A", "A-A", "C");
                    cl.SetProperty("A/mu", "mu-A", "D");
                });
            }

            using (SvnLookClient look = new SvnLookClient())
            {
                int i = 0;
                look.InheritedPropertyList(new SvnLookOrigin(uri.LocalPath, 2), "trunk/A/mu",
                                           delegate(object sender2, SvnLookInheritedPropertyListEventArgs ee)
                {
                    switch (i++)
                    {
                    case 0:
                        Assert.That(ee.Path, Is.EqualTo("trunk"));
                        Assert.That(ee.Properties.Contains("root-A"));
                        break;

                    case 1:
                        Assert.That(ee.Path, Is.EqualTo("trunk/A"));
                        Assert.That(ee.Properties.Contains("A-A"));
                        break;

                    case 2:
                        Assert.That(ee.Path, Is.EqualTo("trunk/A/mu"));
                        Assert.That(ee.Properties.Contains("mu-A"));
                        break;

                    default:
                        throw new InvalidOperationException("Too many invocations");
                    }
                });

                Assert.That(i, Is.GreaterThan(0), "No props listed");
            }
        }
Example #12
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"));
            }
        }
Example #13
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"));
            }
        }
        public void LookInheritedProps()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri uri = sbox.CreateRepository(SandBoxRepository.Greek);

            using (InstallHook(uri, SvnHookType.PreCommit, OnChangedProps))
            {
                Client.RepositoryOperation(new Uri(uri, "trunk"), delegate(SvnMultiCommandClient cl)
                    {
                        cl.SetProperty("", "root-A", "B");
                        cl.SetProperty("A", "A-A", "C");
                        cl.SetProperty("A/mu", "mu-A", "D");
                    });
            }

            using (SvnLookClient look = new SvnLookClient())
            {
                int i = 0;
                look.InheritedPropertyList(new SvnLookOrigin(uri.LocalPath, 2), "trunk/A/mu",
                    delegate(object sender2, SvnLookInheritedPropertyListEventArgs ee)
                    {
                        switch (i++)
                        {
                            case 0:
                                Assert.That(ee.Path, Is.EqualTo("trunk"));
                                Assert.That(ee.Properties.Contains("root-A"));
                                break;
                            case 1:
                                Assert.That(ee.Path, Is.EqualTo("trunk/A"));
                                Assert.That(ee.Properties.Contains("A-A"));
                                break;
                            case 2:
                                Assert.That(ee.Path, Is.EqualTo("trunk/A/mu"));
                                Assert.That(ee.Properties.Contains("mu-A"));
                                break;
                            default:
                                throw new InvalidOperationException("Too many invocations");
                        }
                    });

                Assert.That(i, Is.GreaterThan(0), "No props listed");
            }
        }
Example #15
0
        private void OnChangedDirs(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient lc = new SvnLookClient())
            {
                SvnChangedArgs ca = new SvnChangedArgs();
                ca.Transaction = e.HookArgs.TransactionName;

                Collection <SvnChangedEventArgs> list;
                Assert.That(lc.GetChanged(e.HookArgs.LookOrigin, ca, out list));

                Assert.That(list.Count, Is.EqualTo(16));
                Assert.That(list[0].Name, Is.EqualTo("a"));
                Assert.That(list[0].Path, Is.EqualTo("/a/"));
                Assert.That(list[1].Name, Is.EqualTo("b"));
                Assert.That(list[1].Path, Is.EqualTo("/a/b/"));
                Assert.That(list[2].Name, Is.EqualTo("c"));
                Assert.That(list[2].Path, Is.EqualTo("/a/b/c/"));
            }
        }
Example #16
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));
            }
        }
Example #17
0
        private void OnCopyDir(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient lc = new SvnLookClient())
            {
                SvnChangedArgs ca = new SvnChangedArgs();
                ca.Transaction = e.HookArgs.TransactionName;

                Collection <SvnChangedEventArgs> list;
                Assert.That(lc.GetChanged(e.HookArgs.LookOrigin, ca, out list));
                Assert.That(list.Count, Is.EqualTo(2));

                Assert.That(list[0].Name, Is.EqualTo("d"));
                Assert.That(list[0].Path, Is.EqualTo("/d/"));
                Assert.That(list[0].CopyFromPath, Is.EqualTo("/a/b/c/d"));
                Assert.That(list[0].CopyFromRevision, Is.EqualTo(1L));
                Assert.That(list[1].Name, Is.EqualTo("j"));
                Assert.That(list[1].Path, Is.EqualTo("/j/"));
                Assert.That(list[1].CopyFromPath, Is.EqualTo("/i/j"));
                Assert.That(list[1].CopyFromRevision, Is.EqualTo(1L));
            }
        }
Example #18
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);
                    }
                }
            }
        }
Example #19
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));
            }
        }
Example #20
0
        public void LookGetLock_Test()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.DefaultBranched);
            int n = 0;

            Client.RemoteLock(new Uri(sbox.Uri, "src/file3.cpp"), "LOCKED!");

            using (InstallHook(sbox.RepositoryUri, SvnHookType.PreLock,
                delegate (object sender, ReposHookEventArgs e)
                {
                    using (SvnLookClient look = new SvnLookClient())
                    {
                        SvnLockInfo info;
                        look.GetLock(e.HookArgs.LookOrigin, e.HookArgs.Path, out info);
                        n++;
                    }
                }))
            using (InstallHook(sbox.RepositoryUri, SvnHookType.PostLock,
                delegate (object sender, ReposHookEventArgs e)
                {
                    using (SvnLookClient look = new SvnLookClient())
                    {
                        SvnLockInfo info;
                        foreach (string path in e.HookArgs.Paths)
                        {
                            look.GetLock(e.HookArgs.LookOrigin, path, out info);
                            Assert.That(info, Is.Not.Null);
                            n++;
                        }
                        n++; // 1 more
                    }
                }))
            using (InstallHook(sbox.RepositoryUri, SvnHookType.PreUnlock,
                delegate (object sender, ReposHookEventArgs e)
                {
                    using (SvnLookClient look = new SvnLookClient())
                    {
                        SvnLockInfo info;
                        look.GetLock(e.HookArgs.LookOrigin, e.HookArgs.Path, out info);
                        n++;
                    }
                }))
            using (InstallHook(sbox.RepositoryUri, SvnHookType.PostUnlock,
                delegate (object sender, ReposHookEventArgs e)
                {
                    using (SvnLookClient look = new SvnLookClient())
                    {
                        SvnLockInfo info;
                        foreach (string path in e.HookArgs.Paths)
                        {
                            look.GetLock(e.HookArgs.LookOrigin, path, out info);
                            Assert.That(info, Is.Null);
                            n++;
                        }
                        n++; // 1 more
                    }
                }))
            {

                using (SvnLookClient look = new SvnLookClient())
                {
                    SvnLockInfo info;
                    look.GetLock(new SvnLookOrigin(sbox.RepositoryUri.LocalPath), "trunk/src/file3.cpp", out info);
                    Assert.That(info, Is.Not.Null);
                    Assert.That(info.Comment, Is.EqualTo("LOCKED!"));
                }
                Client.Lock(Path.Combine(sbox.Wc, "src", "file1.cs"), "Can I?");

                Client.Unlock(Path.Combine(sbox.Wc, "src", "file1.cs"));

                string[] twopaths = new string[]
                {
                     Path.Combine(sbox.Wc, "src", "file1.cs"),
                     Path.Combine(sbox.Wc, "src", "file2.vb")
                };
                Client.Lock(twopaths, "Can I?");
                Client.Unlock(twopaths);
            }

            Assert.That(n, Is.EqualTo(16));
        }
Example #21
0
        public void LookGetLock_Test()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.DefaultBranched);
            int n = 0;

            Client.RemoteLock(new Uri(sbox.Uri, "src/file3.cpp"), "LOCKED!");

            using (InstallHook(sbox.RepositoryUri, SvnHookType.PreLock,
                               delegate(object sender, ReposHookEventArgs e)
            {
                using (SvnLookClient look = new SvnLookClient())
                {
                    SvnLockInfo info;
                    look.GetLock(e.HookArgs.LookOrigin, e.HookArgs.Path, out info);
                    n++;
                }
            }))
                using (InstallHook(sbox.RepositoryUri, SvnHookType.PostLock,
                                   delegate(object sender, ReposHookEventArgs e)
                {
                    using (SvnLookClient look = new SvnLookClient())
                    {
                        SvnLockInfo info;
                        foreach (string path in e.HookArgs.Paths)
                        {
                            look.GetLock(e.HookArgs.LookOrigin, path, out info);
                            Assert.That(info, Is.Not.Null);
                            n++;
                        }
                        n++; // 1 more
                    }
                }))
                    using (InstallHook(sbox.RepositoryUri, SvnHookType.PreUnlock,
                                       delegate(object sender, ReposHookEventArgs e)
                    {
                        using (SvnLookClient look = new SvnLookClient())
                        {
                            SvnLockInfo info;
                            look.GetLock(e.HookArgs.LookOrigin, e.HookArgs.Path, out info);
                            n++;
                        }
                    }))
                        using (InstallHook(sbox.RepositoryUri, SvnHookType.PostUnlock,
                                           delegate(object sender, ReposHookEventArgs e)
                        {
                            using (SvnLookClient look = new SvnLookClient())
                            {
                                SvnLockInfo info;
                                foreach (string path in e.HookArgs.Paths)
                                {
                                    look.GetLock(e.HookArgs.LookOrigin, path, out info);
                                    Assert.That(info, Is.Null);
                                    n++;
                                }
                                n++; // 1 more
                            }
                        }))
                        {
                            using (SvnLookClient look = new SvnLookClient())
                            {
                                SvnLockInfo info;
                                look.GetLock(new SvnLookOrigin(sbox.RepositoryUri.LocalPath), "trunk/src/file3.cpp", out info);
                                Assert.That(info, Is.Not.Null);
                                Assert.That(info.Comment, Is.EqualTo("LOCKED!"));
                            }
                            Client.Lock(Path.Combine(sbox.Wc, "src", "file1.cs"), "Can I?");

                            Client.Unlock(Path.Combine(sbox.Wc, "src", "file1.cs"));

                            string[] twopaths = new string[]
                            {
                                Path.Combine(sbox.Wc, "src", "file1.cs"),
                                Path.Combine(sbox.Wc, "src", "file2.vb")
                            };
                            Client.Lock(twopaths, "Can I?");
                            Client.Unlock(twopaths);
                        }

            Assert.That(n, Is.EqualTo(16));
        }
Example #22
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));
            }
        }
Example #23
0
        private void OnCopyDir(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient lc = new SvnLookClient())
            {
                SvnChangedArgs ca = new SvnChangedArgs();
                ca.Transaction = e.HookArgs.TransactionName;

                Collection<SvnChangedEventArgs> list;
                Assert.That(lc.GetChanged(e.HookArgs.LookOrigin, ca, out list));
                Assert.That(list.Count, Is.EqualTo(2));

                Assert.That(list[0].Name, Is.EqualTo("d"));
                Assert.That(list[0].Path, Is.EqualTo("/d/"));
                Assert.That(list[0].CopyFromPath, Is.EqualTo("/a/b/c/d"));
                Assert.That(list[0].CopyFromRevision, Is.EqualTo(1L));
                Assert.That(list[1].Name, Is.EqualTo("j"));
                Assert.That(list[1].Path, Is.EqualTo("/j/"));
                Assert.That(list[1].CopyFromPath, Is.EqualTo("/i/j"));
                Assert.That(list[1].CopyFromRevision, Is.EqualTo(1L));
            }
        }
Example #24
0
        private void OnChangedDirs(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient lc = new SvnLookClient())
            {
                SvnChangedArgs ca = new SvnChangedArgs();
                ca.Transaction = e.HookArgs.TransactionName;

                Collection<SvnChangedEventArgs> list;
                Assert.That(lc.GetChanged(e.HookArgs.LookOrigin, ca, out list));

                Assert.That(list.Count, Is.EqualTo(16));
                Assert.That(list[0].Name, Is.EqualTo("a"));
                Assert.That(list[0].Path, Is.EqualTo("/a/"));
                Assert.That(list[1].Name, Is.EqualTo("b"));
                Assert.That(list[1].Path, Is.EqualTo("/a/b/"));
                Assert.That(list[2].Name, Is.EqualTo("c"));
                Assert.That(list[2].Path, Is.EqualTo("/a/b/c/"));
            }
        }
Example #25
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));
            }
        }
Example #26
0
        private void OnPreCommitBigFile(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient cl = new SvnLookClient())
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    cl.Write(e.HookArgs.LookOrigin, "/bigfile", ms);
                }

                string b_p;
                Assert.That(cl.GetProperty(e.HookArgs.LookOrigin, "/bigfile", "a", out b_p));
                Assert.That(b_p, Is.EqualTo("b"));
            }
        }
Example #27
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);
                    }
                }
            }
        }
Example #28
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));
                    }
                }
            }
        }