Esempio n. 1
0
        public void Merge_MinimalMergeTest()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Empty);

            using (SvnClient client = NewSvnClient(true, false))
            {
                string merge1 = Path.Combine(sbox.Wc, "mmerge-1");
                string merge2 = Path.Combine(sbox.Wc, "mmerge-2");
                client.CreateDirectory(merge1);

                string f1 = Path.Combine(merge1, "myfile.txt");

                using (StreamWriter fs = File.CreateText(f1))
                {
                    fs.WriteLine("First line");
                    fs.WriteLine("Second line");
                    fs.WriteLine("Third line");
                    fs.WriteLine("Fourth line");
                }

                client.Add(f1);

                SvnCommitResult ci;
                client.Commit(sbox.Wc, out ci);
                client.Copy(new SvnPathTarget(merge1), merge2);
                client.Commit(sbox.Wc);
                client.Update(sbox.Wc);

                SvnMergeSourcesCollection sources;
                client.GetSuggestedMergeSources(new SvnPathTarget(merge1), out sources);

                Assert.That(sources.Count, Is.EqualTo(0));

                client.GetSuggestedMergeSources(new SvnPathTarget(merge2), out sources);

                Assert.That(sources.Count, Is.EqualTo(1));

                Uri fromUri = new Uri(sbox.RepositoryUri, new Uri("mmerge-1", UriKind.Relative));
                Assert.That(sources[0].Uri, Is.EqualTo(fromUri));

                SvnAppliedMergeInfo applied;
                client.GetAppliedMergeInfo(new SvnPathTarget(merge2), out applied);

                Assert.That(applied, Is.Null);
                //Assert.That(applied.AppliedMerges.Count, Is.EqualTo(0));
                //Assert.That(applied.Target, Is.Not.Null);

                Collection <SvnMergesEligibleEventArgs> available;
                client.GetMergesEligible(new SvnPathTarget(merge2), fromUri, out available);
                Assert.That(available, Is.Not.Null);
                Assert.That(available.Count, Is.EqualTo(0));

                /*Assert.That(available[0].Revision, Is.EqualTo(ci.Revision));
                 * //Assert.That(available.MergeRanges[0].End, Is.EqualTo(ci.Revision + 1));
                 * //Assert.That(available.MergeRanges[0].Inheritable, Is.True);
                 * Assert.That(available[0].SourceUri, Is.Not.Null);*/

                using (StreamWriter fs = File.AppendText(f1))
                {
                    fs.WriteLine("Fifth line");
                }
                client.Commit(merge1);

                client.GetMergesEligible(new SvnPathTarget(merge2), fromUri, out available);
                Assert.That(available, Is.Not.Null);
                Assert.That(available.Count, Is.EqualTo(1));
                Assert.That(available[0].Revision, Is.EqualTo(3));
                Assert.That(available[0].SourceUri, Is.Not.Null);

                client.Merge(merge2, fromUri, available[0].AsRange());

                client.GetMergesEligible(new SvnPathTarget(merge2), fromUri, out available);
                Assert.That(available, Is.Not.Null);
                Assert.That(available.Count, Is.EqualTo(0));

                client.Commit(sbox.Wc);

                client.GetMergesEligible(new SvnPathTarget(merge2), fromUri, out available);
                Assert.That(available, Is.Not.Null);
                Assert.That(available.Count, Is.EqualTo(0));

                client.GetAppliedMergeInfo(new SvnPathTarget(merge2), out applied);

                Assert.That(applied, Is.Not.Null);
                Assert.That(applied.AppliedMerges.Count, Is.EqualTo(1));
                Assert.That(applied.AppliedMerges[0].Uri, Is.EqualTo(fromUri));
                Assert.That(applied.AppliedMerges[0].MergeRanges, Is.Not.Null);
                Assert.That(applied.AppliedMerges[0].MergeRanges.Count, Is.EqualTo(1));
                Assert.That(applied.AppliedMerges[0].MergeRanges[0].Start, Is.EqualTo(ci.Revision + 1));
                Assert.That(applied.AppliedMerges[0].MergeRanges[0].End, Is.EqualTo(ci.Revision + 2));
                Assert.That(applied.AppliedMerges[0].MergeRanges[0].Inheritable, Is.True);
                Assert.That(applied.Target, Is.Not.Null);
            }
        }