Exemplo n.º 1
0
        //  Other Methods
        //  =============

        /// <exception cref="Kallithea_Klone.MainActionException"></exception>
        private async Task Update(RepositoryData location)
        {
            string remotePath = GetDefaultRemotePath(location.URL);
            Uri    uri        = new Uri(remotePath);

            string     fullURL    = $"{uri.Scheme}://{HttpUtility.UrlEncode(AccountSettings.Username)}:{HttpUtility.UrlEncode(AccountSettings.Password)}@{uri.Host}{uri.PathAndQuery}";
            string     shelfName  = DateTime.Now.ToString(dateTimeFormat);
            CMDProcess cmdProcess = new CMDProcess("UPDATE", location.Name, new string[]
            {
                $"cd /d {location.URL}" +
                $"hg --config \"extensions.shelve = \" shelve --name {shelfName} {debugArg}" +
                $"hg pull {fullURL} {debugArg}" +
                $"hg update -m {debugArg}" +
                $"hg --config \"extensions.shelve = \" unshelve --name {shelfName} --tool :other {debugArg}"
            });

            try
            {
                await cmdProcess.Run();
            }
            catch (Exception e)
            {
                throw new MainActionException("Unable to start the necessary command window process", e);
            }

            cmdProcess.ReportErrorsAsync(Verb);
        }
Exemplo n.º 2
0
        //  Other Methods
        //  =============

        /// <exception cref="Kallithea_Klone.MainActionException"></exception>
        public async Task CloneAsync(Uri host, RepositoryData location)
        {
            string     fullURL    = $"{host.Scheme}://{HttpUtility.UrlEncode(AccountSettings.Username)}:{HttpUtility.UrlEncode(AccountSettings.Password)}@{host.Host}{host.PathAndQuery}{location.URL}";
            CMDProcess cmdProcess = new CMDProcess("CLONE", location.Name, $"hg clone {fullURL} \"{RunLocation}\\{location.Name}\" {debugArg}");

            try
            {
                await cmdProcess.Run();
            }
            catch (Exception e)
            {
                throw new MainActionException("Unable to start the necessary command window process", e);
            }

            cmdProcess.ReportErrorsAsync(Verb);
        }
Exemplo n.º 3
0
        //  Other Methods
        //  =============

        /// <exception cref="Kallithea_Klone.MainActionException"></exception>
        private async Task Revert(RepositoryData location)
        {
            CMDProcess cmdProcess = new CMDProcess("REVERT", location.Name, new string[]
            {
                $"cd /d {location.URL}",
                $"hg revert --all {debugArg}",
                $"hg --config \"extensions.purge = \" purge --all {debugArg}"
            });

            try
            {
                await cmdProcess.Run();
            }
            catch (Exception e)
            {
                throw new MainActionException("Unable to start the necessary command window process", e);
            }

            cmdProcess.ReportErrorsAsync(Verb);
        }
Exemplo n.º 4
0
        //  State Methods
        //  =============

        /// <exception cref="Kallithea_Klone.MainActionException"></exception>
        private async Task ReClone(RepositoryData location)
        {
            string remotePath = GetDefaultRemotePath(location.URL);
            Uri    uri        = new Uri(remotePath);

            string fullURL = $"{uri.Scheme}://{HttpUtility.UrlEncode(AccountSettings.Username)}:{HttpUtility.UrlEncode(AccountSettings.Password)}@{uri.Host}{uri.PathAndQuery}";

            try
            {
                ClearOutRepository(location.Name);
            }
            catch (Exception e)
            {
                throw new MainActionException($"Unable to properly delete the original repository, it is now probably half deleted.", e);
            }

            CMDProcess cmdProcess = new CMDProcess("RE-CLONE", location.Name, new string[]
            {
                $"cd /d \"{location.URL}\"",
                $"hg init {debugArg}",
                $"hg pull {fullURL} {debugArg}",
                $"hg update {debugArg}"
            });

            try
            {
                await cmdProcess.Run();
            }
            catch (Exception e)
            {
                throw new MainActionException("Unable to start the necessary command window process", e);
            }

            cmdProcess.ReportErrorsAsync(Verb);

            string passwordSafeURL = $"{uri.Scheme}://{HttpUtility.UrlEncode(AccountSettings.Username)}@{uri.Host}{uri.PathAndQuery}";

            SetDefaultLocation(location.URL, passwordSafeURL);
        }