Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team changes #41

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
aa22aac
1) foresee TeamChangesetProvider : get all not yet merged changesets.
RubenWillems Apr 20, 2018
3a65834
Initial split team and solo
DieterVantilt Apr 20, 2018
6adb43c
reworked teamChangesetProvider : removed hard coded test settings
RubenWillems Apr 20, 2018
8893a44
Merge conflict changes
DieterVantilt Apr 20, 2018
02f04db
Merge branch 'TeamChanges' of https://github.com/RubenWillems/AutoMer…
DieterVantilt Apr 20, 2018
30da8ab
Branch change set
DieterVantilt Apr 20, 2018
5f672fe
Choosing the source and target branch
DieterVantilt Apr 20, 2018
ab56d59
Implementation for the merging and adding all associated work items.
dieter-vantilt May 1, 2018
64b855c
nameof operator iso strings for raise event
RubenWillems May 3, 2018
9a9a740
Merge branch 'TeamChanges' of https://github.com/RubenWillems/AutoMer…
RubenWillems May 3, 2018
749bbf1
move providers into separate folder
RubenWillems May 3, 2018
bbdebe1
list tfs projects, list branches of project
RubenWillems May 3, 2018
cf4bd95
show all branches, --> recursionType Full
RubenWillems May 3, 2018
e431011
Adding button to fetch all changesets
DieterVantilt May 8, 2018
10138ac
Merge branch 'TeamChanges' of https://github.com/RubenWillems/AutoMer…
DieterVantilt May 8, 2018
d15fc40
dummy values for testing (remove later on)
RubenWillems May 17, 2018
610465c
fix merge
RubenWillems May 17, 2018
5fc01da
Project source en target branches
dieter-vantilt May 17, 2018
016a3f2
resolve conflicts
RubenWillems May 18, 2018
5bdf8c0
Change to target branch
DieterVantilt May 18, 2018
6b225fb
clean up code
RubenWillems May 18, 2018
c09eaa2
clean up code
RubenWillems May 18, 2018
b4fa7a7
set .Net target framework back to 4.6.2
RubenWillems Jun 15, 2018
38e9251
fix build ? removed newer C# syntax features
RubenWillems Jun 19, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,5 @@ $RECYCLE.BIN/

# ide temp
*.sln.ide/
/.vs
/src/.vs/AutoMerge/v15/Server/sqlite3
4 changes: 4 additions & 0 deletions src/AutoMerge.Tests/AutoMerge.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<TargetFrameworkVersion Condition="'$(VisualStudioVersion)' == '15.0'">v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>ea07ad34</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -70,6 +71,9 @@
<Name>AutoMerge</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
Expand Down
822 changes: 423 additions & 399 deletions src/AutoMerge/AutoMerge.csproj

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions src/AutoMerge/AutoMergeTeamNavigationItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.ComponentModel.Composition;
using AutoMerge.Base;
using AutoMerge.VersionControl;
using Microsoft.TeamFoundation.Controls;
using Microsoft.VisualStudio.Shell;

namespace AutoMerge
{
[TeamExplorerNavigationItem(GuidList.AutoMergeTeamNavigationItemId, 211, TargetPageId = GuidList.AutoMergeTeamPageId)]
class AutoMergeTeamNavigationItem : TeamExplorerNavigationItemBase
{
[ImportingConstructor]
public AutoMergeTeamNavigationItem(
[Import(typeof(SVsServiceProvider))]
IServiceProvider serviceProvider)
: base(serviceProvider, GuidList.AutoMergeTeamPageId, VersionControlProvider.TeamFoundation)
{
Text = Resources.AutoMergeTeamPageName;
Image = Resources.MergeImage;
}
}
}
14 changes: 14 additions & 0 deletions src/AutoMerge/AutoMergeTeamPage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using AutoMerge.Base;
using Microsoft.TeamFoundation.Controls;

namespace AutoMerge
{
[TeamExplorerPage(GuidList.AutoMergeTeamPageId)]
public class AutoMergeTeamPage : TeamExplorerPageBase
{
public AutoMergeTeamPage()
{
Title = Resources.AutoMergeTeamPageName;
}
}
}
26 changes: 13 additions & 13 deletions src/AutoMerge/Base/TeamExplorerSectionViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Common.Internal;
Expand Down Expand Up @@ -33,11 +33,9 @@ protected virtual Task InitializeAsync(object sender, SectionInitializeEventArgs
return _emptyTask;
}

