예제 #1
0
        public void SyncNow_AlreadySetupFauxUsbAvailable_UsbGetsSync()
        {
            // setup main repo
            SyncOptions  options      = new SyncOptions();
            Synchronizer synchronizer = Synchronizer.FromProjectConfiguration(_project, _progress);

            synchronizer.SyncNow(options);

            // setup faux USB repo
            options.RepositorySourcesToTry.Add(synchronizer.UsbPath);
            string usbDirectory = Path.Combine(UsbKeyRepositorySource.RootDirForUsbSourceDuringUnitTest, "foo project");

            HgHighLevel.MakeCloneFromLocalToUsb(synchronizer.Repository.PathToRepo, usbDirectory, _progress);

            // make a change to the main repo and sync
            WriteTestFile("version two");
            options.CheckinDescription = "Changing to two";
            synchronizer.SyncNow(options);

            // check if USB repo received the change
            var usb = new HgRepository(usbDirectory, _progress);

            Assert.AreEqual("Changing to two", usb.GetTip().Summary);
            // ensure that the USB repo is still bare
            Assert.That(File.Exists(Path.Combine(usbDirectory, "foo.txt")), Is.False);
        }
예제 #2
0
        /// <summary>
        /// used for local sources (usb, sd media, etc)
        /// </summary>
        private void TryToMakeCloneForSource(RepositoryAddress repoDescriptor)
        {
            var possibleRepoCloneUris = repoDescriptor.GetPossibleCloneUris(Repository.Identifier, RepoProjectName, _progress);

            if (possibleRepoCloneUris == null)
            {
                _progress.WriteMessage("No Uris available for cloning to {0}",
                                       repoDescriptor.Name);
                return;
            }

            foreach (var uri in possibleRepoCloneUris)
            {
                // target may be uri, or some other folder.
                var target = HgRepository.GetUniqueFolderPath(
                    _progress,
                    //"Folder at {0} already exists, so it can't be used. Creating clone in {1}, instead.",
                    RepositoryAddress.DuplicateWarningMessage.Replace(RepositoryAddress.MediumVariable, "USB flash drive"),
                    uri);
                try
                {
                    _progress.WriteMessage("Copying repository to {0}...", repoDescriptor.GetFullName(target));
                    _progress.WriteVerbose("({0})", target);
                    HgHighLevel.MakeCloneFromLocalToUsb(_localRepositoryPath, target, _progress);
                    return;
                }
                catch (Exception error)
                {
                    _progress.WriteError("Could not create repository on {0}. Error follow:", target);
                    _progress.WriteException(error);
                    // keep looping
                }
            }
        }
예제 #3
0
 public void CloneToUsbWithoutUpdateFollowedByIdentifierDoesNotAffectHgrc()
 {
     using (var repo = new RepositorySetup("source"))
         using (var f = new TemporaryFolder("clonetest"))
         {
             // The MakeCloneFromLocalToLocal with false on alsoDoCheckout is the core of the usb clone operation.
             // We need to make sure that this clone is bare of extensions, and remains so after the identifier is checked.
             HgHighLevel.MakeCloneFromLocalToUsb(repo.ProjectFolder.Path, f.Path, new NullProgress());
             var cloneRepo    = new HgRepository(f.Path, new NullProgress());
             var hgFolderPath = Path.Combine(f.Path, ".hg");
             Assert.IsTrue(Directory.Exists(hgFolderPath));
             var hgrcLines = File.ReadAllLines(Path.Combine(hgFolderPath, "hgrc"));
             //SUT
             CollectionAssert.DoesNotContain(hgrcLines, "[extensions]", "extensions section created in bare clone");
             var id = cloneRepo.Identifier;
             CollectionAssert.DoesNotContain(hgrcLines, "[extensions]", "extensions section created after Identifier property read");
         }
 }