Esempio n. 1
0
        public void Synchronizer_HandlesBothDefaultBranchOptions()
        {
            // Revisions can come in with both default or empty string on the default branch depending on OS
            string savedSettings = "";
            var    rev1          = new Revision(null, "default", "Fred", "1234", "hash1234", "change something");
            // The first revision we see on another branch doesn't produce a warning...it might be something old everyone has upgraded from.
            var revs = new[] { rev1 };

            Assert.That(LiftSynchronizerAdjunct.GetRepositoryBranchCheckData(revs, "", ref savedSettings), Is.Null);

            var rev2 = new Revision(null, "", "Joe", "1235", "hash1235", "change something else");

            // To get the right result this time, the list of revisions must include both branches we are pretending are in the repo.
            revs = new[] { rev1, rev2 };
            Assert.That(LiftSynchronizerAdjunct.GetRepositoryBranchCheckData(revs, "default", ref savedSettings), Is.Null);             // first change we've seen on this branch

            var rev3 = new Revision(null, "default", "Fred", "1236", "hash1236", "Fred's second change");

            revs = new[] { rev2, rev3 };
            Assert.That(LiftSynchronizerAdjunct.GetRepositoryBranchCheckData(revs, "default", ref savedSettings), Is.Null);

            var rev4 = new Revision(null, "", "Joe", "1236", "hash1237", "Joe's second change");

            revs = new[] { rev3, rev4 };
            Assert.That(LiftSynchronizerAdjunct.GetRepositoryBranchCheckData(revs, "", ref savedSettings), Is.Null);
        }
Esempio n. 2
0
        public void LiftSynchronizerReadsLift15VersionCorrectly()
        {
            // Setup
            using (var myfile = new TempFile(testLift15File))
            {
                // SUT
                var syncAdjunct = new LiftSynchronizerAdjunct(myfile.Path);

                // Verification
                Assert.AreEqual("LIFT0.15", syncAdjunct.BranchName, "BranchName should be 'LIFT0.15'");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Maybe let the user know about the need to update, or that other team members are still using an older version.
        /// </summary>
        public void CheckRepositoryBranches(IEnumerable <Revision> branches, IProgress progress)
        {
            var savedSettings   = Settings.Default.OtherBranchRevisions;
            var conflictingUser = LiftSynchronizerAdjunct.GetRepositoryBranchCheckData(branches, BranchName, ref savedSettings);

            Settings.Default.OtherBranchRevisions = savedSettings;
            Settings.Default.Save();
            if (!string.IsNullOrEmpty(conflictingUser))
            {
                progress.WriteWarning(string.Format(Resources.ksOtherRevisionWarning, conflictingUser));
            }
        }
Esempio n. 4
0
        public void LiftSynchronizerReadsLift13VersionCorrectly()
        {
            // Setup
            using (var liftProject = new TemporaryFolder("TempProj_LIFT_NOLDML"))
                using (var liftFile = new TempFileFromFolder(liftProject, "proj.lift", TestLift13File))
                {
                    // SUT
                    var syncAdjunct = new LiftSynchronizerAdjunct(liftFile.Path);

                    // Verification
                    Assert.AreEqual("default", syncAdjunct.BranchName, "BranchName should be 'default' for LIFT0.13");
                }
        }
Esempio n. 5
0
 public void CorrectlyAppendsLdmlVersion3ToBranchName()
 {
     using (var liftProject = new TemporaryFolder("TempProj_LIFT"))
         using (var liftFile = new TempFileFromFolder(liftProject, "proj.lift", TestLift13File))
         {
             var wsDirectory = Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(liftFile.Path), "WritingSystems"));
             using (var writingSystemsDir =
                        TempFileFromFolder.CreateAt(liftProject.Combine("WritingSystems", "lang.ldml"), LdmlContentForTests.Version3("en", "", "", "")))
             {
                 var syncAdjunct = new LiftSynchronizerAdjunct(liftFile.Path);
                 Assert.AreEqual("LIFT0.13_ldml3", syncAdjunct.BranchName, "BranchName should be 'LIFT0.13_ldml3' with version 3 ldml files");
             }
         }
 }
Esempio n. 6
0
        public void Synchronizer_DoesNotReportOldChangeOnOtherBranch()
        {
            string savedSettings = "";
            var    rev1          = new Revision(null, "default", "Fred", "1234", "hash1234", "change something");
            // The first revision we see on another branch doesn't produce a warning...it might be something old everyone has upgraded from.
            var revs = new[] { rev1 };

            Assert.That(LiftSynchronizerAdjunct.GetRepositoryBranchCheckData(revs, "7.2.1", ref savedSettings), Is.Null);
            //Assert.That(savedSettings, Is.EqualTo("default:1234")); // Don't really care what is here as long as it works

            var rev2 = new Revision(null, "default", "Fred", "1234", "hash1234", "change something else");

            revs = new[] { rev2 };
            Assert.That(LiftSynchronizerAdjunct.GetRepositoryBranchCheckData(revs, "7.2.1", ref savedSettings), Is.Null);
        }
