Esempio n. 1
0
        /// <remarks>
        /// This is not used in a multithreaded method, it doesn't need to be thread-safe
        /// </remarks>
        private void EnqueueFileAddOperation(ITracer activity, DiffTreeResult operation)
        {
            // Each filepath should be case-insensitive unique. If there are duplicates, only the last parsed one should remain.
            if (!this.filesAdded.Add(operation.TargetPath))
            {
                foreach (KeyValuePair <string, HashSet <PathWithMode> > kvp in this.FileAddOperations)
                {
                    PathWithMode tempPathWithMode = new PathWithMode(operation.TargetPath, 0x0000);
                    if (kvp.Value.Remove(tempPathWithMode))
                    {
                        break;
                    }
                }
            }

            if (this.stagedFileDeletes.Remove(operation.TargetPath))
            {
                EventMetadata metadata = new EventMetadata();
                metadata.Add(nameof(operation.TargetPath), operation.TargetPath);
                metadata.Add(TracingConstants.MessageKey.WarningMessage, "A case change was attempted. It will not be reflected in the working directory.");
                activity.RelatedEvent(EventLevel.Warning, "CaseConflict", metadata);
            }

            this.FileAddOperations.AddOrUpdate(
                operation.TargetSha,
                new HashSet <PathWithMode> {
                new PathWithMode(operation.TargetPath, operation.TargetMode)
            },
                (key, oldValue) =>
            {
                oldValue.Add(new PathWithMode(operation.TargetPath, operation.TargetMode));
                return(oldValue);
            });

            this.RequiredBlobs.Add(operation.TargetSha);
        }