2
This code is derived from jgit (http://eclipse.org/jgit).
3
Copyright owners are documented in jgit's IP log.
5
This program and the accompanying materials are made available
6
under the terms of the Eclipse Distribution License v1.0 which
7
accompanies this distribution, is reproduced below, and is
8
available at http://www.eclipse.org/org/documents/edl-v10.php
12
Redistribution and use in source and binary forms, with or
13
without modification, are permitted provided that the following
16
- Redistributions of source code must retain the above copyright
17
notice, this list of conditions and the following disclaimer.
19
- Redistributions in binary form must reproduce the above
20
copyright notice, this list of conditions and the following
21
disclaimer in the documentation and/or other materials provided
22
with the distribution.
24
- Neither the name of the Eclipse Foundation, Inc. nor the
25
names of its contributors may be used to endorse or promote
26
products derived from this software without specific prior
29
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
30
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
31
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
32
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
36
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
38
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
41
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49
namespace NGit.Revwalk
51
/// <summary>Base object type accessed during revision walking.</summary>
52
/// <remarks>Base object type accessed during revision walking.</remarks>
54
public abstract class RevObject : ObjectIdOwnerMap.Entry
56
internal const int PARSED = 1;
60
protected internal RevObject(AnyObjectId name) : base(name)
64
/// <exception cref="NGit.Errors.MissingObjectException"></exception>
65
/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
66
/// <exception cref="System.IO.IOException"></exception>
67
internal abstract void ParseHeaders(RevWalk walk);
69
/// <exception cref="NGit.Errors.MissingObjectException"></exception>
70
/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
71
/// <exception cref="System.IO.IOException"></exception>
72
internal abstract void ParseBody(RevWalk walk);
74
/// <summary>Get Git object type.</summary>
76
/// Get Git object type. See
77
/// <see cref="NGit.Constants">NGit.Constants</see>
80
/// <returns>object type</returns>
81
public abstract int Type
86
/// <summary>Get the name of this object.</summary>
87
/// <remarks>Get the name of this object.</remarks>
88
/// <returns>unique hash of this object.</returns>
97
/// <summary>Test to see if the flag has been set on this object.</summary>
98
/// <remarks>Test to see if the flag has been set on this object.</remarks>
99
/// <param name="flag">the flag to test.</param>
100
/// <returns>true if the flag has been added to this object; false if not.</returns>
101
public bool Has(RevFlag flag)
103
return (flags & flag.mask) != 0;
106
/// <summary>Test to see if any flag in the set has been set on this object.</summary>
107
/// <remarks>Test to see if any flag in the set has been set on this object.</remarks>
108
/// <param name="set">the flags to test.</param>
110
/// true if any flag in the set has been added to this object; false
113
public bool HasAny(RevFlagSet set)
115
return (flags & set.mask) != 0;
118
/// <summary>Test to see if all flags in the set have been set on this object.</summary>
119
/// <remarks>Test to see if all flags in the set have been set on this object.</remarks>
120
/// <param name="set">the flags to test.</param>
122
/// true if all flags of the set have been added to this object;
123
/// false if some or none have been added.
125
public bool HasAll(RevFlagSet set)
127
return (flags & set.mask) == set.mask;
130
/// <summary>Add a flag to this object.</summary>
132
/// Add a flag to this object.
134
/// If the flag is already set on this object then the method has no effect.
136
/// <param name="flag">the flag to mark on this object, for later testing.</param>
137
public void Add(RevFlag flag)
142
/// <summary>Add a set of flags to this object.</summary>
143
/// <remarks>Add a set of flags to this object.</remarks>
144
/// <param name="set">the set of flags to mark on this object, for later testing.</param>
145
public void Add(RevFlagSet set)
150
/// <summary>Remove a flag from this object.</summary>
152
/// Remove a flag from this object.
154
/// If the flag is not set on this object then the method has no effect.
156
/// <param name="flag">the flag to remove from this object.</param>
157
public void Remove(RevFlag flag)
162
/// <summary>Remove a set of flags from this object.</summary>
163
/// <remarks>Remove a set of flags from this object.</remarks>
164
/// <param name="set">the flag to remove from this object.</param>
165
public void Remove(RevFlagSet set)
170
public override string ToString()
172
StringBuilder s = new StringBuilder();
173
s.Append(Constants.TypeString(Type));
181
/// <param name="s">buffer to append a debug description of core RevFlags onto.</param>
182
protected internal virtual void AppendCoreFlags(StringBuilder s)
184
s.Append((flags & RevWalk.TOPO_DELAY) != 0 ? 'o' : '-');
185
s.Append((flags & RevWalk.TEMP_MARK) != 0 ? 't' : '-');
186
s.Append((flags & RevWalk.REWRITE) != 0 ? 'r' : '-');
187
s.Append((flags & RevWalk.UNINTERESTING) != 0 ? 'u' : '-');
188
s.Append((flags & RevWalk.SEEN) != 0 ? 's' : '-');
189
s.Append((flags & RevWalk.PARSED) != 0 ? 'p' : '-');