/// <summary> /// Commits the changes introduced by this <see cref="MergeJob"/>. /// </summary> /// <param name="command"> /// Any extra options to the commit method. /// </param> /// <returns> /// The <see cref="RevSpec"/> with the hash of the new changeset. /// </returns> /// <exception cref="ArgumentNullException"> /// <para><paramref name="command"/> is <c>null</c>.</para> /// </exception> /// <exception cref="InvalidOperationException"> /// <para>This MergeJob has already been committed, cannot commit again.</para> /// <para>- or -</para> /// <para>This MergeJob has been cancelled, cannot commit</para> /// <para>- or -</para> /// <para>There are unresolved merge conflicts in this MergeJob, cannot commit</para> /// </exception> public RevSpec Commit(CommitCommand command) { if (command == null) { throw new ArgumentNullException("command"); } switch (State) { case MergeJobState.Committed: throw new InvalidOperationException("This MergeJob has already been committed, cannot commit again"); case MergeJobState.Canceled: throw new InvalidOperationException("This MergeJob has been cancelled, cannot commit"); case MergeJobState.HasUnresolvedConflicts: throw new InvalidOperationException("There are unresolved merge conflicts in this MergeJob, cannot commit"); case MergeJobState.ReadyToCommit: Repository.Commit(command); _InternalState = MergeJobState.Committed; return(command.Result); default: throw new InvalidOperationException("Internal error, unknown MergeJobState for this MergeJob"); } }
/// <summary> /// Commits the changes introduced by this <see cref="MergeJob"/>. /// </summary> /// <param name="message"> /// The commit message to use. /// </param> /// <param name="command"> /// Any extra options to the commit method, or <c>null</c> for default options. /// </param> /// <returns> /// The <see cref="RevSpec"/> with the hash of the new changeset. /// </returns> /// <exception cref="ArgumentNullException"> /// <para><paramref name="message"/> is <c>null</c> or empty.</para> /// </exception> /// <exception cref="InvalidOperationException"> /// <para>This MergeJob has already been committed, cannot commit again.</para> /// <para>- or -</para> /// <para>This MergeJob has been cancelled, cannot commit</para> /// <para>- or -</para> /// <para>There are unresolved merge conflicts in this MergeJob, cannot commit</para> /// </exception> public RevSpec Commit(string message, CommitCommand command = null) { if (StringEx.IsNullOrWhiteSpace(message)) { throw new ArgumentNullException("message"); } command = (command ?? new CommitCommand()) .WithMessage(message); return(Commit(command)); }