private int PerformRCheckin(TfsChangesetInfo parentChangeset, string refToCheckin)
{
if (_globals.Repository.IsBare)
AutoRebase = false;
if (_globals.Repository.WorkingCopyHasUnstagedOrUncommitedChanges)
{
throw new GitTfsException("error: You have local changes; rebase-workflow checkin only possible with clean working directory.")
.WithRecommendation("Try 'git stash' to stash your local changes and checkin again.");
}
// get latest changes from TFS to minimize possibility of late conflict
Trace.TraceInformation("Fetching changes from TFS to minimize possibility of late conflict...");
parentChangeset.Remote.Fetch();
if (parentChangeset.ChangesetId != parentChangeset.Remote.MaxChangesetId)
{
if (AutoRebase)
{
_globals.Repository.CommandNoisy("rebase", "--preserve-merges", parentChangeset.Remote.RemoteRef);
parentChangeset = _globals.Repository.GetTfsCommit(parentChangeset.Remote.MaxCommitHash);
}
else
{
if (_globals.Repository.IsBare)
_globals.Repository.UpdateRef(refToCheckin, parentChangeset.Remote.MaxCommitHash);
throw new GitTfsException("error: New TFS changesets were found.")
.WithRecommendation("Try to rebase HEAD onto latest TFS checkin and repeat rcheckin or alternatively checkins");
}
}
IEnumerable<GitCommit> commitsToCheckin = _globals.Repository.FindParentCommits(refToCheckin, parentChangeset.Remote.MaxCommitHash);
Trace.WriteLine("Commit to checkin count:" + commitsToCheckin.Count());
if (!commitsToCheckin.Any())
throw new GitTfsException("error: latest TFS commit should be parent of commits being checked in");
SetupMetadataExport(parentChangeset.Remote);
return _PerformRCheckinQuick(parentChangeset, refToCheckin, commitsToCheckin);
}