本文整理汇总了C#中HgRepository.RollbackWorkingDirectoryToRevision方法的典型用法代码示例。如果您正苦于以下问题:C# HgRepository.RollbackWorkingDirectoryToRevision方法的具体用法?C# HgRepository.RollbackWorkingDirectoryToRevision怎么用?C# HgRepository.RollbackWorkingDirectoryToRevision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HgRepository
的用法示例。
在下文中一共展示了HgRepository.RollbackWorkingDirectoryToRevision方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateToTheDescendantRevision
/// <summary>
/// If everything got merged, then this is trivial. But in case of a merge failure,
/// the "tip" might be the other guy's unmergable data (maybe because he has a newer
/// version of some application than we do) We don't want to switch to that!
///
/// So if there are more than one head out there, we update to the one that is a descendant
/// of our latest checkin (which in the simple merge failure case is the the checkin itself,
/// but in a 3-or-more source scenario could be the result of a merge with a more cooperative
/// revision).
/// </summary>
private void UpdateToTheDescendantRevision(HgRepository repository, Revision parent)
{
try
{
var heads = repository.GetHeads();
//if there is only one head for the branch we started from just update
if (heads.Count(rev => rev.Branch == parent.Branch) == 1)
{
repository.Update(); //update to the tip
_sychronizerAdjunct.SimpleUpdate(_progress, false);
return;
}
if (heads.Count == 0)
{
return;//nothing has been checked in, so we're done! (this happens during some UI tests)
}
// when there are more than 2 people merging and there's a failure or a no-op merge happened
foreach (var head in heads)
{
if (parent.Number.Hash == head.Number.Hash || (head.Branch == parent.Branch && head.IsDirectDescendantOf(parent)))
{
repository.RollbackWorkingDirectoryToRevision(head.Number.LocalRevisionNumber);
_sychronizerAdjunct.SimpleUpdate(_progress, true);
return;
}
}
_progress.WriteWarning("Staying at previous-tip (unusual). Other users recent changes will not be visible.");
}
catch (UserCancelledException)
{
throw;
}
catch (Exception error)
{
ExplainAndThrow(error, "Could not update.");
}
}