Example #1
0
        void UpdateNodeStatus(GenericNode node)
        {
            if (node.Meta == null)
            {
                node.Meta = new Dictionary <string, object>();
            }

            if (!node.Meta.ContainsKey(META_VC))
            {
                LocateVC(node);
            }

            IVCManager currentVC = node.Meta[META_VC] as IVCManager;
            string     root      = (string)node.Meta[META_ROOT];

            if (currentVC != null)
            {
                VCItemStatus status = currentVC.GetOverlay(node.BackingPath, root);
                node.Meta[META_STATUS] = status;
                OverlayMap.SetOverlay(status, node, currentTree);
            }
        }
        internal static bool HandleFileDelete(string[] paths, bool confirm)
        {
            if (paths == null || paths.Length == 0)
            {
                return(false);
            }
            WatcherVCResult result = fsWatchers.ResolveVC(Path.GetDirectoryName(paths[0]));

            if (result == null)
            {
                return(false);
            }

            List <string> svnRemove       = new List <string>();
            List <string> regularRemove   = new List <string>();
            List <string> hasModification = new List <string>();
            List <string> hasUnknown      = new List <string>();

            try
            {
                foreach (string path in paths)
                {
                    result = fsWatchers.ResolveVC(path, true);
                    if (result == null || result.Status == VCItemStatus.Unknown || result.Status == VCItemStatus.Ignored)
                    {
                        regularRemove.Add(path);
                    }
                    else
                    {
                        IVCManager manager = result.Manager;
                        string     root    = result.Watcher.Path;
                        int        p       = root.Length + 1;

                        if (Directory.Exists(path))
                        {
                            List <string> files = new List <string>();
                            GetAllFiles(path, files);
                            foreach (string file in files)
                            {
                                VCItemStatus status = manager.GetOverlay(file, root);
                                if (status == VCItemStatus.Unknown || status == VCItemStatus.Ignored)
                                {
                                    hasUnknown.Add(file.Substring(p));
                                }
                                else if (status > VCItemStatus.UpToDate)
                                {
                                    hasModification.Add(file.Substring(p));
                                }
                            }
                        }
                        else if (result.Status > VCItemStatus.UpToDate)
                        {
                            hasModification.Add(path);
                        }

                        if (svnRemove.Count > 0)
                        {
                            if (Path.GetDirectoryName(svnRemove[0]) != Path.GetDirectoryName(path))
                            {
                                throw new UnsafeOperationException(TextHelper.GetString("SourceControl.Info.ElementsLocatedInDiffDirs"));
                            }
                        }
                        svnRemove.Add(path);
                    }
                }
                if (regularRemove.Count > 0 && svnRemove.Count > 0)
                {
                    throw new UnsafeOperationException(TextHelper.GetString("SourceControl.Info.MixedSelectionOfElements"));
                }

                if (svnRemove.Count == 0 && regularRemove.Count > 0)
                {
                    return(false); // regular deletion
                }
            }
            catch (UnsafeOperationException upex)
            {
                MessageBox.Show(upex.Message, TextHelper.GetString("SourceControl.Info.UnsafeDeleteOperation"), MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(true); // prevent regular deletion
            }

            if (hasUnknown.Count > 0 && confirm)
            {
                string title = TextHelper.GetString("FlashDevelop.Title.ConfirmDialog");
                string msg   = TextHelper.GetString("SourceControl.Info.ConfirmUnversionedDelete") + "\n\n" + GetSomeFiles(hasUnknown);
                if (MessageBox.Show(msg, title, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
                {
                    return(true);
                }
            }

            if (hasModification.Count > 0 && confirm)
            {
                string title = TextHelper.GetString("FlashDevelop.Title.ConfirmDialog");
                string msg   = TextHelper.GetString("SourceControl.Info.ConfirmLocalModsDelete") + "\n\n" + GetSomeFiles(hasModification);
                if (MessageBox.Show(msg, title, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
                {
                    return(true);
                }
            }

            return(result.Manager.FileActions.FileDelete(paths, confirm));
        }