/// <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> /// Cancels the merge by updating back to the initial parent. /// </summary> /// <remarks> /// WARNING! This will revert and undo any local changes in the working directory. /// </remarks> /// <exception cref="InvalidOperationException"> /// Cannot cancel this <see cref="MergeJob"/>, it has already been committed. /// </exception> public void CancelMerge() { switch (State) { case MergeJobState.Canceled: break; case MergeJobState.Committed: throw new InvalidOperationException("Cannot cancel this MergeJob, it has already been committed"); case MergeJobState.HasUnresolvedConflicts: case MergeJobState.ReadyToCommit: _Repository.Update(".", new UpdateCommand().WithClean()); Cleanup(); _InternalState = MergeJobState.Canceled; break; default: throw new InvalidOperationException("Internal error, unknown MergeJobState for this MergeJob"); } }