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"); } }
public void Test_GetProxyAndCredentials() { using (var setup = new HgTestSetup()) { var result = setup.Repository.GetProxyConfigParameterString("http://proxycheck.palaso.org/"); } }
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"); } }
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); } }
public void RemoveOldLocks_NoLocks_ReturnsTrue() { using (var setup = new HgTestSetup()) { Assert.IsTrue(setup.Repository.RemoveOldLocks()); } }
public void Commit_WLockExists_GetTimeoutException() { HgRunner.TimeoutSecondsOverrideForUnitTests = 1; using (var setup = new HgTestSetup()) using (setup.GetWLock()) { Assert.Throws <TimeoutException>(() => setup.Repository.Commit(false, "test")); } }
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)); } }
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); } }
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)); } }
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[]{}), ); } }
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")); } }
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)); } }
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); } }
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); } }
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())); } } }
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)); } } }
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); } }
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()); } } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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()); } } }
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)); } } }
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); } }
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")); } }
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); } }
public void Commit_WLockExists_GetTimeoutException() { HgRunner.TimeoutSecondsOverrideForUnitTests = 1; using (var setup = new HgTestSetup()) using (setup.GetWLock()) { Assert.Throws<TimeoutException>(() => setup.Repository.Commit(false, "test")); } }
public void Test_GetProxyAndCredentials() { using (var setup = new HgTestSetup()) { var result =setup.Repository.GetProxyConfigParameterString("http://proxycheck.palaso.org/"); } }
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())); } } }