public void SyncNow_BackupAlreadySetUp_GetsSync()
        {
            SyncOptions options = new SyncOptions();
            _synchronizer.SyncNow(options);
            string projectDirOnBackup = Path.Combine(_pathToBackupFolder, "foo project.2");
            //_synchronizer.MakeClone(projectDirOnBackup, true);
            HgHighLevel.MakeCloneFromUsbToLocal(_synchronizer.Repository.PathToRepo, projectDirOnBackup, _progress);

            string contents = File.ReadAllText(Path.Combine(projectDirOnBackup, "foo.txt"));
            Assert.AreEqual("version one", contents);
            WriteTestFile("version two");
        }
        public void SyncNow_FileMissing_GetsRemoved()
        {
            SyncOptions options = new SyncOptions();
            _synchronizer.SyncNow(options);

            string path = Path.Combine(_pathToProjectRoot, "foo.txt");
            Assert.IsTrue(File.Exists(path));
            _synchronizer.SyncNow(options);
            File.Delete(path);
            _synchronizer.SyncNow(options);

            Assert.IsFalse(File.Exists(path));
        }
        public void SyncNow_OnlyABlankFauxUsbAvailable_UsbGetsClone()
        {
            Synchronizer synchronizer = Synchronizer.FromProjectConfiguration(_project, _progress);
            SyncOptions options = new SyncOptions();
            options.DoMergeWithOthers = true;
            options.DoSendToOthers = true;
            options.RepositorySourcesToTry.Add(synchronizer.UsbPath);

            WriteTestFile("version two");

            synchronizer.SyncNow(options);
            string dir = Path.Combine(UsbKeyRepositorySource.RootDirForUsbSourceDuringUnitTest, "foo project");
            Assert.IsTrue(Directory.Exists(dir));
        }
		public void CommitWithMergeDoesNotThrowWithDefaultSychronizerAdjunct()
		{
			using (var bob = RepositoryWithFilesSetup.CreateWithLiftFile("bob"))
			using (var sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
			{
				bob.ReplaceSomething("bobWasHere");
				bob.AddAndCheckIn();
				sally.ReplaceSomething("sallyWasHere");

				var options = new SyncOptions
				{
					DoMergeWithOthers = true,
					DoPullFromOthers = true,
					DoSendToOthers = true
				};
				options.RepositorySourcesToTry.Add(bob.RepoPath);
				var synchronizer = sally.Synchronizer;

				Assert.DoesNotThrow(() => sally.SyncWithOptions(options, synchronizer));
			}
		}
예제 #5
0
        public SyncControlModel(ProjectFolderConfiguration projectFolderConfiguration, 
            SyncUIFeatures uiFeatureFlags,
            IChorusUser user)
        {
            _user = user;
            _progress = new MultiProgress();
            StatusProgress = new SimpleStatusProgress();
            _progress.Add(StatusProgress);
            Features = uiFeatureFlags;
            _synchronizer = Synchronizer.FromProjectConfiguration(projectFolderConfiguration, _progress);
            _backgroundWorker = new BackgroundWorker();
            _backgroundWorker.WorkerSupportsCancellation = true;
            _backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_backgroundWorker_RunWorkerCompleted);
            _backgroundWorker.DoWork += worker_DoWork;

            //clients will normally change these
            SyncOptions = new SyncOptions();
            SyncOptions.CheckinDescription = "[" + Application.ProductName + ": " + Application.ProductVersion + "] sync";
            SyncOptions.DoPullFromOthers = true;
            SyncOptions.DoMergeWithOthers = true;
            SyncOptions.RepositorySourcesToTry.AddRange(GetRepositoriesToList().Where(r => r.Enabled));
        }
