Ejemplo n.º 1
0
        public void BackoutHead_BackingOutTheCurrentHead_LeaveUsOnTheNewHead()
        {
            /*
            @  changeset:   2:0ced43559525
            |  tag:         tip
            |  summary:     backout
            |
            o  changeset:   1:ddc098603f64
            |  summary:     tuetcscw.u0v-->bad
            |
            o  changeset:   0:999cb7368d7a
               summary:     Add tuetcscw.u0v
            */
            using (var setup = new HgTestSetup())
            {
                var path = setup.Root.GetNewTempFile(true).Path;
                File.WriteAllText(path, "original");
                setup.Repository.AddAndCheckinFile(path);
                setup.ChangeAndCheckinFile(path, "bad");
                setup.AssertHeadOfWorkingDirNumber("1");
                setup.AssertHeadCount(1);

                string backoutRev = setup.Repository.BackoutHead("1", "backout");
                Assert.AreEqual("2", backoutRev);
                setup.AssertHeadCount(1);

                setup.AssertHeadOfWorkingDirNumber("2");
            }
        }
Ejemplo n.º 2
0
 public void Test_GetProxyAndCredentials()
 {
     using (var setup = new HgTestSetup())
     {
         var result = setup.Repository.GetProxyConfigParameterString("http://proxycheck.palaso.org/");
     }
 }
Ejemplo n.º 3
0
        public void BackoutHead_BackingOutTheCurrentHead_LeaveUsOnTheNewHead()
        {
            /*
             * @  changeset:   2:0ced43559525
             |  tag:         tip
             |  summary:     backout
             |
             | o  changeset:   1:ddc098603f64
             |  summary:     tuetcscw.u0v-->bad
             |
             | o  changeset:   0:999cb7368d7a
             | summary:     Add tuetcscw.u0v
             */
            using (var setup = new HgTestSetup())
            {
                var path = setup.Root.GetNewTempFile(true).Path;
                File.WriteAllText(path, "original");
                setup.Repository.AddAndCheckinFile(path);
                setup.ChangeAndCheckinFile(path, "bad");
                setup.AssertHeadOfWorkingDirNumber("1");
                setup.AssertHeadCount(1);

                string backoutRev = setup.Repository.BackoutHead("1", "backout");
                Assert.AreEqual("2", backoutRev);
                setup.AssertHeadCount(1);

                setup.AssertHeadOfWorkingDirNumber("2");
            }
        }
Ejemplo n.º 4
0
        public void BackoutHead_CurrentlyOnAnotherBranch_LeaveUsWhereWeWere()
        {
            /*
             * o  changeset:   3:61688974b0c3
             |  tag:         tip
             |  summary:     backout
             |
             | @  changeset:   2:79a705ba0bbd
             | |  summary:     daeao4yo.zb2-->ok
             | |
             | o |  changeset:   1:0be0d43dd824
             |/    summary:     daeao4yo.zb2-->bad
             |
             | o  changeset:   0:534055cd5da5
             |      summary:     Add daeao4yo.zb2
             */
            using (var setup = new HgTestSetup())
            {
                var path = setup.Root.GetNewTempFile(true).Path;
                File.WriteAllText(path, "original");
                setup.Repository.AddAndCheckinFile(path);
                setup.ChangeAndCheckinFile(path, "bad");
                setup.AssertHeadOfWorkingDirNumber("1");
                setup.Repository.Update("0");                //go back to start a new branch
                setup.ChangeAndCheckinFile(path, "ok");
                setup.AssertHeadCount(2);

                string backoutRev = setup.Repository.BackoutHead("1", "backout");
                Assert.AreEqual("3", backoutRev);
                setup.AssertHeadCount(2);

                setup.AssertHeadOfWorkingDirNumber("2");                //expect to be left on the branch we were on, not the backed out one
                Assert.AreEqual("0", setup.Repository.GetRevisionWorkingSetIsBasedOn().Parents[0].LocalRevisionNumber);
            }
        }
Ejemplo n.º 5
0
 public void RemoveOldLocks_NoLocks_ReturnsTrue()
 {
     using (var setup = new HgTestSetup())
     {
         Assert.IsTrue(setup.Repository.RemoveOldLocks());
     }
 }
Ejemplo n.º 6
0
 public void Commit_WLockExists_GetTimeoutException()
 {
     HgRunner.TimeoutSecondsOverrideForUnitTests = 1;
     using (var setup = new HgTestSetup())
         using (setup.GetWLock())
         {
             Assert.Throws <TimeoutException>(() => setup.Repository.Commit(false, "test"));
         }
 }
