public void RegisterUpdated(EntityBase entity, IPersistRepository repository) { if (!Modified.ContainsKey(entity)) { Modified.Add(entity, repository); } }
public override void AddLine(LineSpan lineSpan, bool willUpdateImmediately) { if (lineSpan.Highlight) { lineSpan.Highlight = false; if (!willUpdateImmediately) { Modified.Add(lineSpan); } } }
/// <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); }
private PathStatus OnModified(string path, PathStatus status) { if (Options.PerPathNotificationCallback != null) { if (status == null) { status = new PathStatus(Repository, path); } status.WorkingPathStatus = WorkingPathStatus.Modified; } Modified.Add(path); AnyDifferences = true; return(status); }
public override IEnumerable <LineSpan> GetModified() { if (Nearest != null) { while (Modified.Remove(Nearest)) { } Nearest.Highlight = true; Modified.Add(Nearest); Modified.AddRange(Nearest.LinkedLines); Nearest = null; } return(Modified); }
public override void AddLine(LineSpan line, bool willUpdateImmediately) { bool isTouching = false; if (line.FirstLine - 1 == LineNumber || line.LastLine + 1 == LineNumber) { isTouching = true; } if (line.Highlight != isTouching) { line.Highlight = isTouching; if (!willUpdateImmediately) { Modified.Add(line); } Modified.AddRange(line.LinkedLines); } }
public override void AddLine(LineSpan line, bool willUpdateImmediately) { if (line.FirstLine <= LineNumber && LineNumber <= line.LastLine && (line.LastLine - line.FirstLine >= MinimumLength || line.LinkedLines.Any()) && line.Indent <= Position && (Nearest == null || line.Indent > Nearest.Indent)) { Nearest = line; } if (line.Highlight) { line.Highlight = false; if (!willUpdateImmediately) { Modified.Add(line); } Modified.AddRange(line.LinkedLines); } }
public override void AddLine(LineSpan line, bool willUpdateImmediately) { bool isTouching = false; if (line.FirstLine - 1 <= LineNumber && LineNumber <= line.LastLine + 1 && line.LastLine - line.FirstLine >= MinimumLength && line.Indent == Position) { isTouching = true; } if (line.Highlight != isTouching) { line.Highlight = isTouching; if (!willUpdateImmediately) { Modified.Add(line); } Modified.AddRange(line.LinkedLines); } }
public bool Diff(object prev, object cur, string parent = null) { Contract.Requires(prev != null); Contract.Requires(cur != null); var prevObj = ToJObject(prev); var curObj = ToJObject(cur); // Added and modified foreach (var curProp in EnumerateProperties(curObj)) { var prevProp = GetProperty(prevObj, curProp.Name); var key = curProp.Name; var prefix = parent == null ? string.Empty : parent; if (IsArray(prevObj)) { key = "[" + key + "]"; // We have a parent that's an array, use brackets } else if (parent != null) { prefix += "."; // We have a parent that's not an array, use dot notation } if (prevProp == null) // Property just created now { Added.Add(prefix + key, curProp.Value); continue; } // Property already exists if (IsValue(curProp.Value)) { if (object.Equals(curProp.Value, prevProp.Value)) { continue; // Values are the same, no change here } Modified.Add(prefix + key, curProp.Value); continue; } // This is an object Diff(prevProp.Value, curProp.Value, prefix + key); } // Deleted foreach (var prevProp in EnumerateProperties(prevObj).Where(x => !EnumerateProperties(curObj).Any(y => y.Name == x.Name))) { var key = prevProp.Name; var prefix = parent == null ? string.Empty : parent; if (IsArray(prev)) { key = "[" + key + "]"; } else if (parent != null) { prefix += "."; } Deleted.Add(prefix + key); } IsDifferent = Added.Count + Modified.Count + Deleted.Count > 0; return(IsDifferent); }
/// <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; } } } } } }