public void SettingSychronizerAdjunctToNullEndsWithDoNothingDefaultInterfaceImplementation()
		{
			using (var bob = new RepositorySetup("bob", true))
			{
				var synchronizer = bob.CreateSynchronizer();
				Assert.IsNotNull(synchronizer.SynchronizerAdjunct);
				Assert.IsInstanceOf<DefaultSychronizerAdjunct>(synchronizer.SynchronizerAdjunct);

				synchronizer.SynchronizerAdjunct = null;
				Assert.IsNotNull(synchronizer.SynchronizerAdjunct);
				Assert.IsInstanceOf<DefaultSychronizerAdjunct>(synchronizer.SynchronizerAdjunct);
			}
		}
Пример #2
0
        public void SynchNow_OnNamedBranchAndDefaultBranchExists_DoesNotMergeWithIt()
        {
            using (var repo = new RepositorySetup("bob"))
            {
                if (repo.Synchronizer == null)
                    repo.Synchronizer = repo.CreateSynchronizer();
                repo.Synchronizer.SynchronizerAdjunct = new ProgrammableSynchronizerAdjunct("default");
                repo.AddAndCheckinFile("test.txt", "apple");
                var afterFirstCheckin = repo.CreateBookmarkHere();
                repo.ChangeFileAndCommit("test.txt", "pear", "second on default");

                afterFirstCheckin.Go();
                repo.Repository.BranchingHelper.Branch(new ConsoleProgress(), "animals");
                repo.Synchronizer.SynchronizerAdjunct = new ProgrammableSynchronizerAdjunct("animals");
                repo.ChangeFileAndCommit("test.txt", "dog", "first on animals");
                var animalHead = repo.CreateBookmarkHere();

                repo.AssertHeadCount(2);
                repo.CheckinAndPullAndMerge();
                repo.AssertHeadCount(2);
                animalHead.AssertRepoIsAtThisPoint();
            }
        }
		public void BasicCommitHasCommitFileButNotMergeFile()
		{
			using (var bob = new RepositorySetup("bob", true))
			{
				var syncAdjunct = new FileWriterSychronizerAdjunct(bob.RootFolder.Path);
				CheckNoFilesExist(syncAdjunct);

				var options = new SyncOptions
				{
					DoMergeWithOthers = false,
					DoPullFromOthers = false,
					DoSendToOthers = false
				};
				var synchronizer = bob.CreateSynchronizer();
				synchronizer.SynchronizerAdjunct = syncAdjunct;

				var syncResults = bob.SyncWithOptions(options, synchronizer);
				Assert.IsFalse(syncResults.DidGetChangesFromOthers);
				CheckExistanceOfAdjunctFiles(syncAdjunct, true, false, false, false, true, false);
			}
		}
Пример #4
0
        public void SetUserNameInIni_SetsName()
        {
            using (new MercurialIniForTests())
            using (var setup = new RepositorySetup("Dan"))
            {
                setup.EnsureNoHgrcExists();
                var repository = setup.CreateSynchronizer().Repository;
                repository.SetUserNameInIni("bill", _progress);
                Assert.AreEqual("bill", repository.GetUserNameFromIni(_progress, "anonymous"));

                //this time, the hgrc does exist
                repository.SetUserNameInIni("sue", _progress);
                Assert.AreEqual("sue", repository.GetUserNameFromIni(_progress, "anonymous"));
            }
        }
Пример #5
0
        public void SetTheOnlyAddressOfThisType_SettingLANPathHadSameType_IsReplacedByNew()
        {
            using (new MercurialIniForTests())
            using (var setup = new RepositorySetup("Dan"))
            {
                setup.EnsureNoHgrcExists();
                var repository = setup.CreateSynchronizer().Repository;
                var x = RepositoryAddress.Create("theInterent", @"http://two.org");
                var y1 = RepositoryAddress.Create("aPath1", @"\\someone1\someFolder");
                repository.SetKnownRepositoryAddresses(new List<RepositoryAddress>(new RepositoryAddress[] { x, y1 }));
                Assert.AreEqual(y1.URI, repository.GetRepositoryPathsInHgrc().ToArray()[1].URI, "Test setup is wrong");

                var y2 = RepositoryAddress.Create("aPath2", @"\\someoneElse2\someOtherFolder");
                repository.SetTheOnlyAddressOfThisType(y2);
                Assert.AreEqual(2, repository.GetRepositoryPathsInHgrc().Count());
                AssertHgrcNowContainsUri(repository, x.URI);
                AssertHgrcNowContainsUri(repository, y2.URI);
            }
        }
Пример #6
0
 public void SetTheOnlyAddressOfThisType_WasEmtpy_HasNewAddress()
 {
     using (new MercurialIniForTests())
     using (var setup = new RepositorySetup("Dan"))
     {
         setup.EnsureNoHgrcExists();
         var repository = setup.CreateSynchronizer().Repository;
         var y1 = RepositoryAddress.Create("aPath1", @"\\someone1\someFolder");
         repository.SetTheOnlyAddressOfThisType(y1);
         Assert.AreEqual(1, repository.GetRepositoryPathsInHgrc().Count());
         Assert.AreEqual(y1.URI, repository.GetRepositoryPathsInHgrc().ToArray()[0].URI);
     }
 }
