Ejemplo n.º 1
0
        /// <summary>
        /// Removes all files that were deleted and are no longer available
        /// </summary>
        private void CleanupHistory(ChangeSetHistory history)
        {
            var deletedIds = history.ChangeSets
                             .SelectMany(set => set.Items)
                             .Where(item => item.IsDelete())
                             .Select(item => item.Id);

            var deletedIdsHash = new HashSet <string>(deletedIds);

            foreach (var set in history.ChangeSets)
            {
                set.Items.RemoveAll(item => deletedIdsHash.Contains(item.Id));
            }

            // Delete empty commits
            var changeSetsCopy = history.ChangeSets.ToList();

            foreach (var changeSet in changeSetsCopy)
            {
                if (!changeSet.Items.Any())
                {
                    history.ChangeSets.Remove(changeSet);
                }
            }
        }
Ejemplo n.º 2
0
        private static void ClearEmptyCommits(ChangeSetHistory history)
        {
            // Delete empty commits
            var changeSetsCopy = history.ChangeSets.ToList();

            foreach (var changeSet in changeSetsCopy)
            {
                if (!changeSet.Items.Any())
                {
                    history.ChangeSets.Remove(changeSet);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes all files that were deleted and are no longer available
        /// </summary>
        private void CleanupHistory(ChangeSetHistory history)
        {
            var deletedIdsHash = history.ChangeSets
                                 .SelectMany(set => set.Items)
                                 .Where(item => item.IsDelete())
                                 .Select(item => item.Id).ToHashSet();

            foreach (var set in history.ChangeSets)
            {
                set.Items.RemoveAll(item => deletedIdsHash.Contains(item.Id));
            }

            ClearEmptyCommits(history);
        }