예제 #1
0
        override protected void runner_Output(object sender, string line)
        {
            int fileIndex = 3;

            if (line.Length < fileIndex || line.Length < 3)
            {
                return;
            }
            char c0 = line[0];
            char c1 = line[1];

            if (c1 == ':')
            {
                return;
            }

            VCItemStatus s = VCItemStatus.UpToDate;

            //else if (c0 == 'I') s = VCItemStatus.Ignored; // TODO look into .gitignore
            if (c0 == '?')
            {
                s = VCItemStatus.Unknown;
            }
            if (c0 == 'U')
            {
                s = VCItemStatus.Conflicted;
            }
            else if (c0 == 'A')
            {
                s = VCItemStatus.Added;
            }
            else if (c0 == 'C')
            {
                s = VCItemStatus.Added;                 // copied
            }
            else if (c0 == 'R')
            {
                s = VCItemStatus.Added;                 // renamed
            }
            else if (c0 == 'M' || c1 == 'M')
            {
                s = VCItemStatus.Modified;
            }
            else if (c0 == 'D' || c1 == 'D')
            {
                s = VCItemStatus.Deleted;
            }

            int p = line.IndexOf(" -> ");

            if (p > 0)
            {
                line = line.Substring(p + 4);
            }
            else
            {
                line = line.Substring(fileIndex);
            }
            temp.MapPath(line, s);
        }
예제 #2
0
        static public void SetOverlay(VCItemStatus status, TreeNode node, TreeView tree)
        {
            if (!maps.ContainsKey(status))
            {
                return;
            }
            OverlayMap map = maps[status];

            if (map.ContainsKey(node.ImageIndex))
            {
                node.SelectedImageIndex = node.ImageIndex = map[node.ImageIndex];
                return;
            }

            if (tree.ImageList.Images.Count <= node.ImageIndex)
            {
                return;
            }

            Image  original = tree.ImageList.Images[node.ImageIndex];
            Bitmap composed = original.Clone() as Bitmap;

            using (Graphics destination = Graphics.FromImage(composed))
            {
                destination.DrawImage(iconSkin, new Rectangle(0, 0, 16, 16),
                                      new Rectangle((int)status * 16, 0, 16, 16), GraphicsUnit.Pixel);
            }
            int index = tree.ImageList.Images.Count;

            tree.ImageList.Images.Add(composed);
            map[node.ImageIndex]    = index;
            node.SelectedImageIndex = node.ImageIndex = index;
        }
예제 #3
0
        override protected void runner_Output(object sender, string line)
        {
            int fileIndex = 30;

            if (line.Length < fileIndex)
            {
                return;
            }
            char c0 = line[0];
            char c1 = line[1];

            VCItemStatus s = VCItemStatus.Unknown;

            if (c0 == '?')
            {
                return;
            }
            if (c0 == 'M' || c1 == 'M')
            {
                s = VCItemStatus.Modified;
            }
            else if (c0 == 'I')
            {
                s = VCItemStatus.Ignored;
            }
            else if (c0 == ' ')
            {
                s = VCItemStatus.UpToDate;
            }
            else if (c0 == 'A')
            {
                s = VCItemStatus.Added;
            }
            else if (c0 == 'D')
            {
                s = VCItemStatus.Deleted;
            }
            else if (c0 == 'C')
            {
                s = VCItemStatus.Conflicted;
            }
            else if (c0 == 'R')
            {
                s = VCItemStatus.Replaced;
            }
            else if (c0 == 'X')
            {
                s = VCItemStatus.External;
            }
            else if (c0 == '!')
            {
                s = VCItemStatus.Missing;
            }

            if (s != VCItemStatus.Unknown)
            {
                line = line.Substring(line.IndexOf(' ', fileIndex) + 1).Trim();
                temp.MapPath(line, s);
            }
        }
