Exemplo n.º 1
0
        private void AddChangeset(Changeset change)
        {
            Changesets.AddLast(change);
            var changesetId = Changesets.Count;

            DumpChangeset(change, changesetId);
        }
        protected override async Task RefreshAsync()
        {
            InitBranchselectors();

            Changesets.Clear();

            var changesetProvider = new MyChangesetChangesetProvider(ServiceProvider, Settings.Instance.ChangesetCount);
            //var userLogin = VersionControlNavigationHelper.GetAuthorizedUser(ServiceProvider);

            //var source = "$/Bookhus husudlejning/Bookhus husudlejning/Feature-Newdesign";
            //var target = "$/Bookhus husudlejning/Bookhus husudlejning/Main_Version7.1";

            var source = SourceBranch;
            var target = TargetBranch;

            Logger.Info("Getting changesets ...");
            var changesets = await changesetProvider.GetChangesets(source, target);

            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];
                }
            }
        }
Exemplo n.º 3
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);
        }
        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();
        }
 private bool CanMerge()
 {
     return(SelectedChangesets != null &&
            SelectedChangesets.Any() &&
            Changesets.Count(x => x.ChangesetId >= SelectedChangesets.Min(y => y.ChangesetId) &&
                             x.ChangesetId <= SelectedChangesets.Max(y => y.ChangesetId)) == SelectedChangesets.Count);
 }
