private void RefreshTo(NoSccStatus status, SvnNodeKind nodeKind) { _cookie = NextCookie(); _statusDirty = XBool.False; GitItemState set = GitItemState.None; GitItemState unset = GitItemState.Modified | GitItemState.Added | GitItemState.Deleted | GitItemState.Conflicted | GitItemState.Ignored | GitItemState.Versioned | GitItemState.IsWCRoot | GitItemState.GitDirty | GitItemState.Ignored; switch (status) { case NoSccStatus.NotExisting: SetState(set, GitItemState.Exists | GitItemState.ReadOnly | GitItemState.IsDiskFile | GitItemState.IsDiskFolder | GitItemState.Versionable | unset); _status = GitStatusData.NotExisting; break; case NoSccStatus.NotVersionable: unset |= GitItemState.Versionable; goto case NoSccStatus.NotVersioned; // fall through case NoSccStatus.NotVersioned: SetState(GitItemState.Exists | set, GitItemState.None | unset); _status = GitStatusData.NotVersioned; break; case NoSccStatus.Unknown: default: SetDirty(set | unset); _statusDirty = XBool.True; break; } //InitializeFromKind(nodeKind); }
static bool NewFullPathOk(GitItem item, string fullPath, GitStatusData status) { if (item == null) { throw new ArgumentNullException("item"); } else if (status == null) { throw new ArgumentNullException("status"); } if (fullPath == item.FullPath) { return(true); } /*switch (status.LocalNodeStatus) * { * case GitStatus.Added: * case GitStatus.Conflicted: * case GitStatus.Merged: * case GitStatus.Modified: * case GitStatus.Normal: * case GitStatus.Replaced: * case GitStatus.Deleted: * case GitStatus.Incomplete: * return false; * default: * return true; * }*/ return(false); }
private void RefreshTo(GitStatusData status) { _cookie = NextCookie(); _statusDirty = XBool.False; _status = status; GitItemState set = GitItemState.None; GitItemState unset = GitItemState.None; if (status.IsConflicted) set |= GitItemState.Conflicted; else unset |= GitItemState.Conflicted; if (status.IsIgnored) { set |= GitItemState.Versionable | GitItemState.Exists; unset |= GitItemState.Added | GitItemState.Deleted | GitItemState.Modified | GitItemState.Ignored | GitItemState.GitDirty | GitItemState.Versioned; } else if (MaxModified(status.IndexStatus) && MaxModified(status.WorkingStatus)) { // We don't know if the node is a file or directory yet set |= GitItemState.Versioned | GitItemState.Versionable | GitItemState.Exists; unset |= GitItemState.Added | GitItemState.Deleted | GitItemState.Ignored; if (status.Modified) set |= GitItemState.GitDirty | GitItemState.Modified; else unset |= GitItemState.GitDirty | GitItemState.Modified; } else if (status.IndexStatus == GitStatus.New || status.WorkingStatus == GitStatus.New) { set |= GitItemState.Versioned | GitItemState.Versionable | GitItemState.Exists | GitItemState.Added; unset |= GitItemState.Deleted | GitItemState.Modified | GitItemState.Ignored | GitItemState.GitDirty; } else if (status.IndexStatus == GitStatus.Deleted || status.WorkingStatus == GitStatus.Deleted) { set |= GitItemState.Versioned | GitItemState.Versionable | GitItemState.Exists | GitItemState.Deleted; unset |= GitItemState.Deleted | GitItemState.Modified | GitItemState.Ignored | GitItemState.GitDirty; } else { throw new NotImplementedException(); } switch(status.NodeKind) { case SvnNodeKind.File: set |= GitItemState.IsDiskFile; unset |= GitItemState.IsDiskFolder; break; case SvnNodeKind.Directory: set |= GitItemState.IsDiskFolder; unset |= GitItemState.IsDiskFile; break; } SetState(set, unset); }
public GitItem(IGitStatusCache context, string fullPath, GitStatusData status) : base(fullPath) { _context = context; _status = status; _enqueued = true; RefreshTo(status); _enqueued = false; }
void IGitItemUpdate.RefreshTo(GitItem lead) { if (lead == null) throw new ArgumentNullException("lead"); else if (lead._status == null) throw new InvalidOperationException("Lead status = null"); _status = lead._status; _statusDirty = lead._statusDirty; GitItemState current = lead._currentState; GitItemState valid = lead._validState; SetState(current & valid, (~current) & valid); _ticked = false; _modified = lead._modified; _cookie = NextCookie(); // Status 100% the same, but changed... Cookies are free ;) }
/// <summary> /// Called from RefreshPath's call to <see cref="GitClient::Status"/> /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// All information we receive here is live from Git and Disk and is therefore propagated /// in all GitItems wishing information /// </remarks> void RefreshCallback(object sender, GitStatusEventArgs e) { // Note: There is a lock(_lock) around this in our caller GitStatusData status = new GitStatusData(e); string path = e.FullPath; // Fully normalized if (_root == null) { _root = new string[] { e.FullPath, e.RelativePath } } ; GitItem item; if (!_map.TryGetValue(path, out item) || !NewFullPathOk(item, path, status)) { // We only create an item if we don't have an existing // with a valid path. (No casing changes allowed!) GitItem newItem = CreateItem(path, status); StoreItem(newItem); if (item != null) { ((IGitItemUpdate)item).RefreshTo(newItem); item.Dispose(); } item = newItem; } else { ((IGitItemUpdate)item).RefreshTo(status); } // Note: There is a lock(_lock) around this in our caller } /// <summary> /// Marks the specified file dirty /// </summary> /// <param name="file"></param> void ISccStatusCache.MarkDirty(string path) { if (path == null) { throw new ArgumentNullException("path"); } string normPath = SvnTools.GetNormalizedFullPath(path); lock (_lock) { GitItem item; if (_map.TryGetValue(normPath, out item)) { item.MarkDirty(); } } } void ISccStatusCache.MarkDirtyRecursive(string path) { if (path == null) { throw new ArgumentNullException("path"); } lock (_lock) { List <string> names = new List <string>(); foreach (GitItem v in _map.Values) { string name = v.FullPath; if (v.IsBelowPath(path)) { v.MarkDirty(); } } } }
GitItem CreateItem(string fullPath, GitStatusData status) { return(new GitItem(this, fullPath, status)); }
void IGitItemUpdate.RefreshTo(GitStatusData newData) { RefreshTo(newData); }