internal static void MakeLocalClone(string sourceFolder, string targetFolder)
        {
            var parentFolder = Directory.GetParent(targetFolder).FullName;

            if (!Directory.Exists(parentFolder))
            {
                Directory.CreateDirectory(parentFolder);
            }

            // Do a clone of the lift repo into the new home.
            var oldRepo = new HgRepository(sourceFolder, new NullProgress());

            oldRepo.CloneLocalWithoutUpdate(targetFolder);

            // Now copy the original hgrc file into the new location.
            File.Copy(Path.Combine(sourceFolder, Utilities.hg, "hgrc"), Path.Combine(targetFolder, Utilities.hg, "hgrc"), true);

            // Move the import failure notification file, if it exists.
            var roadblock = Path.Combine(sourceFolder, LiftUtilties.FailureFilename);

            if (File.Exists(roadblock))
            {
                File.Copy(roadblock, Path.Combine(targetFolder, LiftUtilties.FailureFilename), true);
            }
        }
示例#2
0
        //TODO: get rid of this, or somehow combine it with the other Clone() options out there
        /// <returns>path to clone, or empty if it failed</returns>
        private static string MakeCloneFromLocalToLocal(string sourcePath, string targetDirectory, bool cloningFromUsb, IProgress progress)
        {
            RequireThat.Directory(sourcePath).Exists();
            //Handled by GetUniqueFolderPath call now down in CloneLocal call. RequireThat.Directory(targetDirectory).DoesNotExist();
            RequireThat.Directory(targetDirectory).Parent().Exists();

            HgRepository local = new HgRepository(sourcePath, progress);

            if (!local.RemoveOldLocks())
            {
                progress.WriteError("Chorus could not create the clone at this time.  Try again after restarting the computer.");
                return string.Empty;
            }

            using (new ConsoleProgress("Trying to Create repository clone at {0}", targetDirectory))
            {
                // Make a backward compatibile clone if cloning to USB (http://mercurial.selenic.com/wiki/UpgradingMercurial)
                targetDirectory = local.CloneLocalWithoutUpdate(targetDirectory, cloningFromUsb ? null : "--config format.dotencode=false --pull");
                File.WriteAllText(Path.Combine(targetDirectory, "~~Folder has an invisible repository.txt"), "In this folder, there is a (possibly hidden) folder named '.hg' that contains the actual data of this Chorus repository. Depending on your Operating System settings, that leading '.' might make the folder invisible to you. But Chorus clients (WeSay, FLEx, OneStory, etc.) can see it and can use this folder to perform Send/Receive operations.");

                if (cloningFromUsb)
                {
                    var clone = new HgRepository(targetDirectory, progress);
                    clone.Update();
                }
                return targetDirectory;
            }
        }
示例#3
0
        //TODO: get rid of this, or somehow combine it with the other Clone() options out there
        /// <returns>path to clone, or empty if it failed</returns>
        private static string MakeCloneFromLocalToLocal(string sourcePath, string targetDirectory, bool cloningFromUsb, IProgress progress)
        {
            RequireThat.Directory(sourcePath).Exists();
            //Handled by GetUniqueFolderPath call now down in CloneLocal call. RequireThat.Directory(targetDirectory).DoesNotExist();
            RequireThat.Directory(targetDirectory).Parent().Exists();

            HgRepository local = new HgRepository(sourcePath, progress);

            if (!local.RemoveOldLocks())
            {
                progress.WriteError("Chorus could not create the clone at this time.  Try again after restarting the computer.");
                return(string.Empty);
            }

            using (new ConsoleProgress("Trying to Create repository clone at {0}", targetDirectory))
            {
                // Make a backward compatibile clone if cloning to USB (http://mercurial.selenic.com/wiki/UpgradingMercurial)
                targetDirectory = local.CloneLocalWithoutUpdate(targetDirectory, cloningFromUsb ? null : "--config format.dotencode=false --pull");
                File.WriteAllText(Path.Combine(targetDirectory, "~~Folder has an invisible repository.txt"), "In this folder, there is a (possibly hidden) folder named '.hg' that contains the actual data of this Chorus repository. Depending on your Operating System settings, that leading '.' might make the folder invisible to you. But Chorus clients (WeSay, FLEx, OneStory, etc.) can see it and can use this folder to perform Send/Receive operations.");

                if (cloningFromUsb)
                {
                    var clone = new HgRepository(targetDirectory, progress);
                    clone.Update();
                }
                return(targetDirectory);
            }
        }
