Exemplo n.º 1
0
        internal void PrescanOneTree()
        {
            var visitor = new AbstractIndexTreeVisitor
            {
                VisitEntry = (m, i, f) =>
                {
                    if (m != null)
                    {
                        if (!f.IsFile())
                        {
                            CheckConflictsWithFile(f);
                        }
                    }
                    else
                    {
                        if (f.Exists)
                        {
                            Removed.Add(i.Name);
                            Conflicts.Remove(i.Name);
                        }
                    }
                }
            };

            new IndexTreeWalker(_index, _merge, _root, visitor).Walk();

            Conflicts.RemoveAll(conflict => Removed.Contains(conflict));
        }
Exemplo n.º 2
0
        internal void PrescanTwoTrees()
        {
            var visitor = new AbstractIndexTreeVisitor
            {
                VisitEntryAux = (treeEntry, auxEntry, indexEntry, file) =>
                {
                    if (treeEntry is Tree || auxEntry is Tree)
                    {
                        throw new ArgumentException("Can't pass me a tree!");
                    }

                    ProcessEntry(treeEntry, auxEntry, indexEntry);
                },

                FinishVisitTree = (tree, auxTree, currentDirectory) =>
                {
                    if (currentDirectory.Length == 0)
                    {
                        return;
                    }
                    if (auxTree == null)
                    {
                        return;
                    }

                    if (_index.GetEntry(currentDirectory) != null)
                    {
                        Removed.Add(currentDirectory);
                    }
                }
            };

            new IndexTreeWalker(_index, _head, _merge, _root, visitor).Walk();

            // if there's a conflict, don't list it under
            // to-be-removed, since that messed up our next
            // section
            Removed.RemoveAll(removed => Conflicts.Contains(removed));

            foreach (string path in _updated.Keys)
            {
                if (_index.GetEntry(path) == null)
                {
                    FileSystemInfo file = new FileInfo(Path.Combine(_root.DirectoryName(), path));
                    if (file.IsFile())
                    {
                        Conflicts.Add(path);
                    }
                    else if (file.IsDirectory())
                    {
                        CheckConflictsWithFile(file);
                    }
                }
            }

            Conflicts.RemoveAll(conflict => Removed.Contains(conflict));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Run the diff operation. Until this is called, all lists will be empty
        /// </summary>
        /// <returns>true if anything is different between index, tree, and workdir</returns>
        public bool Diff()
        {
            DirectoryInfo root    = _index.Repository.WorkingDirectory;
            var           visitor = new AbstractIndexTreeVisitor
            {
                VisitEntry = delegate(TreeEntry treeEntry, GitIndex.Entry indexEntry, FileInfo file)
                {
                    if (treeEntry == null)
                    {
                        Added.Add(indexEntry.Name);
                        _anyChanges = true;
                    }
                    else if (indexEntry == null)
                    {
                        if (!(treeEntry is Tree))
                        {
                            Removed.Add(treeEntry.FullName);
                        }
                        _anyChanges = true;
                    }
                    else
                    {
                        if (!treeEntry.Id.Equals(indexEntry.ObjectId))
                        {
                            Changed.Add(indexEntry.Name);
                            _anyChanges = true;
                        }
                    }

                    if (indexEntry != null)
                    {
                        if (!file.Exists)
                        {
                            Missing.Add(indexEntry.Name);
                            _anyChanges = true;
                        }
                        else
                        {
                            if (indexEntry.IsModified(root, true))
                            {
                                Modified.Add(indexEntry.Name);
                                _anyChanges = true;
                            }
                        }
                    }
                }
            };

            new IndexTreeWalker(_index, _tree, root, visitor).Walk();

            CheckUntrackedDirectory(root.FullName, "");

            return(_anyChanges);
        }
Exemplo n.º 4
0
 public void Remove <T>(T entity) where T : class
 {
     //if (typeof(T) == typeof(Log))
     //{
     //    LogRemoved.Add(entity);
     //}
     //else
     //{
     Removed.Add(entity);
     //}
 }
Exemplo n.º 5
0
        private void RemoveItemAt(int index)
        {
            var container = Items[index];

            Items.RemoveAt(index);
            // If the item being removed was added, that means we don't need to track it
            // anymore, so the below does not apply.
            if (container.Action != ChangeAction.Add)
            {
                container.Action = ChangeAction.Remove;
                Removed.Add(container);
            }
        }
Exemplo n.º 6
0
 private PathStatus OnRemoved(string path, PathStatus status)
 {
     if (Options.PerPathNotificationCallback != null)
     {
         if (status == null)
         {
             status = new PathStatus(Repository, path);
         }
         status.IndexPathStatus = IndexPathStatus.Removed;
     }
     Removed.Add(path);
     AnyDifferences = true;
     return(status);
 }
Exemplo n.º 7
0
        //public void RegisterClean(TModel e)
        //{
        //    Dirty.Remove(e);
        //}

        public TModel RegisterRemoved(TModel e)
        {
            if (New.Remove(e))
            {
                return(e);
            }

            Dirty.Remove(e);
            if (!Removed.Contains(e))
            {
                Removed.Add(e);
            }

            return(e);
        }
Exemplo n.º 8
0
        public override void Update(float elapsed)
        {
            foreach (IController controller in Controllers)
            {
                controller.UpdateSystemCommands(elapsed);
            }
            if (!isPaused)
            {
                if (Scene.mario.CurrentPowerState is MarioDeadState)
                {
                    Scene.mario.Update(elapsed);
                }
                else
                {
                    hud.Update(elapsed);
                    foreach (IController controller in Controllers)
                    {
                        controller.UpdatePlayerCommands(elapsed);
                    }
                    SpatialGrid collisionGrid = new SpatialGrid(Scene.Bound);

                    foreach (Entity entity in Entities)
                    {
                        if (entity.Removed)
                        {
                            Removed.Add(entity);
                        }
                        else
                        {
                            entity.Update(elapsed);
                            if (entity.Collidable)
                            {
                                collisionGrid.Add(entity);
                            }
                        }
                    }

                    scene.RemoveEntities();
                    scene.UpdateCamera();

                    collisionGrid.CheckCollisions();
                }
            }
        }
Exemplo n.º 9
0
        private async Task RemoveMissingFilesAsync(IDbConnection connection, Stopwatch stopwatch, IProgress <SyncProgress> progress)
        {
            progress?.Report(new SyncProgress()
            {
                Message = "Removing deleted files...", Elapsed = stopwatch.Elapsed
            });

            var allFiles = await GetAllFilesAsync(connection);

            string rootPath = GetRootPath(connection);

            foreach (var file in allFiles)
            {
                if (!System.IO.File.Exists(Path.Combine(rootPath, file.Path)))
                {
                    Removed.Add(file);
                    progress?.Report(new SyncProgress()
                    {
                        Message = $"Removing {file.Path}", Elapsed = stopwatch.Elapsed
                    });
                    await RemoveFileAsync(connection, file);
                }
            }
        }
Exemplo n.º 10
0
 public override EntityEntry <T> Remove(T entity)
 {
     Removed.Add(entity);
     return(null);
 }
Exemplo n.º 11
0
 public void Remove(IDataRecord item)
 {
     Repository.Signal <IDataRecordRemoving>(_ => _.RecordRemoving(item));
     Removed.Add(item.Identifier);
     Repository.Signal <IDataRecordRemoved>(_ => _.RecordRemoved(item));
 }
Exemplo n.º 12
0
        private void ProcessEntry(TreeEntry h, TreeEntry m, GitIndex.Entry i)
        {
            ObjectId iId = (i == null ? null : i.ObjectId);
            ObjectId mId = (m == null ? null : m.Id);
            ObjectId hId = (h == null ? null : h.Id);

            string name = (i != null ? i.Name : (h != null ? h.FullName : m.FullName));

            if (i == null)
            {
                //
                //				    I (index)                H        M        Result
                //			        -------------------------------------------------------
                //			        0 nothing             nothing  nothing  (does not happen)
                //			        1 nothing             nothing  exists   use M
                //			        2 nothing             exists   nothing  remove path from index
                //			        3 nothing             exists   exists   use M

                if (h == null)
                {
                    _updated.Add(name, mId);
                }
                else if (m == null)
                {
                    Removed.Add(name);
                }
                else
                {
                    _updated.Add(name, mId);
                }
            }
            else if (h == null)
            {
                //
                //					  clean I==H  I==M       H        M        Result
                //			         -----------------------------------------------------
                //			        4 yes   N/A   N/A     nothing  nothing  keep index
                //			        5 no    N/A   N/A     nothing  nothing  keep index
                //
                //			        6 yes   N/A   yes     nothing  exists   keep index
                //			        7 no    N/A   yes     nothing  exists   keep index
                //			        8 yes   N/A   no      nothing  exists   fail
                //			        9 no    N/A   no      nothing  exists   fail

                if (m == null || mId.Equals(iId))
                {
                    if (HasParentBlob(_merge, name))
                    {
                        if (i.IsModified(_root, true))
                        {
                            Conflicts.Add(name);
                        }
                        else
                        {
                            Removed.Add(name);
                        }
                    }
                }
                else
                {
                    Conflicts.Add(name);
                }
            }
            else if (m == null)
            {
                //
                //					10 yes   yes   N/A     exists   nothing  remove path from index
                //			        11 no    yes   N/A     exists   nothing  fail
                //			        12 yes   no    N/A     exists   nothing  fail
                //			        13 no    no    N/A     exists   nothing  fail
                //

                if (hId.Equals(iId))
                {
                    if (i.IsModified(_root, true))
                    {
                        Conflicts.Add(name);
                    }
                    else
                    {
                        Removed.Add(name);
                    }
                }
                else
                {
                    Conflicts.Add(name);
                }
            }
            else
            {
                if (!hId.Equals(mId) && !hId.Equals(iId) && !mId.Equals(iId))
                {
                    Conflicts.Add(name);
                }
                else if (hId.Equals(iId) && !mId.Equals(iId))
                {
                    if (i.IsModified(_root, true))
                    {
                        Conflicts.Add(name);
                    }
                    else
                    {
                        _updated.Add(name, mId);
                    }
                }
            }
        }
 void IOdeToFoodDb.Remove <T>(T entity)
 {
     Removed.Add(entity);
 }
Exemplo n.º 14
0
 public void Remove <T>(T entity) where T : class
 {
     Removed.Add(entity);
 }
Exemplo n.º 15
0
 /// 由于不需要 Note 来支持回滚,这里只保留最新的改变即可。
 internal void LogRemove(K key)
 {
     Removed.Add(key);
     Replaced.Remove(key);
 }
Exemplo n.º 16
0
        /// <summary>
        /// Run the diff operation. Until this is called, all lists will be empty
        /// </summary>
        /// <returns>true if anything is different between index, tree, and workdir</returns>
        private void UpdateDirectory(IEnumerable <string> paths, bool recursive)
        {
            RevWalk  rw     = new RevWalk(Repository);
            ObjectId id     = Repository.Resolve(Constants.HEAD);
            var      commit = id != null?rw.ParseCommit(id) : null;

            TreeWalk treeWalk = new TreeWalk(Repository);

            treeWalk.Reset();
            treeWalk.Recursive = false;

            if (commit != null)
            {
                treeWalk.AddTree(commit.Tree);
            }
            else
            {
                treeWalk.AddTree(new EmptyTreeIterator());
            }

            DirCache dc = Repository.ReadDirCache();

            treeWalk.AddTree(new DirCacheIterator(dc));

            FileTreeIterator workTree = new FileTreeIterator(Repository.WorkTree, Repository.FileSystem, WorkingTreeOptions.KEY.Parse(Repository.GetConfig()));

            treeWalk.AddTree(workTree);

            List <TreeFilter> filters = new List <TreeFilter> ();

            filters.Add(new SkipWorkTreeFilter(1));

            var pathFilters = paths.Where(p => p != ".").Select(p => PathFilter.Create(p)).ToArray();

            if (pathFilters.Length > 1)
            {
                filters.Add(OrTreeFilter.Create(pathFilters));                   // Use an OR to join all path filters
            }
            else if (pathFilters.Length == 1)
            {
                filters.Add(pathFilters[0]);
            }

            if (filters.Count > 1)
            {
                treeWalk.Filter = AndTreeFilter.Create(filters);
            }
            else
            {
                treeWalk.Filter = filters[0];
            }

            while (treeWalk.Next())
            {
                AbstractTreeIterator treeIterator        = treeWalk.GetTree <AbstractTreeIterator>(0);
                DirCacheIterator     dirCacheIterator    = treeWalk.GetTree <DirCacheIterator>(1);
                WorkingTreeIterator  workingTreeIterator = treeWalk.GetTree <WorkingTreeIterator>(2);
                NGit.FileMode        fileModeTree        = treeWalk.GetFileMode(0);

                if (treeWalk.IsSubtree)
                {
                    treeWalk.EnterSubtree();
                    continue;
                }

                int stage = dirCacheIterator != null?dirCacheIterator.GetDirCacheEntry().Stage : 0;

                if (stage > 1)
                {
                    continue;
                }
                else if (stage == 1)
                {
                    MergeConflict.Add(dirCacheIterator.EntryPathString);
                    changesExist = true;
                    continue;
                }

                if (treeIterator != null)
                {
                    if (dirCacheIterator != null)
                    {
                        if (!treeIterator.EntryObjectId.Equals(dirCacheIterator.EntryObjectId))
                        {
                            // in repo, in index, content diff => changed
                            Modified.Add(dirCacheIterator.EntryPathString);
                            changesExist = true;
                        }
                    }
                    else
                    {
                        // in repo, not in index => removed
                        if (!fileModeTree.Equals(NGit.FileMode.TYPE_TREE))
                        {
                            Removed.Add(treeIterator.EntryPathString);
                            changesExist = true;
                        }
                    }
                }
                else
                {
                    if (dirCacheIterator != null)
                    {
                        // not in repo, in index => added
                        Added.Add(dirCacheIterator.EntryPathString);
                        changesExist = true;
                    }
                    else
                    {
                        // not in repo, not in index => untracked
                        if (workingTreeIterator != null && !workingTreeIterator.IsEntryIgnored())
                        {
                            Untracked.Add(workingTreeIterator.EntryPathString);
                            changesExist = true;
                        }
                    }
                }
                if (dirCacheIterator != null)
                {
                    if (workingTreeIterator == null)
                    {
                        // in index, not in workdir => missing
                        Missing.Add(dirCacheIterator.EntryPathString);
                        changesExist = true;
                    }
                    else
                    {
                        // Workaround to file time resolution issues
                        long itime = dirCacheIterator.GetDirCacheEntry().LastModified;
                        long ftime = workingTreeIterator.GetEntryLastModified();
                        if (itime / 1000 != ftime / 1000)
                        {
                            if (!dirCacheIterator.IdEqual(workingTreeIterator))
                            {
                                // in index, in workdir, content differs => modified
                                Modified.Add(dirCacheIterator.EntryPathString);
                                changesExist = true;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
 public void Remove(object content)
 {
     Removed.Add(content.ToString());
 }