bool CompareFileStateMask(IVsProject pscp, uint itemid, long stateMask)
        {
            string childFilename = string.Empty;

            if (GetItemFileName(pscp, itemid, out childFilename))
            {
                HGLib.HGFileStatus status = this.sccService.GetFileStatus(childFilename);
                if ((stateMask & (long)status) != 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
0
        public void ShowHgHistoryDlg(string fileName)
        {
            StoreSolution();

            if (fileName != string.Empty)
            {
                HGLib.HGFileStatus status = this.sccService.GetFileStatus(fileName);
                if (status != HGLib.HGFileStatus.scsUncontrolled &&
                    status != HGLib.HGFileStatus.scsAdded &&
                    status != HGLib.HGFileStatus.scsIgnored)
                {
                    LogDialog(fileName);
                }
            }
        }
Esempio n. 3
0
        OLECMDF QueryStatus_icmdHgDiff()
        {
            string filename = GetSingleSelectedFileName();

            if (filename != String.Empty)
            {
                HGLib.HGFileStatus status = this.sccService.GetFileStatus(filename);
                if (status != HGLib.HGFileStatus.scsUncontrolled &&
                    status != HGLib.HGFileStatus.scsAdded &&
                    status != HGLib.HGFileStatus.scsIgnored &&
                    status != HGLib.HGFileStatus.scsClean)
                {
                    return(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED);
                }
            }

            return(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE);
        }
        // ------------------------------------------------------------------------
        // find selected file state mask - for quick menu flags detection
        // ------------------------------------------------------------------------
        public bool FindSelectedFirstMask(bool includeChildItems, long stateMask)
        {
            var selectedNodes = GetSelectedNodes();

            foreach (VSITEMSELECTION node in selectedNodes)
            {
                IVsProject pscp = node.pHier as IVsProject;

                string filename = string.Empty;
                if (pscp != null)
                {
                    GetItemFileName(pscp, node.itemid, out filename);
                }
                else
                {
                    filename = GetSolutionFileName();
                }
                if (filename != string.Empty)
                {
                    HGLib.HGFileStatus status = this.sccService.GetFileStatus(filename);
                    if ((stateMask & (long)status) != 0)
                    {
                        return(true);
                    }
                }
            }

            if (includeChildItems)
            {
                foreach (VSITEMSELECTION node in selectedNodes)
                {
                    IVsProject pscp = node.pHier as IVsProject;

                    if (pscp != null)
                    {
                        if (FindProjectSelectedFileStateMask(node.pHier, node.itemid, stateMask))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Esempio n. 5
0
        // ------------------------------------------------------------------------
        // get item index by status
        // ------------------------------------------------------------------------
        int GetStateIcon(HGLib.HGFileStatus status)
        {
            switch (status)
            {
            case HGLib.HGFileStatus.scsMissing: return(5);      // missing

            case HGLib.HGFileStatus.scsModified: return(1);     // modified

            case HGLib.HGFileStatus.scsAdded: return(2);        // added

            case HGLib.HGFileStatus.scsRemoved: return(4);      // removed

            case HGLib.HGFileStatus.scsRenamed: return(3);      // renamed

            case HGLib.HGFileStatus.scsCopied: return(6);       // copied

            case HGLib.HGFileStatus.scsUncontrolled: return(5); // unknown
            }
            return(0);
        }
Esempio n. 6
0
        public void HgAddSelected(List <string> array)
        {
            StoreSolution();

            List <string> addList = new List <string>();

            foreach (string name in array)
            {
                HGLib.HGFileStatus status = this.sccService.GetFileStatus(name);
                if (status == HGLib.HGFileStatus.scsUncontrolled ||
                    status == HGLib.HGFileStatus.scsIgnored)
                {
                    addList.Add(name);
                }
            }

            if (addList.Count > 0)
            {
                AddFilesDialog(addList.ToArray());
            }
        }
Esempio n. 7
0
        public void CommitDialog(List <string> array)
        {
            StoreSolution();

            List <string> commitList = new List <string>();

            foreach (string name in array)
            {
                HGLib.HGFileStatus status = this.sccService.GetFileStatus(name);
                if (status != HGLib.HGFileStatus.scsUncontrolled &&
                    status != HGLib.HGFileStatus.scsClean &&
                    status != HGLib.HGFileStatus.scsIgnored)
                {
                    commitList.Add(name);
                }
            }

            if (commitList.Count > 0)
            {
                CommitDialog(commitList.ToArray());
            }
        }
Esempio n. 8
0
        public void ShowHgDiffDlg(string fileName)
        {
            StoreSolution();

            if (fileName != String.Empty)
            {
                string versionedFile = fileName;

                HGLib.HGFileStatus status = this.sccService.GetFileStatus(fileName);
                if (status != HGLib.HGFileStatus.scsUncontrolled &&
                    status != HGLib.HGFileStatus.scsAdded &&
                    status != HGLib.HGFileStatus.scsIgnored)
                {
                    if (status == HGLib.HGFileStatus.scsRenamed ||
                        status == HGLib.HGFileStatus.scsCopied)
                    {
                        versionedFile = HGLib.HG.GetOriginalOfRenamedFile(fileName);
                    }

                    if (versionedFile != null)
                    {
                        try
                        {
                            DiffDialog(versionedFile, fileName, Configuration.Global.ExternalDiffToolCommandMask);
                        }
                        catch
                        {
                            if (Configuration.Global.ExternalDiffToolCommandMask != string.Empty)
                            {
                                MessageBox.Show("The DiffTool raised an error\nPlease check your command mask:\n\n" + Configuration.Global.ExternalDiffToolCommandMask,
                                                "VisualHG",
                                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        // ------------------------------------------------------------------------
        // update menu flags on list selection changed event
        private void _pendingItemsListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            // enable menu commands
            bool singleSel = false;

            HGLib.HGFileStatus status = HGLib.HGFileStatus.scsUncontrolled;
            if (_pendingItemsListView.SelectedIndices.Count > 0)
            {
                singleSel = (_pendingItemsListView.SelectedIndices.Count == 1) ? true : false;
                int index = _pendingItemsListView.SelectedIndices[0];
                HGLib.HGFileStatusInfo info = _pendingItemsListView._list[index];
                status = info.status;
            }

            annotateFileToolStripMenuItem.Visible = singleSel && status != HGLib.HGFileStatus.scsAdded &&
                                                    status != HGLib.HGFileStatus.scsRemoved &&
                                                    status != HGLib.HGFileStatus.scsRenamed;
            diffToolStripMenuItem.Visible = singleSel && status != HGLib.HGFileStatus.scsRemoved &&
                                            status != HGLib.HGFileStatus.scsAdded;
            historyToolStripMenuItem.Visible = singleSel && status != HGLib.HGFileStatus.scsAdded &&
                                               status != HGLib.HGFileStatus.scsRenamed;
            openInEditorToolStripMenuItem.Visible = status != HGLib.HGFileStatus.scsRemoved;
        }
Esempio n. 10
0
        public void HgAnnotateDlg(string fileName)
        {
            StoreSolution();

            if (fileName != String.Empty)
            {
                HGLib.HGFileStatus status = this.sccService.GetFileStatus(fileName);
                if (status == HGLib.HGFileStatus.scsRenamed)
                {
                    // get original filename
                    string orgName = HGLib.HG.GetOriginalOfRenamedFile(fileName);
                    if (orgName != string.Empty)
                    {
                        HGLib.HGTK.AnnotateDialog(orgName);
                    }
                }

                if (status != HGLib.HGFileStatus.scsUncontrolled &&
                    status != HGLib.HGFileStatus.scsIgnored)
                {
                    HGLib.HGTK.AnnotateDialog(fileName);
                }
            }
        }
Esempio n. 11
0
        public void HgRevertFileDlg(string[] array)
        {
            StoreSolution();

            List <string> addList = new List <string>();

            foreach (string name in array)
            {
                HGLib.HGFileStatus status = this.sccService.GetFileStatus(name);
                if (status == HGLib.HGFileStatus.scsModified ||
                    status == HGLib.HGFileStatus.scsAdded ||
                    status == HGLib.HGFileStatus.scsCopied ||
                    status == HGLib.HGFileStatus.scsRemoved ||
                    status == HGLib.HGFileStatus.scsRenamed)
                {
                    addList.Add(name);
                }
            }

            if (addList.Count > 0)
            {
                RevertDialog(addList.ToArray());
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Provide source control icons for the specified files and returns scc status of files
        /// </summary>
        /// <returns>The method returns S_OK if at least one of the files is controlled, S_FALSE if none of them are</returns>
        public int GetSccGlyph([InAttribute] int cFiles, [InAttribute] string[] rgpszFullPaths, [OutAttribute] VsStateIcon[] rgsiGlyphs, [OutAttribute] uint[] rgdwSccStatus)
        {
            if (rgpszFullPaths[0] == null)
            {
                return(0);
            }

            // Return the icons and the status. While the status is a combination a flags, we'll return just values
            // with one bit set, to make life easier for GetSccGlyphsFromStatus
            HGLib.HGFileStatus status = _sccStatusTracker.GetFileStatus(rgpszFullPaths[0]);
            if (rgdwSccStatus != null)
            {
                rgdwSccStatus[0] = 1; //__SccStatus.SCC_STATUS_CONTROLLED; -> SCC_STATUS_CONTROLLED = 1
            }
            switch (status)
            {
            // STATEICON_CHECKEDIN schloss
            // STATEICON_CHECKEDOUT roter haken
            // STATEICON_CHECKEDOUTEXCLUSIVE roter haken
            // STATEICON_CHECKEDOUTSHAREDOTHER männchen
            // STATEICON_DISABLED roter ring / durchgestrichen
            //  STATEICON_EDITABLE bleistift
            // STATEICON_EXCLUDEDFROMSCC einbahnstrasse
            // STATEICON_MAXINDEX nix
            // STATEICON_NOSTATEICON nix
            // STATEICON_ORPHANED blaue flagge
            // STATEICON_READONLY schloss

            // my states
            case HGLib.HGFileStatus.scsClean:
                rgsiGlyphs[0] = (VsStateIcon)(_baseIndex + 0);
                break;

            case HGLib.HGFileStatus.scsModified:
                rgsiGlyphs[0] = (VsStateIcon)(_baseIndex + 1);
                break;

            case HGLib.HGFileStatus.scsAdded:
                rgsiGlyphs[0] = (VsStateIcon)(_baseIndex + 2);
                break;

            case HGLib.HGFileStatus.scsRenamed:
                rgsiGlyphs[0] = (VsStateIcon)(_baseIndex + 3);
                break;

            case HGLib.HGFileStatus.scsCopied:
                rgsiGlyphs[0] = (VsStateIcon)(_baseIndex + 3);     // no better icon
                break;

            case HGLib.HGFileStatus.scsRemoved:
                rgsiGlyphs[0] = (VsStateIcon)(_baseIndex + 1);
                break;

            case HGLib.HGFileStatus.scsIgnored:
                rgsiGlyphs[0] = VsStateIcon.STATEICON_BLANK;
                break;

            case HGLib.HGFileStatus.scsUncontrolled:
                rgsiGlyphs[0] = VsStateIcon.STATEICON_BLANK;
                break;
            }

            return(VSConstants.S_OK);
        }
Esempio n. 13
0
        //--------------------------------------------------------------------------------
        // IVsSccManagerTooltip specific functions
        //--------------------------------------------------------------------------------
        #region IVsSccManagerTooltip interface functions

        /// <summary>
        /// Called by solution explorer to provide tooltips for items. Returns a text describing the source control status of the item.
        /// </summary>
        public int GetGlyphTipText([InAttribute] IVsHierarchy phierHierarchy, [InAttribute] uint itemidNode, out string pbstrTooltipText)
        {
            // Initialize output parameters
            pbstrTooltipText = "";

            IList <string> files = SccProvider.GetNodeFiles(phierHierarchy, itemidNode);

            if (files.Count == 0)
            {
                return(VSConstants.S_OK);
            }

            // Return the glyph text based on the first file of node (the master file)
            HGLib.HGFileStatus status = _sccStatusTracker.GetFileStatus(files[0]);
            switch (status)
            {
            // my states
            case HGLib.HGFileStatus.scsClean:
                pbstrTooltipText = "Clean";
                break;

            case HGLib.HGFileStatus.scsModified:
                pbstrTooltipText = "Modified";
                break;

            case HGLib.HGFileStatus.scsAdded:
                pbstrTooltipText = "Added";
                break;

            case HGLib.HGFileStatus.scsRenamed:
                pbstrTooltipText = "Renamed";
                break;

            case HGLib.HGFileStatus.scsRemoved:
                pbstrTooltipText = "Removed";
                break;

            case HGLib.HGFileStatus.scsCopied:
                pbstrTooltipText = "Copied";
                break;

            case HGLib.HGFileStatus.scsIgnored:
                pbstrTooltipText = "Ignored";
                break;

            case HGLib.HGFileStatus.scsUncontrolled:
                pbstrTooltipText = "Uncontrolled";
                break;

            default:
                pbstrTooltipText = string.Empty;
                break;
            }

            if (pbstrTooltipText != string.Empty)
            {
                string root = HGLib.HG.FindRootDirectory(files[0]);
                //string branchName = HGLib.HG.GetCurrentBranchName(root);
                string branchName = _sccStatusTracker.GetCurrentBranchOf(root);

                pbstrTooltipText += " [" + branchName + "]";
            }

            return(VSConstants.S_OK);
        }