Skip to content

Commit

Permalink
Fixed issue #148
Browse files Browse the repository at this point in the history
  • Loading branch information
xelibrion committed Feb 25, 2012
1 parent 21a5ead commit 64c3501
Showing 1 changed file with 35 additions and 23 deletions.
58 changes: 35 additions & 23 deletions GitTfs.VsCommon/Wrappers.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Microsoft.TeamFoundation.Server;
using Microsoft.TeamFoundation.VersionControl.Client;
using Sep.Git.Tfs.Core.TfsInterop;
using System.Collections.Generic;
using System.IO;

namespace Sep.Git.Tfs.VsCommon
{
public class WrapperForVersionControlServer :WrapperFor<VersionControlServer>, IVersionControlServer
public class WrapperForVersionControlServer : WrapperFor<VersionControlServer>, IVersionControlServer
{
private readonly TfsApiBridge _bridge;
private readonly VersionControlServer _versionControlServer;
Expand Down Expand Up @@ -37,15 +37,18 @@ public IItem[] GetItems(string itemPath, int changesetNumber, TfsRecursionType r
DeletedState.NonDeleted,
ItemType.Any,
true
);
);
return _bridge.Wrap<WrapperForItem, Item>(itemSet.Items);
}

public IEnumerable<IChangeset> QueryHistory(string path, int version, int deletionId,
TfsRecursionType recursion, string user, int versionFrom, int versionTo, int maxCount,
bool includeChanges, bool slotMode, bool includeDownloadInfo)
public IEnumerable<IChangeset> QueryHistory(string path, int version, int deletionId,
TfsRecursionType recursion, string user, int versionFrom, int versionTo, int maxCount,
bool includeChanges, bool slotMode, bool includeDownloadInfo)
{
var history = _versionControlServer.QueryHistory(path, new ChangesetVersionSpec(version), deletionId, _bridge.Convert<RecursionType>(recursion), user, new ChangesetVersionSpec(versionFrom), new ChangesetVersionSpec(versionTo), maxCount, includeChanges, slotMode, includeDownloadInfo);
var history = _versionControlServer.QueryHistory(path, new ChangesetVersionSpec(version), deletionId,
_bridge.Convert<RecursionType>(recursion), user, new ChangesetVersionSpec(versionFrom),
new ChangesetVersionSpec(versionTo), maxCount, includeChanges, slotMode,
includeDownloadInfo);
return _bridge.Wrap<WrapperForChangeset, Changeset>(history);
}
}
Expand All @@ -61,7 +64,7 @@ public WrapperForChangeset(TfsApiBridge bridge, Changeset changeset) : base(chan
_changeset = changeset;
}

public IChange [] Changes
public IChange[] Changes
{
get { return _bridge.Wrap<WrapperForChange, Change>(_changeset.Changes); }
}
Expand All @@ -72,7 +75,7 @@ public string Committer
{
var committer = _changeset.Committer;
var owner = _changeset.Owner;

// Sometimes TFS itself commits the changeset
if (owner != committer)
return owner;
Expand Down Expand Up @@ -248,7 +251,8 @@ public WrapperForPendingChange(PendingChange pendingChange) : base(pendingChange
public class WrapperForCheckinNote : WrapperFor<CheckinNote>, ICheckinNote
{
public WrapperForCheckinNote(CheckinNote checkiNote) : base(checkiNote)
{}
{
}
}

public class WrapperForCheckinEvaluationResult : WrapperFor<CheckinEvaluationResult>, ICheckinEvaluationResult
Expand Down Expand Up @@ -386,17 +390,18 @@ public WrapperForWorkspace(TfsApiBridge bridge, Workspace workspace) : base(work
_workspace = workspace;
}

public IPendingChange [] GetPendingChanges()
public IPendingChange[] GetPendingChanges()
{
return _bridge.Wrap<WrapperForPendingChange, PendingChange>(_workspace.GetPendingChanges());
}

public void Shelve(IShelveset shelveset, IPendingChange [] changes, TfsShelvingOptions options)
public void Shelve(IShelveset shelveset, IPendingChange[] changes, TfsShelvingOptions options)
{
_workspace.Shelve(_bridge.Unwrap<Shelveset>(shelveset), _bridge.Unwrap<PendingChange>(changes), _bridge.Convert<ShelvingOptions>(options));
}

public int Checkin(IPendingChange[] changes, string comment, ICheckinNote checkinNote, IEnumerable<IWorkItemCheckinInfo> workItemChanges, TfsPolicyOverrideInfo policyOverrideInfo)
public int Checkin(IPendingChange[] changes, string comment, ICheckinNote checkinNote, IEnumerable<IWorkItemCheckinInfo> workItemChanges,
TfsPolicyOverrideInfo policyOverrideInfo)
{
return _workspace.CheckIn(
_bridge.Unwrap<PendingChange>(changes),
Expand All @@ -414,7 +419,8 @@ private PolicyOverrideInfo ToTfs(TfsPolicyOverrideInfo policyOverrideInfo)
_bridge.Unwrap<PolicyFailure>(policyOverrideInfo.Failures));
}

public ICheckinEvaluationResult EvaluateCheckin(TfsCheckinEvaluationOptions options, IPendingChange[] allChanges, IPendingChange[] changes, string comment, ICheckinNote checkinNote, IEnumerable<IWorkItemCheckinInfo> workItemChanges)
public ICheckinEvaluationResult EvaluateCheckin(TfsCheckinEvaluationOptions options, IPendingChange[] allChanges, IPendingChange[] changes,
string comment, ICheckinNote checkinNote, IEnumerable<IWorkItemCheckinInfo> workItemChanges)
{
return _bridge.Wrap<WrapperForCheckinEvaluationResult, CheckinEvaluationResult>(_workspace.EvaluateCheckin(
_bridge.Convert<CheckinEvaluationOptions>(options),
Expand Down Expand Up @@ -442,17 +448,11 @@ public int PendDelete(string path)

public int PendRename(string pathFrom, string pathTo)
{
//looks like TFS Api cannot overwrite existing target file
EnsureTargetFileDoesNotExist(pathTo);
TfsApiLimitations.PendRename.EnsureTargetFileDoesNotExist(pathTo);

return _workspace.PendRename(pathFrom, pathTo);
}

private void EnsureTargetFileDoesNotExist(string pathTo)
{
File.Delete(pathTo);
}

public void ForceGetFile(string path, int changeset)
{
var item = new ItemSpec(path, RecursionType.None);
Expand All @@ -464,4 +464,16 @@ public string OwnerName
get { return _workspace.OwnerName; }
}
}
}

internal class TfsApiLimitations
{
internal class PendRename
{
internal static void EnsureTargetFileDoesNotExist(string pathTo)
{
if (File.Exists(pathTo))
File.Delete(pathTo);
}
}
}
}

0 comments on commit 64c3501

Please sign in to comment.