本文整理汇总了C#中RevWalk类的典型用法代码示例。如果您正苦于以下问题:C# RevWalk类的具体用法?C# RevWalk怎么用?C# RevWalk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RevWalk类属于命名空间,在下文中一共展示了RevWalk类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Of
/// <summary>
/// Compute the tracking status for the <code>branchName</code> in
/// <code>repository</code>.
/// </summary>
/// <remarks>
/// Compute the tracking status for the <code>branchName</code> in
/// <code>repository</code>.
/// </remarks>
/// <param name="repository">the git repository to compute the status from</param>
/// <param name="branchName">the local branch</param>
/// <returns>the tracking status, or null if it is not known</returns>
/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
public static NGit.BranchTrackingStatus Of(Repository repository, string branchName
)
{
BranchConfig branchConfig = new BranchConfig(repository.GetConfig(), branchName);
string trackingBranch = branchConfig.GetTrackingBranch();
if (trackingBranch == null)
{
return null;
}
Ref tracking = repository.GetRef(trackingBranch);
if (tracking == null)
{
return null;
}
Ref local = repository.GetRef(branchName);
if (local == null)
{
return null;
}
RevWalk walk = new RevWalk(repository);
RevCommit localCommit = walk.ParseCommit(local.GetObjectId());
RevCommit trackingCommit = walk.ParseCommit(tracking.GetObjectId());
walk.SetRevFilter(RevFilter.MERGE_BASE);
walk.MarkStart(localCommit);
walk.MarkStart(trackingCommit);
RevCommit mergeBase = walk.Next();
walk.Reset();
walk.SetRevFilter(RevFilter.ALL);
int aheadCount = RevWalkUtils.Count(walk, localCommit, mergeBase);
int behindCount = RevWalkUtils.Count(walk, trackingCommit, mergeBase);
return new NGit.BranchTrackingStatus(trackingBranch, aheadCount, behindCount);
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:44,代码来源:BranchTrackingStatus.cs
示例2: InitialGenerator
public InitialGenerator(RevWalk w, Generator s, BoundaryGenerator parent) // [henon] parent needed because we cannot access outer instances in C#
{
_walk = w;
_held = new FIFORevQueue();
_source = s;
_source.shareFreeList(_held);
_parent = parent;
}
开发者ID:dev218,项目名称:GitSharp,代码行数:8,代码来源:BoundaryGenerator.cs
示例3: Include
/// <exception cref="NGit.Errors.StopWalkException"></exception>
/// <exception cref="NGit.Errors.MissingObjectException"></exception>
/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
/// <exception cref="System.IO.IOException"></exception>
public override bool Include(RevWalk walker, RevCommit cmit)
{
if (skip > count++)
{
return false;
}
return true;
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:12,代码来源:SkipRevFilter.cs
示例4: parseCanonical
public void parseCanonical(RevWalk walk, byte[] raw)
{
MutableObjectId idBuffer = walk.idBuffer;
idBuffer.FromString(raw, 5);
tree = walk.lookupTree(idBuffer);
int ptr = 46;
if (parents == null)
{
RevCommit[] pList = new RevCommit[1];
int nParents = 0;
for (; ; )
{
if (raw[ptr] != (byte)'p')
break;
idBuffer.FromString(raw, ptr + 7);
RevCommit p = walk.lookupCommit(idBuffer);
if (nParents == 0)
pList[nParents++] = p;
else if (nParents == 1)
{
pList = new RevCommit[] { pList[0], p };
nParents = 2;
}
else
{
if (pList.Length <= nParents)
{
RevCommit[] old = pList;
pList = new RevCommit[pList.Length + 32];
Array.Copy(old, 0, pList, 0, nParents);
}
pList[nParents++] = p;
}
ptr += 48;
}
if (nParents != pList.Length)
{
RevCommit[] old = pList;
pList = new RevCommit[nParents];
Array.Copy(old, 0, pList, 0, nParents);
}
parents = pList;
}
// extract time from "committer "
ptr = RawParseUtils.committer(raw, ptr);
if (ptr > 0)
{
ptr = RawParseUtils.nextLF(raw, ptr, (byte)'>');
// In 2038 commitTime will overflow unless it is changed to long.
commitTime = RawParseUtils.parseBase10(raw, ptr, null);
}
buffer = raw;
flags |= PARSED;
}
开发者ID:stephensong,项目名称:GitSharp,代码行数:58,代码来源:RevCommit.cs
示例5: parseBody
internal override void parseBody(RevWalk walk)
{
if (_buffer == null)
{
_buffer = loadCanonical(walk);
if ((Flags & PARSED) == 0)
parseCanonical(walk, _buffer);
}
}
开发者ID:dev218,项目名称:GitSharp,代码行数:9,代码来源:RevTag.cs
示例6: RebaseOperation
public RebaseOperation (NGit.Repository repo, string upstreamRef, IProgressMonitor monitor)
{
this.monitor = monitor;
this.repo = repo;
this.upstreamRef = upstreamRef;
rw = new RevWalk (repo);
branch = repo.GetBranch ();
starting = true;
}
开发者ID:nickname100,项目名称:monodevelop,代码行数:9,代码来源:RebaseOperation.cs
示例7: Include
/// <exception cref="NGit.Errors.StopWalkException"></exception>
/// <exception cref="NGit.Errors.MissingObjectException"></exception>
/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
/// <exception cref="System.IO.IOException"></exception>
public override bool Include(RevWalk walker, RevCommit cmit)
{
count++;
if (count > maxCount)
{
throw StopWalkException.INSTANCE;
}
return true;
}
开发者ID:nocache,项目名称:monodevelop,代码行数:13,代码来源:MaxCountRevFilter.cs
示例8: GetFullMessage
public string GetFullMessage(string hash)
{
var walk = new RevWalk(this.git.GetRepository());
RevCommit commit = walk.ParseCommit(ObjectId.FromString(hash));
walk.Dispose();
return commit.GetFullMessage();
}
开发者ID:dineshkummarc,项目名称:Ometh,代码行数:10,代码来源:Repository.cs
示例9: TestTaggingOnHead
public virtual void TestTaggingOnHead()
{
Git git = new Git(db);
RevCommit commit = git.Commit().SetMessage("initial commit").Call();
Ref tagRef = git.Tag().SetName("tag").Call();
NUnit.Framework.Assert.AreEqual(commit.Id, db.Peel(tagRef).GetPeeledObjectId());
RevWalk walk = new RevWalk(db);
NUnit.Framework.Assert.AreEqual("tag", walk.ParseTag(tagRef.GetObjectId()).GetTagName
());
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:10,代码来源:TagCommandTest.cs
示例10: parse
internal override void parse(RevWalk walk)
{
ObjectLoader ldr = walk.db.openObject(walk.curs, this);
if (ldr == null)
throw new MissingObjectException(this, TYPE_COMMIT);
byte[] data = ldr.getCachedBytes();
if (Constants.OBJ_COMMIT != ldr.getType())
throw new IncorrectObjectTypeException(this, TYPE_COMMIT);
parseCanonical(walk, data);
}
开发者ID:stephensong,项目名称:GitSharp,代码行数:10,代码来源:RevCommit.cs
示例11: ParseHeaders
/// <exception cref="NGit.Errors.MissingObjectException"></exception>
/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
/// <exception cref="System.IO.IOException"></exception>
internal override void ParseHeaders(RevWalk walk)
{
if (walk.reader.Has(this))
{
flags |= PARSED;
}
else
{
throw new MissingObjectException(this, Type);
}
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:14,代码来源:RevTree.cs
示例12: RefAdvertiser
public RefAdvertiser(PacketLineOut o, RevWalk.RevWalk protoWalk, RevFlag advertisedFlag)
{
_tmpLine = new StringBuilder(100);
_tmpId = new char[2 * Constants.OBJECT_ID_LENGTH];
_capabilities = new List<string>();
_first = true;
_pckOut = o;
_walk = protoWalk;
ADVERTISED = advertisedFlag;
}
开发者ID:georgeck,项目名称:GitSharp,代码行数:11,代码来源:RefAdvertiser.cs
示例13: ListCommits
public IEnumerable<CommitInfo> ListCommits() {
using(var repository = new GitSharp.Repository(FullPath)) {
var w = new RevWalk(repository);
w.markStart(((GitSharp.Core.Repository)repository).getAllRefsByPeeledObjectId().Keys.Select(w.parseCommit));
return w.Select(t => new CommitInfo {
Id = t.getId().Name,
Date = t.AsCommit(w).Author.When.MillisToDateTimeOffset(t.AsCommit(w).Author.TimeZoneOffset),
Message = t.getShortMessage()
}).ToArray();
}
}
开发者ID:mios-fi,项目名称:mios.guvnor,代码行数:11,代码来源:Repository.cs
示例14: RepositoryWalker
public RepositoryWalker(CoreRepository repo)
{
if (repo == null)
{
throw new ArgumentNullException(nameof(repo));
}
_walker = new RevWalk(repo);
_assistantWalker = new RevWalk(repo);
_initCommit = new RevCommit(repo.Head.ObjectId);
}
开发者ID:dotnet,项目名称:docfx,代码行数:12,代码来源:RepositoryWalker.cs
示例15: Setup
/// <exception cref="System.Exception"></exception>
public virtual void Setup(int count)
{
Git git = new Git(db);
for (int i = 0; i < count; i++)
{
git.Commit().SetCommitter(committer).SetAuthor(author).SetMessage("commit " + i).
Call();
}
list = new RevCommitList<RevCommit>();
RevWalk w = new RevWalk(db);
w.MarkStart(w.LookupCommit(db.Resolve(Constants.HEAD)));
list.Source(w);
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:14,代码来源:RevCommitListTest.cs
示例16: FileDiff
public ActionResult FileDiff(string path, string fromSha1,string toSha1)
{
var nGit = TM_UserData_Git.Current.NGit;
Func<Repository, string, string, string, string> getDiff =
(gitRepo, repoPath, fromCommitId, toCommitId) =>
{
var fromCommit = gitRepo.Resolve(fromCommitId);
var toCommit = gitRepo.Resolve(toCommitId);
var outputStream = "Sharpen.dll".assembly().type("ByteArrayOutputStream").ctor(new object[0]).cast<OutputStream>();
//return "diffing from {0} to {1}".format(fromCommit, toCommit);
var diffFormater = new DiffFormatter(outputStream);
var pathFilter = PathFilter.Create(repoPath);
diffFormater.SetRepository(gitRepo);
diffFormater.SetPathFilter(pathFilter);
//diffFormater.Format(refLog.GetNewId(), refLog.GetOldId());
diffFormater.Format(fromCommit, toCommit);
return "result: " + outputStream.str();
};
Func<Repository, string, string, string> getFistValue =
(gitRepo, commitSha1, repoPath) =>
{
var revCommit = nGit.commit(commitSha1);
var outputStream = "Sharpen.dll".assembly().type("ByteArrayOutputStream").ctor(new object[0]).cast<OutputStream>();
var diffFormater = new DiffFormatter(outputStream);
var pathFilter = PathFilter.Create(repoPath);
diffFormater.SetRepository(gitRepo);
diffFormater.SetPathFilter(pathFilter);
var revWalk = new RevWalk(gitRepo);
var canonicalTreeParser = new CanonicalTreeParser(null, revWalk.GetObjectReader(), revCommit.Tree);
diffFormater.Format(new EmptyTreeIterator(), canonicalTreeParser);
return outputStream.str().fix_CRLF();
};
var rawDiff = fromSha1 == NGit_Consts.EMPTY_SHA1
? getFistValue(nGit.repository(), fromSha1, path)
: getDiff(nGit.repository(), path, fromSha1, toSha1);
var viewFile = new View_GitFileDiff()
{
FilePath = path,
FromSha1 = fromSha1,
ToSha1 = toSha1,
Diff = rawDiff
};
return View(viewFile);
}
开发者ID:TeamMentor,项目名称:Dev,代码行数:51,代码来源:GitUserDataController.cs
示例17: CheckoutCommit
/// <exception cref="System.InvalidOperationException"></exception>
/// <exception cref="System.IO.IOException"></exception>
private void CheckoutCommit(RevCommit commit)
{
RevWalk walk = new RevWalk(db);
RevCommit head = walk.ParseCommit(db.Resolve(Constants.HEAD));
DirCacheCheckout dco = new DirCacheCheckout(db, head.Tree, db.LockDirCache(), commit
.Tree);
dco.SetFailOnConflict(true);
dco.Checkout();
walk.Release();
// update the HEAD
RefUpdate refUpdate = db.UpdateRef(Constants.HEAD, true);
refUpdate.SetNewObjectId(commit);
refUpdate.ForceUpdate();
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:16,代码来源:RebaseCommandTest.cs
示例18: parseCanonical
public void parseCanonical(RevWalk walk, byte[] rawTag)
{
var pos = new MutableInteger { value = 53 };
int oType = Constants.decodeTypeString(this, rawTag, (byte)'\n', pos);
walk.IdBuffer.FromString(rawTag, 7);
_object = walk.lookupAny(walk.IdBuffer, oType);
int p = pos.value += 4; // "tag "
int nameEnd = RawParseUtils.nextLF(rawTag, p) - 1;
_tagName = RawParseUtils.decode(Constants.CHARSET, rawTag, p, nameEnd);
if (walk.isRetainBody())
_buffer = rawTag;
Flags |= PARSED;
}
开发者ID:dev218,项目名称:GitSharp,代码行数:16,代码来源:RevTag.cs
示例19: parseCanonical
public void parseCanonical(RevWalk walk, byte[] rawTag)
{
MutableInteger pos = new MutableInteger();
int oType;
pos.value = 53; // "@object $sha1\ntype "
oType = Constants.decodeTypeString(this, rawTag, (byte)'\n', pos);
walk.idBuffer.FromString(rawTag, 7);
@object = walk.lookupAny(walk.idBuffer, oType);
int p = pos.value += 4; // "tag "
int nameEnd = RawParseUtils.nextLF(rawTag, p) - 1;
name = RawParseUtils.decode(Constants.CHARSET, rawTag, p, nameEnd);
buffer = rawTag;
flags |= PARSED;
}
开发者ID:stephensong,项目名称:GitSharp,代码行数:16,代码来源:RevTag.cs
示例20: CreateRevWalker
private RevWalk CreateRevWalker()
{
var repository = _git.GetRepository();
try
{
var revWalk = new RevWalk(repository);
foreach (var reference in repository.GetAllRefs())
{
revWalk.MarkStart(revWalk.ParseCommit(reference.Value.GetObjectId()));
}
return revWalk;
}
finally
{
repository.Close();
}
}
开发者ID:sbcfwebdev,项目名称:Target-Process-Plugins,代码行数:18,代码来源:GitClient.cs
注:本文中的RevWalk类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论