Exemplo n.º 6
0
        public void RefreshChangesets()
        {
            Changesets.ForEach(x => x.IsSelected = false);

            if (_ChangesetsCollectionView.View != null)
            {
                _ChangesetsCollectionView.View.Refresh();
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Refresh the changeset data asynchronously.
        /// </summary>
        private async Task RefreshAsync()
        {
            if (!IsEnabled)
            {
                IsBusy = false;
                return;
            }
            try
            {
                IsBusy = true;
                Changesets.Clear();

                ObservableCollection <ChangesetInfo> changesets = new ObservableCollection <ChangesetInfo>();
                await Task.Run(() =>
                {
                    ITeamFoundationContext context = CurrentContext;
                    if (context != null && context.HasCollection && context.HasTeamProject)
                    {
                        VersionControlServer vcs = context.TeamProjectCollection.GetService <VersionControlServer>();
                        if (vcs != null)
                        {
                            // Ask the derived section for the history parameters
                            string user;
                            int maxCount;
                            GetHistoryParameters(vcs, out user, out maxCount);

                            string path = GetPath();
                            foreach (Changeset changeset in vcs.QueryHistory(path, VersionSpec.Latest, 0, RecursionType.Full,
                                                                             user, null, null, maxCount, false, true))
                            {
                                changesets.Add(new ChangesetInfo(changeset, IsUserNameVisible ? null : string.Empty));
                            }
                        }
                    }
                });

                Changesets   = changesets;
                SectionTitle = Changesets.Count > 0 ? String.Format("{0} ({1})", BaseTitle, Changesets.Count)
                                                                                                           : BaseTitle;
            }
            catch (Exception ex)
            {
                Output.Exception(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 8
0
        // After running the program with my changes I had instances of consecutive revisions
        // with the same check-in message that are just seconds apart.
        // I used this function to combine those into one revision
        private void MergeChangesets()
        {
            // DV: Merge file checkins done within some time window into a single revision
            //     if done by the same user and with the same comment (even if empty)
            // The algorithm merges 2 consecutive checkins and assigns them the newer date, then
            // it looks at the next consecutive checkin and so on.
            //
            // This can potentially merge lots of files into a single revision if there were no comments (usually)
            // and all files are checked in within seconds apart (as defined by the interval).
            //
            // But really this shouldn't be a big problem
            //
            //

            Int32 initial_count = Changesets.Count;

            this.LogMessage("Total Revision count: {0}. Merging identical within {1} seconds window...", initial_count, RevisionTimeWindow);

            for (Int32 i = 0; i < Changesets.Count; i++)
            {
                Changeset set_i    = Changesets.Values[i];
                DateTime  dt_upper = set_i.DateTime.AddSeconds(RevisionTimeWindow);
                for (Int32 j = i + 1; j < Changesets.Count; j++)
                {
                    Changeset set_j = Changesets.Values[j];
                    if (dt_upper >= set_j.DateTime &&
                        set_i.Username == set_j.Username &&
                        set_i.Comment == set_j.Comment)
                    {
                        set_j.Files.AddRange(set_i.Files);
                        Changesets[set_j.DateTime] = set_j;
                        Changesets.RemoveAt(i);
                        i--;                 // so that we can re-compare the same set with the next revision on the list
                        break;
                    }
                }
            }

            Int32 new_count = Changesets.Count;

            if (new_count != initial_count)
            {
                this.LogMessage("New revision count is {0}.", new_count);
            }
            else
            {
                this.LogMessage("Nothing to merge.");
            }
        }
Exemplo n.º 9
0
        public PrepareMergeViewModel(TfsItemCache tfsItemCache, IEnumerable <ITfsChangeset> changesets)
            : base(typeof(PrepareMergeViewModel))
        {
            try
            {
                TfsItemCache = tfsItemCache;
                Changesets   = changesets.OrderBy(changeset => changeset.Changeset.ChangesetId).ToList();

                MergeSourcesLoading  = new LoadingProgressViewModel();
                MergeTargetsLoading  = new LoadingProgressViewModel();
                ChangesetsLoading    = new LoadingProgressViewModel();
                ChangesetsRefreshing = new LoadingProgressViewModel();

                OpenChangesetCommand         = new RelayCommand((o) => OpenChangeset((int)o));
                FindOriginalChangesetCommand = new RelayCommand((o) => FindOriginalChangeset((int)o));
                PerformMergeCommand          = new RelayCommand((o) => PerformMerge(o as ChangesetListElement));
                PickPathFilterCommand        = new RelayCommand((o) => PickPathFilter());
                AutoMergeCommand             = new RelayCommand((o) => AutoMerge(), (o) => IsAnythingToMergeLeft());
                OKCommand = new RelayCommand((o) => OK());


                var  potentialMergeSourceBranches = Enumerable.Empty <ITfsBranch>();
                bool finished = Repository.Instance.BackgroundTaskManager.RunWithCancelDialog(
                    (progressParams) =>
                {
                    progressParams.TrackProgress.MaxProgress = Changesets.Count();
                    foreach (var changeset in Changesets)
                    {
                        progressParams.CancellationToken.ThrowIfCancellationRequested();
                        var list = changeset.GetAffectedBranchesForActiveProject().ToArray();
                        potentialMergeSourceBranches = potentialMergeSourceBranches.Union(list);
                        progressParams.TrackProgress.Increment();
                    }
                });
                if (!finished)
                {
                    throw new OperationCanceledException();
                }

                PossibleMergeSources = potentialMergeSourceBranches.ToList();
                ListenToSettingsChanges();
            }
            catch (Exception ex)
            {
                SimpleLogger.Log(ex, true, true);
                throw;
            }
        }
Exemplo n.º 10
0
        public PrepareMergeViewModel(TfsItemCache tfsItemCache, IEnumerable <ITfsChangeset> changesets)
            : base(typeof(PrepareMergeViewModel))
        {
            TfsItemCache = tfsItemCache;
            Changesets   = changesets.Where(changeset => changeset.Changeset.CreationDate >= (DateTime.Now - new TimeSpan(30, 0, 0, 0))).ToList();

            MergeSourcesLoading  = new LoadingProgressViewModel();
            MergeTargetsLoading  = new LoadingProgressViewModel();
            ChangesetsLoading    = new LoadingProgressViewModel();
            ChangesetsRefreshing = new LoadingProgressViewModel();

            OpenChangesetCommand  = new RelayCommand((o) => OpenChangeset((int)o));
            PerformMergeCommand   = new RelayCommand((o) => PerformMerge(o as ChangesetListElement));
            PickPathFilterCommand = new RelayCommand((o) => PickPathFilter());
            AutoMergeCommand      = new RelayCommand((o) => AutoMerge(), (o) => IsAnythingToMergeLeft());
            OKCommand             = new RelayCommand((o) => OK());

            var  potentialMergeSourceBranches = Enumerable.Empty <ITfsBranch>();
            bool finished = Repository.Instance.BackgroundTaskManager.RunWithCancelDialog(
                (progressParams) =>
            {
                WorkItems = new List <ITfsWorkItem>();
                progressParams.TrackProgress.MaxProgress = Changesets.Count();
                foreach (var changeset in Changesets)
                {
                    progressParams.CancellationToken.ThrowIfCancellationRequested();
                    foreach (var workItem in changeset.RelatedWorkItems)
                    {
                        progressParams.CancellationToken.ThrowIfCancellationRequested();
                        WorkItems.Add(workItem);
                    }
                    potentialMergeSourceBranches = potentialMergeSourceBranches.Union(changeset.GetAffectedBranchesForActiveProject());
                    progressParams.TrackProgress.Increment();
                }
            });

            if (!finished)
            {
                throw new OperationCanceledException();
            }

            _potentialMergeSourceBranches = potentialMergeSourceBranches.ToList();
        }
        private async Task FetchChangesetsAsync()
        {
            await _setBusyWhileExecutingAsync(async() =>
            {
                Changesets.Clear();

                var changesets = await _teamService.GetChangesetsAsync(SelectedSourceBranch, SelectedTargetBranch);

                Changesets = new ObservableCollection <Changeset>(changesets);

                if (_configManager.GetValue <bool>(ConfigKeys.ENABLE_AUTO_SELECT_ALL_CHANGESETS))
                {
                    SelectedChangesets.AddRange(Changesets.Except(SelectedChangesets));
                    RaisePropertyChanged(nameof(SelectedChangesets));
                }
            });

            MergeCommand.RaiseCanExecuteChanged();
        }
Exemplo n.º 12
0
        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];
                }
            }
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Project != null ? Project.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Tracker != null ? Tracker.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Priority != null ? Priority.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Author != null ? Author.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Category != null ? Category.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Subject != null ? Subject.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ StartDate.GetHashCode();
         hashCode = (hashCode * 397) ^ DueDate.GetHashCode();
         hashCode = (hashCode * 397) ^ DoneRatio.GetHashCode();
         hashCode = (hashCode * 397) ^ PrivateNotes.GetHashCode();
         hashCode = (hashCode * 397) ^ EstimatedHours.GetHashCode();
         hashCode = (hashCode * 397) ^ SpentHours.GetHashCode();
         hashCode = (hashCode * 397) ^ (CustomFields != null ? CustomFields.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CreatedOn.GetHashCode();
         hashCode = (hashCode * 397) ^ UpdatedOn.GetHashCode();
         hashCode = (hashCode * 397) ^ ClosedOn.GetHashCode();
         hashCode = (hashCode * 397) ^ (Notes != null ? Notes.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AssignedTo != null ? AssignedTo.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ParentIssue != null ? ParentIssue.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (FixedVersion != null ? FixedVersion.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ IsPrivate.GetHashCode();
         hashCode = (hashCode * 397) ^ TotalSpentHours.GetHashCode();
         hashCode = (hashCode * 397) ^ TotalEstimatedHours.GetHashCode();
         hashCode = (hashCode * 397) ^ (Journals != null ? Journals.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Changesets != null ? Changesets.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Attachments != null ? Attachments.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Relations != null ? Relations.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Children != null ? Children.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Uploads != null ? Uploads.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Watchers != null ? Watchers.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool Equals(Issue other)
        {
            if (other == null)
            {
                return(false);
            }

            return(
                Id == other.Id &&
                Project == other.Project &&
                Tracker == other.Tracker &&
                Status == other.Status &&
                Priority == other.Priority &&
                Author == other.Author &&
                Category == other.Category &&
                Subject == other.Subject &&
                Description == other.Description &&
                StartDate == other.StartDate &&
                DueDate == other.DueDate &&
                DoneRatio == other.DoneRatio &&
                EstimatedHours == other.EstimatedHours &&
                (CustomFields != null ? CustomFields.Equals <IssueCustomField>(other.CustomFields) : other.CustomFields == null) &&
                CreatedOn == other.CreatedOn &&
                UpdatedOn == other.UpdatedOn &&
                AssignedTo == other.AssignedTo &&
                FixedVersion == other.FixedVersion &&
                Notes == other.Notes &&
                (Watchers != null ? Watchers.Equals <Watcher>(other.Watchers) : other.Watchers == null) &&
                ClosedOn == other.ClosedOn &&
                SpentHours == other.SpentHours &&
                PrivateNotes == other.PrivateNotes &&
                (Attachments != null ? Attachments.Equals <Attachment>(other.Attachments) : other.Attachments == null) &&
                (Changesets != null ? Changesets.Equals <ChangeSet>(other.Changesets) : other.Changesets == null) &&
                (Children != null ?  Children.Equals <IssueChild>(other.Children) : other.Children == null) &&
                (Journals != null ? Journals.Equals <Journal>(other.Journals) : other.Journals == null) &&
                (Relations != null ? Relations.Equals <IssueRelation>(other.Relations) : other.Relations == null)
                );
        }
Exemplo n.º 16
0
        protected override async Task RefreshAsync()
        {
            Changesets.Clear();

            var changesetProvider = new MyChangesetChangesetProvider(ServiceProvider, Settings.Instance.ChangesetCount);
            var userLogin         = VersionControlNavigationHelper.GetAuthorizedUser(ServiceProvider);

            Logger.Info("Getting changesets ...");
            var changesets = await changesetProvider.GetChangesets(userLogin);

            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];
                }
            }
        }
Exemplo n.º 17
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);
            });
        }
