Exemple #1
0
        void Merge(object o)
        {
            try
            {
                var candidates = FilteredChangesets.Where(cs => cs.IsSelected).Select(cs => cs.TfsChangeset);

                if (!candidates.Any())
                {
                    var mbvm = new MessageBoxViewModel("Perform merge", "No changesets are currently selected.", MessageBoxViewModel.MessageBoxButtons.OK);
                    Repository.Instance.ViewManager.ShowModal(mbvm);
                }
                else
                {
                    var mergeViewModel = new PrepareMergeViewModel(TfsItemCache, candidates);
                    var result         = ViewSelectionViewModel.GetMergeSourceTargetBranches();
                    mergeViewModel.MergeSource = result != null ? result.SourceBranch : null;
                    mergeViewModel.MergeTarget = result != null ? result.TargetBranch : null;
                    mergeViewModel.PathFilter  = result != null ? result.PathFilter : null;
                    mergeViewModel.SetDefaults();

                    if (Repository.Instance.Settings.FetchSettings <bool>(Constants.Settings.PerformNonModalMergeKey))
                    {
                        vMergePackage.OpenMergeView(mergeViewModel);
                    }
                    else
                    {
                        Repository.Instance.ViewManager.ShowModal(mergeViewModel, "Modal");
                    }
                }
            }
            catch (Exception ex)
            {
                SimpleLogger.Log(ex, true);
            }
        }
Exemple #2
0
        void Merge(object o)
        {
            try
            {
                var candidates = WorkItems.Where(wi => wi.IsSelected).Select(wi => wi.TfsWorkItem);

                if (!candidates.Any())
                {
                    var mbvm = new MessageBoxViewModel("Perform merge", "No work items are currently selected.", MessageBoxViewModel.MessageBoxButtons.OK);
                    Repository.Instance.ViewManager.ShowModal(mbvm);
                }
                else if (!candidates.Any(candidate => candidate.RelatedChangesetCount > 0))
                {
                    var mbvm = new MessageBoxViewModel("Perform merge", "The selected work items don't have any linked changesets.", MessageBoxViewModel.MessageBoxButtons.OK);
                    Repository.Instance.ViewManager.ShowModal(mbvm);
                }
                else
                {
                    PrepareMergeViewModel mergeViewModel;
                    try
                    {
                        mergeViewModel = new PrepareMergeViewModel(TfsItemCache, WorkItems.Where(wi => wi.IsSelected).Select(wi => wi.TfsWorkItem));
                    }
                    catch (ArgumentException)
                    {
                        var mbvm = new MessageBoxViewModel(
                            "Perform merge",
                            String.Format("The selected work items don't have any linked changesets in the current team project\r\n({0}).", Repository.Instance.TfsBridgeProvider.ActiveTeamProject.Name),
                            MessageBoxViewModel.MessageBoxButtons.OK);
                        Repository.Instance.ViewManager.ShowModal(mbvm);
                        mergeViewModel = null;
                    }

                    if (mergeViewModel != null)
                    {
                        var result = ViewSelectionViewModel.GetMergeSourceTargetBranches();
                        mergeViewModel.MergeSource = result != null ? result.SourceBranch : null;
                        mergeViewModel.MergeTarget = result != null ? result.TargetBranch : null;
                        mergeViewModel.PathFilter  = result != null ? result.PathFilter : null;
                        mergeViewModel.SetDefaults();
                        if (Repository.Instance.Settings.FetchSettings <bool>(Constants.Settings.PerformNonModalMergeKey))
                        {
                            vMergePackage.OpenMergeView(mergeViewModel);
                        }
                        else
                        {
                            Repository.Instance.ViewManager.ShowModal(mergeViewModel, "Modal");
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }