Exemple #1
0
        public void Pull_IntoUnrelatedNonEmptyRepository_ThrowsMercurialExecutionException()
        {
            WriteTextFileAndCommit(Repo1, "test1.txt", "initial contents", "initial commit", true);
            WriteTextFileAndCommit(Repo2, "test2.txt", "initial contents", "initial commit", true);

            Assert.Throws <MercurialExecutionException>(() => Repo2.Pull(Repo1.Path));
        }
Exemple #2
0
        public void Pull_FromOtherWithRevisionSpecification_OnlyPullsInRelevantChanges()
        {
            WriteTextFileAndCommit(Repo1, "test1.txt", "initial contents", "initial commit", true);
            WriteTextFileAndCommit(Repo1, "test1.txt", "changed contents", "2nd commit", false);
            WriteTextFileAndCommit(Repo1, "test1.txt", "changed contents again", "3rd commit", false);

            Repo2.Pull(
                Repo1.Path, new PullCommand
            {
                Revisions =
                {
                    RevSpec.Single(1),
                },
            });

            Changeset[] pulledChangesets   = Repo2.Log().OrderBy(c => c.RevisionNumber).ToArray();
            Changeset[] originalChangesets = Repo1.Log(
                new LogCommand
            {
                Revisions =
                {
                    RevSpec.Range(0, 1),
                },
            }).OrderBy(c => c.RevisionNumber).ToArray();
            CollectionAssert.AreEqual(pulledChangesets, originalChangesets);
        }
Exemple #3
0
        public void Pull_NoChangesets_DoesNotInvokeIncomingHook()
        {
            if (IsUsingPersistentClient)
            {
                Assert.Inconclusive("Hook tests does not function correctly under the persistent client");
                return;
            }

            Repo1.Init();
            Repo2.Clone(Repo1.Path);

            WriteTextFileAndCommit(Repo1, "test.txt", "dummy", "dummy", true);
            Repo2.Pull(Repo1.Path);

            Repo2.SetHook("changegroup");

            var command = new CustomCommand("pull")
                          .WithAdditionalArgument(string.Format(CultureInfo.InvariantCulture, "\"{0}\"", Repo1.Path));

            Repo2.Execute(command);

            Assert.That(command.RawExitCode, Is.EqualTo(0));
            Assert.That(command.RawStandardOutput, Is.Not.StringContaining("Revision:"));
            Assert.That(command.RawStandardOutput, Is.Not.StringContaining("Url:"));
            Assert.That(command.RawStandardOutput, Is.Not.StringContaining("Source:"));
        }
Exemple #4
0
        public void Pull_FromOther_PullsInAllChanges()
        {
            WriteTextFileAndCommit(Repo1, "test1.txt", "initial contents", "initial commit", true);
            WriteTextFileAndCommit(Repo1, "test1.txt", "changed contents", "2nd commit", false);

            Repo2.Pull(Repo1.Path);

            CollectionAssert.AreEqual(Repo2.Log(), Repo1.Log());
        }
Exemple #5
0
        public void Pull_WithUpdateOption_UpdatesAccordingly(bool doUpdate)
        {
            WriteTextFileAndCommit(Repo1, "test1.txt", "initial contents", "initial commit", true);
            Repo2.Pull(
                Repo1.Path, new PullCommand
            {
                Update = doUpdate,
            });

            Assert.That(File.Exists(Path.Combine(Repo2.Path, "test1.txt")), Is.EqualTo(doUpdate));
        }
Exemple #6
0
        public void Pull_ForceIntoUnrelatedNonEmptyRepository_PerformsPull()
        {
            WriteTextFileAndCommit(Repo1, "test1.txt", "initial contents", "initial commit", true);
            WriteTextFileAndCommit(Repo2, "test2.txt", "initial contents", "initial commit", true);

            Repo2.Pull(
                Repo1.Path, new PullCommand
            {
                Force = true,
            });

            Assert.That(Repo2.Log().Count(), Is.EqualTo(2));
        }
Exemple #7
0
        public void Bundle_PulledIntoEmptyRepository_ProducesCloneOfSource()
        {
            string bundleFileName = GetTempFileName();

            Repo1.Init();
            WriteTextFileAndCommit(Repo1, "test1.txt", "dummy", "dummy", true);

            Repo2.Init();

            Repo1.Bundle(bundleFileName, Repo2.Path);
            Repo2.Pull(bundleFileName);

            CollectionAssert.AreEqual(Repo1.Log(new LogCommand().WithIncludePathActions()), Repo2.Log(new LogCommand().WithIncludePathActions()));
        }
Exemple #8
0
        public void Incoming_SavingTheBundle_AllowsPullFromBundle()
        {
            string bundleFileName = Path.GetTempFileName();

            Repo1.Init();
            Repo2.Clone(Repo1.Path);

            WriteTextFileAndCommit(Repo1, "test1.txt", "dummy", "dummy", true);
            Repo2.Incoming(new IncomingCommand().WithBundleFileName(bundleFileName));

            Changeset[] log = Repo2.Log().ToArray();
            Assert.That(log.Length, Is.EqualTo(0));

            Repo2.Pull(bundleFileName);

            log = Repo2.Log().ToArray();
            Assert.That(log.Length, Is.EqualTo(1));
        }
        public void Pull_NoChangesets_DoesNotInvokeIncomingHook()
        {
            Repo1.Init();
            Repo2.Clone(Repo1.Path);

            WriteTextFileAndCommit(Repo1, "test.txt", "dummy", "dummy", true);
            Repo2.Pull(Repo1.Path);

            Repo2.SetHook("incoming");

            var command = new CustomCommand("pull")
                          .WithAdditionalArgument(string.Format(CultureInfo.InvariantCulture, "\"{0}\"", Repo1.Path));

            Repo2.Execute(command);

            Assert.That(command.RawExitCode, Is.EqualTo(0));
            Assert.That(command.RawStandardOutput, Is.Not.Contains("Revision:"));
            Assert.That(command.RawStandardOutput, Is.Not.Contains("Url:"));
            Assert.That(command.RawStandardOutput, Is.Not.Contains("Source:"));
        }
Exemple #10
0
        public void Pull_Branch_OnlyPullsThatBranch()
        {
            WriteTextFileAndCommit(Repo1, "test1.txt", "initial contents", "initial commit", true);
            Repo2.Pull(Repo1.Path);

            Repo1.Branch("newbranch");
            WriteTextFileAndCommit(Repo1, "test2.txt", "initial contents", "2nd commit", true);
            Repo1.Update(0);
            WriteTextFileAndCommit(Repo1, "test3.txt", "initial contents", "3rd commit", true);

            Changeset[] log = Repo2.Log().ToArray();
            Assert.That(log.Length, Is.EqualTo(1));

            Repo2.Pull(
                Repo1.Path, new PullCommand
            {
                Branches =
                {
                    "newbranch",
                },
            });
            log = Repo2.Log().ToArray();
            Assert.That(log.Length, Is.EqualTo(2));
        }
Exemple #11
0
 public void Pull_WithNullOrEmptySource_ThrowsMercurialExecutionException(string source)
 {
     Assert.Throws <ArgumentNullException>(() => Repo2.Pull(source));
 }
Exemple #12
0
 public void Pull_WithoutSource_ThrowsMercurialExecutionException()
 {
     Assert.Throws <MercurialExecutionException>(() => Repo2.Pull());
 }