Ejemplo n.º 7
0
 public void RemoveOldLocks_WLockButNotRunningHg_LockRemoved()
 {
     using (var setup = new HgTestSetup())
     {
         var file = TempFileFromFolder.CreateAt(setup.Root.Combine(".hg", "wlock"), "blah");
         Assert.IsTrue(setup.Repository.RemoveOldLocks());
         Assert.IsFalse(File.Exists(file.Path));
     }
 }
Ejemplo n.º 8
0
 public void CommitWithNoUsernameInHgrcFileUsesDefaultFromEnvironment()
 {
     using (var setup = new HgTestSetup())
     {
         var path = setup.Root.GetNewTempFile(true).Path;
         setup.Repository.AddAndCheckinFile(path);
         var rev = setup.Repository.GetAllRevisions()[0];
         Assert.AreEqual(Environment.UserName.Replace(" ", string.Empty), rev.UserId);
     }
 }
Ejemplo n.º 9
0
 public void AddAndCheckinFile_WLockExists_GetTimeoutException()
 {
     HgRunner.TimeoutSecondsOverrideForUnitTests = 1;
     using (var setup = new HgTestSetup())
         using (setup.GetWLock())
         {
             Assert.Throws <TimeoutException>(() =>
                                              setup.Repository.AddAndCheckinFile(setup.Root.GetNewTempFile(true).Path));
         }
 }
Ejemplo n.º 10
0
 public void AddAndCheckinFiles_UserNameHasASpace_DoesnotDie()
 {
     using (var setup = new HgTestSetup())
     {
         setup.Repository.SetUserNameInIni("charlie brown", new NullProgress());
         var path = setup.Root.GetNewTempFile(true).Path;
         setup.ChangeAndCheckinFile(path, "hello");
         //setup.Repository.AddAndCheckinFiles(new List<string>(new[]{}), );
     }
 }
Ejemplo n.º 11
0
 public void AddAndCheckinFiles_UserNameHasASpace_DoesnotDie()
 {
     using (var setup = new HgTestSetup())
     {
         setup.Repository.SetUserNameInIni("charlie brown", new NullProgress());
         var path = setup.Root.GetNewTempFile(true).Path;
         setup.ChangeAndCheckinFile(path, "hello");
         //setup.Repository.AddAndCheckinFiles(new List<string>(new[]{}), );
     }
 }
Ejemplo n.º 12
0
 public void BackoutHead_FirstChangeSetInTheRepo_Throws()
 {
     using (var setup = new HgTestSetup())
     {
         var path = setup.Root.GetNewTempFile(true).Path;
         setup.Repository.AddAndCheckinFile(path);
         Assert.Throws <ApplicationException>(() =>
                                              setup.Repository.BackoutHead("0", "testing"));
     }
 }
Ejemplo n.º 13
0
 public void AddAndCheckinFile_WLockExists_GetTimeoutException()
 {
     HgRunner.TimeoutSecondsOverrideForUnitTests = 1;
     using (var setup = new HgTestSetup())
     using (setup.GetWLock())
     {
         Assert.Throws<TimeoutException>(() =>
             setup.Repository.AddAndCheckinFile(setup.Root.GetNewTempFile(true).Path));
     }
 }
Ejemplo n.º 14
0
 public void RemoveOldLocks_WLockAndLockButNotRunningHg_BothLocksRemoved()
 {
     using (var setup = new HgTestSetup())
     {
         var file1 = TempFileFromFolder.CreateAt(setup.Root.Combine(".hg", "wlock"), "blah");
         var file2 = TempFileFromFolder.CreateAt(setup.Root.Combine(".hg", "store", "lock"), "blah");
         Assert.That(setup.Repository.RemoveOldLocks(), Is.True);
         Assert.That(File.Exists(file1.Path), Is.False);
         Assert.That(File.Exists(file2.Path), Is.False);
     }
 }
Ejemplo n.º 15
0
 public void CommitCommentWithDoubleQuotes_HasCorrectComment()
 {
     using (var setup = new HgTestSetup())
     {
         var path = setup.Root.GetNewTempFile(true).Path;
         setup.Repository.AddAndCheckinFile(path);
         File.WriteAllText(path, "new stuff");
         const string message = "New \"double quoted\" comment";
         setup.Repository.Commit(true, message);
         setup.AssertCommitMessageOfRevision("1", message);
     }
 }
