Skip to content

Correct the deprecation path for MergeConflictException #1243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions LibGit2Sharp.Tests/CheckoutFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,23 @@ public void CanCheckoutPathFromCurrentBranch(string fileName)
}
}

[Fact]
public void CanCatchDeprecatedException()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we necessarily need to assert this behavior.

{
bool caught = false;

try
{
throw new CheckoutConflictException();
}
catch (MergeConflictException)
{
caught = true;
}

Assert.True(caught);
}

/// <summary>
/// Helper method to populate a simple repository with
/// a single file and two branches.
Expand Down
38 changes: 1 addition & 37 deletions LibGit2Sharp/CheckoutConflictException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;
using LibGit2Sharp.Core;

namespace LibGit2Sharp
Expand All @@ -10,49 +9,14 @@ namespace LibGit2Sharp
/// in the working directory.
/// </summary>
[Serializable]
public class CheckoutConflictException : LibGit2SharpException
public class CheckoutConflictException : MergeConflictException
{
/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.CheckoutConflictException"/> class.
/// </summary>
public CheckoutConflictException()
{ }

/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.CheckoutConflictException"/> class with a specified error message.
/// </summary>
/// <param name="message">A message that describes the error.</param>
public CheckoutConflictException(string message)
: base(message)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.CheckoutConflictException"/> class with a specified error message.
/// </summary>
/// <param name="format">A composite format string for use in <see cref="String.Format(IFormatProvider, string, object[])"/>.</param>
/// <param name="args">An object array that contains zero or more objects to format.</param>
public CheckoutConflictException(string format, params object[] args)
: base(format, args)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.CheckoutConflictException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception. If the <paramref name="innerException"/> parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception.</param>
public CheckoutConflictException(string message, Exception innerException)
: base(message, innerException)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.CheckoutConflictException"/> class with a serialized data.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
protected CheckoutConflictException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }

internal CheckoutConflictException(string message, GitErrorCode code, GitErrorCategory category)
: base(message, code, category)
{ }
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp/LibGit2Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<Compile Include="IndexReucEntryCollection.cs" />
<Compile Include="IndexNameEntry.cs" />
<Compile Include="MergeAndCheckoutOptionsBase.cs" />
<Compile Include="MergeConflictException.cs" />
<Compile Include="CheckoutConflictException.cs" />
<Compile Include="MergeOptions.cs" />
<Compile Include="MergeOptionsBase.cs" />
<Compile Include="MergeResult.cs" />
Expand Down Expand Up @@ -249,7 +249,7 @@
<Compile Include="FetchHead.cs" />
<Compile Include="Handlers.cs" />
<Compile Include="Ignore.cs" />
<Compile Include="CheckoutConflictException.cs" />
<Compile Include="MergeConflictException.cs" />
<Compile Include="MergeHead.cs" />
<Compile Include="NameConflictException.cs" />
<Compile Include="NonFastForwardException.cs" />
Expand Down
51 changes: 49 additions & 2 deletions LibGit2Sharp/MergeConflictException.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Runtime.Serialization;
using LibGit2Sharp.Core;

namespace LibGit2Sharp
{
Expand All @@ -9,6 +11,51 @@ namespace LibGit2Sharp
/// </summary>
[Serializable]
[Obsolete("This type will be removed in the next release. Please use CheckoutConflictException instead.")]
public class MergeConflictException : CheckoutConflictException
{ }
public class MergeConflictException : LibGit2SharpException
{
/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.MergeConflictException"/> class.
/// </summary>
public MergeConflictException()
{ }

/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.MergeConflictException"/> class with a specified error message.
/// </summary>
/// <param name="message">A message that describes the error.</param>
public MergeConflictException(string message)
: base(message)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.MergeConflictException"/> class with a specified error message.
/// </summary>
/// <param name="format">A composite format string for use in <see cref="String.Format(IFormatProvider, string, object[])"/>.</param>
/// <param name="args">An object array that contains zero or more objects to format.</param>
public MergeConflictException(string format, params object[] args)
: base(format, args)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.MergeConflictException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception. If the <paramref name="innerException"/> parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception.</param>
public MergeConflictException(string message, Exception innerException)
: base(message, innerException)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="LibGit2Sharp.MergeConflictException"/> class with a serialized data.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
protected MergeConflictException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }

internal MergeConflictException(string message, GitErrorCode code, GitErrorCategory category)
: base(message, code, category)
{ }
}
}