Esempio n. 1
0
        /// <summary>
        /// Executes the given <see cref="IMercurialCommand"/> command against
        /// the Mercurial repository.
        /// </summary>
        /// <param name="repositoryPath">
        /// The root path of the repository to execute the command in.
        /// </param>
        /// <param name="command">
        /// The <see cref="IMercurialCommand"/> command to execute.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="repositoryPath"/> is <c>null</c>.</para>
        /// <para>- or -</para>
        /// <para><paramref name="command"/> is <c>null</c>.</para>
        /// </exception>
        /// <exception cref="MercurialException">
        /// HG did not complete within the allotted time.
        /// </exception>
        public static void Execute(string repositoryPath, IMercurialCommand command)
        {
            if (StringEx.IsNullOrWhiteSpace(repositoryPath))
            {
                throw new ArgumentNullException("repositoryPath");
            }
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            ClientExecutable.LazyInitialize();
            var specialArguments = (IEnumerable <string>) new[]
            {
                "--noninteractive", "--encoding", ClientExecutable.GetTerminalEncoding().WebName,
            };
            var environmentVariables = new KeyValuePair <string, string>[]
            {
                new KeyValuePair <string, string>("LANGUAGE", "EN"),
                new KeyValuePair <string, string>("HGENCODING", ClientExecutable.GetTerminalEncoding().WebName),
            };

            CommandProcessor.Execute(repositoryPath, ClientExecutable.ClientPath, command, environmentVariables, specialArguments);
            MercurialVersionBase.Current.WaitForLocksToDissipate(repositoryPath);
        }