Exemplo n.º 18
0
        private void AddFileVersionToChangeset(IVSSItem vssFile, Int32 f_count, IVSSVersion vssVersion, bool isAdd)
        {
            string    filePath;
            VSSItem   versionItem;
            string    comment;
            Changeset thisChangeset;

            // define the working copy filename
            if (!this.IsPreview)
            {
                filePath = Path.Combine(this.SvnFullRepositoryPath, this.VssRelativeFilePaths[f_count]);
            }
            else
            {
                filePath = string.Empty;
            }

            //get version item to get the version of the file
            versionItem = vssFile.get_Version(vssVersion.VersionNumber);
            comment     = versionItem.VSSVersion.Comment;

            if (Changesets.ContainsKey(vssVersion.Date))
            {
                // using an existing change set
                thisChangeset = Changesets[vssVersion.Date];

                // different comment, so create a new change set anyway
                if (thisChangeset.Comment != comment)
                {
                    bool done = false;

                    //there are two different changes at the same time
                    //I'm not sure how this happened, but it did.
                    //make the date/time of this changeset after any existing changeset
                    thisChangeset = new Changeset()
                    {
                        Comment  = comment,
                        DateTime = vssVersion.Date,
                        Username = vssVersion.Username
                    };

                    //make sure not to try and add this entry if an entry with the time already exists
                    while (!done)
                    {
                        if (Changesets.ContainsKey(thisChangeset.DateTime))
                        {
                            thisChangeset.DateTime = thisChangeset.DateTime.AddSeconds(1);
                        }
                        else
                        {
                            done = true;
                        }
                    }

                    this.Changesets.Add(thisChangeset.DateTime, thisChangeset);
                }
            }
            else
            {
                // create a new change set
                thisChangeset = new Changeset()
                {
                    Comment  = comment,
                    DateTime = vssVersion.Date,
                    Username = vssVersion.Username
                };
                this.Changesets.Add(thisChangeset.DateTime, thisChangeset);
            }

            // add the file to the change set
            thisChangeset.Files.Add(new ChangesetFileInfo()
            {
                FilePath   = filePath,
                IsAdd      = isAdd,
                VssFile    = vssFile,
                VssVersion = vssVersion
            });
        }
Exemplo n.º 19
0
 private void ResetChangesets()
 {
     Changesets.Clear();
     FilteredChangesets.Clear();
 }