예제 #4
0
        override protected void Runner_Output(object sender, string line)
        {
            int fileIndex = 0;

            if (line.Length < 3)
            {
                return;
            }
            char c0 = line[0];
            char c1 = line[1];

            VCItemStatus s = VCItemStatus.Added;

            if (c0 == '?')
            {
                s = VCItemStatus.Unknown;
            }
            else if (c0 == '!')
            {
                s = VCItemStatus.Missing;
            }
            else if (c0 == 'A')
            {
                s = VCItemStatus.Added;
            }
            else if (c0 == 'C')
            {
                s = VCItemStatus.UpToDate;                 // clean == UpToDate
            }
            else if (c0 == 'I')
            {
                s = VCItemStatus.Ignored;
            }
            else if (c0 == 'M' || c1 == 'M')
            {
                s = VCItemStatus.Modified;
            }
            else if (c0 == 'R' || c1 == 'R')
            {
                s = VCItemStatus.Deleted;
            }

            if (s == VCItemStatus.Unknown)
            {
                return;
            }
            int p = line.IndexOf(" ");

            if (p > 0)
            {
                line = line.Substring(p + 1);
            }
            else
            {
                line = line.Substring(fileIndex);
            }
            temp.MapPath(line, s);
        }
예제 #5
0
        /// <summary>
        /// Recursively create (if needed) nodes to match the path
        /// </summary>
        /// <returns>Last node of the path</returns>
        public StatusNode MapPath(string path, VCItemStatus status)
        {
            int p = path.IndexOf(Path.DirectorySeparatorChar);

            if (p < 0)
            {
                return(AddChild(path, status, true));
            }
            else
            {
                return(AddChild(path.Substring(0, p), status, false)
                       .MapPath(path.Substring(p + 1), status));
            }
        }
예제 #6
0
        private StatusNode AddChild(string name, VCItemStatus status, bool isLeaf)
        {
            if (name == ".")
            {
                if (status != VCItemStatus.Unknown)
                {
                    Status = status;
                }
                return(this);
            }

            // inherit child status
            if (Status < status && status > VCItemStatus.UpToDate)
            {
                Status = status == VCItemStatus.Conflicted ? status : VCItemStatus.Modified;
            }

            // add/retrieve child
            if (!isLeaf)
            {
                if (status > VCItemStatus.UpToDate && status != VCItemStatus.Conflicted)
                {
                    status = VCItemStatus.Modified;
                }
                else
                {
                    status = VCItemStatus.UpToDate;
                }
            }

            StatusNode node = new StatusNode(name, status);

            node.Parent = this;
            if (!HasChildren)
            {
                HasChildren = true;
                Children    = new Dictionary <string, StatusNode>();
                Children.Add(name, node);
            }
            else if (Children.ContainsKey(name))
            {
                return(Children[name]);
            }
            else
            {
                Children.Add(name, node);
            }
            return(node);
        }
예제 #7
0
        /// <summary>
        /// Recursively create (if needed) nodes to match the path
        /// </summary>
        /// <returns>Last node of the path</returns>
        public StatusNode MapPath(string path, VCItemStatus status)
        {
            int p = path.IndexOf('/');

            if (p < 0)
            {
                return(AddChild(path, status, true));
            }
            else if (p == path.Length - 1)
            {
                return(AddChild(path.Substring(0, path.Length - 1), status, true));
            }
            else
            {
                return(AddChild(path.Substring(0, p), status, false)
                       .MapPath(path.Substring(p + 1), status));
            }
        }
예제 #8
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);
            }
        }
예제 #9
0
        static public void SetOverlay(VCItemStatus status, TreeNode node, TreeView tree)
        {
            if (!maps.ContainsKey(status))
            {
                return;
            }
            OverlayMap map = maps[status];

            if (map.ContainsKey(node.ImageIndex))
            {
                node.SelectedImageIndex = node.ImageIndex = map[node.ImageIndex];
                return;
            }

            if (tree.ImageList.Images.Count <= node.ImageIndex)
            {
                return;
            }

            Image  original = tree.ImageList.Images[node.ImageIndex];
            Bitmap composed = original.Clone() as Bitmap;
            Int32  curSize  = ScaleHelper.GetScale() > 1.5 ? 32 : 16;

            using (Graphics destination = Graphics.FromImage(composed))
            {
                destination.DrawImage(iconSkin,
                                      new Rectangle(0, 0, composed.Width, composed.Height),
                                      new Rectangle((int)status * curSize, 0, curSize, curSize), GraphicsUnit.Pixel);
            }
            int index = tree.ImageList.Images.Count;

            composed = (Bitmap)PluginCore.PluginBase.MainForm.ImageSetAdjust((Image)composed);
            tree.ImageList.Images.Add(composed);
            map[node.ImageIndex]    = index;
            node.SelectedImageIndex = node.ImageIndex = index;
        }
