本文整理汇总了C#中NGit.Update方法的典型用法代码示例。如果您正苦于以下问题:C# NGit.Update方法的具体用法?C# NGit.Update怎么用?C# NGit.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NGit
的用法示例。
在下文中一共展示了NGit.Update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MergeTrees
public static MergeCommandResult MergeTrees (NGit.ProgressMonitor monitor, NGit.Repository repo, RevCommit srcBase, RevCommit srcCommit, string sourceDisplayName, bool commitResult)
{
RevCommit newHead = null;
RevWalk revWalk = new RevWalk(repo);
try
{
// get the head commit
Ref headRef = repo.GetRef(Constants.HEAD);
if (headRef == null)
{
throw new NoHeadException(JGitText.Get().commitOnRepoWithoutHEADCurrentlyNotSupported
);
}
RevCommit headCommit = revWalk.ParseCommit(headRef.GetObjectId());
ResolveMerger merger = (ResolveMerger)((ThreeWayMerger)MergeStrategy.RESOLVE.NewMerger
(repo));
merger.SetWorkingTreeIterator(new FileTreeIterator(repo));
merger.SetBase(srcBase);
bool noProblems;
IDictionary<string, MergeResult<NGit.Diff.Sequence>> lowLevelResults = null;
IDictionary<string, ResolveMerger.MergeFailureReason> failingPaths = null;
IList<string> modifiedFiles = null;
ResolveMerger resolveMerger = (ResolveMerger)merger;
resolveMerger.SetCommitNames(new string[] { "BASE", "HEAD", sourceDisplayName });
noProblems = merger.Merge(headCommit, srcCommit);
lowLevelResults = resolveMerger.GetMergeResults();
modifiedFiles = resolveMerger.GetModifiedFiles();
failingPaths = resolveMerger.GetFailingPaths();
if (monitor != null)
monitor.Update (50);
if (noProblems)
{
if (modifiedFiles != null && modifiedFiles.Count == 0) {
return new MergeCommandResult(headCommit, null, new ObjectId[] { headCommit.Id, srcCommit
.Id }, MergeStatus.ALREADY_UP_TO_DATE, MergeStrategy.RESOLVE, null, null);
}
DirCacheCheckout dco = new DirCacheCheckout(repo, headCommit.Tree, repo.LockDirCache
(), merger.GetResultTreeId());
dco.SetFailOnConflict(true);
dco.Checkout();
if (commitResult) {
newHead = new NGit.Api.Git(repo).Commit().SetMessage(srcCommit.GetFullMessage()
).SetAuthor(srcCommit.GetAuthorIdent()).Call();
return new MergeCommandResult(newHead.Id, null, new ObjectId[] { headCommit.Id, srcCommit
.Id }, MergeStatus.MERGED, MergeStrategy.RESOLVE, null, null);
} else {
return new MergeCommandResult(headCommit, null, new ObjectId[] { headCommit.Id, srcCommit
.Id }, MergeStatus.MERGED, MergeStrategy.RESOLVE, null, null);
}
}
else
{
if (failingPaths != null)
{
return new MergeCommandResult(null, merger.GetBaseCommit(0, 1), new ObjectId[] {
headCommit.Id, srcCommit.Id }, MergeStatus.FAILED, MergeStrategy.RESOLVE, lowLevelResults
, failingPaths, null);
}
else
{
return new MergeCommandResult(null, merger.GetBaseCommit(0, 1), new ObjectId[] {
headCommit.Id, srcCommit.Id }, MergeStatus.CONFLICTING, MergeStrategy.RESOLVE, lowLevelResults
, null);
}
}
}
finally
{
revWalk.Release();
}
}