Ejemplo n.º 1
0
        public override AstoriaResponse GetResponse()
        {
            LogRequest();

            foreach (AstoriaRequest subRequest in Changesets.SelectMany(c => c).Union(this.Requests))
            {
                subRequest.OnSend(this);
            }

#if !ClientSKUFramework
            // NOTHING should come in between this and actually sending the request
            SetupAPICallLog();
#endif
            AstoriaResponse response = RequestSender.SendRequest(this);

#if !ClientSKUFramework
            // NOTHING should come in between this and actually recieving the response
            RetrieveAPICallLog();
#endif
            BatchResponse batchResponse = new BatchResponse(this, response);

            foreach (AstoriaResponse subResponse in batchResponse.Responses)
            {
                subResponse.Request.OnReceive(this, subResponse);
            }

            return(batchResponse);
        }
Ejemplo n.º 2
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);
            });
        }