Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SvnOrigin"/> class from a SvnTarget
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="target">The target.</param>
        /// <param name="reposRoot">The repos root or <c>null</c> to retrieve the repository root from target</param>
        public SvnOrigin(IAnkhServiceProvider context, SvnTarget target, Uri reposRoot)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            else if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            SvnPathTarget pt = target as SvnPathTarget;

            if (pt != null)
            {
                SvnItem item = context.GetService <ISvnStatusCache>()[pt.FullPath];

                if (item == null || !item.IsVersioned)
                {
                    throw new InvalidOperationException("Can only create a SvnOrigin from versioned items");
                }

                _target    = target;
                _uri       = item.Status.Uri;
                _reposRoot = item.WorkingCopy.RepositoryRoot; // BH: Prefer the actual root over the provided
                return;
            }

            SvnUriTarget ut = target as SvnUriTarget;

            if (ut != null)
            {
                _target = ut;
                _uri    = ut.Uri;
                if (reposRoot != null)
                {
                    _reposRoot = reposRoot;
                }
                else
                {
                    using (SvnClient client = context.GetService <ISvnClientPool>().GetClient())
                    {
                        _reposRoot = client.GetRepositoryRoot(ut.Uri);

                        if (_reposRoot == null)
                        {
                            throw new InvalidOperationException("Can't retrieve the repository root of the UriTarget");
                        }

#if DEBUG
                        Debug.Assert(!_reposRoot.MakeRelativeUri(_uri).IsAbsoluteUri);
#endif
                    }
                }

                return;
            }

            throw new InvalidOperationException("Invalid target type");
        }
Esempio n. 2
0
        public void RefreshText(IAnkhServiceProvider context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            ISvnStatusCache cache = context.GetService <ISvnStatusCache>();

            ImageIndex = PendingChange.IconIndex;
            SvnItem item = cache[FullPath];

            if (item == null)
            {
                throw new InvalidOperationException(); // Item no longer valued
            }
            PendingChangeStatus pcs = PendingChange.Change ?? new PendingChangeStatus(PendingChangeKind.None);

            SetValues(
                pcs.PendingCommitText,
                PendingChange.ChangeList,
                GetDirectory(item),
                PendingChange.FullPath,
                item.IsLocked ? PCResources.LockedValue : "", // Locked
                SafeDate(item.Modified),                      // Modified
                PendingChange.Name,
                PendingChange.RelativePath,
                PendingChange.Project,
                context.GetService <IFileIconMapper>().GetFileType(item),
                SafeWorkingCopy(item));
        }
Esempio n. 3
0
        public static void MaybePerformUpdateCheck(IAnkhServiceProvider context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (_checkedOnce)
            {
                return;
            }

            _checkedOnce = true;

            IAnkhConfigurationService config = context.GetService <IAnkhConfigurationService>();

            using (RegistryKey rk = config.OpenUserInstanceKey("UpdateCheck"))
            {
                int    interval = 24 * 6; // 6 days
                object value    = rk.GetValue("Interval");

                if (value is int)
                {
                    interval = (int)value;

                    if (interval <= 0)
                    {
                        return;
                    }
                }

                TimeSpan ts = TimeSpan.FromHours(interval);

                value = rk.GetValue("LastVersion");

                if (IsDevVersion() || (value is string && (string)value == GetCurrentVersion(context).ToString()))
                {
                    value = rk.GetValue("LastCheck");
                    long lv;
                    if (value is string && long.TryParse((string)value, out lv))
                    {
                        DateTime lc = new DateTime(lv, DateTimeKind.Utc);

                        if ((lc + ts) > DateTime.UtcNow)
                        {
                            return;
                        }

                        // TODO: Check the number of fails to increase the check interval
                    }
                }
            }

            context.GetService <IAnkhScheduler>().Schedule(new TimeSpan(0, 0, 20), AnkhCommand.CheckForUpdates);
        }
 public RefreshState(IAnkhServiceProvider context, IVsHierarchy hier, IVsProject project, string projectDir)
 {
     _hier       = hier;
     _cache      = context.GetService <ISvnStatusCache>();
     _walker     = context.GetService <ISccProjectWalker>();
     _project    = project as IVsProject2;
     _projectDir = projectDir;
     if (projectDir != null)
     {
         _projectDirItem = Cache[projectDir];
     }
 }
Esempio n. 5
0
        static void PerformLog(IAnkhServiceProvider context, ICollection <SvnOrigin> targets, SvnRevision start, SvnRevision end)
        {
            IAnkhPackage package = context.GetService <IAnkhPackage>();

            package.ShowToolWindow(AnkhToolWindow.Log);

            LogToolWindowControl logToolControl = context.GetService <ISelectionContext>().ActiveFrameControl as LogToolWindowControl;

            if (logToolControl != null)
            {
                logToolControl.StartLog(targets, start, end);
            }
        }
Esempio n. 6
0
        private Uri GetRepositoryRoot()
        {
            if (_checkedUri)
            {
                return(null);
            }


            _checkedUri = true;
            using (SvnClient client = _context.GetService <ISvnClientPool>().GetNoUIClient())
            {
                return(_repositoryRoot = client.GetRepositoryRoot(FullPath));
            }
        }