Ejemplo n.º 16
0
 public void SetUserNameInIni_HgrcIsOpenFromAnotherProcess_GetTimeoutException()
 {
     HgRunner.TimeoutSecondsOverrideForUnitTests = 1;
     using (var setup = new HgTestSetup())
     {
         setup.Repository.SetUserNameInIni("me", new NullProgress());
         using (new StreamWriter(setup.Root.Combine(".hg", "hgrc")))
         {
             Assert.Throws <TimeoutException>(() =>
                                              setup.Repository.SetUserNameInIni("otherme", new NullProgress()));
         }
     }
 }
Ejemplo n.º 17
0
        public void RemoveOldLocks_LockAndHgIsRunning_ReturnsFalse()
        {
            using (var setup = new HgTestSetup())
            {
                //we have to pretent to be hg
                var ourName = Process.GetCurrentProcess().ProcessName;

                using (var file = TempFileFromFolder.CreateAt(setup.Root.Combine(".hg", "store", "lock"), "blah"))
                {
                    Assert.IsFalse(setup.Repository.RemoveOldLocks(ourName, true));
                }
            }
        }
Ejemplo n.º 18
0
 public void MakeBundle_InvalidBase_FalseAndFileDoesNotExist()
 {
     using (var setup = new HgTestSetup())
     {
         var path = setup.Root.GetNewTempFile(true).Path;
         File.WriteAllText(path, "original");
         setup.Repository.AddAndCheckinFile(path);
         string bundleFilePath = setup.Root.GetNewTempFile(false).Path;
         Assert.That(setup.Repository.MakeBundle(new [] { "fakehash" },
                                                 bundleFilePath), Is.False);
         Assert.That(File.Exists(bundleFilePath), Is.False);
     }
 }
Ejemplo n.º 19
0
 public void Pull_FileIsLocked_GetTimeoutException()
 {
     HgRunner.TimeoutSecondsOverrideForUnitTests = 1;
     using (var setup = new HgTestSetup())
         using (setup.GetWLock())
         {
             var path = setup.Root.GetNewTempFile(true).Path;
             setup.Repository.AddAndCheckinFile(path);
             using (new StreamWriter(path))
             {
                 Assert.Throws <TimeoutException>(() => setup.Repository.Update());
             }
         }
 }
Ejemplo n.º 20
0
        public void MakeBundle_ValidBase_BundleFileExistsAndReturnsTrue()
        {
            using (var setup = new HgTestSetup())
            {
                var path = setup.Root.GetNewTempFile(true).Path;
                File.WriteAllText(path, "original");
                setup.Repository.AddAndCheckinFile(path);
                Revision revision = setup.Repository.GetTip();
                setup.ChangeAndCheckinFile(path, "bad");

                var bundleFilePath = setup.Root.GetNewTempFile(true).Path;
                Assert.That(setup.Repository.MakeBundle(new [] { revision.Number.Hash }, bundleFilePath), Is.True);
                Assert.That(File.Exists(bundleFilePath), Is.True);
            }
        }
Ejemplo n.º 21
0
        public void BackoutHead_UsesCommitMessage()
        {
            using (var setup = new HgTestSetup())
            {
                var path = setup.Root.GetNewTempFile(true).Path;
                setup.Repository.AddAndCheckinFile(path);
                File.WriteAllText(path, "2");
                setup.Repository.AddAndCheckinFile(path);
                var theMessage = "testing";
                setup.Repository.BackoutHead("1", theMessage);
                setup.AssertLocalNumberOfTip("2");
                setup.AssertHeadOfWorkingDirNumber("2");
                setup.AssertHeadCount(1);

                setup.AssertCommitMessageOfRevision("2", theMessage);
            }
        }
Ejemplo n.º 22
0
        public void BackoutHead_UsesCommitMessage()
        {
            using (var setup = new HgTestSetup())
            {
                var path = setup.Root.GetNewTempFile(true).Path;
                setup.Repository.AddAndCheckinFile(path);
                File.WriteAllText(path, "2");
                setup.Repository.AddAndCheckinFile(path);
                var theMessage = "testing";
                setup.Repository.BackoutHead("1", theMessage);
                setup.AssertLocalNumberOfTip("2");
                setup.AssertHeadOfWorkingDirNumber("2");
                setup.AssertHeadCount(1);

                //for debuging a weird TeamCity failure of this
                Assert.AreEqual((int)'t', (int)(setup.Repository.GetRevision("2").Summary.Trim())[0]);
                Assert.AreEqual((int)'t', (int)(setup.Repository.GetRevision("2").Summary)[0]);
                Assert.AreEqual(theMessage, setup.Repository.GetRevision("2").Summary);

                setup.AssertCommitMessageOfRevision("2", theMessage);
            }
        }
