示例#1
0
        public MergeInfoViewModel Validate(MergeInfoViewModel branchInfo)
        {
            branchInfo.ValidationResult  = ValidateItem(_workspace, branchInfo, _trackMerges);
            branchInfo.ValidationMessage = ToMessage(branchInfo.ValidationResult);

            return(branchInfo);
        }
示例#2
0
        public MergeInfoViewModel Validate(MergeInfoViewModel branchInfo)
        {
            branchInfo.ValidationResult = ValidateItem(_workspace, branchInfo, _trackMerges);
            branchInfo.ValidationMessage = ToMessage(branchInfo.ValidationResult);

            return branchInfo;
        }
示例#3
0
        private MergeInfoViewModel CreateBranch(string targetBranch, string targetPath)
        {
            var mergeInfo = new MergeInfoViewModel(_eventAggregator)
            {
                SourceBranch = _sourceBranch,
                TargetBranch = targetBranch,
                SourcePath = _sourceFolder,
                TargetPath = targetPath,
                ChangesetVersionSpec = _changesetVersion,
                ValidationResult = BranchValidationResult.Success,
            };

            if (_sourceBranch != targetBranch)
            {
                mergeInfo = _branchValidator.Validate(mergeInfo);
            }

            return mergeInfo;
        }
示例#4
0
        private MergeInfoViewModel CreateBranch(string targetBranch, string targetPath)
        {
            var mergeInfo = new MergeInfoViewModel(_eventAggregator)
            {
                SourceBranch         = _sourceBranch,
                TargetBranch         = targetBranch,
                SourcePath           = _sourceFolder,
                TargetPath           = targetPath,
                ChangesetVersionSpec = _changesetVersion,
                ValidationResult     = BranchValidationResult.Success,
            };

            if (_sourceBranch != targetBranch)
            {
                mergeInfo = _branchValidator.Validate(mergeInfo);
            }

            return(mergeInfo);
        }
示例#5
0
        private static BranchValidationResult ValidateItem(Workspace workspace, MergeInfoViewModel mergeInfoViewModel, IEnumerable <ExtendedMerge> trackMerges)
        {
            var result = BranchValidationResult.Success;

            if (result == BranchValidationResult.Success)
            {
                var isMerged = IsMerged(mergeInfoViewModel.SourcePath, mergeInfoViewModel.TargetPath, trackMerges);
                if (isMerged)
                {
                    result = BranchValidationResult.AlreadyMerged;
                }
            }

            if (result == BranchValidationResult.Success)
            {
                var userHasAccess = UserHasAccess(workspace.VersionControlServer, mergeInfoViewModel.TargetPath);
                if (!userHasAccess)
                {
                    result = BranchValidationResult.NoAccess;
                }
            }

            if (result == BranchValidationResult.Success)
            {
                var isMapped = IsMapped(workspace, mergeInfoViewModel.TargetPath);
                if (!isMapped)
                {
                    result = BranchValidationResult.BranchNotMapped;
                }
            }

            if (result == BranchValidationResult.Success)
            {
                var hasLocalChanges = HasLocalChanges(workspace, mergeInfoViewModel.TargetPath);
                if (hasLocalChanges)
                {
                    result = BranchValidationResult.ItemHasLocalChanges;
                }
            }
            return(result);
        }
示例#6
0
        private static BranchValidationResult ValidateItem(Workspace workspace, MergeInfoViewModel mergeInfoViewModel, IEnumerable<ExtendedMerge> trackMerges)
        {
            var result = BranchValidationResult.Success;

            if (result == BranchValidationResult.Success)
            {
                var isMerged = IsMerged(mergeInfoViewModel.SourcePath, mergeInfoViewModel.TargetPath, trackMerges);
                if (isMerged)
                    result = BranchValidationResult.AlreadyMerged;
            }

            if (result == BranchValidationResult.Success)
            {
                var userHasAccess = UserHasAccess(workspace.VersionControlServer, mergeInfoViewModel.TargetPath);
                if (!userHasAccess)
                    result = BranchValidationResult.NoAccess;
            }

            if (result == BranchValidationResult.Success)
            {
                var isMapped = IsMapped(workspace, mergeInfoViewModel.TargetPath);
                if (!isMapped)
                    result = BranchValidationResult.BranchNotMapped;
            }

            if (result == BranchValidationResult.Success)
            {
                var hasLocalChanges = HasLocalChanges(workspace, mergeInfoViewModel.TargetPath);
                if (hasLocalChanges)
                    result = BranchValidationResult.ItemHasLocalChanges;
            }
            return result;
        }
示例#7
0
        private TrackMergeInfo GetTrackMergeInfo(MergeInfoViewModel mergeInfo, Changeset changeset, VersionControlServer versionControl)
        {
            var mergesRelationships = GetMergesRelationships(mergeInfo.SourcePath, versionControl);
            var trackMerges = versionControl.TrackMerges(new[] {changeset.ChangesetId},
                new ItemIdentifier(mergeInfo.SourcePath),
                mergesRelationships.ToArray(),
                null);

            var trackMergeInfo = GetTrackMergeInfo(versionControl,
                trackMerges, mergeInfo.SourcePath);
            trackMergeInfo.FromOriginalToSourceBranches.Reverse();
            trackMergeInfo.SourceComment = changeset.Comment;
            trackMergeInfo.SourceBranch = mergeInfo.SourceBranch;
            trackMergeInfo.SourceChangesetId = changeset.ChangesetId;
            trackMergeInfo.SourceWorkItemIds = changeset.AssociatedWorkItems != null
                ? changeset.AssociatedWorkItems.Select(w => (long) w.Id).ToList()
                : new List<long>();
            trackMergeInfo.OriginaBranch = trackMergeInfo.OriginaBranch ?? trackMergeInfo.SourceBranch;
            trackMergeInfo.OriginalComment = trackMergeInfo.OriginalComment ?? trackMergeInfo.SourceComment;
            return trackMergeInfo;
        }
示例#8
0
 private void OnBranchSelectedChanged(MergeInfoViewModel obj)
 {
     MergeCommand.RaiseCanExecuteChanged();
 }
示例#9
0
        private static MergeResult MergeToBranch(MergeInfoViewModel mergeInfoeViewModel, MergeOption mergeOption,
            List<MergeRelation> mergeRelationships, Workspace workspace)
        {
            var source = mergeInfoeViewModel.SourcePath;
            var target = mergeInfoeViewModel.TargetPath;
            var version = mergeInfoeViewModel.ChangesetVersionSpec;

            if (!GetLatest(target, mergeRelationships, workspace))
            {
                return MergeResult.CanNotGetLatest;
            }

            var mergeOptions = ToTfsMergeOptions(mergeOption);
            var status = workspace.Merge(source, target, version, version, LockLevel.None, RecursionType.Full, mergeOptions);
            if (HasConflicts(status))
            {
                var conflicts = AutoResolveConflicts(workspace, target, mergeOption);
                if (!conflicts.IsNullOrEmpty())
                {
                    return IsTryRestoreUnexpectedFile(conflicts)
                        ? MergeResult.UnexpectedFileRestored
                        : MergeResult.HasConflicts;
                }
            }

            return MergeResult.Merged;
        }