Ejemplo n.º 1
0
        /// <summary>
        /// Called from RefreshPath's call to <see cref="SvnClient::Status"/>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// All information we receive here is live from SVN and Disk and is therefore propagated
        /// in all SvnItems wishing information
        /// </remarks>
        void RefreshCallback(object sender, SvnStatusEventArgs e)
        {
            // Note: There is a lock(_lock) around this in our caller

            var status = new SvnStatusData(e);
            var path   = e.FullPath; // Fully normalized

            SvnItem 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!)

                var newItem = CreateItem(path, status);
                StoreItem(newItem);

                if (item != null)
                {
                    ((ISvnItemUpdate)item).RefreshTo(newItem);
                    item.Dispose();
                }

                item = newItem;
            }
            else
            {
                ((ISvnItemUpdate)item).RefreshTo(status);
            }

            // Note: There is a lock(_lock) around this in our caller
        }
Ejemplo n.º 2
0
        private void RefreshValues()
        {
            bool   exists = SvnItem.Exists;
            string name   = string.IsNullOrEmpty(SvnItem.Name) ? SvnItem.FullPath : SvnItem.Name;

            SvnStatusData     status = SvnItem.Status;
            PendingChangeKind kind   = PendingChange.CombineStatus(status.LocalNodeStatus, status.LocalTextStatus, status.LocalPropertyStatus, SvnItem.IsTreeConflicted, SvnItem);

            if (_chg == null || _chg.State != kind)
            {
                _chg = new PendingChangeStatus(kind);
            }

            SetValues(
                name,
                Modified.ToString("g"),
                View.Context.GetService <IFileIconMapper>().GetFileType(SvnItem),
                _chg.ExplorerText,
                SvnItem.Status.IsLockedLocal ? Ankh.UI.PendingChanges.PCResources.LockedValue : "",
                SvnItem.Status.Revision.ToString(),
                SvnItem.Status.LastChangeTime.ToLocalTime().ToString(),
                SvnItem.Status.LastChangeRevision.ToString(),
                SvnItem.Status.LastChangeAuthor,
                SvnItem.Status.LocalNodeStatus.ToString(),
                SvnItem.Status.LocalPropertyStatus.ToString(),
                SvnItem.Status.IsCopied.ToString(),
                SvnItem.IsConflicted.ToString(),
                SvnItem.FullPath
                );

            StateImageIndex = (int)View.StatusMapper.GetStatusImageForSvnItem(SvnItem);
        }
Ejemplo n.º 3
0
        static bool NewFullPathOk(SvnItem item, string fullPath, SvnStatusData 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 SvnStatus.Added:
            case SvnStatus.Conflicted:
            case SvnStatus.Merged:
            case SvnStatus.Modified:
            case SvnStatus.Normal:
            case SvnStatus.Replaced:
            case SvnStatus.Deleted:
            case SvnStatus.Incomplete:
                return(false);

            default:
                return(true);
            }
        }
Ejemplo n.º 4
0
        static bool MightBeNestedWorkingCopy(SvnStatusData status)
        {
            switch (status.LocalNodeStatus)
            {
            case SvnStatus.NotVersioned:
            case SvnStatus.Ignored:
            case SvnStatus.Obstructed:
                return(true);

            default:
                return(false);
            }
        }
Ejemplo n.º 5
0
        public SvnItem(ISvnStatusCache context, string fullPath, SvnStatusData status)
            : base(fullPath)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            else if (status == null)
            {
                throw new ArgumentNullException("status");
            }

            _context = context;
            _status  = status;

            _enqueued = true;
            RefreshTo(status);
            _enqueued = false;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Copies all information from other.
        /// </summary>
        /// <param name="lead"></param>
        /// <remarks>When this method is called the other item will eventually replace this item</remarks>
        void ISvnItemUpdate.RefreshTo(SvnItem 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;

            SvnItemState current = lead._currentState;
            SvnItemState valid   = lead._validState;

            SetState(current & valid, (~current) & valid);
            _ticked   = false;
            _modified = lead._modified;
            _cookie   = NextCookie(); // Status 100% the same, but changed... Cookies are free ;)
        }
Ejemplo n.º 7
0
        void RefreshTo(NoSccStatus status, SvnNodeKind nodeKind)
        {
            _cookie      = NextCookie();
            _statusDirty = XBool.False;

            SvnItemState set   = SvnItemState.None;
            SvnItemState unset = SvnItemState.Modified | SvnItemState.Added | SvnItemState.HasCopyOrigin
                                 | SvnItemState.Deleted | SvnItemState.ContentConflicted | SvnItemState.Ignored
                                 | SvnItemState.Obstructed | SvnItemState.Replaced | SvnItemState.Versioned
                                 | SvnItemState.SvnDirty | SvnItemState.PropertyModified | SvnItemState.PropertiesConflicted | SvnItemState.Conflicted
                                 | SvnItemState.Obstructed | SvnItemState.MustLock | SvnItemState.IsWCRoot
                                 | SvnItemState.HasProperties | SvnItemState.HasLockToken | SvnItemState.HasCopyOrigin
                                 | SvnItemState.MovedHere;

            switch (status)
            {
            case NoSccStatus.NotExisting:
                SetState(set, SvnItemState.Exists | SvnItemState.ReadOnly | SvnItemState.IsDiskFile | SvnItemState.IsDiskFolder | SvnItemState.Versionable | unset);
                _status = SvnStatusData.NotExisting;
                break;

            case NoSccStatus.NotVersionable:
                unset |= SvnItemState.Versionable;
                goto case NoSccStatus.NotVersioned;     // fall through

            case NoSccStatus.NotVersioned:
                SetState(SvnItemState.Exists | set, SvnItemState.None | unset);
                _status = SvnStatusData.NotVersioned;
                break;

            case NoSccStatus.Unknown:
            default:
                SetDirty(set | unset);
                _statusDirty = XBool.True;
                break;
            }

            InitializeFromKind(nodeKind);
        }