Esempio n. 7
0
            public int SccGlyphChanged(int cAffectedNodes, uint[] rgitemidAffectedNodes, VsStateIcon[] rgsiNewGlyphs, uint[] rgdwNewSccStatus)
            {
                IVsSccManager2 sccService = _context.GetService <IVsSccManager2>(typeof(SVsSccManager));

                string[] rgpszFullPaths = new string[1];
                rgpszFullPaths[0] = GetSolutionFileName(_context);
                VsStateIcon[] rgsiGlyphs    = new VsStateIcon[1];
                uint[]        rgdwSccStatus = new uint[1];
                sccService.GetSccGlyph(1, rgpszFullPaths, rgsiGlyphs, rgdwSccStatus);

                // Set the solution's glyph directly in the hierarchy
                IVsHierarchy solHier = (IVsHierarchy)_context.GetService(typeof(SVsSolution));

                return(solHier.SetProperty(VSItemId.Root, (int)__VSHPROPID.VSHPROPID_StateIconIndex, (int)rgsiGlyphs[0]));
            }
Esempio n. 8
0
        private static bool TryGetDteVersion(IAnkhServiceProvider context, out Version version)
        {
            version = null;
            Type dteType = Type.GetType("EnvDTE._DTE, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", false);

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

            Object dte = context.GetService(typeof(SDTE));

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

            System.Reflection.MethodInfo method = dteType.GetMethod("get_Version");

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

            string verStr = method.Invoke(dte, null) as string;

            if (verStr != null)
            {
                version = new Version(verStr);
                return(true);
            }

            return(false);
        }
Esempio n. 9
0
        public void RefreshText(IAnkhServiceProvider context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            IFileStatusCache cache = context.GetService<IFileStatusCache>();

            ImageIndex = PendingChange.IconIndex;
            SvnItem item = cache[FullPath];

            if (item == null)
                throw new InvalidOperationException(); // Item no longer valued
            PendingChangeStatus pcs = PendingChange.Change ?? new PendingChangeStatus(PendingChangeKind.None);

            SetValues(
                pcs.PendingCommitText,
                PendingChange.ChangeList,
                GetDirectory(item),
                PendingChange.FullPath,
                item.IsLocked ? PCStrings.LockedValue : "", // Locked
                SafeDate(item.Modified), // Modified
                PendingChange.Name,
                PendingChange.RelativePath,
                PendingChange.Project,
                context.GetService<IFileIconMapper>().GetFileType(item),
                SafeWorkingCopy(item));
        }
Esempio n. 10
0
            public ProjectListFilter(IAnkhServiceProvider context, IEnumerable <SccProject> projects)
            {
                if (context == null)
                {
                    throw new ArgumentNullException("context");
                }
                if (projects == null)
                {
                    throw new ArgumentNullException("projects");
                }

                _mapper = context.GetService <IProjectFileMapper>();
                List <SccProject> projectList = new List <SccProject>(projects);

                files.AddRange(_mapper.GetAllFilesOf(projectList));

                foreach (SccProject p in projectList)
                {
                    ISccProjectInfo pi = _mapper.GetProjectInfo(p);

                    if (pi == null)
                    {
                        continue; // Ignore solution and non scc projects
                    }
                    string dir = pi.ProjectDirectory;

                    if (!string.IsNullOrEmpty(dir) && !folders.Contains(dir))
                    {
                        folders.Add(dir);
                    }
                }
            }
Esempio n. 11
0
            public void Tick()
            {
                if (_dlg == null)
                {
                    if (_start > DateTime.UtcNow)
                    {
                        return;
                    }

                    IVsThreadedWaitDialog dlg = _context.GetService <IVsThreadedWaitDialog>(typeof(SVsThreadedWaitDialog));

                    if (dlg != null)
                    {
                        if (VSErr.Succeeded(dlg.StartWaitDialog(_caption, _message, null, (uint)__VSTWDFLAGS.VSTWDFLAGS_TOPMOST, null, null)))
                        {
                            _dlg = dlg;
                        }
                    }
                }
                else
                {
                    int canceled;
                    _dlg.GiveTimeSlice(null, null, 0, out canceled);
                }
            }
Esempio n. 12
0
 public ProjectNotifier(IAnkhServiceProvider context)
     : base(context)
 {
     uint cookie;
     if (ErrorHandler.Succeeded(context.GetService<IVsShell>(typeof(SVsShell)).AdviseBroadcastMessages(this, out cookie)))
         _cookie = cookie;
 }
Esempio n. 13
0
        private static void FindRoot(IAnkhServiceProvider context, Uri selectedUri, CheckoutProject dlg)
        {
            AnkhAction ds = delegate
            {
                using (SvnClient client = context.GetService <ISvnClientPool>().GetClient())
                {
                    string value;
                    if (client.TryGetProperty(selectedUri, AnkhSccPropertyNames.ProjectRoot, out value))
                    {
                        if (dlg.IsHandleCreated)
                        {
                            dlg.Invoke((AnkhAction) delegate
                            {
                                try
                                {
                                    dlg.ProjectTop = new Uri(selectedUri, value);
                                }
                                catch { };
                            });
                        }
                    }
                }
            };

            ds.BeginInvoke(null, null);
        }
Esempio n. 14
0
        const int VSSPROPID_ReleaseVersion = -9068; // VS 12+

        internal static void Ensure(IAnkhServiceProvider context)
        {
            if (FullVersion.Major == 0)
            {
                // Use the old DTE api in an attempt to get the version
                Version ver;
                if (TryGetDteVersion(context, out ver))
                {
                    _vsVersion = ver;
                }
            }

            if (FullVersion.Major == 0)
            {
                string versionStr = null;

                // VS 2012 has a shell property
                IVsShell shell = context.GetService <IVsShell>(typeof(SVsShell));
                if (shell != null)
                {
                    object v;
                    if (VSErr.Succeeded(shell.GetProperty(VSSPROPID_ReleaseVersion, out v)))
                    {
                        versionStr = v as string;
                    }
                }

                if (!string.IsNullOrEmpty(versionStr))
                {
                    ParseVersion(versionStr);
                }
            }
        }
