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

Conflict.cs « LibGit2Sharp - github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 252535af1da007f3b2349859700460bfbf26f45c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using System;
using LibGit2Sharp.Core;

namespace LibGit2Sharp
{
    /// <summary>
    ///  Represents a group of index entries that describe a merge conflict
    ///  in the index.  This is typically a set of ancestor, ours and theirs
    ///  entries for a given path.
    ///
    /// Any side may be missing to reflect additions or deletions in the
    /// branches being merged.
    /// </summary>
    public class Conflict : IEquatable<Conflict>
    {
        private readonly IndexEntry ancestor;
        private readonly IndexEntry ours;
        private readonly IndexEntry theirs;

        private static readonly LambdaEqualityHelper<Conflict> equalityHelper =
            new LambdaEqualityHelper<Conflict>(x => x.Ancestor, x => x.Ours, x => x.Theirs);

        /// <summary>
        /// Needed for mocking purposes.
        /// </summary>
        protected Conflict()
        { }

        internal Conflict(IndexEntry ancestor, IndexEntry ours, IndexEntry theirs)
        {
            this.ancestor = ancestor;
            this.ours = ours;
            this.theirs = theirs;
        }

        /// <summary>
        ///  The index entry of the ancestor side of the conflict (the stage
        ///  1 index entry.)
        /// </summary>
        public virtual IndexEntry Ancestor
        {
            get { return ancestor; }
        }

        /// <summary>
        ///  The index entry of the "ours" (ORIG_HEAD or merge target) side
        ///  of the conflict (the stage 2 index entry.)
        /// </summary>
        public virtual IndexEntry Ours
        {
            get { return ours; }
        }

        /// <summary>
        ///  The index entry of the "theirs" (merge source) side of the
        ///  conflict (the stage 3 index entry.)
        /// </summary>
        public virtual IndexEntry Theirs
        {
            get { return theirs; }
        }

        /// <summary>
        /// Determines whether the specified <see cref="Object"/> is
        /// equal to the current <see cref="Conflict"/>.
        /// </summary>
        /// <param name="obj">The <see cref="Object"/> to compare with
        /// the current <see cref="Conflict"/>.</param>
        /// <returns>true if the specified <see cref="Object"/> is equal
        /// to the current <see cref="Conflict"/>; otherwise,
        /// false.</returns>
        public override bool Equals(object obj)
        {
            return Equals(obj as Conflict);
        }

        /// <summary>
        /// Determines whether the specified <see cref="Conflict"/>
        /// is equal to the current <see cref="Conflict"/>.
        /// </summary>
        /// <param name="other">The <see cref="Conflict"/> to compare
        /// with the current <see cref="Conflict"/>.</param>
        /// <returns>true if the specified <see cref="Conflict"/> is equal
        /// to the current <see cref="Conflict"/>; otherwise,
        /// false.</returns>
        public bool Equals(Conflict other)
        {
            return equalityHelper.Equals(this, other);
        }

        /// <summary>
        /// Returns the hash code for this instance.
        /// </summary>
        /// <returns>A 32-bit signed integer hash code.</returns>
        public override int GetHashCode()
        {
            return equalityHelper.GetHashCode(this);
        }

        /// <summary>
        /// Tests if two <see cref="Conflict"/> are equal.
        /// </summary>
        /// <param name="left">First <see cref="Conflict"/> to compare.</param>
        /// <param name="right">Second <see cref="Conflict"/> to compare.</param>
        /// <returns>True if the two objects are equal; false otherwise.</returns>
        public static bool operator ==(Conflict left, Conflict right)
        {
            return Equals(left, right);
        }

        /// <summary>
        /// Tests if two <see cref="Conflict"/> are different.
        /// </summary>
        /// <param name="left">First <see cref="Conflict"/> to compare.</param>
        /// <param name="right">Second <see cref="Conflict"/> to compare.</param>
        /// <returns>True if the two objects are different; false otherwise.</returns>
        public static bool operator !=(Conflict left, Conflict right)
        {
            return !Equals(left, right);
        }
    }
}