Skip to content

Commit

Permalink
Merge pull request #438 from borysl/fix_attachmentServerUrl_not_found…
Browse files Browse the repository at this point in the history
…_bug

Generic fix (for VS2010/VS2008 and VS2011) of 'ConnectionException: TF26...
  • Loading branch information
sc68cal committed Sep 17, 2013
2 parents 3df5a37 + 31849cf commit e02caaa
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
5 changes: 5 additions & 0 deletions GitTfs.Vs11/TfsHelper.Vs11.cs
Expand Up @@ -77,6 +77,11 @@ protected override string GetAuthenticatedUser()
return VersionControl.AuthorizedUser;
}

protected override bool HasWorkItems(Changeset changeset)
{
return changeset.AssociatedWorkItems.Length > 0;
}

public override bool CanShowCheckinDialog { get { return true; } }

public override long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable<IWorkItemCheckedInfo> checkedInfos, string checkinComment)
Expand Down
19 changes: 19 additions & 0 deletions GitTfs.Vs2008/TfsHelper.Vs2008.cs
Expand Up @@ -54,6 +54,25 @@ protected override string GetAuthenticatedUser()
return VersionControl.AuthenticatedUser;
}

protected override bool HasWorkItems(Changeset changeset)
{
// This method wraps changeset.WorkItems, because
// changeset.WorkItems might result to ConnectionException: TF26175: Team Foundation Core Services attribute 'AttachmentServerUrl' not found.
// in this case assume that it is initialized to null
// NB: in VS2011 a new property appeared (AssociatedWorkItems), which works correctly
WorkItem[] result = null;
try
{
result = changeset.WorkItems;
}
catch (ConnectionException exception)
{
Debug.Assert(exception.Message.StartsWith("TF26175:"), "Not expected exception from TFS.");
}

return result != null && result.Length > 0;
}

public override bool CanShowCheckinDialog
{
get { return false; }
Expand Down
19 changes: 19 additions & 0 deletions GitTfs.Vs2010/TfsHelper.Vs2010.cs
Expand Up @@ -76,6 +76,25 @@ protected override string GetAuthenticatedUser()
return VersionControl.AuthorizedUser;
}

protected override bool HasWorkItems(Changeset changeset)
{
// This method wraps changeset.WorkItems, because
// changeset.WorkItems might result to ConnectionException: TF26175: Team Foundation Core Services attribute 'AttachmentServerUrl' not found.
// in this case assume that it is initialized to null
// NB: in VS2011 a new property appeared (AssociatedWorkItems), which works correctly
WorkItem[] result = null;
try
{
result = changeset.WorkItems;
}
catch (ConnectionException exception)
{
Debug.Assert(exception.Message.StartsWith("TF26175:"), "Not expected exception from TFS.");
}

return result != null && result.Length > 0;
}

public override bool CanShowCheckinDialog { get { return true; } }

public override long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable<IWorkItemCheckedInfo> checkedInfos, string checkinComment)
Expand Down
4 changes: 3 additions & 1 deletion GitTfs.VsCommon/TfsHelper.Common.cs
Expand Up @@ -198,7 +198,7 @@ private ITfsChangeset BuildTfsChangeset(Changeset changeset, IGitTfsRemote remot
var tfsChangeset = _container.With<ITfsHelper>(this).With<IChangeset>(_bridge.Wrap<WrapperForChangeset, Changeset>(changeset)).GetInstance<TfsChangeset>();
tfsChangeset.Summary = new TfsChangesetInfo { ChangesetId = changeset.ChangesetId, Remote = remote };

if (changeset.WorkItems != null)
if (HasWorkItems(changeset))
{
tfsChangeset.Summary.Workitems = changeset.WorkItems.Select(wi => new TfsWorkitem
{
Expand All @@ -212,6 +212,8 @@ private ITfsChangeset BuildTfsChangeset(Changeset changeset, IGitTfsRemote remot
return tfsChangeset;
}

protected abstract bool HasWorkItems(Changeset changeset);

Dictionary<string, Workspace> _workspaces = new Dictionary<string, Workspace>();

public void WithWorkspace(string localDirectory, IGitTfsRemote remote, IEnumerable<Tuple<string, string>> mappings, TfsChangesetInfo versionToFetch, Action<ITfsWorkspace> action)
Expand Down

0 comments on commit e02caaa

Please sign in to comment.