Esempio n. 15
0
        List <IVsHierarchy> GetProjects(IAnkhServiceProvider context, __VSENUMPROJFLAGS flags)
        {
            IVsSolution      solution = context.GetService <IVsSolution>(typeof(SVsSolution));
            Guid             gNone    = Guid.Empty;
            IEnumHierarchies hierEnum;

            Marshal.ThrowExceptionForHR(solution.GetProjectEnum((uint)flags, ref gNone, out hierEnum));

            IVsHierarchy[]      hiers  = new IVsHierarchy[32];
            List <IVsHierarchy> result = new List <IVsHierarchy>();

            uint fetched;

            while (VSErr.Succeeded(hierEnum.Next((uint)hiers.Length, hiers, out fetched)))
            {
                if ((int)fetched == hiers.Length)
                {
                    result.AddRange(hiers);
                }
                else if (fetched > 0)
                {
                    for (int i = 0; i < (int)fetched; i++)
                    {
                        result.Add(hiers[i]);
                    }
                }
                else
                {
                    break;
                }
            }

            return(result);
        }
Esempio n. 16
0
        /// <summary>
        /// Shows the log viewer and sets the revision cell value to the selected revision
        /// </summary>
        /// <param name="row"></param>
        private void SelectRevision(DataGridViewRow row)
        {
            IAnkhServiceProvider context = Context;

            if (context != null)
            {
                string selectedUriString = row.Cells[0].Value as string;

                Uri selectedUri;
                if (!string.IsNullOrEmpty(selectedUriString) &&
                    Uri.TryCreate(selectedUriString, UriKind.Absolute, out selectedUri)
                    )
                {
                    Uri repoRoot = string.Equals(_lastUsedUriString, selectedUriString) ? _lastRepositoryRoot : null;
                    if (repoRoot == null)
                    {
                        if (context.GetService <IProgressRunner>().RunModal(
                                PropertyEditStrings.RetrievingRepositoryRoot,
                                delegate(object sender, ProgressWorkerArgs a)
                        {
                            repoRoot = a.Client.GetRepositoryRoot(selectedUri);
                        }).Succeeded)
                        {
                            //cache the last used repo uri string and the fetched repository root uri
                            _lastRepositoryRoot = repoRoot;
                            _lastUsedUriString  = selectedUriString;
                        }
                    }
                    if (repoRoot != null)
                    {
                        try
                        {
                            // set the current revision value as the initial selection
                            string             rev       = row.Cells[2].Value as string;
                            SvnRevision        rr        = string.IsNullOrEmpty(rev) ? SvnRevision.None : long.Parse(rev);
                            SvnUriTarget       svnTarget = new SvnUriTarget(selectedUri, rr);
                            Ankh.Scc.SvnOrigin origin    = new Ankh.Scc.SvnOrigin(svnTarget, repoRoot);
                            using (Ankh.UI.SvnLog.LogViewerDialog dlg = new Ankh.UI.SvnLog.LogViewerDialog(origin))
                            {
                                if (dlg.ShowDialog(Context) == DialogResult.OK)
                                {
                                    Ankh.Scc.ISvnLogItem li = EnumTools.GetSingle(dlg.SelectedItems);
                                    rev = li == null ? null : li.Revision.ToString();
                                    //set the revision cell value to the selection revision
                                    row.Cells[2].Value = rev ?? string.Empty;
                                }
                            }
                        }
                        catch
                        {
                            // clear cache in case of error
                            _lastUsedUriString  = null;
                            _lastRepositoryRoot = null;
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Gets a boolean indicating whether a component can continue idle processing. Returns false when idle processing should stop
        /// </summary>
        /// <returns></returns>
        public bool ContinueIdle()
        {
            if (_mgr == null)
            {
                _mgr = _context.GetService <IOleComponentManager>(typeof(SOleComponentManager));
            }

            return(_mgr == null || 0 != _mgr.FContinueIdle());
        }
        internal void OpenItem(IAnkhServiceProvider context, string p)
        {
            Ankh.Commands.IAnkhCommandService cmd = context.GetService <Ankh.Commands.IAnkhCommandService>();

            if (cmd != null)
            {
                cmd.ExecCommand(AnkhCommand.ItemOpenVisualStudio, true);
            }
        }
Esempio n. 19
0
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);

            if (DesignMode)
            {
                return;
            }

            IContextControl      cc      = TopLevelControl as IContextControl;
            IAnkhServiceProvider context = null;

            if (cc != null && cc.Context != null)
            {
                context = cc.Context;
            }
            else
            {
                Control c = Parent;

                while (c != null)
                {
                    cc = c as IContextControl;
                    if (cc != null)
                    {
                        context = cc.Context;
                        break;
                    }

                    context = c as IAnkhServiceProvider;
                    if (context != null)
                    {
                        break;
                    }

                    c = c.Parent;
                }
            }

            if (context == null)
            {
                return;
            }

            IVSTextEditorFactory factory = context.GetService <IVSTextEditorFactory>();

            IVSTextEditorImplementation implementation;

            if (factory != null && factory.TryInstantiateIn(this, out implementation))
            {
                implementation.HorizontalTextScroll += ImplementOnHorizontalTextScroll;
                implementation.VerticalTextScroll   += ImplementOnVerticalTextScroll;
                _implementation = implementation;
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Saves all dirty documents within the provided selection
        /// </summary>
        /// <param name="selection">The selection.</param>
        /// <param name="context">The context.</param>
        protected static void SaveAllDirtyDocuments(ISelectionContext selection, IAnkhServiceProvider context)
        {
            if (selection == null)
                throw new ArgumentNullException("selection");
            if (context == null)
                throw new ArgumentNullException("context");

            IAnkhOpenDocumentTracker tracker = context.GetService<IAnkhOpenDocumentTracker>();
            if (tracker != null)
                tracker.SaveDocuments(selection.GetSelectedFiles(true));
        }
Esempio n. 21
0
        public override void ResetSettings()
        {
            base.ResetSettings();

            IAnkhServiceProvider sp = (IAnkhServiceProvider)GetService(typeof(IAnkhServiceProvider));
            if (sp != null)
            {
                IAnkhConfigurationService cfgSvc = sp.GetService<IAnkhConfigurationService>();
                cfgSvc.LoadDefaultConfig();
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Gets a boolean indicating whether a component can continue idle processing. Returns false when idle processing should stop
        /// </summary>
        /// <returns></returns>
        public bool ContinueIdle()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (_mgr == null)
            {
                _mgr = _context.GetService <IOleComponentManager>(typeof(SOleComponentManager));
            }

            return(_mgr == null || 0 != _mgr.FContinueIdle());
        }
Esempio n. 23
0
        public WCSolutionNode(IAnkhServiceProvider context, SvnItem item)
            : base(context, null, item)
        {
            string file = Context.GetService<IAnkhSolutionSettings>().SolutionFilename;

            IFileIconMapper iconMapper = context.GetService<IFileIconMapper>();

            if (string.IsNullOrEmpty(file))
                _imageIndex = iconMapper.GetIconForExtension(".sln");
            else
                _imageIndex = iconMapper.GetIcon(file);
        }
Esempio n. 24
0
            public OutputPaneReporter(IAnkhServiceProvider context, SvnClient client)
                : base(context)
            {
                if (client == null)
                {
                    throw new ArgumentNullException("client");
                }

                _mgr      = context.GetService <IOutputPaneManager>();
                _sb       = new StringBuilder();
                _reporter = new SvnClientReporter(client, _sb);
            }
Esempio n. 25
0
 private bool DeleteIssueRepositoryProperties(IAnkhServiceProvider context, SvnItem item)
 {
     return(context.GetService <IProgressRunner>().RunModal("Removing Issue Repository settings",
                                                            delegate(object sender, ProgressWorkerArgs wa)
     {
         wa.Client.DeleteProperty(item.FullPath, AnkhSccPropertyNames.IssueRepositoryConnector);
         wa.Client.DeleteProperty(item.FullPath, AnkhSccPropertyNames.IssueRepositoryUri);
         wa.Client.DeleteProperty(item.FullPath, AnkhSccPropertyNames.IssueRepositoryId);
         wa.Client.DeleteProperty(item.FullPath, AnkhSccPropertyNames.IssueRepositoryPropertyNames);
         wa.Client.DeleteProperty(item.FullPath, AnkhSccPropertyNames.IssueRepositoryPropertyValues);
     }).Succeeded);
 }
Esempio n. 26
0
        private void UpdateText()
        {
            IFileIconMapper mapper = Context.GetService <IFileIconMapper>();

            ImageIndex = GetIcon(mapper);

            StateImageIndex = mapper.GetStateIcon(GetIcon(_status));

            SetValues(
                _item.Status.ChangeList,
                _item.Directory,
                _item.FullPath,
                _localStatus.PendingCommitText,
                (_status.RemoteLock != null) ? PCResources.LockedValue : "", // Locked
                SafeDate(_item.Modified),
                _item.Name,
                GetRelativePath(_item),
                GetProject(_item),
                _remoteStatus.PendingCommitText,
                Context.GetService <IFileIconMapper>().GetFileType(_item),
                SafeWorkingCopy(_item));
        }
Esempio n. 27
0
        private static string DoExternalDiff(IAnkhServiceProvider context, IEnumerable <SvnItem> selection, SvnRevision start, SvnRevision end)
        {
            foreach (SvnItem item in selection)
            {
                // skip unmodified for a diff against the textbase
                if (start == SvnRevision.Base && end == SvnRevision.Working && !item.IsModified)
                {
                    continue;
                }

                string tempDir = context.GetService <IAnkhTempDirManager>().GetTempDir();

                AnkhDiffArgs da = new AnkhDiffArgs();

                da.BaseFile = GetPath(context, start, item, tempDir);
                da.MineFile = GetPath(context, end, item, tempDir);


                context.GetService <IAnkhDiffHandler>().RunDiff(da);
            }

            return(null);
        }
Esempio n. 28
0
        private static string GetPath(IAnkhServiceProvider context, SvnRevision revision, SvnItem item, string tempDir)
        {
            if (revision == SvnRevision.Working)
            {
                return(item.FullPath);
            }

            string strRevision;

            if (revision.RevisionType == SvnRevisionType.Time)
            {
                strRevision = revision.Time.ToLocalTime().ToString("yyyyMMdd_hhmmss");
            }
            else
            {
                strRevision = revision.ToString();
            }
            string tempFile = Path.GetFileNameWithoutExtension(item.Name) + "." + strRevision + Path.GetExtension(item.Name);

            tempFile = Path.Combine(tempDir, tempFile);
            // we need to get it from the repos
            context.GetService <IProgressRunner>().RunModal(CommandStrings.RetrievingFileForComparison, delegate(object o, ProgressWorkerArgs ee)
            {
                SvnTarget target;

                switch (revision.RevisionType)
                {
                case SvnRevisionType.Head:
                case SvnRevisionType.Number:
                case SvnRevisionType.Time:
                    target = item.Uri;
                    break;

                default:
                    target = item.FullPath;
                    break;
                }
                SvnWriteArgs args = new SvnWriteArgs();
                args.Revision     = revision;
                args.AddExpectedError(SvnErrorCode.SVN_ERR_CLIENT_UNRELATED_RESOURCES);

                using (FileStream stream = File.Create(tempFile))
                {
                    ee.Client.Write(target, stream, args);
                }
            });

            return(tempFile);
        }
Esempio n. 29
0
        public WCSolutionNode(IAnkhServiceProvider context, SvnItem item)
            : base(context, null, item)
        {
            string file = Context.GetService <IAnkhSolutionSettings>().SolutionFilename;

            IFileIconMapper iconMapper = context.GetService <IFileIconMapper>();

            if (string.IsNullOrEmpty(file))
            {
                _imageIndex = iconMapper.GetIconForExtension(".sln");
            }
            else
            {
                _imageIndex = iconMapper.GetIcon(file);
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Returns an object that represents a service provided by the <see cref="T:System.ComponentModel.Component"/> or by its <see cref="T:System.ComponentModel.Container"/>.
        /// </summary>
        /// <param name="service">A service provided by the <see cref="T:System.ComponentModel.Component"/>.</param>
        /// <returns>
        /// An <see cref="T:System.Object"/> that represents a service provided by the <see cref="T:System.ComponentModel.Component"/>, or null if the <see cref="T:System.ComponentModel.Component"/> does not provide the specified service.
        /// </returns>
        protected override object GetService(Type service)
        {
            object r;

            if (Context != null)
            {
                r = Context.GetService(service);

                if (r != null)
                {
                    return(r);
                }
            }

            return(base.GetService(service));
        }
Esempio n. 31
0
        protected override void OnItemChecked(ItemCheckedEventArgs e)
        {
            base.OnItemChecked(e);

            if (_shell == null)
            {
                IAnkhServiceProvider sps = SelectionPublishServiceProvider;
                if (sps != null)
                {
                    _shell = sps.GetService <IVsUIShell>(typeof(SVsUIShell));
                }
            }
            if (_shell != null)
            {
                _shell.UpdateCommandUI(0); // Make sure the toolbar is updated on check actions
            }
        }
Esempio n. 32
0
        private bool SetIssueRepositoryProperties(IAnkhServiceProvider context, SvnItem item, IssueRepositorySettings settings)
        {
            return(context.GetService <IProgressRunner>().RunModal("Applying Issue Repository settings",
                                                                   delegate(object sender, ProgressWorkerArgs wa)
            {
                wa.Client.SetProperty(item.FullPath, AnkhSccPropertyNames.IssueRepositoryConnector, settings.ConnectorName);
                wa.Client.SetProperty(item.FullPath, AnkhSccPropertyNames.IssueRepositoryUri, settings.RepositoryUri.ToString());
                string repositoryId = settings.RepositoryId;
                if (string.IsNullOrEmpty(repositoryId))
                {
                    wa.Client.DeleteProperty(item.FullPath, AnkhSccPropertyNames.IssueRepositoryId);
                }
                else
                {
                    wa.Client.SetProperty(item.FullPath, AnkhSccPropertyNames.IssueRepositoryId, settings.RepositoryId);
                }
                IDictionary <string, object> customProperties = settings.CustomProperties;
                if (customProperties == null ||
                    customProperties.Count == 0
                    )
                {
                    wa.Client.DeleteProperty(item.FullPath, AnkhSccPropertyNames.IssueRepositoryPropertyNames);
                    wa.Client.DeleteProperty(item.FullPath, AnkhSccPropertyNames.IssueRepositoryPropertyValues);
                }
                else
                {
                    string[] propNameArray = new string[customProperties.Keys.Count];
                    customProperties.Keys.CopyTo(propNameArray, 0);
                    string propNames = string.Join(",", propNameArray);

                    List <string> propValueList = new List <string>();
                    foreach (string propName in propNameArray)
                    {
                        object propValue;
                        if (!customProperties.TryGetValue(propName, out propValue))
                        {
                            propValue = string.Empty;
                        }
                        propValueList.Add(propValue == null ? string.Empty : propValue.ToString());
                    }
                    string propValues = string.Join(",", propValueList.ToArray());
                    wa.Client.SetProperty(item.FullPath, AnkhSccPropertyNames.IssueRepositoryPropertyNames, propNames);
                    wa.Client.SetProperty(item.FullPath, AnkhSccPropertyNames.IssueRepositoryPropertyValues, propValues);
                }
            }).Succeeded);
        }
Esempio n. 33
0
        public IList <string> GetSubFiles()
        {
            if (_subFiles != null)
            {
                return(_subFiles);
            }

            ISccProjectWalker walker = _context.GetService <ISccProjectWalker>();

            List <string> files = new List <string>(walker.GetSccFiles(Project.ProjectHierarchy, ProjectItemId, ProjectWalkDepth.SpecialFiles, null));

            files.Remove(Filename);

            _subFiles = files.AsReadOnly();

            return(_subFiles);
        }
Esempio n. 34
0
        protected override IDisposable DialogRunContext(IAnkhServiceProvider context)
        {
            IAnkhDialogOwner owner = null;

            if (context != null)
            {
                owner = context.GetService <IAnkhDialogOwner>();
            }

            if (owner != null)
            {
                return(owner.InstallFormRouting(this, EventArgs.Empty));
            }
            else
            {
                return(base.DialogRunContext(context));
            }
        }
Esempio n. 35
0
        List<IVsHierarchy> GetProjects(IAnkhServiceProvider context, __VSENUMPROJFLAGS flags)
        {
            IVsSolution solution = context.GetService<IVsSolution>(typeof(SVsSolution));
            Guid gNone = Guid.Empty;
            IEnumHierarchies hierEnum;
            ErrorHandler.ThrowOnFailure(solution.GetProjectEnum((uint)flags, ref gNone, out hierEnum));

            IVsHierarchy[] hiers = new IVsHierarchy[32];
            List<IVsHierarchy> result = new List<IVsHierarchy>();

            uint fetched;
            while(ErrorHandler.Succeeded(hierEnum.Next((uint)hiers.Length, hiers, out fetched)))
            {
                if((int)fetched == hiers.Length)
                    result.AddRange(hiers);
                else if(fetched > 0)
                    for(int i = 0; i < (int)fetched; i++)
                        result.Add(hiers[i]);
                else
                    break;
            }

            return result;
        }
Esempio n. 36
0
        private static void FindRoot(IAnkhServiceProvider context, Uri selectedUri, CheckoutProject dlg)
        {
            AnkhAction ds = delegate
            {
                using (SvnClient client = context.GetService<ISvnClientPool>().GetClient())
                {
                    string value;
                    if (client.TryGetProperty(selectedUri, AnkhSccPropertyNames.ProjectRoot, out value))
                    {
                        if (dlg.IsHandleCreated)
                            dlg.Invoke((AnkhAction)delegate
                            {
                                try
                                {
                                    dlg.ProjectTop = new Uri(selectedUri, value);
                                }
                                catch { };
                            });
                    }
                }
            };

            ds.BeginInvoke(null, null);
        }
Esempio n. 37
0
        static void PerformLog(IAnkhServiceProvider context, ICollection<SvnOrigin> targets, SvnRevision start, SvnRevision end)
        {
            IAnkhPackage package = context.GetService<IAnkhPackage>();

            package.ShowToolWindow(AnkhToolWindow.Log);

            LogToolWindowControl logToolControl = context.GetService<ISelectionContext>().ActiveFrameControl as LogToolWindowControl;
            if (logToolControl != null)
                logToolControl.StartLog(targets, start, end);
        }
Esempio n. 38
0
        public void RefreshText(IAnkhServiceProvider context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            IFileStatusCache cache = context.GetService<IFileStatusCache>();

            ImageIndex = PendingChange.IconIndex;
            SvnItem item = cache[FullPath];

            if (item == null)
                throw new InvalidOperationException(); // Item no longer valued

            PendingChangeStatus pcs = PendingChange.Change ?? new PendingChangeStatus(PendingChangeKind.None);

            SetValues(
                pcs.PendingCommitText,
                _lastChangeList = PendingChange.ChangeList,
                GetDirectory(item),
                PendingChange.FullPath,
                item.IsLocked ? PCStrings.LockedValue : "", // Locked
                SafeDate(item.Modified), // Modified
                PendingChange.Name,
                PendingChange.RelativePath,
                PendingChange.Project,
                GetRevision(PendingChange),
                PendingChange.FileType,
                SafeWorkingCopy(item));

            if (!SystemInformation.HighContrast)
            {
                System.Drawing.Color clr = System.Drawing.Color.Black;

                if (item.IsConflicted || PendingChange.Kind == PendingChangeKind.WrongCasing)
                    clr = System.Drawing.Color.Red;
                else if (item.IsDeleteScheduled)
                    clr = System.Drawing.Color.DarkRed;
                else if (item.Status.IsCopied || item.Status.CombinedStatus == SharpSvn.SvnStatus.Added)
                    clr = System.Drawing.Color.FromArgb(100, 0, 100);
                else if (!item.IsVersioned)
                {
                    if (item.InSolution && !item.IsIgnored)
                        clr = System.Drawing.Color.FromArgb(100, 0, 100); // Same as added+copied
                    else
                        clr = System.Drawing.Color.Black;
                }
                else if (item.IsModified)
                    clr = System.Drawing.Color.DarkBlue;

                ForeColor = clr;
            }
        }
Esempio n. 39
0
        private static string GetPath(IAnkhServiceProvider context, SvnRevision revision, SvnItem item, string tempDir)
        {
            if (revision == SvnRevision.Working)
            {
                return item.FullPath;
            }

            string strRevision;
            if (revision.RevisionType == SvnRevisionType.Time)
                strRevision = revision.Time.ToLocalTime().ToString("yyyyMMdd_hhmmss");
            else
                strRevision = revision.ToString();
            string tempFile = Path.GetFileNameWithoutExtension(item.Name) + "." + strRevision + Path.GetExtension(item.Name);
            tempFile = Path.Combine(tempDir, tempFile);
            // we need to get it from the repos
            context.GetService<IProgressRunner>().RunModal("Retrieving file for diffing", delegate(object o, ProgressWorkerArgs ee)
            {
                SvnTarget target;

                switch(revision.RevisionType)
                {
                    case SvnRevisionType.Head:
                    case SvnRevisionType.Number:
                    case SvnRevisionType.Time:
                        target = new SvnUriTarget(item.Uri);
                        break;
                    default:
                        target = new SvnPathTarget(item.FullPath);
                        break;
                }
                SvnWriteArgs args = new SvnWriteArgs();
                args.Revision = revision;
                args.AddExpectedError(SvnErrorCode.SVN_ERR_CLIENT_UNRELATED_RESOURCES);

                using (FileStream stream = File.Create(tempFile))
                {
                    ee.Client.Write(target, stream, args);
                }
            });

            return tempFile;
        }
Esempio n. 40
0
        protected override IDisposable DialogRunContext(IAnkhServiceProvider context)
        {
            IAnkhDialogOwner owner = null;
            if (context != null)
                owner = context.GetService<IAnkhDialogOwner>();

            if (owner != null)
                return owner.InstallFormRouting(this, EventArgs.Empty);
            else
                return base.DialogRunContext(context);
        }
Esempio n. 41
0
        internal void OpenItem(IAnkhServiceProvider context, string p)
        {
            Ankh.Commands.IAnkhCommandService cmd = context.GetService<Ankh.Commands.IAnkhCommandService>();

            if (cmd != null)
                cmd.ExecCommand(AnkhCommand.ItemOpenVisualStudio, true);
        }
Esempio n. 42
0
        private static void AddIgnores(IAnkhServiceProvider context, string path, List<string> ignores)
        {
            try
            {
                context.GetService<IProgressRunner>().RunModal(CommandStrings.IgnoreCaption,
                    delegate(object sender, ProgressWorkerArgs e)
                    {
                        SvnGetPropertyArgs pa = new SvnGetPropertyArgs();
                        pa.ThrowOnError = false;
                        SvnTargetPropertyCollection tpc;
                        if (e.Client.GetProperty(path, SvnPropertyNames.SvnIgnore, pa, out tpc))
                        {
                            SvnPropertyValue pv;
                            if (tpc.Count > 0 && null != (pv = tpc[0]) && pv.StringValue != null)
                            {
                                int n = 0;
                                foreach (string oldItem in pv.StringValue.Split('\n'))
                                {
                                    string item = oldItem.TrimEnd('\r');

                                    if (item.Trim().Length == 0)
                                        continue;

                                    // Don't add duplicates
                                    while (n < ignores.Count && ignores.IndexOf(item, n) >= 0)
                                        ignores.RemoveAt(ignores.IndexOf(item, n));

                                    if (ignores.Contains(item))
                                        continue;

                                    ignores.Insert(n++, item);
                                }
                            }

                            StringBuilder sb = new StringBuilder();
                            bool next = false;
                            foreach (string item in ignores)
                            {
                                if (next)
                                    sb.Append('\n'); // Subversion wants only newlines
                                else
                                    next = true;

                                sb.Append(item);
                            }

                            e.Client.SetProperty(path, SvnPropertyNames.SvnIgnore, sb.ToString());
                        }
                    });

                // Make sure a changed directory is visible in the PC Window
                context.GetService<IFileStatusMonitor>().ScheduleMonitor(path);
            }
            finally
            {
                // Ignore doesn't bubble
                context.GetService<IFileStatusCache>().MarkDirtyRecursive(path);
            }
        }
Esempio n. 43
0
        public static void MaybePerformUpdateCheck(IAnkhServiceProvider context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            if (_checkedOnce)
                return;

            _checkedOnce = true;

            IAnkhConfigurationService config = context.GetService<IAnkhConfigurationService>();
            using (RegistryKey rk = config.OpenUserInstanceKey("UpdateCheck"))
            {
                int interval = 24 * 6; // 6 days
                object value = rk.GetValue("Interval");

                if (value is int)
                {
                    interval = (int)value;

                    if (interval <= 0)
                        return;
                }

                TimeSpan ts = TimeSpan.FromHours(interval);

                value = rk.GetValue("LastVersion");

                if (IsDevVersion() || (value is string && (string)value == GetCurrentVersion(context).ToString()))
                {
                    value = rk.GetValue("LastCheck");
                    long lv;
                    if (value is string && long.TryParse((string)value, out lv))
                    {
                        DateTime lc = new DateTime(lv, DateTimeKind.Utc);

                        if ((lc + ts) > DateTime.UtcNow)
                            return;

                        // TODO: Check the number of fails to increase the check interval
                    }
                }
            }

            context.GetService<IAnkhScheduler>().Schedule(new TimeSpan(0, 0, 20), AnkhCommand.CheckForUpdates);
        }
Esempio n. 44
0
 public WCMyComputerNode(IAnkhServiceProvider context)
     : base(context, null)
 {
     _imageIndex = context.GetService<IFileIconMapper>().GetSpecialFolderIcon(WindowsSpecialFolder.MyComputer);
 }
 public RefreshState(IAnkhServiceProvider context, IVsHierarchy hier, IVsProject project, string projectDir)
 {
     _hier = hier;
     _cache = context.GetService<IFileStatusCache>();
     _walker = context.GetService<ISccProjectWalker>();
     _project = project as IVsProject2;
     _projectDir = projectDir;
     if (projectDir != null)
         _projectDirItem = Cache[projectDir];
 }
Esempio n. 46
0
        static Version GetCurrentVersion(IAnkhServiceProvider context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            if (_currentVersion != null)
                return _currentVersion;

            IAnkhPackage pkg = context.GetService<IAnkhPackage>();

            if (pkg != null)
                return _currentVersion = pkg.PackageVersion;
            return _currentVersion = typeof(CheckForUpdates).Assembly.GetName().Version;
        }
Esempio n. 47
0
        public CodeEditorWindow(IAnkhServiceProvider context, Control container)
            : base(context)
        {
            if (container == null)
                throw new ArgumentNullException("container");

            _container = container;
            _serviceProvider = context.GetService<IOleServiceProvider>();
        }
Esempio n. 48
0
            public DiffToolMonitor(IAnkhServiceProvider context, string monitor, bool monitorDir)
                : base(context)
            {
                if (string.IsNullOrEmpty(monitor))
                    throw new ArgumentNullException("monitor");
                else if (!SvnItem.IsValidPath(monitor))
                    throw new ArgumentOutOfRangeException("monitor");

                _monitorDir = monitorDir;
                _toMonitor = monitor;

                IVsFileChangeEx fx = context.GetService<IVsFileChangeEx>(typeof(SVsFileChangeEx));

                _cookie = 0;
                if (fx == null)
                { }
                else if (!_monitorDir)
                {
                    if (!ErrorHandler.Succeeded(fx.AdviseFileChange(monitor,
                            (uint)(_VSFILECHANGEFLAGS.VSFILECHG_Time | _VSFILECHANGEFLAGS.VSFILECHG_Size
                            | _VSFILECHANGEFLAGS.VSFILECHG_Add | _VSFILECHANGEFLAGS.VSFILECHG_Del
                            | _VSFILECHANGEFLAGS.VSFILECHG_Attr),
                            this,
                            out _cookie)))
                    {
                        _cookie = 0;
                    }
                }
                else
                {
                    if (!ErrorHandler.Succeeded(fx.AdviseDirChange(monitor, 1, this, out _cookie)))
                    {
                        _cookie = 0;
                    }
                }
            }
Esempio n. 49
0
        private static string DoExternalDiff(IAnkhServiceProvider context, PathSelectorResult info)
        {
            foreach (SvnItem item in info.Selection)
            {
                // skip unmodified for a diff against the textbase
                if (info.RevisionStart == SvnRevision.Base &&
                    info.RevisionEnd == SvnRevision.Working && !item.IsModified)
                    continue;

                string tempDir = context.GetService<IAnkhTempDirManager>().GetTempDir();

                AnkhDiffArgs da = new AnkhDiffArgs();

                da.BaseFile = GetPath(context, info.RevisionStart, item, tempDir);
                da.MineFile = GetPath(context, info.RevisionEnd, item, tempDir);

                context.GetService<IAnkhDiffHandler>().RunDiff(da);
            }

            return null;
        }
Esempio n. 50
0
            public ProjectListFilter(IAnkhServiceProvider context, IEnumerable<SvnProject> projects)
            {
                if (context == null)
                    throw new ArgumentNullException("context");
                if (projects == null)
                    throw new ArgumentNullException("projects");

                _mapper = context.GetService<IProjectFileMapper>();
                List<SvnProject> projectList = new List<SvnProject>(projects);

                files.AddRange(_mapper.GetAllFilesOf(projectList));

                foreach (SvnProject p in projectList)
                {
                    ISvnProjectInfo pi = _mapper.GetProjectInfo(p);

                    if (pi == null)
                        continue; // Ignore solution and non scc projects

                    string dir = pi.ProjectDirectory;

                    if (!string.IsNullOrEmpty(dir) && !folders.Contains(dir))
                        folders.Add(dir);
                }
            }
Esempio n. 51
0
        /// <summary>
        /// Installs a visual studio command handler for the specified control
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="control">The control.</param>
        /// <param name="command">The command.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="updateHandler">The update handler.</param>
        public static void Install(IAnkhServiceProvider context, Control control, CommandID command, EventHandler<CommandEventArgs> handler, EventHandler<CommandUpdateEventArgs> updateHandler)
        {
            if (context == null)
                throw new ArgumentNullException("context");
            else if (control == null)
                throw new ArgumentNullException("control");
            else if (command == null)
                throw new ArgumentNullException("command");

            IAnkhCommandHandlerInstallerService svc = context.GetService<IAnkhCommandHandlerInstallerService>();

            if (svc != null)
                svc.Install(control, command, handler, updateHandler);
        }
Esempio n. 52
0
        /// <summary>
        /// Generates the diff from the current selection.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="selection"></param>
        /// <param name="revisions"></param>
        /// <param name="visibleFilter"></param>
        /// <returns>The diff as a string.</returns>
        protected virtual string GetDiff(IAnkhServiceProvider context, ISelectionContext selection, SvnRevisionRange revisions, Predicate<SvnItem> visibleFilter)
        {
            if (selection == null)
                throw new ArgumentNullException("selection");
            if (context == null)
                throw new ArgumentNullException("context");

            IUIShell uiShell = context.GetService<IUIShell>();

            bool foundModified = false;
            foreach (SvnItem item in selection.GetSelectedSvnItems(true))
            {
                if (item.IsModified || item.IsDocumentDirty)
                {
                    foundModified = true;
                    break; // no need (yet) to keep searching
                }
            }

            PathSelectorInfo info = new PathSelectorInfo("Select items for diffing", selection.GetSelectedSvnItems(true));
            info.VisibleFilter += visibleFilter;
            if (foundModified)
                info.CheckedFilter += delegate(SvnItem item) { return item.IsFile && (item.IsModified || item.IsDocumentDirty); };

            info.RevisionStart = revisions == null ? SvnRevision.Base : revisions.StartRevision;
            info.RevisionEnd = revisions == null ? SvnRevision.Working : revisions.EndRevision;

            PathSelectorResult result;
            // should we show the path selector?
            if (!Shift && (revisions == null || !foundModified))
            {
                result = uiShell.ShowPathSelector(info);
                if (!result.Succeeded)
                    return null;
            }
            else
                result = info.DefaultResult;

            if (!result.Succeeded)
                return null;

            SaveAllDirtyDocuments(selection, context);

            return DoExternalDiff(context, result);
        }
Esempio n. 53
0
            public OutputPaneReporter(IAnkhServiceProvider context, SvnClient client)
            {
                if (context == null)
                    throw new ArgumentNullException("context");
                else if (client == null)
                    throw new ArgumentNullException("client");

                _mgr = context.GetService<IOutputPaneManager>();
                _sb = new StringBuilder();
                _reporter = new SvnClientReporter(client, _sb);
            }
Esempio n. 54
0
        public void BrowsePath(IAnkhServiceProvider context, string path)
        {
            if (context == null)
                throw new ArgumentNullException("context");
            else if (string.IsNullOrEmpty(path))
                throw new ArgumentNullException("path");

            folderTree.BrowsePath(path);

            if (context.GetService<IFileStatusCache>()[path].IsFile)
            {
                fileList.SelectPath(path);
            }
        }