Ejemplo n.º 1
0
        /// <summary>
        /// Reads the SCM repository provider information from the registry
        /// </summary>
        private void ReadProviderRegistry()
        {
            IAnkhPackage ankhPackage = GetService <IAnkhPackage>();

            if (ankhPackage != null)
            {
                using (RegistryKey key = ankhPackage.ApplicationRegistryRoot)
                {
                    using (RegistryKey aKey = key.OpenSubKey("ScmRepositoryProviders"))
                    {
                        if (aKey == null)
                        {
                            return;
                        }

                        string[] providerKeys = aKey.GetSubKeyNames();
                        foreach (string providerKey in providerKeys)
                        {
                            using (RegistryKey provider = aKey.OpenSubKey(providerKey))
                            {
                                string                serviceName = (string)provider.GetValue("");
                                RepositoryType        rt          = GetRepositoryType(provider.GetValue("ScmType") as string);
                                ScmRepositoryProvider descriptor  = new ScmRepositoryProviderProxy(this, providerKey, serviceName, rt);
                                if (!_nameProviderMap.ContainsKey(providerKey))
                                {
                                    _nameProviderMap.Add(providerKey, descriptor);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
            public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
            {
                List <SvnChangeList> names = new List <SvnChangeList>();

                if (context != null)
                {
                    IAnkhPackage package = context.GetService(typeof(IAnkhPackage)) as IAnkhPackage;

                    if (package != null)
                    {
                        IPendingChangesManager pcm = package.GetService <IPendingChangesManager>();

                        foreach (string cl in pcm.GetSuggestedChangeLists())
                        {
                            names.Add(cl);
                        }
                    }
                }

                names.Add("ignore-on-commit");

                StandardValuesCollection svc = new StandardValuesCollection(names);

                return(svc);
            }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads the issue repository connector information from the registry
        /// </summary>
        private void ReadConnectorRegistry()
        {
            IAnkhPackage ankhPackage = GetService <IAnkhPackage>();

            if (ankhPackage != null)
            {
                using (RegistryKey key = ankhPackage.ApplicationRegistryRoot)
                {
                    using (RegistryKey aKey = key.OpenSubKey("IssueRepositoryConnectors"))
                    {
                        if (aKey == null)
                        {
                            return;
                        }

                        string[] connectorKeys = aKey.GetSubKeyNames();
                        foreach (string connectorKey in connectorKeys)
                        {
                            using (RegistryKey connector = aKey.OpenSubKey(connectorKey))
                            {
                                string serviceName = (string)connector.GetValue("");
                                IssueRepositoryConnector descriptor = new IssueRepositoryConnectorProxy(this, serviceName, connectorKey);
                                _nameConnectorMap.Add(serviceName, descriptor);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void OnExecute(CommandEventArgs e)
        {
            string info;

            if (e.Argument is string)
            {
                // Allow opening from
                info = (string)e.Argument;
            }
            else if (e.Command == AnkhCommand.WorkingCopyAdd)
            {
                using (AddWorkingCopyExplorerRootDialog dlg = new AddWorkingCopyExplorerRootDialog())
                {
                    DialogResult dr = dlg.ShowDialog(e.Context);

                    if (dr != DialogResult.OK || string.IsNullOrEmpty(dlg.NewRoot))
                    {
                        return;
                    }

                    info = dlg.NewRoot;
                }
            }
            else
            {
                throw new InvalidOperationException("WorkingCopyBrowse was called without a path");
            }

            if (!string.IsNullOrEmpty(info))
            {
                WorkingCopyExplorerControl ctrl = e.Selection.ActiveDialogOrFrameControl as WorkingCopyExplorerControl;

                if (ctrl == null)
                {
                    IAnkhPackage pkg = e.GetService <IAnkhPackage>();
                    pkg.ShowToolWindow(AnkhToolWindow.WorkingCopyExplorer);
                }

                ctrl = e.Selection.ActiveDialogOrFrameControl as WorkingCopyExplorerControl;

                if (ctrl != null)
                {
                    switch (e.Command)
                    {
                    case AnkhCommand.WorkingCopyAdd:
                        ctrl.AddRoot(info);
                        break;

                    case AnkhCommand.WorkingCopyBrowse:
                        ctrl.BrowsePath(e.Context, info);
                        break;
                    }
                }
            }
        }
Ejemplo 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);
            }
        }
Ejemplo n.º 6
0
        private void EnsureEnlistUserSettings()
        {
            if (_translateDataLoaded)
            {
                return;
            }

            _translateDataLoaded = true;
            IAnkhPackage pkg = GetService <IAnkhPackage>();

            if (pkg != null)
            {
                pkg.ForceLoadUserSettings(AnkhId.SccTranslateStream);
            }
        }
Ejemplo n.º 7
0
        static Version GetUIVersion(AnkhContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

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

            if (pkg != null)
            {
                return(pkg.UIVersion);
            }

            return(GetCurrentVersion(context));
        }
Ejemplo n.º 8
0
        public override void OnExecute(CommandEventArgs e)
        {
            IAnkhPackage package = e.Context.GetService <IAnkhPackage>();

            AnkhToolWindow toolWindow;

            switch (e.Command)
            {
            case AnkhCommand.ShowPendingChanges:
                toolWindow = AnkhToolWindow.PendingChanges;
                break;

            case AnkhCommand.ShowWorkingCopyExplorer:
                toolWindow = AnkhToolWindow.WorkingCopyExplorer;
                break;

            case AnkhCommand.ShowRepositoryExplorer:
                toolWindow = AnkhToolWindow.RepositoryExplorer;
                break;

            case AnkhCommand.ShowSubversionInfo:
                toolWindow = AnkhToolWindow.SvnInfo;
                break;

            default:
                return;
            }

            package.ShowToolWindow(toolWindow);

            if (e.Command == AnkhCommand.ShowRepositoryExplorer)
            {
                IAnkhSolutionSettings ss = e.GetService <IAnkhSolutionSettings>();

                if (ss.ProjectRootUri != null)
                {
                    RepositoryExplorerControl ctrl = e.Selection.ActiveDialogOrFrameControl as RepositoryExplorerControl;

                    if (ctrl != null)
                    {
                        ctrl.AddRoot(ss.ProjectRootUri);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public void MaybeMigrate()
        {
            IAnkhPackage        pkg = GetService <IAnkhPackage>();
            IAnkhCommandService cs  = GetService <IAnkhCommandService>();

            if (pkg == null || cs == null)
            {
                return;
            }

            using (RegistryKey rkRoot = pkg.UserRegistryRoot)
                using (RegistryKey ankhMigration = rkRoot.CreateSubKey("AnkhSVN-Trigger"))
                {
                    int    migrateFrom = 0;
                    object value       = ankhMigration.GetValue(MigrateId, migrateFrom);

                    if (value is int)
                    {
                        migrateFrom = (int)value;
                    }
                    else
                    {
                        ankhMigration.DeleteValue(MigrateId, false);
                    }

                    if (migrateFrom < 0)
                    {
                        migrateFrom = 0;
                    }

                    if (migrateFrom >= AnkhId.MigrateVersion)
                    {
                        return;                 // Nothing to do
                    }
                    try
                    {
                        if (cs.DirectlyExecCommand(AnkhCommand.MigrateSettings).Success)
                        {
                            ankhMigration.SetValue(MigrateId, AnkhId.MigrateVersion);
                        }
                    }
                    catch
                    { /* NOP: Don't fail here... ever! */ }
                }
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            AnkhRuntime  runtime = null;
            IAnkhPackage pkg     = GetService(typeof(IAnkhPackage)) as IAnkhPackage;

            if (pkg != null)
            {
                runtime = AnkhRuntime.Get(pkg);
            }

            if (runtime != null)
            {
                runtime.AddModule(new AnkhWpfModule(runtime));
                runtime.AddModule(new AnkhWpfUIModule(runtime));
            }
            else
            {
                Trace.WriteLine(string.Format("Failed to initialize {0}, because the Ankh Runtime is not available", typeof(AnkhSvnWpfPackage).FullName));
            }
        }
Ejemplo n.º 12
0
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // Switches to the UI thread in order to consume some services used in command initialization
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            AnkhRuntime  runtime = null;
            IAnkhPackage pkg     = await GetServiceAsync(typeof(IAnkhPackage)) as IAnkhPackage;

            if (pkg != null)
            {
                runtime = AnkhRuntime.Get(pkg);
            }

            if (runtime != null)
            {
                runtime.AddModule(new AnkhWpfModule(runtime));
                runtime.AddModule(new AnkhWpfUIModule(runtime));
            }
            else
            {
                Trace.WriteLine(string.Format("Failed to initialize {0}, because the Ankh Runtime is not available", typeof(AnkhSvnWpfPackage).FullName));
            }
        }
Ejemplo n.º 13
0
        public void OnExecute(CommandEventArgs e)
        {
            Uri info;

            if (e.Argument is string)
            {
                string arg = (string)e.Argument;

                info = null;
                if (SvnItem.IsValidPath(arg, true))
                {
                    SvnItem item = e.GetService <ISvnStatusCache>()[arg];

                    if (item.IsVersioned)
                    {
                        info = item.Uri;

                        if (item.IsFile)
                        {
                            info = new Uri(info, "./");
                        }
                    }
                }

                if (info == null)
                {
                    info = new Uri((string)e.Argument);
                }
            }
            else if (e.Argument is Uri)
            {
                info = (Uri)e.Argument;
            }
            else
            {
                using (RepositorySelectionWizard wizard = new RepositorySelectionWizard(e.Context))
                {
                    if (wizard.ShowDialog(e.Context) != DialogResult.OK)
                    {
                        return;
                    }
                    info = wizard.GetSelectedRepositoryUri();
                }
            }

            if (info != null)
            {
                RepositoryExplorerControl ctrl = e.Selection.ActiveDialogOrFrameControl as RepositoryExplorerControl;

                if (ctrl == null)
                {
                    IAnkhPackage pkg = e.GetService <IAnkhPackage>();
                    pkg.ShowToolWindow(AnkhToolWindow.RepositoryExplorer);
                }

                ctrl = e.Selection.ActiveDialogOrFrameControl as RepositoryExplorerControl;

                if (ctrl != null)
                {
                    ctrl.AddRoot(info);
                }
            }
        }
Ejemplo n.º 14
0
        private void ShowErrorDialog(Exception ex, bool showStackTrace, bool internalError, ExceptionInfo info)
        {
            string stackTrace = ex.ToString();
            string message    = GetNestedMessages(ex);

            System.Collections.Specialized.StringDictionary additionalInfo =
                new System.Collections.Specialized.StringDictionary();

            IAnkhSolutionSettings ss = GetService <IAnkhSolutionSettings>();

            if (ss != null)
            {
                additionalInfo.Add("VS-Version", VSVersion.FullVersion.ToString());
            }

            if (info != null && info.CommandArgs != null)
            {
                additionalInfo.Add("Command", info.CommandArgs.Command.ToString());
            }

            IAnkhPackage pkg = GetService <IAnkhPackage>();

            if (pkg != null)
            {
                additionalInfo.Add("Ankh-Version", pkg.UIVersion.ToString());
            }

            additionalInfo.Add("SharpSvn-Version", SharpSvn.SvnClient.SharpSvnVersion.ToString());
            additionalInfo.Add("Svn-Version", SharpSvn.SvnClient.Version.ToString());
            additionalInfo.Add("OS-Version", Environment.OSVersion.Version.ToString());

            using (ErrorDialog dlg = new ErrorDialog())
            {
                dlg.ErrorMessage   = message;
                dlg.ShowStackTrace = showStackTrace;
                dlg.StackTrace     = stackTrace;
                dlg.InternalError  = internalError;

                if (dlg.ShowDialog(Context) == DialogResult.Retry)
                {
                    string subject = _errorReportSubject;

                    if (info != null && info.CommandArgs != null)
                    {
                        subject = string.Format("Error handling {0}", info.CommandArgs.Command);
                    }

                    SvnException sx = ex as SvnException;
                    SvnException ix;

                    while (sx != null &&
                           sx.SvnErrorCode == SvnErrorCode.SVN_ERR_BASE &&
                           (null != (ix = sx.InnerException as SvnException)))
                    {
                        sx = ix;
                    }

                    if (sx != null)
                    {
                        SvnException rc = sx.RootCause as SvnException;
                        if (rc == null || rc.SvnErrorCode == sx.SvnErrorCode)
                        {
                            subject += " (" + ErrorToString(sx) + ")";
                        }
                        else
                        {
                            subject += " (" + ErrorToString(sx) + "-" + ErrorToString(rc) + ")";
                        }
                    }

                    AnkhErrorMessage.SendByMail(_errorReportMailAddress,
                                                subject, ex, typeof(AnkhErrorHandler).Assembly, additionalInfo);
                }
            }
        }