예제 #6
0
        public void GetAllRevisionss_AfterSyncingTwoTimes_CorrectHistory()
        {
            Synchronizer setup = new Synchronizer(_project.FolderPath, _project, _progress);
            SyncOptions options = new SyncOptions();
            options.DoPullFromOthers = false;
            options.DoMergeWithOthers = false;
            options.CheckinDescription = "first one";
            options.DoSendToOthers = false;

            setup.SyncNow(options);
            File.WriteAllText(_pathToText, "version two of my pretend txt");
            options.CheckinDescription = "second one";
            setup.SyncNow(options);

            List<Revision> items = _repository.GetAllRevisions();
            Assert.AreEqual(2, items.Count);
            Assert.AreEqual("bob", items[0].UserId);
            Assert.AreEqual("second one", items[0].Summary);

            Assert.AreEqual("bob", items[1].UserId);
            Assert.AreEqual("first one", items[1].Summary);
        }
        public void SyncNow_AlreadySetupFauxUsbAvailable_UsbGetsSync()
        {
            SyncOptions options = new SyncOptions();
            Synchronizer synchronizer = Synchronizer.FromProjectConfiguration(_project, _progress);
            synchronizer.SyncNow(options);

            options.RepositorySourcesToTry.Add(synchronizer.UsbPath);
            string usbDirectory = Path.Combine(UsbKeyRepositorySource.RootDirForUsbSourceDuringUnitTest, "foo project");
            // synchronizer.MakeClone(usbDirectory, true);
            HgHighLevel.MakeCloneFromLocalToLocal(synchronizer.Repository.PathToRepo, usbDirectory, true, _progress);

            string contents = File.ReadAllText(Path.Combine(usbDirectory, "foo.txt"));
            Assert.AreEqual("version one", contents);
            WriteTestFile("version two");
            //_progress.ShowVerbose = true;
            options.CheckinDescription = "Changing to two";
            synchronizer.SyncNow(options);
            var usb = new HgRepository(usbDirectory, _progress);
            Assert.AreEqual("Changing to two", usb.GetTip().Summary);

            //did it update too (which we should do with usb, unless we switch to leave them as "bare" .hgs)?
            contents = File.ReadAllText(Path.Combine(usbDirectory, "foo.txt"));
            Assert.AreEqual("version two", contents);
        }