Пример #7
0
        public void SetTheOnlyAddressOfThisType_HadAnotherType_HasOldAddressAndNew()
        {
            using (new MercurialIniForTests())
            using (var setup = new RepositorySetup("Dan"))
            {
                setup.EnsureNoHgrcExists();
                var repository = setup.CreateSynchronizer().Repository;
                var x = RepositoryAddress.Create("theInterent", @"http://two.org");
                repository.SetKnownRepositoryAddresses(new List<RepositoryAddress>(new RepositoryAddress[] { x }));

                var y2 = RepositoryAddress.Create("aPath2", @"\\someoneElse2\someOtherFolder");
                repository.SetTheOnlyAddressOfThisType(y2);
                Assert.AreEqual(2, repository.GetRepositoryPathsInHgrc().Count());
                AssertHgrcNowContainsUri(repository, x.URI);
                AssertHgrcNowContainsUri(repository, y2.URI);
             }
        }
Пример #8
0
        public void SetTheOnlyAddressOfThisType_SettingInternetPathHadSameType_IsReplacedByNew()
        {
            using (new MercurialIniForTests())
            using (var setup = new RepositorySetup("Dan"))
            {
                setup.EnsureNoHgrcExists();
                var repository = setup.CreateSynchronizer().Repository;
                var x1 = RepositoryAddress.Create("interent1", @"http://one.org");
                var y = RepositoryAddress.Create("aPath", @"\\someone1\someFolder");
                repository.SetKnownRepositoryAddresses(new List<RepositoryAddress>(new RepositoryAddress[] { x1, y }));
                Assert.AreEqual(x1.URI, repository.GetRepositoryPathsInHgrc().ToArray()[0].URI, "Test setup is wrong");

                var x2 = RepositoryAddress.Create("internet2", @"http://two.org");
                repository.SetTheOnlyAddressOfThisType(x2);
                Assert.AreEqual(2, repository.GetRepositoryPathsInHgrc().Count());
                AssertHgrcNowContainsUri(repository, y.URI);
                AssertHgrcNowContainsUri(repository, x2.URI);
            }
        }
Пример #9
0
        public void SetRepositoryAliases()
        {
            using (new MercurialIniForTests())
            using (var setup = new RepositorySetup("Dan"))
            {
                setup.EnsureNoHgrcExists();
                var repository = setup.CreateSynchronizer().Repository;
                var x = RepositoryAddress.Create("one", @"c:\one");
                var y = RepositoryAddress.Create("two", @"http://two.org");
                repository.SetKnownRepositoryAddresses(new List<RepositoryAddress>(new RepositoryAddress[]{x,y}));
                Assert.AreEqual(2, repository.GetRepositoryPathsInHgrc().Count());
                Assert.AreEqual(x.Name, repository.GetRepositoryPathsInHgrc().First().Name);
                Assert.AreEqual(x.URI, repository.GetRepositoryPathsInHgrc().First().URI);
                Assert.AreEqual(y.Name, repository.GetRepositoryPathsInHgrc().ToArray()[1].Name);
                Assert.AreEqual(y.URI, repository.GetRepositoryPathsInHgrc().ToArray()[1].URI);

                var z = RepositoryAddress.Create("three", @"http://three.org");
                //this time, the hgrc does exist
                repository.SetKnownRepositoryAddresses(new List<RepositoryAddress>(new RepositoryAddress[]{z}));
                Assert.AreEqual(1, repository.GetRepositoryPathsInHgrc().Count());
                Assert.AreEqual(z.Name, repository.GetRepositoryPathsInHgrc().First().Name);
                Assert.AreEqual(z.URI, repository.GetRepositoryPathsInHgrc().First().URI);
            }
        }
Пример #10
0
        public void SetAndGetDefaultSyncRepositories()
        {
            using (new MercurialIniForTests())
            using (var setup = new RepositorySetup("Dan"))
            {
                setup.EnsureNoHgrcExists();
                var repository = setup.CreateSynchronizer().Repository;
                var x =  RepositoryAddress.Create("one", @"c:\one");
                var y = RepositoryAddress.Create("two", @"http://two.org");
                var z = RepositoryAddress.Create("three", @"http://three.org");
                repository.SetKnownRepositoryAddresses(new List<RepositoryAddress>(new RepositoryAddress[] { x, y,z }));

                repository.SetDefaultSyncRepositoryAliases(new string[] {"one", "three"});
                Assert.AreEqual(2, repository.GetDefaultSyncAliases().Count());

                repository.SetDefaultSyncRepositoryAliases(new string[] { "two" });
                Assert.AreEqual(1, repository.GetDefaultSyncAliases().Count());
            }
        }
Пример #11
0
 public void GetUserName_NoHgrcYet_ReturnsDefault()
 {
     using (new MercurialIniForTests())
     using (var setup = new RepositorySetup("Dan"))
     {
         setup.EnsureNoHgrcExists();
         var repository = setup.CreateSynchronizer().Repository;
         Assert.AreEqual("anonymous", repository.GetUserNameFromIni(_progress, "anonymous"));
     }
 }
Пример #12
0
 public void GetUserName_NameInLocalReop_GetsName()
 {
     using (new MercurialIniForTests())
     using (var setup = new RepositorySetup("Dan"))
     {
         setup.WriteIniContents(@"[ui]
     username = joe
     ");
         var repository = setup.CreateSynchronizer().Repository;
         Assert.AreEqual("joe", repository.GetUserNameFromIni(_progress, "anonymous"));
     }
 }
Пример #13
0
 public void GetUserName_EmptyHgrc_ReturnsDefault()
 {
     using (new MercurialIniForTests())
     using (var setup = new RepositorySetup("Dan"))
     {
         setup.WriteIniContents(@"");
         var repository = setup.CreateSynchronizer().Repository;
         Assert.AreEqual("anonymous", repository.GetUserNameFromIni(_progress, "anonymous"));
     }
 }