Пример #1
0
        /// <summary>
        /// Initializes a repository remotely, through a server which supports such functionality.
        /// </summary>
        /// <param name="command">
        /// The options to the init method.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// <para><paramref name="command"/> is <c>null</c>.</para>
        /// </exception>
        public static void RemoteInit(RemoteInitCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            NonPersistentClient.Execute(command);
        }
Пример #2
0
        /// <summary>
        /// Initializes a repository remotely, through a server which supports such functionality.
        /// </summary>
        /// <param name="location">
        /// The url of the repository to initialize remotely.
        /// </param>
        /// <param name="command">
        /// Any extra options to the init method, or <c>null</c> for default options.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// <para><paramref name="location"/> is <c>null</c> or empty.</para>
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// <para><see cref="RemoteInitCommand.Location"/> cannot be set before calling this method.</para>
        /// </exception>
        public static void RemoteInit(string location, RemoteInitCommand command = null)
        {
            if (StringEx.IsNullOrWhiteSpace(location))
            {
                throw new ArgumentNullException("location");
            }
            if (command != null && !StringEx.IsNullOrWhiteSpace(command.Location))
            {
                throw new ArgumentException("RemoteInitCommand.Location cannot be set before calling this method", "command");
            }

            command = (command ?? new RemoteInitCommand())
                      .WithLocation(location);

            NonPersistentClient.Execute(command);
        }
Пример #3
0
        private static Version DoGetVersion()
        {
            var command = new VersionCommand();

            NonPersistentClient.Execute(command);
            string firstLine = command.Result.Split(
                new[]
            {
                '\n', '\r'
            }, StringSplitOptions.RemoveEmptyEntries).First();
            var   re = new Regex(@"\(version\s+(?<version>[0-9.]+)(\+\d+-[a-f0-9]+)?\)", RegexOptions.IgnoreCase);
            Match ma = re.Match(firstLine);

            if (!ma.Success)
            {
                throw new InvalidOperationException(
                          string.Format(CultureInfo.InvariantCulture, "Unable to locate Mercurial version number in '{0}'",
                                        firstLine));
            }

            string versionString = ma.Groups["version"].Value;

            switch (versionString.Split(new[] { '.' }).Length)
            {
            case 1:
                return(new Version(string.Format(CultureInfo.InvariantCulture, "{0}.0.0.0", versionString)));

            case 2:
                return(new Version(string.Format(CultureInfo.InvariantCulture, "{0}.0.0", versionString)));

            case 3:
                return(new Version(string.Format(CultureInfo.InvariantCulture, "{0}.0", versionString)));

            case 4:
                return(new Version(versionString));

            default:
                throw new InvalidOperationException(
                          string.Format(CultureInfo.InvariantCulture,
                                        "Incorrect version number length, too many or too few parts: {0}", versionString));
            }
        }