Ejemplo n.º 8
0
 public SvnItem CreateItem(string fullPath, SvnStatusData status)
 {
     return(new SvnItem(fullPath, status));
 }
Ejemplo n.º 9
0
 void ISvnItemUpdate.RefreshTo(SvnStatusData status)
 {
     _ticked = false;
     RefreshTo(status);
 }
Ejemplo n.º 10
0
        void RefreshTo(SvnStatusData status)
        {
            if (status == null)
            {
                throw new ArgumentNullException("status");
            }

            if (status.LocalNodeStatus == SvnStatus.External)
            {
                // When iterating the status of an external in it's parent directory
                // We get an external status and no really usefull information

                SetState(SvnItemState.Exists | SvnItemState.Versionable | SvnItemState.IsDiskFolder,
                         SvnItemState.IsDiskFile | SvnItemState.ReadOnly | SvnItemState.MustLock | SvnItemState.IsTextFile);

                if (_statusDirty != XBool.False)
                {
                    _statusDirty = XBool.True; // Walk the path itself to get the data you want
                }
                return;
            }
            else if (MightBeNestedWorkingCopy(status) && IsDirectory)
            {
                // A not versioned directory might be a working copy by itself!

                if (_statusDirty == XBool.False)
                {
                    return; // No need to remove valid cache entries
                }
                if (SvnTools.IsManagedPath(FullPath))
                {
                    _statusDirty = XBool.True; // Walk the path itself to get the data

                    // Extract useful information we got anyway

                    SetState(SvnItemState.Exists | SvnItemState.Versionable | SvnItemState.Versioned | SvnItemState.IsWCRoot | SvnItemState.IsDiskFolder,
                             SvnItemState.IsDiskFile | SvnItemState.ReadOnly | SvnItemState.MustLock | SvnItemState.IsTextFile);

                    return;
                }
                else
                {
                    SetState(SvnItemState.None, SvnItemState.IsWCRoot);
                }
                // Fall through
            }

            _cookie      = NextCookie();
            _statusDirty = XBool.False;
            _status      = status;

            const SvnItemState unset = SvnItemState.Modified | SvnItemState.Added |
                                       SvnItemState.HasCopyOrigin | SvnItemState.Deleted | SvnItemState.ContentConflicted |
                                       SvnItemState.Ignored | SvnItemState.Obstructed | SvnItemState.Replaced |
                                       SvnItemState.MovedHere;

            const SvnItemState managed = SvnItemState.Versioned;


            // Let's assume status is more recent than our internal property cache
            // Set all caching properties we can

            bool svnDirty        = true;
            bool exists          = true;
            bool provideDiskInfo = true;

            switch (status.LocalNodeStatus)
            {
            case SvnStatus.None:
                SetState(SvnItemState.None, managed | unset);
                svnDirty        = false;
                exists          = false;
                provideDiskInfo = false;
                break;

            case SvnStatus.NotVersioned:
                // Node exists but is not managed by us in this directory
                // (Might be from an other location as in the nested case)
                SetState(SvnItemState.None, unset | managed);
                svnDirty = false;
                break;

            case SvnStatus.Ignored:
                // Node exists but is not managed by us in this directory
                // (Might be from an other location as in the nested case)
                SetState(SvnItemState.Ignored, unset | managed);
                svnDirty = false;
                break;

            case SvnStatus.Added:
                if (status.IsMoved && status.IsCopied)
                {
                    SetState(managed | SvnItemState.Added | SvnItemState.HasCopyOrigin | SvnItemState.MovedHere, unset);
                }
                else if (status.IsCopied)
                {
                    SetState(managed | SvnItemState.Added | SvnItemState.HasCopyOrigin, unset);
                }
                else
                {
                    SetState(managed | SvnItemState.Added, unset);
                }

                if (status.LocalTextStatus == SvnStatus.Modified)
                {
                    SetState(SvnItemState.Modified, SvnItemState.None);
                }
                else if (status.LocalTextStatus == SvnStatus.Normal)
                {
                    SetState(SvnItemState.None, SvnItemState.Modified);
                }
                break;

            case SvnStatus.Replaced:
                if (status.IsMoved && status.IsCopied)
                {
                    SetState(managed | SvnItemState.Replaced | SvnItemState.HasCopyOrigin | SvnItemState.MovedHere, unset);
                }
                else if (status.IsCopied)
                {
                    SetState(managed | SvnItemState.Replaced | SvnItemState.HasCopyOrigin, unset);
                }
                else
                {
                    SetState(managed | SvnItemState.Replaced, unset);
                }

                if (status.LocalTextStatus == SvnStatus.Modified)
                {
                    SetState(SvnItemState.Modified, SvnItemState.None);
                }
                else if (status.LocalTextStatus == SvnStatus.Normal)
                {
                    SetState(SvnItemState.None, SvnItemState.Modified);
                }
                break;

            case SvnStatus.Modified:
            case SvnStatus.Conflicted:
            {
                bool done = false;
                switch (status.LocalTextStatus)
                {
                case SvnStatus.Modified:
                    SetState(managed | SvnItemState.Modified, unset);
                    done = true;
                    break;

                case SvnStatus.Conflicted:
                    SetState(managed | SvnItemState.ContentConflicted | SvnItemState.Conflicted, unset);
                    done = true;
                    break;
                }
                if (!done)
                {
                    goto case SvnStatus.Normal;
                }
                break;
            }

            case SvnStatus.Obstructed:     // node exists but is of the wrong type
                SetState(SvnItemState.None, managed | unset);
                provideDiskInfo = false;   // Info is wrong
                break;

            case SvnStatus.Missing:
                exists          = false;
                provideDiskInfo = false;     // Info is wrong
                SetState(managed, unset);
                break;

            case SvnStatus.Deleted:
                SetState(managed | SvnItemState.Deleted, unset);
                if (status.LocalFileExists)
                {
                    exists = provideDiskInfo = true;
                }
                else
                {
                    exists          = false;
                    provideDiskInfo = false;     // Folder might still exist
                }
                break;

            case SvnStatus.External:
                // Should be handled above
                throw new InvalidOperationException();

            case SvnStatus.Incomplete:
                SetState(managed, unset);
                break;

            default:
                Trace.WriteLine(string.Format("Ignoring undefined status {0} in SvnItem.Refresh()", status.LocalNodeStatus));
                provideDiskInfo = false;     // Can't trust an unknown status
                goto case SvnStatus.Normal;

            case SvnStatus.Normal:
                SetState(managed | SvnItemState.Exists, unset);
                svnDirty = false;
                break;
            }

            if (exists)
            {
                SetState(SvnItemState.Versionable, SvnItemState.None);
            }
            else
            {
                SetState(SvnItemState.None, SvnItemState.Versionable);
            }

            if (status.Conflicted)
            {
                SetState(SvnItemState.Conflicted, SvnItemState.None);
            }
            else
            {
                SetState(SvnItemState.None, SvnItemState.Conflicted);
            }


            bool hasProperties = true;

            switch (status.LocalPropertyStatus)
            {
            case SvnStatus.None:
                hasProperties = false;
                SetState(SvnItemState.None, SvnItemState.PropertiesConflicted | SvnItemState.PropertyModified | SvnItemState.HasProperties);
                break;

            case SvnStatus.Modified:
                SetState(SvnItemState.PropertyModified | SvnItemState.HasProperties,
                         SvnItemState.PropertiesConflicted);
                svnDirty = true;
                break;

            case SvnStatus.Conflicted:
                SetState(SvnItemState.PropertyModified | SvnItemState.PropertiesConflicted | SvnItemState.HasProperties,
                         SvnItemState.None);
                svnDirty = true;
                break;

            case SvnStatus.Normal:
            default:
                SetState(SvnItemState.HasProperties,
                         SvnItemState.PropertiesConflicted | SvnItemState.PropertyModified);
                break;
            }

            if (svnDirty)
            {
                SetState(SvnItemState.SvnDirty, SvnItemState.None);
            }
            else
            {
                SetState(SvnItemState.None, SvnItemState.SvnDirty);
            }

            if (!hasProperties)
            {
                SetState(SvnItemState.None, SvnItemState.MustLock);
            }

            if (provideDiskInfo)
            {
                if (exists) // Behaviour must match updating from UpdateAttributeInfo()
                {
                    switch (status.NodeKind)
                    {
                    case SvnNodeKind.Directory:
                        SetState(SvnItemState.IsDiskFolder | SvnItemState.Exists, SvnItemState.ReadOnly | SvnItemState.MustLock | SvnItemState.IsTextFile | SvnItemState.IsDiskFile);
                        break;

                    case SvnNodeKind.File:
                        SetState(SvnItemState.IsDiskFile | SvnItemState.Exists, SvnItemState.IsDiskFolder);
                        break;

                    default:
                        // Handle direct replacement without an additional stat
                        if (status.LocalFileExists)
                        {
                            goto case SvnNodeKind.File;
                        }
                        break;
                    }
                }
                else
                {
                    SetState(SvnItemState.None, SvnItemState.Exists);
                }
            }

            if (status.IsLockedLocal)
            {
                SetState(SvnItemState.HasLockToken, SvnItemState.None);
            }
            else
            {
                SetState(SvnItemState.None, SvnItemState.HasLockToken);
            }
        }