protected ChangesetViewModel ToChangesetViewModel(Changeset tfsChangeset, ChangesetService changesetService)
        {
            var changesetViewModel = new ChangesetViewModel
            {
                ChangesetId = tfsChangeset.ChangesetId,
                Comment = tfsChangeset.Comment,
                Branches = changesetService.GetAssociatedBranches(tfsChangeset.ChangesetId)
                    .Select(i => i.Item)
                    .ToList()
            };

            return changesetViewModel;
        }
Exemple #2
0
        protected ChangesetViewModel ToChangesetViewModel(Changeset tfsChangeset, ChangesetService changesetService)
        {
            var changesetViewModel = new ChangesetViewModel
            {
                ChangesetId = tfsChangeset.ChangesetId,
                Comment     = tfsChangeset.Comment,
                Branches    = changesetService.GetAssociatedBranches(tfsChangeset.ChangesetId)
                              .Select(i => i.Item)
                              .ToList()
            };

            return(changesetViewModel);
        }
        protected ChangesetViewModel ToChangesetViewModel(Changeset tfsChangeset, ChangesetService changesetService)
        {
            var branches = changesetService.GetAssociatedBranches(tfsChangeset.ChangesetId)
                .Select(i => i.Item)
                .ToList();
            var changesetViewModel = new ChangesetViewModel
            {
                ChangesetId = tfsChangeset.ChangesetId,
                Comment = tfsChangeset.Comment,
                Branches = branches,
                DisplayBranchName = BranchHelper.GetDisplayBranchName(branches, _settings.BranchNameMatches)
            };

            return changesetViewModel;
        }
Exemple #4
0
        protected ChangesetViewModel ToChangesetViewModel(Changeset tfsChangeset, ChangesetService changesetService)
        {
            var changesetViewModel = new ChangesetViewModel
            {
                ChangesetId     = tfsChangeset.ChangesetId,
                Comment         = tfsChangeset.Comment,
                ChangeDate      = tfsChangeset.CreationDate.ToString("yyyy-MM-dd"),
                Username        = tfsChangeset.Committer,
                UserDisplayName = tfsChangeset.CommitterDisplayName,
                Branches        = changesetService.GetAssociatedBranches(tfsChangeset.ChangesetId)
                                  .Select(i => i.Item)
                                  .ToList()
            };

            return(changesetViewModel);
        }
        private ObservableCollection<MergeInfoViewModel> GetBranches(ITeamFoundationContext context, ChangesetViewModel changesetViewModel)
        {
            if (context == null)
                return new ObservableCollection<MergeInfoViewModel>();
            var tfs = context.TeamProjectCollection;
            var versionControl = tfs.GetService<VersionControlServer>();

            var result = new ObservableCollection<MergeInfoViewModel>();

            var workspace = _workspace;

            var changesetService = _changesetService;

            var changes = changesetService.GetChanges(changesetViewModel.ChangesetId);

            var sourceTopFolder = CalculateTopFolder(changes);
            var mergesRelationships = GetMergesRelationships(sourceTopFolder, versionControl);



            if (mergesRelationships.Count > 0)
            {
                var sourceBranchIdentifier = changesetViewModel.Branches.Select(b => new ItemIdentifier(b)).First();

                var sourceBranch = sourceBranchIdentifier.Item;

                var trackMerges = versionControl.TrackMerges(new[] { changesetViewModel.ChangesetId },
                    new ItemIdentifier(sourceTopFolder),
                    mergesRelationships.ToArray(),
                    null);

                var changesetVersionSpec = new ChangesetVersionSpec(changesetViewModel.ChangesetId);

                var branchValidator = new BranchValidator(workspace, trackMerges);
                var branchFactory = new BranchFactory(sourceBranch, sourceTopFolder,
                    changesetVersionSpec, branchValidator,
                    _eventAggregator, _settings);

                var sourceBranchInfo = versionControl.QueryBranchObjects(sourceBranchIdentifier, RecursionType.None)[0];
                if (sourceBranchInfo.Properties != null && sourceBranchInfo.Properties.ParentBranch != null
                    && !sourceBranchInfo.Properties.ParentBranch.IsDeleted)
                {
                    var targetBranch = sourceBranchInfo.Properties.ParentBranch;
                    var targetPath = GetTargetPath(mergesRelationships, targetBranch);
                    if (targetPath != null)
                    {
                        var mergeInfo = branchFactory.CreateTargetBranchInfo(targetBranch, targetPath);
                        mergeInfo._checked = mergeInfo.ValidationResult == BranchValidationResult.Success;

                        result.Add(mergeInfo);
                    }
                }

                var currentBranchInfo = branchFactory.CreateSourceBranch();
                result.Add(currentBranchInfo);

                if (sourceBranchInfo.ChildBranches != null)
                {
                    var childBranches = sourceBranchInfo.ChildBranches.Where(b => !b.IsDeleted)
                        .Reverse();
                    foreach (var childBranch in childBranches)
                    {
                        var targetBranch = childBranch;
                        var targetPath = GetTargetPath(mergesRelationships, targetBranch);
                        if (targetPath != null)
                        {
                            var mergeInfo = branchFactory.CreateTargetBranchInfo(targetBranch, targetPath);
                            result.Add(mergeInfo);
                        }
                    }
                }

                // Feature branch
                if (mergesRelationships.Count > 0)
                {
                    var changetIds =
                        mergesRelationships.Select(r => r.Version).Cast<ChangesetVersionSpec>().Select(c => c.ChangesetId)
                        .Distinct()
                        .ToArray();
                    var branches = _changesetService.GetAssociatedBranches(changetIds);

                    foreach (var mergesRelationship in mergesRelationships)
                    {
                        var targetBranch = branches.FirstOrDefault(b => IsTargetPath(mergesRelationship, b));
                        if (targetBranch != null)
                        {
                            var mergeInfo = branchFactory.CreateTargetBranchInfo(targetBranch, mergesRelationship);
                            result.Add(mergeInfo);
                        }
                    }
                }
            }

            return result;
        }
 private void OnSelectedChangeset(ChangesetViewModel changeset)
 {
     _changeset = changeset;
     Refresh();
 }
        private static string CalculateError(ChangesetViewModel changeset)
        {
            if (changeset == null)
                return "Changeset not selected";

            if (changeset.Branches.IsNullOrEmpty())
                return "Changeset has not branch";

            if (changeset.Branches.Count > 1)
                return string.Format("Changeset has {0} branches. Merge not possible.", changeset.Branches.Count);

            return null;
        }
 private void RestoreContext(SectionInitializeEventArgs e)
 {
     var context = (BranchesViewModelContext)e.Context;
     _changeset = context.Changeset;
     Branches = context.Branches;
     ErrorMessage = context.ErrorMessage;
     MergeMode = context.MergeMode;
     MergeModes = context.MergeModes;
     MergeOption = context.MergeOption;
     SelectedBranch = context.SelectedBranch;
     ShowWorkspaceChooser = context.ShowWorkspaceChooser;
     Workspace = context.Workspace;
     Workspaces = context.Workspaces;
 }