示例#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");
            }
        }
示例#2
0
 public void Test_GetProxyAndCredentials()
 {
     using (var setup = new HgTestSetup())
     {
         var result = setup.Repository.GetProxyConfigParameterString("http://proxycheck.palaso.org/");
     }
 }
示例#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");
            }
        }
示例#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);
            }
        }
示例#5
0
 public void RemoveOldLocks_NoLocks_ReturnsTrue()
 {
     using (var setup = new HgTestSetup())
     {
         Assert.IsTrue(setup.Repository.RemoveOldLocks());
     }
 }
示例#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"));
         }
 }
示例#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));
     }
 }
示例#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);
     }
 }
示例#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));
         }
 }
示例#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[]{}), );
     }
 }
示例#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[]{}), );
     }
 }
示例#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"));
     }
 }
示例#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));
     }
 }
示例#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);
     }
 }
示例#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);
     }
 }
示例#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()));
         }
     }
 }
示例#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));
                }
            }
        }
示例#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);
     }
 }
示例#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());
             }
         }
 }
示例#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);
            }
        }
示例#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);
            }
        }
示例#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);
            }
        }
示例#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);
            }
        }
示例#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);
     }
 }
示例#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);
     }
 }
示例#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);
            }
        }
示例#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);
            }
        }
示例#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());
         }
     }
 }
示例#29
0
 public void RemoveOldLocks_NoLocks_ReturnsTrue()
 {
     using (var setup = new HgTestSetup())
     {
         Assert.IsTrue(setup.Repository.RemoveOldLocks());
     }
 }
示例#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));
                }
            }
        }
示例#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);
            }
        }
示例#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));
     }
 }
示例#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"));
     }
 }
示例#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);
     }
 }
示例#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"));
     }
 }
示例#36
0
 public void Test_GetProxyAndCredentials()
 {
     using (var setup = new HgTestSetup())
     {
         var result =setup.Repository.GetProxyConfigParameterString("http://proxycheck.palaso.org/");
     }
 }
示例#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()));
         }
     }
 }