本文整理汇总了C#中HgRepository.RecoverFromInterruptedTransactionIfNeeded方法的典型用法代码示例。如果您正苦于以下问题:C# HgRepository.RecoverFromInterruptedTransactionIfNeeded方法的具体用法?C# HgRepository.RecoverFromInterruptedTransactionIfNeeded怎么用?C# HgRepository.RecoverFromInterruptedTransactionIfNeeded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HgRepository
的用法示例。
在下文中一共展示了HgRepository.RecoverFromInterruptedTransactionIfNeeded方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SyncNow
public SyncResults SyncNow(SyncOptions options)
{
SyncResults results = new SyncResults();
List<RepositoryAddress> sourcesToTry = options.RepositorySourcesToTry;
//this just saves us from trying to connect twice to the same repo that is, for example, no there.
Dictionary<RepositoryAddress, bool> connectionAttempts = new Dictionary<RepositoryAddress, bool>();
try
{
if (_progress.ProgressIndicator != null)
{
_progress.ProgressIndicator.IndicateUnknownProgress();
}
var repo = new HgRepository(_localRepositoryPath, _progress);
RemoveLocks(repo);
repo.RecoverFromInterruptedTransactionIfNeeded();
repo.FixUnicodeAudio();
string branchName = _sychronizerAdjunct.BranchName;
ChangeBranchIfNecessary(branchName);
Commit(options);
var workingRevBeforeSync = repo.GetRevisionWorkingSetIsBasedOn();
if (options.DoPullFromOthers)
{
results.DidGetChangesFromOthers = PullFromOthers(repo, sourcesToTry, connectionAttempts);
}
if (options.DoMergeWithOthers)
{
MergeHeadsOrRollbackAndThrow(repo, workingRevBeforeSync);
}
if (options.DoSendToOthers)
{
SendToOthers(repo, sourcesToTry, connectionAttempts);
}
//If we did pull any data or a trivial merge succeeded we should call UpdateToTheDescendantRevision
if (results.DidGetChangesFromOthers || //we pulled something
(workingRevBeforeSync!=null //will be null if this is the 1st checkin ever, but no files were added so there was no actual rev created
&& !repo.GetRevisionWorkingSetIsBasedOn().Number.Hash.Equals(workingRevBeforeSync.Number.Hash))) //a merge happened
{
UpdateToTheDescendantRevision(repo, workingRevBeforeSync);
}
_sychronizerAdjunct.CheckRepositoryBranches(repo.BranchingHelper.GetBranches(), _progress);
results.Succeeded = true;
_progress.WriteMessage("Done");
}
catch (SynchronizationException error)
{
error.DoNotifications(Repository, _progress);
results.Succeeded = false;
results.ErrorEncountered = error;
}
catch (UserCancelledException error)
{
results.Succeeded = false;
results.Cancelled = true;
results.ErrorEncountered = null;
}
catch (Exception error)
{
if (error.InnerException != null)
{
_progress.WriteVerbose("inner exception:");
_progress.WriteError(error.InnerException.Message);
_progress.WriteVerbose(error.InnerException.StackTrace);
}
_progress.WriteException(error);//this preserves the whole exception for later retrieval by the client
_progress.WriteError(error.Message);//review still needed if we have this new WriteException?
_progress.WriteVerbose(error.StackTrace);//review still needed if we have this new WriteException?
results.Succeeded = false;
results.ErrorEncountered = error;
}
return results;
}