public async override void Initialize(object sender, SectionInitializeEventArgs e)
public override async void Initialize(object sender, SectionInitializeEventArgs e)
{
ShowBusy();

try
await SetBusyWhileExecutingAsync(async () =>
{
base.Initialize(sender, e);
if (ServiceProvider != null)
Expand All @@ -52,22 +50,24 @@ public async override void Initialize(object sender, SectionInitializeEventArgs
}
}
await InitializeAsync(sender, e);
}
catch (Exception ex)
{
ShowError(ex.Message);
}
});
}

HideBusy();
public override async void Refresh()
{
await SetBusyWhileExecutingAsync(async () =>
{
await RefreshAsync();
});
}

public async override void Refresh()
protected async Task SetBusyWhileExecutingAsync(Func<Task> task)
{
ShowBusy();

try
{
await RefreshAsync();
await task();
}
catch (Exception ex)
{
Expand Down
11 changes: 11 additions & 0 deletions src/AutoMerge/Branches/Branch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace AutoMerge.Branches
{
public class Branch
{
public string Name { get; set; }

public List<string> Branches { get; set; }
}
}
14 changes: 2 additions & 12 deletions src/AutoMerge/Branches/BranchesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,6 @@ public ObservableCollection<MergeMode> MergeModes

public DelegateCommand OpenSourceControlExplorerCommand { get; set; }

private static ObservableCollection<Workspace> GetWorkspaces(VersionControlServer versionControl, TfsTeamProjectCollection tfs)
{
var queryWorkspaces = versionControl.QueryWorkspaces(null, tfs.AuthorizedIdentity.UniqueName, Environment.MachineName);
if (queryWorkspaces.Length > 1)
{
return new ObservableCollection<Workspace>(queryWorkspaces.OrderBy(w => w.Name));
}
return new ObservableCollection<Workspace>(queryWorkspaces);
}

protected async override Task InitializeAsync(object sender, SectionInitializeEventArgs e)
{
Logger.Debug("Start initilize branches section");
Expand All @@ -204,7 +194,7 @@ protected async override Task InitializeAsync(object sender, SectionInitializeEv

if (e.Context == null)
{
Workspaces = GetWorkspaces(versionControl, tfs);
Workspaces = WorkspaceHelper.GetWorkspaces(versionControl, tfs);
if (Workspaces.Count > 0)
{
Workspace = WorkspaceHelper.GetWorkspace(versionControl, Workspaces);
Expand Down Expand Up @@ -1252,7 +1242,7 @@ private void RefreshWorkspaces(object sender, WorkspaceEventArgs e)
var tfs = Context.TeamProjectCollection;
var versionControl = tfs.GetService<VersionControlServer>();

Workspaces = GetWorkspaces(versionControl, tfs);
Workspaces = WorkspaceHelper.GetWorkspaces(versionControl, tfs);
if (Workspaces.Count > 0)
{
Workspace = Workspaces[0];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace AutoMerge
namespace AutoMerge
{
public class RecentChangesetFocusableControlNames
public class ChangesetFocusableControlNames
{
public const string ChangesetIdTextBox = "changesetIdTextBox";
public const string AddChangesetByIdLink = "addChangesetByIdLink";
public const string ChangesetList = "changesetList";
}
}
}
146 changes: 146 additions & 0 deletions src/AutoMerge/Changesets/ChangesetsViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using AutoMerge.Events;
using AutoMerge.Prism.Command;
using AutoMerge.Prism.Events;
using Microsoft.TeamFoundation;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Controls;
using Microsoft.TeamFoundation.Controls.WPF.TeamExplorer;
using Task = System.Threading.Tasks.Task;

using TeamExplorerSectionViewModelBase = AutoMerge.Base.TeamExplorerSectionViewModelBase;

namespace AutoMerge
{
public abstract class ChangesetsViewModel : TeamExplorerSectionViewModelBase
{
private readonly IEventAggregator _eventAggregator;

protected ChangesetsViewModel(ILogger logger)
: base(logger)
{
Title = BaseTitle;
IsVisible = true;
IsExpanded = true;
IsBusy = false;
Changesets = new ObservableCollection<ChangesetViewModel>();

_eventAggregator = EventAggregatorFactory.Get();
_eventAggregator.GetEvent<MergeCompleteEvent>()
.Subscribe(OnMergeComplete);

ViewChangesetDetailsCommand = new DelegateCommand(ViewChangesetDetailsExecute, ViewChangesetDetailsCanExecute);
}

public ChangesetViewModel SelectedChangeset
{
get
{
return _selectedChangeset;
}
set
{
_selectedChangeset = value;
RaisePropertyChanged("SelectedChangeset");
_eventAggregator.GetEvent<SelectChangesetEvent>().Publish(value);
}
}
private ChangesetViewModel _selectedChangeset;

public ObservableCollection<ChangesetViewModel> Changesets
{
get
{
return _changesets;
}
protected set
{
_changesets = value;
RaisePropertyChanged("Changesets");
}
}
private ObservableCollection<ChangesetViewModel> _changesets;



public DelegateCommand ViewChangesetDetailsCommand { get; private set; }

private void ViewChangesetDetailsExecute()
{
var changesetId = SelectedChangeset.ChangesetId;
TeamExplorerUtils.Instance.NavigateToPage(TeamExplorerPageIds.ChangesetDetails, ServiceProvider, changesetId);
}

private bool ViewChangesetDetailsCanExecute()
{
return SelectedChangeset != null;
}

private async void OnMergeComplete(bool obj)
{
await RefreshAsync();
}

protected override async Task InitializeAsync(object sender, SectionInitializeEventArgs e)
{
if (e.Context == null)
{
await RefreshAsync();
}
else
{
RestoreContext(e);
}
}

protected async Task GetChangesetAndUpdateTitleAsync()
{
Changesets.Clear();

Logger.Info("Getting changesets ...");
var changesets = await GetChangesetsAsync();
Logger.Info("Getting changesets end");

Changesets = new ObservableCollection<ChangesetViewModel>(changesets);
UpdateTitle();

if (Changesets.Count > 0)
{
if (SelectedChangeset == null || SelectedChangeset.ChangesetId != Changesets[0].ChangesetId)
SelectedChangeset = Changesets[0];
}
}

public abstract Task<List<ChangesetViewModel>> GetChangesetsAsync();

protected void UpdateTitle()
{
Title = Changesets.Count > 0
? string.Format("{0} ({1})", BaseTitle, Changesets.Count)
: BaseTitle;
}

protected virtual void InvalidateCommands()
{
ViewChangesetDetailsCommand.RaiseCanExecuteChanged();
}

public override void Dispose()
{
base.Dispose();
_eventAggregator.GetEvent<MergeCompleteEvent>().Unsubscribe(OnMergeComplete);
}

protected abstract void RestoreContext(SectionInitializeEventArgs e);

protected override void OnContextChanged(object sender, ContextChangedEventArgs e)
{
Refresh();
}

protected abstract string BaseTitle { get; }
}
}
14 changes: 14 additions & 0 deletions src/AutoMerge/Changesets/ChangesetsViewModelContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections.ObjectModel;

namespace AutoMerge
{
public class ChangesetsViewModelContext
{
public ObservableCollection<ChangesetViewModel> Changesets { get; set; }

public string Title { get; set; }

public ChangesetViewModel SelectedChangeset { get; set; }
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace AutoMerge
{
public class ChangesetByIdChangesetProvider : ChangesetProviderBase
{
private readonly IEnumerable<int> _changesetIds;

public ChangesetByIdChangesetProvider(IServiceProvider serviceProvider, IEnumerable<int> changesetIds)
: base(serviceProvider)
{
if (changesetIds == null)
throw new ArgumentNullException("changesetIds");

_changesetIds = changesetIds;
}

protected override List<ChangesetViewModel> GetChangesetsInternal()
{
var changesets = new List<ChangesetViewModel>();
var changesetService = GetChangesetService();
if (changesetService != null)
{
changesets = _changesetIds
.Select(changesetService.GetChangeset)
.Where(c => c != null)
.Select(tfsChangeset => ToChangesetViewModel(tfsChangeset, changesetService))
.ToList();
}

return changesets;
}
}
}
Loading