private async void AddChangesetByIdExecute()
        {
            ShowBusy();
            try
            {
                var changesetIds = GeChangesetIdsToAdd(ChangesetIdsText);
                if (changesetIds.Count > 0)
                {
                    var changesetProvider = new ChangesetByIdChangesetProvider(ServiceProvider, changesetIds);
                    var changesets        = await changesetProvider.GetChangesets(null);

                    if (changesets.Count > 0)
                    {
                        Changesets.Add(changesets[0]);
                        SelectedChangeset = changesets[0];
                        SetMvvmFocus(RecentChangesetFocusableControlNames.ChangesetList);
                        UpdateTitle();
                    }
                    ShowAddByIdChangeset = false;
                }
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
            HideBusy();
        }
Beispiel #2
0
        public MockEnvironment Changeset(string comitter, string committerDisplayName, string comment)
        {
            End();

            _changesetCounter++;
            _changes = new List <IChange>();
            _items   = new List <IItem>();

            _changeset = new Mock <IChangeset>();
            _changeset.Setup(c => c.ChangesetId).Returns(_changesetCounter);
            _changeset.Setup(c => c.Comment).Returns($"[C{_changesetCounter}] {comment}");
            _changeset.Setup(c => c.Committer).Returns(comitter);
            _changeset.Setup(c => c.CommitterDisplayName).Returns(committerDisplayName);
            _changeset.Setup(c => c.CreationDate).Returns(System.DateTime.Now);
            _changeset.Setup(c => c.Version).Returns(new Version(_changesetCounter));

            Changesets.Add(_changeset.Object);

            return(this);
        }
Beispiel #3
0
        private void LoadAllAssociatedChangesetsIncludingMergesTask(BackgroundTask task)
        {
            task.TrackProgress.ProgressInfo = "Loading ...";
            var results = new List <MergedChangesetLink>();

            lock (_changesetLock)
            {
                bool fallback = false;
                int  count    = 0;

                foreach (var changeset in Changesets)
                {
                    task.TrackProgress.ProgressInfo = string.Format("Loading changesets ({0} done)", ++count);
                    if (ChangesetHasMixedContent(changeset))
                    {
                        fallback = true;
                    }
                }

                if (!fallback)
                {
                    var rootChangesets = new List <ITfsChangeset>();
                    count = 0;
                    foreach (
                        var changesetWithMerges
                        in Changesets.Where(
                            changeset => ChangesetConsistsOnlyOfMerges(changeset)))
                    {
                        task.TrackProgress.ProgressInfo = string.Format("Finding root changesets ({0} done) ...", ++count);
                        var rootChangesetResult = changesetWithMerges.SourceChangesets.Where(changeset => ChangesetDoesNotContainMerges(changeset)).ToArray();
                        if (rootChangesetResult.Length != 1)
                        {
                            fallback = true;
                            break;
                        }
                        rootChangesets.Add(rootChangesetResult[0]);
                    }

                    if (!fallback)
                    {
                        Changesets.RemoveAll(
                            changeset => ChangesetConsistsOnlyOfMerges(changeset));
                        foreach (var rootCS in rootChangesets)
                        {
                            if (Changesets.Any(cs => cs.Changeset.ChangesetId == rootCS.Changeset.ChangesetId))
                            {
                                continue;
                            }
                            Changesets.Add(rootCS);
                        }
                    }
                }

                var temporaryRootBranches =
                    Changesets
                    .SelectMany(changeset => changeset.GetAffectedBranchesForActiveProject())
                    .GroupBy(branch => branch.Name)
                    .OrderByDescending(grouping => grouping.Count())
                    .Select(grouping => grouping.First())
                    .ToList();

                count = 0;
                foreach (var changeset in Changesets)
                {
                    task.TrackProgress.ProgressInfo = string.Format("Tracking changesets ({0} done) ...", ++count);
                    foreach (var rootBranch in temporaryRootBranches)
                    {
                        FindMergesForChangesetAndBranch(results, changeset, rootBranch);
                    }
                }
            }

            Repository.Instance.BackgroundTaskManager.Post(
                () =>
            {
                _allAssociatedChangesetsIncludingMergesLoadingTaskActive = false;
                _allAssociatedChangesetsIncludingMerges = results;
                bool loadChangesets = _changesetList != null;
                RaisePropertyChanged("AllAssociatedChangesetsIncludingMerges");
                if (loadChangesets)
                {
                    LoadChangesetList(true);
                }
                return(true);
            });
        }