Esempio n. 7
0
        public void SynchronizerWithOnlyCurrentBranchRevision_ReportsNothing()
        {
            var    rev1          = new Revision(null, "default", "Fred", "1234", "hash1234", "change something");
            var    revs          = new[] { rev1 };
            string savedSettings = "";

            Assert.That(LiftSynchronizerAdjunct.GetRepositoryBranchCheckData(revs, "default", ref savedSettings), Is.Null);
            Assert.That(savedSettings, Is.EqualTo(""));

            // Even if we have remembered a previous revision on our own branch, we don't report problems on the current branch.
            var rev2 = new Revision(null, "default", "Fred", "1235", "hash1234", "change something else");

            revs          = new[] { rev2 };
            savedSettings = "default";
            Assert.That(LiftSynchronizerAdjunct.GetRepositoryBranchCheckData(revs, "default", ref savedSettings), Is.Null);
            Assert.That(savedSettings, Is.EqualTo(""));             // still no revs on other branches to save.
        }
        public void StartWorking(Dictionary <string, string> commandLineArgs)
        {
            // As per the API, -p will be the main FW data file.
            // REVIEW (RandyR): What if it is the DB4o file?
            // REVIEW (RandyR): What is sent if the user is a client of the DB4o server?
            // -p <$fwroot>\foo\foo.fwdata
            var pathToLiftProject = Utilities.LiftOffset(Path.GetDirectoryName(commandLineArgs["-p"]));

            using (var chorusSystem = Utilities.InitializeChorusSystem(pathToLiftProject, commandLineArgs["-u"], LiftFolder.AddLiftFileInfoToFolderConfiguration))
            {
                var newlyCreated = false;
                if (chorusSystem.Repository.Identifier == null)
                {
                    // First do a commit, since the repo is brand new.
                    var projectConfig = chorusSystem.ProjectFolderConfiguration;
                    ProjectFolderConfiguration.EnsureCommonPatternsArePresent(projectConfig);
                    projectConfig.IncludePatterns.Add("**.ChorusRescuedFile");

                    chorusSystem.Repository.AddAndCheckinFiles(projectConfig.IncludePatterns, projectConfig.ExcludePatterns, "Initial commit");
                    newlyCreated = true;
                }
                chorusSystem.EnsureAllNotesRepositoriesLoaded();

                // Do the Chorus business.
                using (var syncDlg = (SyncDialog)chorusSystem.WinForms.CreateSynchronizationDialog(SyncUIDialogBehaviors.Lazy, SyncUIFeatures.NormalRecommended | SyncUIFeatures.PlaySoundIfSuccessful))
                {
                    var syncAdjunt = new LiftSynchronizerAdjunct(LiftUtilties.PathToFirstLiftFile(pathToLiftProject));
                    syncDlg.SetSynchronizerAdjunct(syncAdjunt);

                    // Chorus does it in this order:
                    // Local Commit
                    // Pull
                    // Merge (Only if anything came in with the pull from other sources, and commit of merged results)
                    // Push
                    syncDlg.SyncOptions.DoPullFromOthers  = true;
                    syncDlg.SyncOptions.DoMergeWithOthers = true;
                    syncDlg.SyncOptions.DoSendToOthers    = true;
                    syncDlg.Text          = Resources.SendReceiveView_DialogTitleLift;
                    syncDlg.StartPosition = FormStartPosition.CenterScreen;
                    syncDlg.BringToFront();
                    var dlgResult = syncDlg.ShowDialog();

                    if (dlgResult == DialogResult.OK)
                    {
                        if (newlyCreated && (!syncDlg.SyncResult.Succeeded || syncDlg.SyncResult.ErrorEncountered != null))
                        {
                            _gotChanges = false;
                            // Wipe out new repo, since something bad happened in S/R,
                            // and we don't want to leave the user in a sad state (cf. LT-14751).
                            Directory.Delete(pathToLiftProject, true);
                        }
                        else if (syncDlg.SyncResult.DidGetChangesFromOthers || syncAdjunt.WasUpdated)
                        {
                            _gotChanges = true;
                        }
                    }
                    else
                    {
                        // User probably bailed out of S/R using the "X" to close the dlg.
                        if (newlyCreated)
                        {
                            _gotChanges = false;
                            // Wipe out new repo, since the user cancelled without even trying the S/R,
                            // and we don't want to leave the user in a sad state (cf. LT-14751).
                            Directory.Delete(pathToLiftProject, true);
                        }
                    }
                }
            }
        }