Ejemplo n.º 23
0
        public void BackoutHead_UsesCommitMessage()
        {
            using (var setup = new HgTestSetup())
            {
                var path = setup.Root.GetNewTempFile(true).Path;
                setup.Repository.AddAndCheckinFile(path);
                File.WriteAllText(path,"2");
                setup.Repository.AddAndCheckinFile(path);
                var theMessage = "testing";
                setup.Repository.BackoutHead("1", theMessage);
                setup.AssertLocalNumberOfTip("2");
                setup.AssertHeadOfWorkingDirNumber("2");
                setup.AssertHeadCount(1);

                setup.AssertCommitMessageOfRevision("2",theMessage);
            }
        }
Ejemplo n.º 24
0
 public void CommitCommentWithDoubleQuotes_HasCorrectComment()
 {
     using (var setup = new HgTestSetup())
     {
         var path = setup.Root.GetNewTempFile(true).Path;
         setup.Repository.AddAndCheckinFile(path);
         File.WriteAllText(path, "new stuff");
         const string message = "New \"double quoted\" comment";
         setup.Repository.Commit(true, message);
         setup.AssertCommitMessageOfRevision("1", message);
     }
 }
Ejemplo n.º 25
0
 public void CommitWithNoUsernameInHgrcFileUsesDefaultFromEnvironmentButWithoutSpaces()
 {
     using (var setup = new HgTestSetup())
     {
         var path = setup.Root.GetNewTempFile(true).Path;
         setup.Repository.AddAndCheckinFile(path);
         var rev = setup.Repository.GetAllRevisions()[0];
         Assert.AreEqual(Environment.UserName.Replace(" ", ""), rev.UserId);
     }
 }
Ejemplo n.º 26
0
        public void BackoutHead_UsesCommitMessage()
        {
            using (var setup = new HgTestSetup())
            {
                var path = setup.Root.GetNewTempFile(true).Path;
                setup.Repository.AddAndCheckinFile(path);
                File.WriteAllText(path,"2");
                setup.Repository.AddAndCheckinFile(path);
                var theMessage = "testing";
                setup.Repository.BackoutHead("1", theMessage);
                setup.AssertLocalNumberOfTip("2");
                setup.AssertHeadOfWorkingDirNumber("2");
                setup.AssertHeadCount(1);

                //for debuging a weird TeamCity failure of this
                Assert.AreEqual((int)'t', (int)(setup.Repository.GetRevision("2").Summary.Trim())[0]);
                Assert.AreEqual((int)'t', (int)(setup.Repository.GetRevision("2").Summary)[0]);
                Assert.AreEqual(theMessage, setup.Repository.GetRevision("2").Summary);

                setup.AssertCommitMessageOfRevision("2",theMessage);
            }
        }
Ejemplo n.º 27
0
        public void MakeBundle_ValidBase_BundleFileExistsAndReturnsTrue()
        {
            using (var setup = new HgTestSetup())
            {
                var path = setup.Root.GetNewTempFile(true).Path;
                File.WriteAllText(path, "original");
                setup.Repository.AddAndCheckinFile(path);
                Revision revision = setup.Repository.GetTip();
                setup.ChangeAndCheckinFile(path, "bad");

                var bundleFilePath = setup.Root.GetNewTempFile(true).Path;
                Assert.That(setup.Repository.MakeBundle(new []{revision.Number.Hash}, bundleFilePath), Is.True);
                Assert.That(File.Exists(bundleFilePath), Is.True);
            }
        }
Ejemplo n.º 28
0
 public void Pull_FileIsLocked_GetTimeoutException()
 {
     HgRunner.TimeoutSecondsOverrideForUnitTests = 1;
     using (var setup = new HgTestSetup())
     using (setup.GetWLock())
     {
         var path = setup.Root.GetNewTempFile(true).Path;
         setup.Repository.AddAndCheckinFile(path);
         using (new StreamWriter(path))
         {
            Assert.Throws<TimeoutException>(() => setup.Repository.Update());
         }
     }
 }
Ejemplo n.º 29
0
 public void RemoveOldLocks_NoLocks_ReturnsTrue()
 {
     using (var setup = new HgTestSetup())
     {
         Assert.IsTrue(setup.Repository.RemoveOldLocks());
     }
 }