예제 #10
0
 private static void AddOverlay(VCItemStatus status)
 {
     maps.Add(status, new OverlayMap());
 }
예제 #11
0
        private StatusNode AddChild(string name, VCItemStatus status, bool isLeaf)
        {
            if (name == ".")
            {
                if (status != VCItemStatus.Unknown) Status = status;
                return this;
            }

            // inherit child status
            if (Status < status && status > VCItemStatus.UpToDate)
                Status = status == VCItemStatus.Conflicted ? status : VCItemStatus.Modified;

            // add/retrieve child
            if (!isLeaf && status > VCItemStatus.UpToDate && status != VCItemStatus.Conflicted)
                status = VCItemStatus.Modified;

            StatusNode node = new StatusNode(name, status);
            node.Parent = this;
            if (!HasChildren)
            {
                HasChildren = true;
                Children = new Dictionary<string, StatusNode>();
                Children.Add(name, node);
            }
            else if (Children.ContainsKey(name))
            {
                return Children[name];
            }
            else Children.Add(name, node);
            return node;
        }
예제 #12
0
 public VCStatusReport(string path, VCItemStatus status)
 {
     Path   = path;
     Status = status;
 }
예제 #13
0
 /// <summary>
 /// Recursively create (if needed) nodes to match the path
 /// </summary>
 /// <returns>Last node of the path</returns>
 public StatusNode MapPath(string path, VCItemStatus status)
 {
     int p = path.IndexOf(Path.DirectorySeparatorChar);
     if (p < 0) return AddChild(path, status, true);
     else return AddChild(path.Substring(0, p), status, false)
         .MapPath(path.Substring(p + 1), status);
 }
예제 #14
0
 public StatusNode(string name, VCItemStatus status)
 {
     Name = name;
     Status = status;
 }
예제 #15
0
 public VCStatusReport(string path, VCItemStatus status)
 {
     Path = path;
     Status = status;
 }
예제 #16
0
 /// <summary>
 /// Recursively create (if needed) nodes to match the path
 /// </summary>
 /// <returns>Last node of the path</returns>
 public StatusNode MapPath(string path, VCItemStatus status)
 {
     int p = path.IndexOf('/');
     if (p < 0) return AddChild(path, status, true);
     else if (p == path.Length - 1) return AddChild(path.Substring(0, path.Length - 1), status, true);
     else return AddChild(path.Substring(0, p), status, false)
         .MapPath(path.Substring(p + 1), status);
 }
예제 #17
0
        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));
        }
예제 #18
0
        public ProjectSelectionState(ProjectTreeView tree)
        {
            if (tree == null || tree.SelectedNodes.Count == 0)
            {
                return;
            }

            foreach (TreeNode node in tree.SelectedNodes)
            {
                if (node is FileNode)
                {
                    Files++;
                }
                else if (node is DirectoryNode)
                {
                    Dirs++;
                }
                else
                {
                    return;  // unknown node in selection - no action
                }
                GenericNode gnode = (GenericNode)node;
                if (gnode.Meta == null || !gnode.Meta.ContainsKey(OverlayManager.META_STATUS) ||
                    !gnode.Meta.ContainsKey(OverlayManager.META_VC))
                {
                    return; // incomplete status
                }
                if (Manager == null)
                {
                    Manager = gnode.Meta[OverlayManager.META_VC] as IVCManager;
                }
                else if (gnode.Meta[OverlayManager.META_VC] != Manager)
                {
                    return; // several managers...
                }
                VCItemStatus status = (VCItemStatus)(gnode.Meta[OverlayManager.META_STATUS]);
                if (status == VCItemStatus.Unknown)
                {
                    Unknown++;
                }
                else if (status == VCItemStatus.Ignored)
                {
                    Ignored++;
                }
                else if (status == VCItemStatus.Added)
                {
                    Added++;
                }
                else if (status == VCItemStatus.Conflicted)
                {
                    Conflict++;
                }
                else if (status == VCItemStatus.Modified)
                {
                    Modified++; Revert++; Diff++;
                }
                else if (status == VCItemStatus.Deleted)
                {
                    Revert++; Diff++;
                }
                else if (status == VCItemStatus.Replaced)
                {
                    Replaced++; Revert++;
                }
                else
                {
                    Other++;
                }
                Total++;
            }
        }
예제 #19
0
 public StatusNode(string name, VCItemStatus status)
 {
     Name   = name;
     Status = status;
 }