Ejemplo n.º 1
0
        public SccEditEnlistment(EnlistmentState state)
            : this()
        {
            if (state == null)
                throw new ArgumentNullException("state");
            _enlistState = state;

            projectLocationGroup.Enabled = state.NeedLocation;
            debugLocationBox.Enabled = state.NeedDebugLocation;

            projectLocationBrowse.Enabled = state.CanBrowseForLocation;
            debugLocationBrowse.Enabled = state.CanBrowseForDebugLocation;

            projectLocationBox.ReadOnly = state.AllowEditLocation;
            debugLocationBox.ReadOnly = state.AllowEditDebugLocation;

            projectLocationBox.Text = state.Location;
            debugLocationBox.Text = state.DebugLocation;
        }
Ejemplo n.º 2
0
            public EnlistmentEventArgs(EnlistmentState state)
            {
                if (state == null)
                    throw new ArgumentNullException("state");

                _state = state;
            }
Ejemplo n.º 3
0
        void PerformEnlist()
        {
            _enlistCompleted = true;
            _solutionDirectory = _solutionFile = null; // Clear cache

            if (_enlistState.Count == 0)
                return; // Nothing to do here

            IVsSolutionPersistence ps = GetService<IVsSolutionPersistence>(typeof(SVsSolutionPersistence));
            if (ps != null)
            {
                int hr = ps.LoadPackageUserOpts((IVsPersistSolutionOpts)GetService<Ankh.UI.IAnkhPackage>(), AnkhId.SubversionSccName + "Enlist");

            }

            #if DEBUG_ENLISTMENT

            IVsSolution2 sol = GetService<IVsSolution2>(typeof(SVsSolution));
            // TODO: Load previous enlist state

            foreach (EnlistData item in _enlistState)
            {
                if (string.IsNullOrEmpty(item.EnlistType))
                    continue;

                Guid value;

                if(!TryParseGuid(item.EnlistType, out value))
                    continue;

                Guid[] factoryGuid = new Guid[] { value };

                IVsProjectFactory factory;
                if (!ErrorHandler.Succeeded(sol.GetProjectFactory(0, factoryGuid, null, out factory)) || factory == null)
                    continue;

                IVsSccProjectEnlistmentFactory enlistmentFactory = factory as IVsSccProjectEnlistmentFactory;

                if (enlistmentFactory == null)
                    continue;

                GC.KeepAlive(enlistmentFactory);
                string enlistLocal, enlistUnc;
                uint options;

                //SolutionFilePath

                string projectPath;

                if(item.Path.Contains("://"))
                    projectPath = item.Path;
                else
                    projectPath = Path.GetFullPath(Path.Combine(SolutionDirectory, item.Path));

                if(!ErrorHandler.Succeeded(enlistmentFactory.GetDefaultEnlistment(projectPath, out enlistLocal, out enlistUnc)))
                {
                    continue;
                }

                if (!ErrorHandler.Succeeded(enlistmentFactory.GetEnlistmentFactoryOptions(out options)))
                    options = (int)(__VSSCCENLISTMENTFACTORYOPTIONS.VSSCC_EFO_CANBROWSEENLISTMENTPATH | __VSSCCENLISTMENTFACTORYOPTIONS.VSSCC_EFO_CANEDITENLISTMENTPATH);

                EnlistmentState state = new EnlistmentState(
                    0 != (options & (int)(__VSSCCENLISTMENTFACTORYOPTIONS.VSSCC_EFO_CANBROWSEENLISTMENTPATH | __VSSCCENLISTMENTFACTORYOPTIONS.VSSCC_EFO_CANEDITENLISTMENTPATH)),
                    0 != (options & (int)(__VSSCCENLISTMENTFACTORYOPTIONS.VSSCC_EFO_CANEDITDEBUGGINGPATH| __VSSCCENLISTMENTFACTORYOPTIONS.VSSCC_EFO_CANEDITDEBUGGINGPATH)));

                state.Location = state.DebugLocation = enlistUnc;

                if(0 != (options & (int)__VSSCCENLISTMENTFACTORYOPTIONS.VSSCC_EFO_CANBROWSEENLISTMENTPATH))
                    state.BrowseLocation += delegate(object sender, EnlistmentState.EnlistmentEventArgs e)
                    {
                        string location, uncLocation;

                        if(ErrorHandler.Succeeded(enlistmentFactory.BrowseEnlistment(projectPath, e.State.Location, out location, out uncLocation)))
                        {
                            e.State.LocalLocation = location;
                            e.State.Location = uncLocation;
                        }
                    };

                if(0 != (options & (int)__VSSCCENLISTMENTFACTORYOPTIONS.VSSCC_EFO_CANBROWSEDEBUGGINGPATH))
                    state.BrowseDebugLocation += delegate(object sender, EnlistmentState.EnlistmentEventArgs e)
                    {
                        string location, uncLocation;

                        if(ErrorHandler.Succeeded(enlistmentFactory.BrowseEnlistment(projectPath, e.State.DebugLocation, out location, out uncLocation)))
                        {
                            e.State.LocalDebugLocation = location;
                            e.State.DebugLocation = uncLocation;
                        }
                    };

                IUIShell uiShell = GetService<IUIShell>();

                if(!uiShell.EditEnlistmentState(state))
                {
                    continue;
                }

                GC.KeepAlive(enlistLocal);
            }
            #endif
        }