Beispiel #1
0
        private void LoadChangesetList(bool refresh = false)
        {
            if (_changesetLoadingTaskActive)
            {
                if (!refresh)
                {
                    return;
                }
            }

            _changesetLoadingTaskActive = true;
            Repository.Instance.BackgroundTaskManager.Start(
                Constants.Tasks.LoadChangesetListKey,
                refresh ? ChangesetsRefreshing : ChangesetsLoading,
                (task) =>
            {
                var results = new List <ChangesetListElement>();
                task.TrackProgress.ProgressInfo = "Loading changesets ...";
                lock (_changesetLock)
                {
                    int count = 0;
                    foreach (var changeset in _changesets)
                    {
                        task.TrackProgress.ProgressInfo = string.Format("Loading changesets ({0} done) ...", ++count);
                        var source = FindChangeset(changeset, MergeSource);
                        var target = FindChangeset(changeset, MergeTarget);

                        var changesetListElement =
                            new ChangesetListElement()
                        {
                            Changeset   = TfsItemCache.UpdateChangesetFromCache(new TfsChangesetWrapper(changeset)),
                            CanBeMerged = (target == null),

                            SourceExists      = (source != null),
                            SourceCheckinDate = (source != null) ? source.Changeset.CreationDate : DateTime.MinValue,
                            SourceCheckinId   = (source != null) ? source.Changeset.ChangesetId : 0,

                            TargetExists      = (target != null),
                            TargetCheckinDate = (target != null) ? new DateTime?(target.Changeset.CreationDate) : null,
                            TargetCheckinId   = (target != null) ? target.Changeset.ChangesetId : 0
                        };
                        DetermineWarningStatus(changesetListElement);
                        results.Add(changesetListElement);
                    }
                }
                Repository.Instance.BackgroundTaskManager.Post(
                    () =>
                {
                    _changesetLoadingTaskActive = false;
                    _changesetList = results;
                    RaisePropertyChanged("ChangesetList");
                    return(true);
                });
            });
        }
Beispiel #2
0
        private void CommitMerge(CheckInSummaryViewModel vm, TrackProgressParameters externalProgress = null)
        {
            var associatedWorkItems
                = vm
                  .SourceChangesets
                  .SelectMany(changeset => changeset.RelatedWorkItems)
                  .GroupBy(workItem => workItem.WorkItem.Id)
                  .Select(group => group.First());

            int cs = -1;

            try
            {
                Repository.Instance.BackgroundTaskManager.RunWithCancelDialog(
                    (progressParams) =>
                {
                    //cs = vm.TemporaryWorkspace.CheckIn(associatedWorkItems, vm.CheckInComment);
                    cs = 1;
                }, externalProgress);
            }
            catch (OperationCanceledException)
            {
            }

            var newChangeset = TfsItemCache.UpdateChangesetFromCache(new TfsChangesetWrapper(Repository.Instance.TfsBridgeProvider.GetChangesetById(cs)));

            var relatedChangesetListElements =
                _changesetList.Where(element => vm.SourceChangesets.Any(changeset => changeset.Changeset.ChangesetId == element.SourceCheckinId));

            foreach (var sourceCS in vm.SourceChangesets)
            {
                _allAssociatedChangesetsIncludingMerges.Add(new MergedChangesetLink()
                {
                    Source = TfsItemCache.GetChangesetFromCache(sourceCS.Changeset.ChangesetId), Target = newChangeset
                });
            }

            foreach (var element in relatedChangesetListElements)
            {
                element.TargetCheckinDate = newChangeset.TfsChangeset.Changeset.CreationDate;
                element.TargetCheckinId   = newChangeset.TfsChangeset.Changeset.ChangesetId;
                element.TargetExists      = true;
                element.CanBeMerged       = false;
                DetermineWarningStatus(element);
            }
        }