Ejemplo n.º 30
0
        public void RemoveOldLocks_WLockAndHgIsRunning_ReturnsFalse()
        {
            using (var setup = new HgTestSetup())
            {
                //we have to pretent to be hg
                var ourName =System.Diagnostics.Process.GetCurrentProcess().ProcessName;

                using(var file = TempFileFromFolder.CreateAt(setup.Root.Combine(".hg", "wlock"), "blah"))
                {
                    Assert.IsFalse(setup.Repository.RemoveOldLocks(ourName, true));
                }
            }
        }
Ejemplo n.º 31
0
        public void BackoutHead_CurrentlyOnAnotherBranch_LeaveUsWhereWeWere()
        {
            /*
            o  changeset:   3:61688974b0c3
            |  tag:         tip
            |  summary:     backout
            |
            | @  changeset:   2:79a705ba0bbd
            | |  summary:     daeao4yo.zb2-->ok
            | |
            o |  changeset:   1:0be0d43dd824
            |/    summary:     daeao4yo.zb2-->bad
            |
            o  changeset:   0:534055cd5da5
                summary:     Add daeao4yo.zb2
            */
            using (var setup = new HgTestSetup())
            {
                var path = setup.Root.GetNewTempFile(true).Path;
                File.WriteAllText(path, "original");
                setup.Repository.AddAndCheckinFile(path);
                setup.ChangeAndCheckinFile(path, "bad");
                setup.AssertHeadOfWorkingDirNumber("1");
                setup.Repository.Update("0");//go back to start a new branch
                setup.ChangeAndCheckinFile(path, "ok");
                setup.AssertHeadCount(2);

                string backoutRev = setup.Repository.BackoutHead("1", "backout");
                Assert.AreEqual("3",backoutRev);
                setup.AssertHeadCount(2);

                setup.AssertHeadOfWorkingDirNumber("2");//expect to be left on the branch we were on, not the backed out one
                Assert.AreEqual("0", setup.Repository.GetRevisionWorkingSetIsBasedOn().Parents[0].LocalRevisionNumber);
            }
        }
Ejemplo n.º 32
0
 public void RemoveOldLocks_WLockButNotRunningHg_LockRemoved()
 {
     using (var setup = new HgTestSetup())
     {
         var file = TempFileFromFolder.CreateAt(setup.Root.Combine(".hg", "wlock"), "blah");
         Assert.IsTrue(setup.Repository.RemoveOldLocks());
         Assert.IsFalse(File.Exists(file.Path));
     }
 }
Ejemplo n.º 33
0
 public void BackoutHead_FirstChangeSetInTheRepo_Throws()
 {
     using (var setup = new HgTestSetup())
     {
         var path = setup.Root.GetNewTempFile(true).Path;
         setup.Repository.AddAndCheckinFile(path);
         Assert.Throws<ApplicationException>(() =>
             setup.Repository.BackoutHead("0", "testing"));
     }
 }
Ejemplo n.º 34
0
 public void MakeBundle_InvalidBase_FalseAndFileDoesNotExist()
 {
     using (var setup = new HgTestSetup())
     {
         var path = setup.Root.GetNewTempFile(true).Path;
         File.WriteAllText(path, "original");
         setup.Repository.AddAndCheckinFile(path);
         string bundleFilePath = setup.Root.GetNewTempFile(false).Path;
         Assert.That(setup.Repository.MakeBundle(new []{"fakehash"},
             bundleFilePath), Is.False);
         Assert.That(File.Exists(bundleFilePath), Is.False);
     }
 }
Ejemplo n.º 35
0
 public void Commit_WLockExists_GetTimeoutException()
 {
     HgRunner.TimeoutSecondsOverrideForUnitTests = 1;
     using (var setup = new HgTestSetup())
     using (setup.GetWLock())
     {
        Assert.Throws<TimeoutException>(() => setup.Repository.Commit(false, "test"));
     }
 }
Ejemplo n.º 36
0
 public void Test_GetProxyAndCredentials()
 {
     using (var setup = new HgTestSetup())
     {
         var result =setup.Repository.GetProxyConfigParameterString("http://proxycheck.palaso.org/");
     }
 }
Ejemplo n.º 37
0
 public void SetUserNameInIni_HgrcIsOpenFromAnotherProcess_GetTimeoutException()
 {
     HgRunner.TimeoutSecondsOverrideForUnitTests = 1;
     using (var setup = new HgTestSetup())
     {
         setup.Repository.SetUserNameInIni("me", new NullProgress());
         using (new StreamWriter(setup.Root.Combine(".hg", "hgrc")))
         {
             Assert.Throws<TimeoutException>(() =>
                 setup.Repository.SetUserNameInIni("otherme", new NullProgress()));
         }
     }
 }