Beispiel #1
0
        public IEnumerable<Graph<IFileReference>> GetChangeGraphs(IMultiFileSystemDiff diff)
        {
            foreach (var changeList in diff.FileChanges)
            {
                var graph = new Graph<IFileReference>(m_FileReferenceComparer);

                foreach (var historyName in changeList.HistoryNames)
                {
                    var changes = changeList.GetChanges(historyName).ToArray();
                    
                    // add changes for the current history to the graph
                    if (changes.Any())
                    {
                        graph.AddEdgeFromStartNode(changes.First().FromVersion);
                        foreach (var change in changes)
                        {
                            graph.AddEdge(change.FromVersion, change.ToVersion);
                        }
                    }
                    // for histories without a change to the current file, add the current file version as node
                    else
                    {                        
                        var rootDirectory = diff.ToSnapshot.GetSnapshot(historyName).RootDirectory;
                        graph.AddEdgeFromStartNode(rootDirectory.GetFileReferenceOrDefault(changeList.Path));
                    }
                }

                yield return graph;
            }            
        }
        public FilteredMultiFileSystemDiff(IMultiFileSystemDiff innerDiff, IMultiFileSystemChangeFilter filter)
        {
            if (innerDiff == null)
                throw new ArgumentNullException(nameof(innerDiff));

            if (filter == null)
                throw new ArgumentNullException(nameof(filter));

            m_InnerDiff = innerDiff;
            m_Filter = filter;
        }
Beispiel #3
0
 bool ContainsNewFolders(IMultiFileSystemDiff diff)
 {            
     return diff.FromSnapshot != null && diff.HistoryChanges.Any(c => c.Type == ChangeType.Added);
 }
Beispiel #4
0
        bool ResetSyncStateIfNecessary(IGroup group, IMultiFileSystemDiff diff)
        {
            var syncPointService = group.GetSyncPointService();
            var syncActionService = group.GetSyncActionService();
            var conflictService = group.GetSyncConflictService();

            var syncFolders = group.GetConfigurationService().Items.ToArray();
                
            var latestSyncPoint = syncPointService.LatestSyncPoint;

            if (ContainsNewFolders(diff) || WasFilterModified(syncFolders, latestSyncPoint))
            {
                // insert "Reset" sync point
                var resetSyncPoint = new MutableSyncPoint()
                {
                    Id = GetNextSyncPointId(latestSyncPoint),                    
                    MultiFileSystemSnapshotId = null,
                    FilterConfigurations = syncFolders.ToDictionary(f => f.Name, f => f.Filter)
                };

                syncPointService.AddItem(resetSyncPoint);

                // cancel all pending sync actions
                var cancelledSyncActions = syncActionService.PendingItems
                    .Select(a => a.WithState(SyncActionState.Cancelled));

                syncActionService.UpdateItems(cancelledSyncActions);

                // remove all conflicts                
                conflictService.RemoveItems(conflictService.Items.ToArray());


                return true;
            }

            return false;

        }