Exemplo n.º 1
0
        /// <summary>
        /// Update the scope of mergeInto to reflect the changes made in the branch we merge from.
        /// When files are removed I collect them in the "deleted" dictionary.
        /// These are needed later to assign the id to the deleted file.
        /// </summary>
        private void UpdateScopeTwoParents(Differences deltas, Scope mergeIntoScope, Scope mergeFromScope, Dictionary <string, string> deleted, string commitHash)
        {
            foreach (var change in deltas.DiffExclusiveToParent1)
            {
                // These are the changes done on the feature branch. We merge them into the scope.
                UpdateScopeFromMergeSource(mergeIntoScope, mergeFromScope, change, deleted, commitHash);
            }

            foreach (var change in deltas.ChangesInCommit)
            {
                // These are the changes done on the merge commit itself (fixing conflicts etc)
                ApplyChangesToScope(mergeIntoScope, change, deleted);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Returns the deleted files, no longer in scope (server path -> id)
        /// </summary>
        private (Scope, Dictionary <string, string>) ApplyChangesToScope(GraphNode node, Differences deltas)
        {
            var   deletedServerPathToId = new Dictionary <string, string>();
            Scope scope = null;

            if (node.Parents.Count == 0)
            {
                // Called once for the first commit
                scope = new Scope();
                UpdateScopeSingleOrNoParent(deltas, scope, deletedServerPathToId);
            }
            else if (node.Parents.Count == 1)
            {
                var parent = node.Parents.Single();
                scope = parent.Scope;

                Debug.Assert(scope != null);
                if (parent.Children.Count > 1)
                {
                    // We follow two branches, so each one gets its own copy.
                    scope = parent.Scope.Clone();
                }
                else
                {
                    scope = parent.Scope;
                }

                UpdateScopeSingleOrNoParent(deltas, scope, deletedServerPathToId);
            }
            else if (IsMerge(node))
            {
                var mergeInto = node.Parents[0];
                var mergeFrom = node.Parents[1];

                scope = mergeInto.Scope;

                UpdateScopeTwoParents(deltas, mergeInto, mergeFrom, deletedServerPathToId);
            }
            else
            {
                Debug.Assert(false);
            }

            return(scope, deletedServerPathToId);
        }