예제 #8
0
        public SyncResults SyncNow(SyncOptions options)
        {
            SyncResults results = new SyncResults();
            List <RepositoryAddress> sourcesToTry = options.RepositorySourcesToTry;
            //this just saves us from trying to connect twice to the same repo that is, for example, no there.
            Dictionary <RepositoryAddress, bool> connectionAttempts = new Dictionary <RepositoryAddress, bool>();

            try
            {
                if (_progress.ProgressIndicator != null)
                {
                    _progress.ProgressIndicator.IndicateUnknownProgress();
                }
                var repo = new HgRepository(_localRepositoryPath, _progress);

                RemoveLocks(repo);
                repo.RecoverFromInterruptedTransactionIfNeeded();
                repo.FixUnicodeAudio();
                string branchName = _sychronizerAdjunct.BranchName;
                ChangeBranchIfNecessary(branchName);
                Commit(options);

                var workingRevBeforeSync = repo.GetRevisionWorkingSetIsBasedOn();

                if (options.DoPullFromOthers)
                {
                    results.DidGetChangesFromOthers = PullFromOthers(repo, sourcesToTry, connectionAttempts);
                }

                if (options.DoMergeWithOthers)
                {
                    MergeHeadsOrRollbackAndThrow(repo, workingRevBeforeSync);
                }

                if (options.DoSendToOthers)
                {
                    SendToOthers(repo, sourcesToTry, connectionAttempts);
                }

                //If we did pull any data or a trivial merge succeeded we should call UpdateToTheDescendantRevision
                if (results.DidGetChangesFromOthers ||                                                             //we pulled something
                    (workingRevBeforeSync != null &&                //will be null if this is the 1st checkin ever, but no files were added so there was no actual rev created
                     !repo.GetRevisionWorkingSetIsBasedOn().Number.Hash.Equals(workingRevBeforeSync.Number.Hash))) //a merge happened
                {
                    UpdateToTheDescendantRevision(repo, workingRevBeforeSync);
                }
                _sychronizerAdjunct.CheckRepositoryBranches(repo.BranchingHelper.GetBranches(), _progress);

                results.Succeeded = true;
                _progress.WriteMessage("Done");
            }
            catch (SynchronizationException error)
            {
                error.DoNotifications(Repository, _progress);
                results.Succeeded        = false;
                results.ErrorEncountered = error;
            }
            catch (UserCancelledException error)
            {
                results.Succeeded        = false;
                results.Cancelled        = true;
                results.ErrorEncountered = null;
            }
            catch (Exception error)
            {
                if (error.InnerException != null)
                {
                    _progress.WriteVerbose("inner exception:");
                    _progress.WriteError(error.InnerException.Message);
                    _progress.WriteVerbose(error.InnerException.StackTrace);
                }

                _progress.WriteException(error);                //this preserves the whole exception for later retrieval by the client
                _progress.WriteError(error.Message);            //review still needed if we have this new WriteException?
                _progress.WriteVerbose(error.StackTrace);       //review still needed if we have this new WriteException?

                results.Succeeded        = false;
                results.ErrorEncountered = error;
            }
            return(results);
        }
		public void CommitWithMergeHasCommitFileAndMergeFile()
		{
			using (var bob = RepositoryWithFilesSetup.CreateWithLiftFile("bob"))
			using (var sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
			{
				bob.ReplaceSomething("bobWasHere");
				bob.AddAndCheckIn();
				sally.ReplaceSomething("sallyWasHere");

				var syncAdjunct = new FileWriterSychronizerAdjunct(sally.RootFolder.Path);
				CheckNoFilesExist(syncAdjunct);

				var options = new SyncOptions
				{
					DoMergeWithOthers = true,
					DoPullFromOthers = true,
					DoSendToOthers = true
				};
				options.RepositorySourcesToTry.Add(bob.RepoPath);
				var synchronizer = sally.Synchronizer;
				synchronizer.SynchronizerAdjunct = syncAdjunct;

				var syncResults = sally.SyncWithOptions(options, synchronizer);
				Assert.IsTrue(syncResults.DidGetChangesFromOthers);
				CheckExistanceOfAdjunctFiles(syncAdjunct, true, true, false, true, true, true);
			}
		}
예제 #10
0
        private void Commit(SyncOptions options)
        {
            ThrowIfCancelPending();
            _progress.WriteMessage("Storing changes in local repository...");

            _sychronizerAdjunct.PrepareForInitialCommit(_progress);

            // Must be done, before "AddAndCommitFiles" call.
            // It could be here, or first thing inside the 'using' for CommitCop.
            string tooLargeFilesMessage = LargeFileFilter.FilterFiles(Repository, _project, _handlers);
            if (!string.IsNullOrEmpty(tooLargeFilesMessage))
            {
                var msg = "We're sorry, but the Send/Receive system can't handle large files. The following files won't be stored or shared by this system until you can shrink them down below the maximum: "+Environment.NewLine;
                msg+= tooLargeFilesMessage;
                _progress.WriteWarning(msg);
            }

            var commitCopValidationResult = "";
            using (var commitCop = new CommitCop(Repository, _handlers, _progress))
            {
                // NB: The commit must take place in order for CommitCop to work properly.
                // Ergo, don't even think of moving this after the commitCop.ValidationResult check.
                // Too bad I (RBR) already thought of it, and asked, and found out it ought not be moved. :-)
                AddAndCommitFiles(options.CheckinDescription);
                commitCopValidationResult = commitCop.ValidationResult;
            }
            if (string.IsNullOrEmpty(commitCopValidationResult))
                return;

            // Commit cop reported a validation failure, but deal with it here, rather than inside the 'using', as the rollback won't have happened,
            // until Dispose, and that is way too early for the "SimpleUpdate" call.
            _sychronizerAdjunct.SimpleUpdate(_progress, true);
            throw new ApplicationException(
                    "The changed data did not pass validation tests. Your project will be moved back to the last Send/Receive before this problem occurred, so that you can keep working.  Please notify whoever provides you with computer support. Error was: " +
                    commitCopValidationResult);
        }
예제 #11
0
        /// <summary>
        /// not called "CreateReject*Branch* because we're not naming it (but it is, technically, a branch)
        /// </summary>
        public void CreateRejectForkAndComeBack()
        {
            var originalTip = Repository.GetTip();
            ChangeFile("test.txt", "bad");
            var options = new SyncOptions {DoMergeWithOthers = true, DoPullFromOthers = true, DoSendToOthers = true};
            Synchronizer = CreateSynchronizer();
            Synchronizer.SyncNow(options);
            var badRev = Repository.GetTip();

            //notice that we're putting changeset which does the tagging over on the original branch
            Repository.RollbackWorkingDirectoryToRevision(originalTip.Number.Hash);
            Repository.TagRevision(badRev.Number.Hash, Synchronizer.RejectTagSubstring);// this adds a new changeset
            Synchronizer.SyncNow(options);

            Revision revision = Repository.GetRevisionWorkingSetIsBasedOn();
            revision.EnsureParentRevisionInfo();
            Assert.AreEqual(originalTip.Number.LocalRevisionNumber, revision.Parents[0].LocalRevisionNumber, "Should have moved back to original tip.");
        }
		public void OurCommitOnlyFailsCommitCopCheck()
		{
			// 3. Backout after CommitCop bailout.
			//		UpdateToTheDescendantRevision repository.RollbackWorkingDirectoryToRevision(head.Number.LocalRevisionNumber); (line 570)
			//		Expected files to exist: CommitPathname, and RollbackPathname, but not PullPathname or MergePathname.
			using (var bob = RepositoryWithFilesSetup.CreateWithLiftFile("bob"))
			{
				File.WriteAllText(bob.UserFile.Path, "New contents");

				var syncAdjunct = new FileWriterSychronizerAdjunct(bob.RootFolder.Path);
				CheckNoFilesExist(syncAdjunct);

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

				var syncResults = bob.SyncWithOptions(options, synchronizer);
				Assert.IsFalse(syncResults.Cancelled);
				Assert.IsFalse(syncResults.DidGetChangesFromOthers);
				Assert.IsFalse(syncResults.Succeeded);
				CheckExistanceOfAdjunctFiles(syncAdjunct, true, false, true, false, true, false);
			}
		}
예제 #13
0
        public SyncResults SyncNow(SyncOptions options)
        {
            SyncResults results = new SyncResults();
            List<RepositoryAddress> sourcesToTry = options.RepositorySourcesToTry;
            //this just saves us from trying to connect twice to the same repo that is, for example, no there.
            Dictionary<RepositoryAddress, bool> connectionAttempts = new Dictionary<RepositoryAddress, bool>();

            try
            {
                if (_progress.ProgressIndicator != null)
                {
                    _progress.ProgressIndicator.IndicateUnknownProgress();
                }
                var repo = new HgRepository(_localRepositoryPath, _progress);

                RemoveLocks(repo);
                repo.RecoverFromInterruptedTransactionIfNeeded();
                repo.FixUnicodeAudio();
                string branchName = _sychronizerAdjunct.BranchName;
                ChangeBranchIfNecessary(branchName);
                Commit(options);

                var workingRevBeforeSync = repo.GetRevisionWorkingSetIsBasedOn();

                if (options.DoPullFromOthers)
                {
                    results.DidGetChangesFromOthers = PullFromOthers(repo, sourcesToTry, connectionAttempts);
                }

                if (options.DoMergeWithOthers)
                {
                    MergeHeadsOrRollbackAndThrow(repo, workingRevBeforeSync);
                }

                if (options.DoSendToOthers)
                {
                    SendToOthers(repo, sourcesToTry, connectionAttempts);
                }

                //If we did pull any data or a trivial merge succeeded we should call UpdateToTheDescendantRevision
                if (results.DidGetChangesFromOthers || //we pulled something
                    (workingRevBeforeSync!=null //will be null if this is the 1st checkin ever, but no files were added so there was no actual rev created
                    && !repo.GetRevisionWorkingSetIsBasedOn().Number.Hash.Equals(workingRevBeforeSync.Number.Hash))) //a merge happened
                {
                    UpdateToTheDescendantRevision(repo, workingRevBeforeSync);
                }
                _sychronizerAdjunct.CheckRepositoryBranches(repo.BranchingHelper.GetBranches(), _progress);

                results.Succeeded = true;
               _progress.WriteMessage("Done");
            }
            catch (SynchronizationException error)
            {
                error.DoNotifications(Repository, _progress);
                results.Succeeded = false;
                results.ErrorEncountered = error;
            }
            catch (UserCancelledException error)
            {
                results.Succeeded = false;
                results.Cancelled = true;
                results.ErrorEncountered = null;
            }
            catch (Exception error)
            {
                if (error.InnerException != null)
                {
                    _progress.WriteVerbose("inner exception:");
                    _progress.WriteError(error.InnerException.Message);
                    _progress.WriteVerbose(error.InnerException.StackTrace);
                }

                _progress.WriteException(error);//this preserves the whole exception for later retrieval by the client
                _progress.WriteError(error.Message);//review still needed if we have this new WriteException?
                _progress.WriteVerbose(error.StackTrace);//review still needed if we have this new WriteException?

                results.Succeeded = false;
                results.ErrorEncountered = error;
            }
            return results;
        }
예제 #14
0
        public void TypicalUsage()
        {
            UpdateLiftFile(LiftExportPath);

            ProjectSyncInfo projectInfo = new ProjectSyncInfo();
            projectInfo.IncludePatterns.Add(@"**/*.lift");

            SyncOptions options = new SyncOptions();
            options.CheckinDescription = "Some dictionary work.";
            options.DoPullFromOthers = false;
            options.DoMergeWithOthers = false;

            SyncManager chorus = SyncManager.FromChildPath(LiftExportPath,
                Progress, OurUsersName);
            chorus.SyncNow(projectInfo, options);
            ImportLiftFile(LiftExportPath);
        }
		public void BothMadeChanges_MergeFailure_Fires_SimpleUpdate_WithTrue()
		{
			// 2. Rollback on merge failure, when we changed stuff.
			//		UpdateToTheDescendantRevision repository.RollbackWorkingDirectoryToRevision(head.Number.LocalRevisionNumber); (line 570)
			//		Expected files to exist: CommitPathname and RollbackPathname, but not PullPathname or MergePathname.
			using (var bob = RepositoryWithFilesSetup.CreateWithLiftFile("bob"))
			using (var sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
			{
				bob.ReplaceSomething("bobWasHere");
				bob.AddAndCheckIn();
				sally.ReplaceSomething("sallyWasHere");

				var syncAdjunct = new FileWriterSychronizerAdjunct(sally.RootFolder.Path);
				CheckNoFilesExist(syncAdjunct);

				var options = new SyncOptions
				{
					DoMergeWithOthers = true,
					DoPullFromOthers = true,
					DoSendToOthers = true
				};
				options.RepositorySourcesToTry.Add(bob.RepoPath);
				var synchronizer = sally.Synchronizer;
				synchronizer.SynchronizerAdjunct = syncAdjunct;

				using (new FailureSimulator("SychronizerAdjunct"))
				{
					var syncResults = sally.SyncWithOptions(options, synchronizer);
					Assert.IsTrue(syncResults.DidGetChangesFromOthers);
					Assert.IsFalse(syncResults.Cancelled);
					Assert.IsFalse(syncResults.Succeeded);
					CheckExistanceOfAdjunctFiles(syncAdjunct, true, false, true, false, true, false);
				}
			}
		}
예제 #16
0
 public override void RemoteAddAndCommit()
 {
     var opts = new SyncOptions { CheckinDescription = "remoteaddandcommit" };
     Remote.Synchronizer.SyncNow(opts);
     base.RemoteAddAndCommit();
 }
예제 #17
0
        public void AddAndCheckIn()
        {
            var options = new SyncOptions
                            {
                                DoMergeWithOthers = false,
                                DoPullFromOthers = false,
                                DoSendToOthers = false
                            };

            SyncWithOptions(options);
        }
예제 #18
0
 public override void LocalAddAndCommit()
 {
     var opts = new SyncOptions {CheckinDescription = "localaddandcommit"};
     Local.Synchronizer.SyncNow(opts);
     base.LocalAddAndCommit();
 }
예제 #19
0
 public SyncResults SyncWithOptions(SyncOptions options, Synchronizer synchronizer)
 {
     return synchronizer.SyncNow(options);
 }
예제 #20
0
 public SyncResults SyncWithOptions(SyncOptions options)
 {
     if (Synchronizer == null)
         Synchronizer = CreateSynchronizer();
     return SyncWithOptions(options, Synchronizer);
 }
		public void EachOneChangedOrAddedFileButNotSameFile_HasCommitAndPullAndMergeFilesOnly()
		{
			using (var bob = RepositoryWithFilesSetup.CreateWithLiftFile("bob"))
			using (var sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
			{
				bob.ReplaceSomething("bobWasHere");
				bob.AddAndCheckIn();

				sally.ProjectConfiguration.IncludePatterns.Add("sally.txt");

				var newFileForSally = TempFile.WithFilename(Path.Combine(sally.ProjectFolder.Path, "sally.txt"));
				File.WriteAllText(newFileForSally.Path, "Sally's new text.");

				var syncAdjunct = new FileWriterSychronizerAdjunct(sally.RootFolder.Path);
				CheckNoFilesExist(syncAdjunct);

				var options = new SyncOptions
				{
					DoMergeWithOthers = true,
					DoPullFromOthers = true,
					DoSendToOthers = true
				};
				options.RepositorySourcesToTry.Add(bob.RepoPath);
				var synchronizer = sally.Synchronizer;
				synchronizer.SynchronizerAdjunct = syncAdjunct;

				var syncResults = sally.SyncWithOptions(options, synchronizer);
				Assert.IsTrue(syncResults.DidGetChangesFromOthers);
				CheckExistanceOfAdjunctFiles(syncAdjunct, true, true, false, true, true, true);
			}
		}
예제 #22
0
        public void SyncNow_NotSetupBefore_GetsClone()
        {
            SyncOptions options = new SyncOptions();
            options.RepositorySourcesToTry.Add(_directorySource);

               // WriteTestFile("version two");

            Assert.IsTrue(_synchronizer.SyncNow(options).Succeeded);
            string dir = Path.Combine(_pathToBackupFolder, "foo project.2");
            Assert.IsTrue(Directory.Exists(dir));
        }
		public void TheyMadeChanges_WeDidNothing_Fires_SimpleUpdate_WithFalse()
		{
			// 1. Simple pull got new stuff, while we changed nothing
			//		UpdateToTheDescendantRevision repository.Update(); //update to the tip (line 556)
			//		Expected files to exist: CommitPathname and PullPathname, but not RollbackPathname or MergePathname.
			using (var bob = RepositoryWithFilesSetup.CreateWithLiftFile("bob"))
			using (var sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
			{
				bob.ReplaceSomething("bobWasHere");
				bob.AddAndCheckIn();

				var syncAdjunct = new FileWriterSychronizerAdjunct(sally.RootFolder.Path);
				CheckNoFilesExist(syncAdjunct);

				var options = new SyncOptions
				{
					DoMergeWithOthers = true,
					DoPullFromOthers = true,
					DoSendToOthers = true
				};
				options.RepositorySourcesToTry.Add(bob.RepoPath);
				var synchronizer = sally.Synchronizer;
				synchronizer.SynchronizerAdjunct = syncAdjunct;

				var syncResults = sally.SyncWithOptions(options, synchronizer);
				Assert.IsTrue(syncResults.DidGetChangesFromOthers);
				CheckExistanceOfAdjunctFiles(syncAdjunct, true, true, false, false, true, true);
			}
		}
예제 #24
0
 public void ChangeTextFile(Synchronizer sync)
 {
     SyncOptions options = new SyncOptions();
     options.CheckinDescription = "a change to foo.abc";
     string bobsFooTextPath = Path.Combine(_lexiconProjectPath, "foo.abc");
     File.WriteAllText(bobsFooTextPath, "version two of my pretend txt");
     sync.SyncNow(options);
 }
		public void CheckBranchesGetsRightNumberOfBranches()
		{
			using (var bob = RepositoryWithFilesSetup.CreateWithLiftFile("bob"))
			using (var sally = RepositoryWithFilesSetup.CreateByCloning("sally", bob))
			{
				bob.ReplaceSomething("bobWasHere");
				bob.Synchronizer.SynchronizerAdjunct = new ProgrammableSynchronizerAdjunct("NOTDEFAULT");
				bob.AddAndCheckIn();
				sally.ReplaceSomething("sallyWasHere");

				var syncAdjunct = new FileWriterSychronizerAdjunct(sally.RootFolder.Path);

				var options = new SyncOptions
				{
					DoMergeWithOthers = true,
					DoPullFromOthers = true,
					DoSendToOthers = true
				};
				options.RepositorySourcesToTry.Add(bob.RepoPath);
				var synchronizer = sally.Synchronizer;
				synchronizer.SynchronizerAdjunct = syncAdjunct;

				var syncResults = sally.SyncWithOptions(options, synchronizer);
				Assert.IsTrue(syncResults.DidGetChangesFromOthers);
				CheckExistanceOfAdjunctFiles(syncAdjunct, true, true, false, false, true, true);
				var lines = File.ReadAllLines(syncAdjunct.CheckRepoBranchesPathName);
				Assert.AreEqual(lines.Length, 2, "Wrong number of branches on CheckBranches call");
			}
		}
예제 #26
0
        /// <summary>
        /// This version is used by the Chorus UI, which wants to do the sync in the background
        /// </summary>
        public SyncResults SyncNow(BackgroundWorker backgroundWorker, DoWorkEventArgs args, SyncOptions options)
        {
            _backgroundWorker          = backgroundWorker;
            _backgroundWorkerArguments = args;
            var r = SyncNow(options);

            args.Result = r;
            return(r);
        }
		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);
			}
		}
		public void SendReceiveWithNoRemoteChangesGetsNoFiles()
		{
			using (var bob = RepositoryWithFilesSetup.CreateWithLiftFile("bob"))
			{
				var syncAdjunct = new FileWriterSychronizerAdjunct(bob.RootFolder.Path);
				CheckNoFilesExist(syncAdjunct);
				var options = new SyncOptions
				{
					DoMergeWithOthers = true,
					DoPullFromOthers = true,
					DoSendToOthers = true
				};
				var synchronizer = bob.Synchronizer;
				synchronizer.SynchronizerAdjunct = syncAdjunct;
				var syncResults = bob.SyncWithOptions(options, synchronizer);
				Assert.IsFalse(syncResults.DidGetChangesFromOthers);
				CheckExistanceOfAdjunctFiles(syncAdjunct, true, false, false, false, true, true);
			}
		}
예제 #29
0
 /// <summary>
 /// This version is used by the Chorus UI, which wants to do the sync in the background
 /// </summary>
 public SyncResults SyncNow(BackgroundWorker backgroundWorker, DoWorkEventArgs args, SyncOptions options)
 {
     _backgroundWorker = backgroundWorker;
     _backgroundWorkerArguments = args;
     var r=SyncNow(options);
     args.Result = r;
     return r;
 }
		public void SendReceiveWithTrivialMergeCallsSimpleUpdate()
		{
			using (var alistair = RepositoryWithFilesSetup.CreateWithLiftFile("alistair"))
			using (var susanna = RepositoryWithFilesSetup.CreateByCloning("suzy", alistair))
			{
				var syncAdjunct = new FileWriterSychronizerAdjunct(susanna.RootFolder.Path);
				CheckNoFilesExist(syncAdjunct);
				var options = new SyncOptions
				{
					DoMergeWithOthers = true,
					DoPullFromOthers = true,
					DoSendToOthers = true
				};
				var bobOptions = new SyncOptions
				{
					DoMergeWithOthers = true,
					DoPullFromOthers = true,
					DoSendToOthers = true,
					RepositorySourcesToTry = {alistair.RepoPath}
				};
				var synchronizer = susanna.Synchronizer;
				synchronizer.SynchronizerAdjunct = syncAdjunct;
				alistair.ReplaceSomething("nice.");
				alistair.SyncWithOptions(options);
				susanna.ReplaceSomethingElse("no problems.");
				var syncResults = susanna.SyncWithOptions(bobOptions, synchronizer);
				Assert.IsTrue(syncResults.DidGetChangesFromOthers);
				CheckExistanceOfAdjunctFiles(syncAdjunct, true, true, false, true, true, true);
			}
		}
예제 #31
0
        /// <summary>
        /// Check in, to the local disk repository, any changes to this point.
        /// </summary>
        /// <param name="checkinDescription">A description of what work was done that you're wanting to checkin. E.g. "Delete a Book"</param>
        /// <param name="progress">Can be null if you don't want any progress report</param>
        public void AsyncLocalCheckIn(string checkinDescription, Action<SyncResults> callbackWhenFinished)
        {
            var repoPath = this._synchronizer.Repository.PathToRepo.CombineForPath(".hg");
            Require.That(Directory.Exists(repoPath), "The repository should already exist before calling AsyncLocalCheckIn(). Expected to find the hg folder at " + repoPath);

            //NB: if someone were to call this fast and repeatedly, I won't vouch for any kind of safety here.
            //This is just designed for checking in occasionally, like as users do some major new thing, or finish some task.
            if (_asyncLocalCheckInWorker != null && !_asyncLocalCheckInWorker.IsBusy)
            {
                _asyncLocalCheckInWorker.Dispose(); //timidly avoid a leak
            }
            _asyncLocalCheckInWorker = new BackgroundWorker();
            _asyncLocalCheckInWorker.DoWork += new DoWorkEventHandler((o, args) =>
                                                        {

               var options = new SyncOptions()
            {
                CheckinDescription = checkinDescription,
                DoMergeWithOthers = false,
                DoPullFromOthers = false,
                DoSendToOthers = false
            };
               var result = _synchronizer.SyncNow(options);
            if (callbackWhenFinished != null)
            {
                callbackWhenFinished(result);
            }
                                                        });
            _asyncLocalCheckInWorker.RunWorkerAsync();
        }
예제 #32
0
        public SyncResults CheckinAndPullAndMerge(RepositorySetup otherUser)
        {
            var options = new SyncOptions
                            {
                                DoMergeWithOthers = true,
                                DoPullFromOthers = true,
                                DoSendToOthers = true
                            };

            if(otherUser!=null)
                options.RepositorySourcesToTry.Add(otherUser.GetRepositoryAddress());

            return SyncWithOptions(options);
        }