Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryorah <yoram.harmelin@gmail.com>2013-09-16 15:55:18 +0400
committeryorah <yoram.harmelin@gmail.com>2013-10-15 15:56:12 +0400
commit11f4cb81f0bea2127e08ef6b6997da02eda67c32 (patch)
tree0549a32e7cd5680b7ffd280fd38a02a632156ba2 /LibGit2Sharp/ContentChanges.cs
parentc5419f7be319ec7b2d589dfd9bd5f6aa8faebfdc (diff)
Split Patch and TreeChanges generation
Remove Patch from TreeChanges Make repo.Diff.Compare() generic
Diffstat (limited to 'LibGit2Sharp/ContentChanges.cs')
-rw-r--r--LibGit2Sharp/ContentChanges.cs54
1 files changed, 53 insertions, 1 deletions
diff --git a/LibGit2Sharp/ContentChanges.cs b/LibGit2Sharp/ContentChanges.cs
index 55e6f58c..68134696 100644
--- a/LibGit2Sharp/ContentChanges.cs
+++ b/LibGit2Sharp/ContentChanges.cs
@@ -1,4 +1,6 @@
using System;
+using System.Diagnostics;
+using System.Globalization;
using System.Text;
using LibGit2Sharp.Core;
@@ -7,8 +9,12 @@ namespace LibGit2Sharp
/// <summary>
/// Holds the changes between two <see cref="Blob"/>s.
/// </summary>
- public class ContentChanges : Changes
+ [DebuggerDisplay("{DebuggerDisplay,nq}")]
+ public class ContentChanges
{
+ private readonly StringBuilder patchBuilder = new StringBuilder();
+ private bool isBinaryComparison;
+
/// <summary>
/// Needed for mocking purposes.
/// </summary>
@@ -23,6 +29,43 @@ namespace LibGit2Sharp
options, FileCallback, HunkCallback, LineCallback);
}
+ internal ContentChanges(bool isBinaryComparison)
+ {
+ this.isBinaryComparison = isBinaryComparison;
+ }
+
+ internal void AppendToPatch(string patch)
+ {
+ patchBuilder.Append(patch);
+ }
+
+ /// <summary>
+ /// The number of lines added.
+ /// </summary>
+ public virtual int LinesAdded { get; internal set; }
+
+ /// <summary>
+ /// The number of lines deleted.
+ /// </summary>
+ public virtual int LinesDeleted { get; internal set; }
+
+ /// <summary>
+ /// The patch corresponding to these changes.
+ /// </summary>
+ public virtual string Patch
+ {
+ get { return patchBuilder.ToString(); }
+ }
+
+ /// <summary>
+ /// Determines if at least one side of the comparison holds binary content.
+ /// </summary>
+ public virtual bool IsBinaryComparison
+ {
+ get { return isBinaryComparison; }
+ private set { isBinaryComparison = value; }
+ }
+
private int FileCallback(GitDiffDelta delta, float progress, IntPtr payload)
{
IsBinaryComparison = delta.IsBinary();
@@ -76,5 +119,14 @@ namespace LibGit2Sharp
AppendToPatch(decodedContent);
return 0;
}
+
+ private string DebuggerDisplay
+ {
+ get
+ {
+ return string.Format(CultureInfo.InvariantCulture,
+ @"{{+{0}, -{1}}}", LinesAdded, LinesDeleted);
+ }
+ }
}
}