示例#4
0
        //TODO: get rid of this, or somehow combine it with the other Clone() options out there
        /// <returns>path to clone, or empty if it failed</returns>
        public static string MakeCloneFromLocalToLocal(string sourcePath, string targetDirectory, bool alsoDoCheckout, IProgress progress)
        {
            RequireThat.Directory(sourcePath).Exists();
            //Handled by GetUniqueFolderPath call now down in CloneLocal call. RequireThat.Directory(targetDirectory).DoesNotExist();
            RequireThat.Directory(targetDirectory).Parent().Exists();

            HgRepository local = new HgRepository(sourcePath, progress);

            if (!local.RemoveOldLocks())
            {
                progress.WriteError("Chorus could not create the clone at this time.  Try again after restarting the computer.");
                return(string.Empty);
            }

            using (new ConsoleProgress("Trying to Create repository clone at {0}", targetDirectory))
            {
                targetDirectory = local.CloneLocalWithoutUpdate(targetDirectory);
                File.WriteAllText(Path.Combine(targetDirectory, "~~Folder has an invisible repository.txt"), "In this folder, there is a (possibly hidden) folder named '.hg' that contains the actual data of this Chorus repository. Depending on your Operating System settings, that leading '.' might make the folder invisible to you. But Chorus clients (WeSay, FLEx, OneStory, etc.) can see it and can use this folder to perform Send/Receive operations.");

                if (alsoDoCheckout)
                {
                    // string userIdForCLone = string.Empty; /* don't assume it's this user... a repo on a usb key probably shouldn't have a user default */
                    var clone = new HgRepository(targetDirectory, progress);
                    clone.Update();
                }
                return(targetDirectory);
            }
        }
示例#5
0
        //TODO: get rid of this, or somehow combine it with the other Clone() options out there
        /// <returns>path to clone, or empty if it failed</returns>
        public static string MakeCloneFromLocalToLocal(string sourcePath, string targetDirectory, bool alsoDoCheckout, IProgress progress)
        {
            RequireThat.Directory(sourcePath).Exists();
            //Handled by GetUniqueFolderPath call now down in CloneLocal call. RequireThat.Directory(targetDirectory).DoesNotExist();
            RequireThat.Directory(targetDirectory).Parent().Exists();

            HgRepository local = new HgRepository(sourcePath, progress);

            if (!local.RemoveOldLocks())
            {
                progress.WriteError("Chorus could not create the clone at this time.  Try again after restarting the computer.");
                return string.Empty;
            }

            using (new ConsoleProgress("Trying to Create repository clone at {0}", targetDirectory))
            {
                targetDirectory = local.CloneLocalWithoutUpdate(targetDirectory);
                File.WriteAllText(Path.Combine(targetDirectory, "~~Folder has an invisible repository.txt"), "In this folder, there is a (possibly hidden) folder named '.hg' that contains the actual data of this Chorus repository. Depending on your Operating System settings, that leading '.' might make the folder invisible to you. But Chorus clients (WeSay, FLEx, OneStory, etc.) can see it and can use this folder to perform Send/Receive operations.");

                if (alsoDoCheckout)
                {
                    // string userIdForCLone = string.Empty; /* don't assume it's this user... a repo on a usb key probably shouldn't have a user default */
                    var clone = new HgRepository(targetDirectory, progress);
                    clone.Update();
                }
                return targetDirectory;
            }
        }
        internal static void MakeLocalClone(string sourceFolder, string targetFolder)
        {
            var parentFolder = Directory.GetParent(targetFolder).FullName;
            if (!Directory.Exists(parentFolder))
                Directory.CreateDirectory(parentFolder);

            // Do a clone of the lift repo into the new home.
            var oldRepo = new HgRepository(sourceFolder, new NullProgress());
            oldRepo.CloneLocalWithoutUpdate(targetFolder);

            // Now copy the original hgrc file into the new location.
            File.Copy(Path.Combine(sourceFolder, Utilities.hg, "hgrc"), Path.Combine(targetFolder, Utilities.hg, "hgrc"), true);

            // Move the import failure notification file, if it exists.
            var roadblock = Path.Combine(sourceFolder, LiftUtilties.FailureFilename);
            if (File.Exists(roadblock))
                File.Copy(roadblock, Path.Combine(targetFolder, LiftUtilties.FailureFilename), true);
        }
示例#7
0
        private static void CreateRepositoryOnLocalAreaNetworkFolderIfNeededThrowIfFails(HgRepository repo, string repoProjectName, List<RepositoryAddress> sourcesToTry)
        {
            var directorySource = sourcesToTry.FirstOrDefault(s => s is DirectoryRepositorySource);
            if (directorySource == null)
                return;

            if (Directory.Exists(directorySource.URI) && Directory.Exists(Path.Combine(directorySource.URI, ".hg")))
            {
                var otherRepo = new HgRepository(directorySource.URI, new NullProgress());
                if (repo.Identifier == otherRepo.Identifier)
                    return;
            }

            var actualTarget = repo.CloneLocalWithoutUpdate(directorySource.GetPotentialRepoUri(directorySource.URI, repoProjectName, new NullProgress()));
            if (directorySource.URI != actualTarget)
            {
                // Reset hgrc to new location.
                var alias = HgRepository.GetAliasFromPath(actualTarget);
                repo.SetTheOnlyAddressOfThisType(RepositoryAddress.Create(alias, actualTarget));
            }
        }