Beispiel #3
0
        private void FindMergesForChangesetAndBranch(List <MergedChangesetLink> results, ITfsChangeset changeset, ITfsBranch rootBranch)
        {
            var merges
                = changeset.FindMergesForActiveProject(rootBranch, _potentialMergeSourceBranches)
                  .Select(
                      item => new MergedChangesetLink()
            {
                Source = TfsItemCache.UpdateChangesetFromCache(new TfsChangesetWrapper(item.Source)),
                Target = TfsItemCache.UpdateChangesetFromCache(new TfsChangesetWrapper(item.Target))
            });

            results.Add(
                new MergedChangesetLink()
            {
                Source = null,
                Target = TfsItemCache.UpdateChangesetFromCache(new TfsChangesetWrapper(changeset))
            });
            results.AddRange(merges);
        }
        private void CommitMerge(CheckInSummaryViewModel vm, TrackProgressParameters externalProgress = null)
        {
            try
            {
                var associatedWorkItems
                    = vm
                      .SourceChangesets
                      .SelectMany(changeset => changeset.RelatedWorkItems)
                      .GroupBy(workItem => workItem.WorkItem.Id)
                      .Select(group => group.First());

                int cs = -1;

                try
                {
                    Exception ex = null;
                    Repository.Instance.BackgroundTaskManager.RunWithCancelDialog(
                        (progressParams) =>
                    {
                        try
                        {
                            cs = vm.TemporaryWorkspace.CheckIn(associatedWorkItems, vm.CheckInComment);
                            Repository.Instance.BackgroundTaskManager.Post(
                                () =>
                            {
                                TfsItemCache.ChangesetsHaveBeenMerged(vm.SourceChangesets);
                                return(true);
                            });
                        }
                        catch (Exception e)
                        {
                            ex = e;
                        }
                    }, externalProgress);

                    if (ex != null && ex.Message.Contains("TF26006"))
                    {
                        MessageBoxViewModel mbvm =
                            new MessageBoxViewModel(
                                "TFS Workspace Exception",
                                "Error TF26006 occurred during check in.\r\n" +
                                "Unfortunately when this happens, the check in has occurred already but\r\n" +
                                "the work item association didn't work; please associate the merged changeset\r\n" +
                                "manually.\r\n\r\n" +
                                "To avoid this error, please clear the local TFS cache manually by \r\n" +
                                "deleting all files in the cache folder before continuing merging.", MessageBoxViewModel.MessageBoxButtons.None);
                        var yesButton = new MessageBoxViewModel.MessageBoxButton("_Show TFS cache");
                        mbvm.ConfirmButtons.Add(yesButton);
                        mbvm.ConfirmButtons.Add(new MessageBoxViewModel.MessageBoxButton("_Ignore"));
                        Repository.Instance.ViewManager.ShowModal(mbvm);
                        if (yesButton.IsChecked)
                        {
                            Process.Start("explorer.exe", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\TeamFoundation\\4.0\\Cache"));
                        }
                    }
                }
                catch (OperationCanceledException)
                {
                }

                var newChangeset = TfsItemCache.UpdateChangesetFromCache(new TfsChangesetWrapper(Repository.Instance.TfsBridgeProvider.GetChangesetById(cs)));

                var relatedChangesetListElements =
                    _changesetList.Where(element => vm.SourceChangesets.Any(changeset => changeset.Changeset.ChangesetId == element.SourceCheckinId));

                foreach (var element in relatedChangesetListElements)
                {
                    element.TargetCheckinDate = newChangeset.TfsChangeset.Changeset.CreationDate;
                    element.TargetCheckinId   = newChangeset.TfsChangeset.Changeset.ChangesetId;
                    element.TargetExists      = true;
                    element.CanBeMerged       = false;
                    DetermineWarningStatus(element);
                }

                if (SelectNewRowAction != null)
                {
                    SelectNewRowAction();
                }

                NothingToMergeLeft = !IsAnythingToMergeLeft();
            }
            catch (Exception ex)
            {
                SimpleLogger.Log(ex, true, true);
                throw;
            }
        }