protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
		{
			DotNetProject project = entry as DotNetProject;
			AddinData data = project != null ? AddinData.GetAddinData (project) : null;
			if (data != null)
				monitor.BeginTask (null, buildingSolution ? 2 : 3);
			
			BuildResult res = base.Build (monitor, entry, configuration);
			if (res.ErrorCount > 0 || data == null)
				return res;
			
			monitor.Step (1);
			
			monitor.Log.WriteLine (AddinManager.CurrentLocalizer.GetString ("Verifying add-in description..."));
			string fileName = data.AddinManifestFileName;
			ProjectFile file = data.Project.Files.GetFile (fileName);
			if (file == null)
				return res;
			
			string addinFile;
			if (file.BuildAction == BuildAction.EmbeddedResource)
				addinFile = project.GetOutputFileName (ConfigurationSelector.Default);
			else
				addinFile = file.FilePath;
			
			AddinDescription desc = data.AddinRegistry.GetAddinDescription (new ProgressStatusMonitor (monitor), addinFile);
			StringCollection errors = desc.Verify ();
			
			foreach (string err in errors) {
				res.AddError (data.AddinManifestFileName, 0, 0, "", err);
				monitor.Log.WriteLine ("ERROR: " + err);
			}
			
			if (!buildingSolution && project.ParentSolution != null) {
				monitor.Step (1);
				SolutionAddinData sdata = project.ParentSolution.GetAddinData ();
				if (sdata != null && sdata.Registry != null) {
					sdata.Registry.Update (new ProgressStatusMonitor (monitor));
					DispatchService.GuiDispatch (delegate {
						sdata.NotifyChanged ();
					});
				}
			}
			
			monitor.EndTask ();
			
			return res;
		}
 public List<WorkItem> LoadByWorkItem(IProgressMonitor progress)
 {
     var ids = this.clientService.GetWorkItemIds(this.query, CachedMetaData.Instance.Fields);
     var list = new List<WorkItem>();
     progress.BeginTask("Loading WorkItems", ids.Count);
     foreach (var id in ids)
     {
         list.Add(clientService.GetWorkItem(id));
         progress.Step(1);
     }
     progress.EndTask();
     return list;
 }
 public List<WorkItem> LoadByPage(IProgressMonitor progress)
 {
     var ids = this.clientService.GetWorkItemIds(this.query, CachedMetaData.Instance.Fields);
     int pages = (int)Math.Ceiling((double)ids.Count / (double)50);
     var result = new List<WorkItem>();
     progress.BeginTask("Loading WorkItems", pages);
     for (int i = 0; i < pages; i++)
     {
         var idList = new List<int>(ids.Skip(i * 50).Take(50));
         var items = this.clientService.PageWorkitemsByIds(this.query, idList);
         result.AddRange(items);
         progress.Step(1);
     }
     progress.EndTask();
     return result;
 }
Esempio n. 4
0
 public void Save(IProgressMonitor monitor)
 {
     if (HasSlnData && !SavingSolution && Item.ParentSolution != null)
     {
         // The project has data that has to be saved in the solution, but the solution is not being saved. Do it now.
         monitor.BeginTask(null, 2);
         SaveItem(monitor);
         monitor.Step(1);
         Solution sol = Item.ParentSolution;
         SolutionFormat.SlnFileFormat.WriteFile(sol.FileName, sol, SolutionFormat, false, monitor);
         sol.NeedsReload = false;
         monitor.EndTask();
     }
     else
     {
         SaveItem(monitor);
     }
 }
Esempio n. 5
0
        public void OnUnload()
        {
            HashSet <Solution> solutions = new HashSet <Solution> ();

            using (IProgressMonitor m = IdeApp.Workbench.ProgressMonitors.GetProjectLoadProgressMonitor(true)) {
                m.BeginTask(null, CurrentNodes.Length);
                foreach (ITreeNavigator nav in CurrentNodes)
                {
                    Project p = (Project)nav.DataItem;
                    p.Enabled = false;
                    p.ParentFolder.ReloadItem(m, p);
                    m.Step(1);
                    solutions.Add(p.ParentSolution);
                }
                m.EndTask();
            }
            IdeApp.ProjectOperations.Save(solutions);
        }
Esempio n. 6
0
        /// <summary>
        /// Compile the project
        /// </summary>
        /// <param name="projectFiles">
        /// Collection of project files
        /// <see cref="ProjectFileCollection"/>
        /// </param>
        /// <param name="packages">
        /// Collection of depended packages
        /// <see cref="ProjectPackageCollection"/>
        /// </param>
        /// <param name="configuration">
        /// Project configuration
        /// <see cref="ValaProjectConfiguration"/>
        /// </param>
        /// <param name="monitor">
        /// Progress monitor to be used
        /// <see cref="IProgressMonitor"/>
        /// </param>
        /// <returns>
        /// Result of the compilation
        /// <see cref="ICompilerResult"/>
        /// </returns>
        public BuildResult Compile(
            ProjectFileCollection projectFiles,
            ProjectPackageCollection packages,
            ValaProjectConfiguration configuration,
            IProgressMonitor monitor)
        {
            if (!appsChecked)
            {
                appsChecked   = true;
                compilerFound = CheckApp(compilerCommand);
            }            /// Check for compiler


            if (!compilerFound)
            {
                BuildResult cres = new BuildResult();
                cres.AddError("Compiler not found: " + compilerCommand);
                return(cres);
            }            /// No compiler!

            CompilerResults cr      = new CompilerResults(new TempFileCollection());
            bool            success = true;

            /// Build compiler params string
            string compilerArgs = GetCompilerFlags(configuration) + " " + GeneratePkgCompilerArgs(packages);

            /// Build executable name
            string outputName = Path.Combine(configuration.OutputDirectory,
                                             configuration.CompiledOutputName);

            monitor.BeginTask(GettextCatalog.GetString("Compiling source"), 1);

            success = DoCompilation(projectFiles, compilerArgs, outputName, monitor, cr);

            GenerateDepfile(configuration, packages);

            if (success)
            {
                monitor.Step(1);
            }
            monitor.EndTask();

            return(new BuildResult(cr, ""));
        }
Esempio n. 7
0
        public static bool WaitForRunningTools(IProgressMonitor monitor)
        {
            IAsyncOperation[] operations;
            lock (runningTasks) {
                operations = runningTasks.Values.ToArray();
            }

            if (operations.Length == 0)
            {
                return(true);
            }

            monitor.BeginTask("Waiting for custom tools...", operations.Length);

            var evt = new AutoResetEvent(false);

            monitor.CancelRequested += delegate {
                evt.Set();
            };

            OperationHandler checkOp = delegate {
                monitor.Step(1);
                if (operations.All(op => op.IsCompleted))
                {
                    evt.Set();
                }
            };

            foreach (var o in operations)
            {
                o.Completed += checkOp;
            }

            evt.WaitOne();
            bool success = operations.All(op => op.Success);

            if (!success)
            {
                monitor.ReportError("Error in custom tool", null);
            }

            monitor.EndTask();
            return(success);
        }
Esempio n. 8
0
        private bool PrecompileHeaders(ProjectFileCollection projectFiles,
                                       CProjectConfiguration configuration,
                                       string args,
                                       IProgressMonitor monitor,
                                       CompilerResults cr)
        {
            monitor.BeginTask(GettextCatalog.GetString("Precompiling headers"), 1);
            bool success = true;

            foreach (ProjectFile file in projectFiles)
            {
                if (file.Subtype == Subtype.Code && CProject.IsHeaderFile(file.Name))
                {
                    string precomp = Path.Combine(configuration.IntermediateOutputDirectory, "prec");
                    precomp = Path.Combine(precomp, configuration.Id);
                    precomp = Path.Combine(precomp, Path.GetFileName(file.Name) + ".ghc");
                    if (file.BuildAction == BuildAction.Compile)
                    {
                        if (!File.Exists(precomp) || configuration.UseCcache || File.GetLastWriteTime(file.Name) > File.GetLastWriteTime(precomp))
                        {
                            if (DoPrecompileHeader(file, precomp, args, monitor, cr) == false)
                            {
                                success = false;
                                break;
                            }
                        }
                    }
                    else
                    {
                        //remove old files or they'll interfere with the build
                        if (File.Exists(precomp))
                        {
                            File.Delete(precomp);
                        }
                    }
                }
            }
            if (success)
            {
                monitor.Step(1);
            }
            monitor.EndTask();
            return(success);
        }
Esempio n. 9
0
        protected override void OnClean(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            if (ParentSolution == null)
            {
                return;
            }
            SolutionConfiguration conf = ParentSolution.GetConfiguration(configuration);

            if (conf == null)
            {
                return;
            }

            try {
                monitor.BeginTask(GettextCatalog.GetString("Cleaning Solution: {0} ({1})", Name, configuration.ToString()), Items.Count);

                foreach (SolutionItem item in Items)
                {
                    if (item is SolutionFolder)
                    {
                        item.Clean(monitor, configuration);
                    }
                    else if (item is SolutionEntityItem)
                    {
                        SolutionEntityItem si = (SolutionEntityItem)item;
                        // ce can be null if you add items to the root solution folder which
                        // causes them to be placed in an autogenerated 'Project Items' folder
                        SolutionConfigurationEntry ce = conf.GetEntryForItem(si);
                        if (ce != null && ce.Build)
                        {
                            si.Clean(monitor, ce.ItemConfigurationSelector);
                        }
                    }
                    else
                    {
                        item.Clean(monitor, configuration);
                    }
                    monitor.Step(1);
                }
            }
            finally {
                monitor.EndTask();
            }
        }
        void WriteWorkspaceItem(FilePath actualFile, FilePath outFile, WorkspaceItem item, IProgressMonitor monitor)
        {
            Workspace ws = item as Workspace;

            if (ws != null)
            {
                monitor.BeginTask(null, ws.Items.Count);
                try
                {
                    foreach (WorkspaceItem it in ws.Items)
                    {
                        it.Save(monitor);
                        monitor.Step(1);
                    }
                }
                finally
                {
                    monitor.EndTask();
                }
            }

            StreamWriter sw = new StreamWriter(outFile);

            try
            {
                monitor.BeginTask(GettextCatalog.GetString("Saving item: {0}", actualFile), 1);
                XmlTextWriter tw = new XmlTextWriter(sw);
                tw.Formatting = Formatting.Indented;
                XmlDataSerializer ser = new XmlDataSerializer(MD1ProjectService.DataContext);
                ser.SerializationContext.BaseFile        = actualFile;
                ser.SerializationContext.ProgressMonitor = monitor;
                ser.Serialize(sw, item, typeof(WorkspaceItem));
            }
            catch (Exception ex)
            {
                monitor.ReportError(GettextCatalog.GetString("Could not save item: {0}", actualFile), ex);
                throw;
            }
            finally
            {
                monitor.EndTask();
                sw.Close();
            }
        }
        protected override void Clean(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
        {
            Project proj = entry as Project;

            if (proj == null)
            {
                base.Clean(monitor, entry, configuration);
                return;
            }

            MakefileData data = proj.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;

            if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty(data.CleanTargetName))
            {
                base.Clean(monitor, entry, configuration);
                return;
            }

            monitor.BeginTask(GettextCatalog.GetString("Cleaning project"), 1);
            try {
                string baseDir = proj.BaseDirectory;

                ProcessWrapper process = Runtime.ProcessService.StartProcess(data.AbsoluteMakeCommand,
                                                                             data.CleanTargetName,
                                                                             baseDir,
                                                                             monitor.Log,
                                                                             monitor.Log,
                                                                             null);
                process.WaitForOutput();

                if (process.ExitCode > 0)
                {
                    throw new Exception(GettextCatalog.GetString("An unspecified error occurred while running '{0} {1}'", data.AbsoluteMakeCommand, data.CleanTargetName));
                }

                monitor.Step(1);
            } catch (Exception e) {
                monitor.ReportError(GettextCatalog.GetString("Project could not be cleaned: "), e);
                return;
            } finally {
                monitor.EndTask();
            }
            monitor.ReportSuccess(GettextCatalog.GetString("Project successfully cleaned"));
        }
Esempio n. 12
0
        void UpdateRepository(IProgressMonitor monitor, Uri baseUri, RepositoryRecord rr)
        {
            Uri absUri = new Uri(baseUri, rr.Url);

            monitor.BeginTask("Updating from " + absUri.ToString(), 2);
            Repository newRep = null;
            Exception  error  = null;

            try {
                var provider = service.GetAddinRepositoryProvider(rr.ProviderId);
                newRep = provider.DownloadRepository(monitor, absUri, rr);
            } catch (Exception ex) {
                error = ex;
            }

            if (newRep == null)
            {
                monitor.ReportError("Could not get information from repository" + ": " + absUri.ToString(), error);
                return;
            }

            monitor.Step(1);

            foreach (ReferenceRepositoryEntry re in newRep.Repositories)
            {
                Uri              refRepUri = new Uri(absUri, re.Url);
                string           refRepUrl = refRepUri.ToString();
                RepositoryRecord refRep    = FindRepositoryRecord(refRepUrl);
                if (refRep == null)
                {
                    refRep = RegisterRepository(refRepUrl, true, rr.ProviderId);
                }
                refRep.Enabled = rr.Enabled;
                // Update the repo if the modified timestamp changes or if there is no timestamp info
                if (refRep.LastModified != re.LastModified || re.LastModified == DateTime.MinValue || !File.Exists(refRep.File))
                {
                    refRep.LastModified = re.LastModified;
                    UpdateRepository(monitor, refRepUri, refRep);
                }
            }
            monitor.EndTask();
            rr.UpdateCachedRepository(newRep);
        }
        void CreateDefaultCatalog(IProgressMonitor monitor)
        {
            IFileScanner[] scanners = TranslationService.GetFileScanners();

            Catalog        catalog  = new Catalog(this);
            List <Project> projects = new List <Project> ();

            foreach (Project p in ParentSolution.GetAllProjects())
            {
                if (IsIncluded(p))
                {
                    projects.Add(p);
                }
            }
            foreach (Project p in projects)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString("Scanning project {0}...", p.Name));
                foreach (ProjectFile file in p.Files)
                {
                    if (!File.Exists(file.FilePath))
                    {
                        continue;
                    }
                    if (file.Subtype == Subtype.Code)
                    {
                        string mimeType = DesktopService.GetMimeTypeForUri(file.FilePath);
                        foreach (IFileScanner fs in scanners)
                        {
                            if (fs.CanScan(this, catalog, file.FilePath, mimeType))
                            {
                                fs.UpdateCatalog(this, catalog, monitor, file.FilePath);
                            }
                        }
                    }
                }
                if (monitor.IsCancelRequested)
                {
                    return;
                }
                monitor.Step(1);
            }
            catalog.Save(Path.Combine(this.BaseDirectory, "messages.po"));
        }
Esempio n. 14
0
        protected override void OnClean(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            if (ParentSolution == null)
            {
                return;
            }
            SolutionConfiguration conf = ParentSolution.GetConfiguration(configuration);

            if (conf == null)
            {
                return;
            }

            try {
                monitor.BeginTask(GettextCatalog.GetString("Cleaning Solution {0}", Name), Items.Count);

                foreach (SolutionItem item in Items)
                {
                    if (item is SolutionFolder)
                    {
                        item.Clean(monitor, configuration);
                    }
                    else if (item is SolutionEntityItem)
                    {
                        SolutionEntityItem         si = (SolutionEntityItem)item;
                        SolutionConfigurationEntry ce = conf.GetEntryForItem(si);
                        if (ce.Build)
                        {
                            si.Clean(monitor, ce.ItemConfigurationSelector);
                        }
                    }
                    else
                    {
                        item.Clean(monitor, configuration);
                    }
                    monitor.Step(1);
                }
            }
            finally {
                monitor.EndTask();
            }
        }
        protected override SolutionEntityItem LoadSolutionItem(IProgressMonitor monitor, string fileName)
        {
            SolutionEntityItem entry = base.LoadSolutionItem(monitor, fileName);

            if (entry == null)
            {
                return(null);
            }

            Project project = entry as Project;

            if (project == null)
            {
                return(entry);
            }

            //Project
            MakefileData data = entry.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;

            if (data == null)
            {
                return(entry);
            }

            monitor.BeginTask(GettextCatalog.GetString("Updating project from Makefile"), 1);
            try {
                data.OwnerProject = project;
                if (data.SupportsIntegration)
                {
                    data.UpdateProject(monitor, false);
                }
                monitor.Step(1);
            } catch (Exception e) {
                monitor.ReportError(GettextCatalog.GetString(
                                        "Error loading Makefile for project {0}", project.Name), e);
            } finally {
                monitor.EndTask();
            }

            entry.SetNeedsBuilding(false);
            return(entry);
        }
        protected override void Execute(IProgressMonitor monitor, SolutionEntityItem entry, ExecutionContext context, ConfigurationSelector configuration)
        {
            Project project = entry as Project;

            if (project == null)
            {
                base.Execute(monitor, entry, context, configuration);
                return;
            }

            MakefileData data = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;

            if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty(data.ExecuteTargetName))
            {
                base.Execute(monitor, entry, context, configuration);
                return;
            }

            IConsole console = context.ConsoleFactory.CreateConsole(true);

            monitor.BeginTask(GettextCatalog.GetString("Executing {0}", project.Name), 1);
            try
            {
                ProcessWrapper process = Runtime.ProcessService.StartProcess("make",
                                                                             data.ExecuteTargetName,
                                                                             project.BaseDirectory,
                                                                             console.Out,
                                                                             console.Error,
                                                                             null);
                process.WaitForOutput();

                monitor.Log.WriteLine(GettextCatalog.GetString("The application exited with code: {0}", process.ExitCode));
                monitor.Step(1);
            } catch (Exception e) {
                monitor.ReportError(GettextCatalog.GetString("Project could not be executed: "), e);
                return;
            } finally {
                monitor.EndTask();
                console.Dispose();
            }
        }
        public void OnReload()
        {
            var solutions = new HashSet <Solution> ();

            using (IProgressMonitor m = IdeApp.Workbench.ProgressMonitors.GetProjectLoadProgressMonitor(true)) {
                m.BeginTask(null, CurrentNodes.Length);
                foreach (ITreeNavigator node in CurrentNodes)
                {
                    UnknownSolutionItem entry = (UnknownSolutionItem)node.DataItem;
                    if (!entry.Enabled)
                    {
                        entry.Enabled = true;
                        solutions.Add(entry.ParentSolution);
                    }
                    entry.ParentFolder.ReloadItem(m, entry);
                    m.Step(1);
                }
                m.EndTask();
            }
            IdeApp.ProjectOperations.Save(solutions);
        }
Esempio n. 18
0
        /// <summary>
        /// Cleans the files produced by this solution item
        /// </summary>
        /// <param name='monitor'>
        /// A progress monitor
        /// </param>
        /// <param name='configuration'>
        /// Configuration to use to clean the project
        /// </param>
        public void Clean(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            ITimeTracker tt = Counters.BuildProjectTimer.BeginTiming("Cleaning " + Name);

            try {
                try {
                    SolutionEntityItem        it    = this as SolutionEntityItem;
                    SolutionItemConfiguration iconf = it != null?it.GetConfiguration(configuration) : null;

                    string confName = iconf != null ? iconf.Id : configuration.ToString();
                    monitor.BeginTask(GettextCatalog.GetString("Cleaning: {0} ({1})", Name, confName), 1);
                    RunTarget(monitor, ProjectService.CleanTarget, configuration);
                    monitor.Step(1);
                } finally {
                    monitor.EndTask();
                }
            }
            finally {
                tt.End();
            }
        }
Esempio n. 19
0
 public IEnumerable<Tuple<ProjectDom, FilePath>> GetFileNames(Solution solution, ProjectDom dom, ICompilationUnit unit, IProgressMonitor monitor)
 {
     int counter = 0;
     ReadOnlyCollection<Project> allProjects = solution.GetAllProjects();
     if (monitor != null)
         monitor.BeginTask(GettextCatalog.GetString("Finding references in solution..."),
       			allProjects.Sum<Project>(p => p.Files.Count));
         foreach (Project project in allProjects) {
             if (monitor != null && monitor.IsCancelRequested) yield break;
             ProjectDom currentDom = ProjectDomService.GetProjectDom(project);
             foreach (ProjectFile projectFile in (Collection<ProjectFile>) project.Files) {
                 if (monitor != null && monitor.IsCancelRequested) yield break;
                 yield return Tuple.Create<ProjectDom, FilePath>(currentDom, projectFile.FilePath);
                 if (monitor != null) {
                     if (counter % 10 == 0) monitor.Step(10);
                     ++counter;
                 }
             }
         }
       if (monitor != null) monitor.EndTask();
 }
Esempio n. 20
0
        public static bool WaitForRunningTools(IProgressMonitor monitor)
        {
            IAsyncOperation[] operations;
            lock (runningTasks) {
                operations = runningTasks.Values.ToArray();
            }

            if (operations.Length == 0)
            {
                return(true);
            }

            monitor.BeginTask("Waiting for custom tools...", operations.Length);

            var evt = new AutoResetEvent(false);

            monitor.CancelRequested += delegate {
                evt.Set();
            };

            OperationHandler checkOp = delegate {
                monitor.Step(1);
                if (operations.All(op => op.IsCompleted))
                {
                    evt.Set();
                }
            };

            foreach (var o in operations)
            {
                o.Completed += checkOp;
            }

            evt.WaitOne();

            monitor.EndTask();

            //the tool operations display warnings themselves
            return(operations.Any(op => !op.SuccessWithWarnings));
        }
Esempio n. 21
0
        public IEnumerable <Tuple <ProjectDom, FilePath> > GetFileNames(Solution solution, ProjectDom dom, ICompilationUnit unit, IProgressMonitor monitor)
        {
            int counter = 0;
            ReadOnlyCollection <Project> allProjects = solution.GetAllProjects();

            if (monitor != null)
            {
                monitor.BeginTask(GettextCatalog.GetString("Finding references in solution..."),
                                  allProjects.Sum <Project>(p => p.Files.Count));
            }
            foreach (Project project in allProjects)
            {
                if (monitor != null && monitor.IsCancelRequested)
                {
                    yield break;
                }
                ProjectDom currentDom = ProjectDomService.GetProjectDom(project);
                foreach (ProjectFile projectFile in (Collection <ProjectFile>)project.Files)
                {
                    if (monitor != null && monitor.IsCancelRequested)
                    {
                        yield break;
                    }
                    yield return(Tuple.Create <ProjectDom, FilePath>(currentDom, projectFile.FilePath));

                    if (monitor != null)
                    {
                        if (counter % 10 == 0)
                        {
                            monitor.Step(10);
                        }
                        ++counter;
                    }
                }
            }
            if (monitor != null)
            {
                monitor.EndTask();
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Copies resource files from the Xcode project (back) to the MonoDevelop project directory.
        /// </summary>
        /// <param name='monitor'>
        /// A progress monitor.
        /// </param>
        /// <param name='context'>
        /// The sync context.
        /// </param>
        void CopyFilesToMD(IProgressMonitor monitor, XcodeSyncBackContext context)
        {
            if (context.FileSyncJobs.Count == 0)
            {
                return;
            }

            monitor.BeginStepTask("Copying files from Xcode back to MonoDevelop...", context.FileSyncJobs.Count, 1);

            foreach (var file in context.FileSyncJobs)
            {
                monitor.Log.WriteLine("Copying {0} file from Xcode: {1}", file.IsFreshlyAdded ? "new" : "changed", file.SyncedRelative);

                if (!Directory.Exists(file.Original.ParentDirectory))
                {
                    Directory.CreateDirectory(file.Original.ParentDirectory);
                }

                var      tempFile = file.Original.ParentDirectory.Combine(".#" + file.Original.ParentDirectory.FileName);
                FilePath path     = context.ProjectDir.Combine(file.SyncedRelative);

                if (File.Exists(path))
                {
                    File.Copy(path, tempFile);
                    FileService.SystemRename(tempFile, file.Original);

                    DateTime mtime = File.GetLastWriteTime(file.Original);
                    context.SetSyncTime(file.SyncedRelative, mtime);
                }
                else
                {
                    monitor.ReportWarning(string.Format("'{0}' does not exist.", file.SyncedRelative));
                }

                monitor.Step(1);
            }

            monitor.EndTask();
        }
		void InstallEntry (IProgressMonitor monitor, DeployContext ctx, SolutionItem entry, ConfigurationSelector configuration)
		{
			foreach (DeployFile df in DeployService.GetDeployFiles (ctx, new SolutionItem[] { entry }, configuration)) {
				string targetPath = df.ResolvedTargetFile;
				if (targetPath == null) {
					monitor.ReportWarning ("Could not copy file '" + df.RelativeTargetPath + "': Unknown target directory.");
					continue;
				}
				
				CopyFile (monitor, df.SourcePath, df.ResolvedTargetFile, df.FileAttributes);
			}
			
			SolutionFolder c = entry as SolutionFolder;
			if (c != null) {
				monitor.BeginTask ("Installing solution '" + c.Name + "'", c.Items.Count);
				foreach (SolutionItem ce in c.Items) {
					InstallEntry (monitor, ctx, ce, configuration);
					monitor.Step (1);
				}
				monitor.EndTask ();
			}
		}
Esempio n. 24
0
        void UpdateRepository(IProgressMonitor monitor, Uri baseUri, RepositoryRecord rr)
        {
            Uri absUri = new Uri(baseUri, rr.Url);

            monitor.BeginTask("Updating from " + absUri.ToString(), 2);
            Repository newRep = null;
            Exception  error  = null;

            try {
                newRep = (Repository)service.Store.DownloadObject(monitor, absUri.ToString(), typeof(Repository));
            } catch (Exception ex) {
                error = ex;
            }

            if (newRep == null)
            {
                monitor.ReportError("Could not get information from repository" + ": " + absUri.ToString(), error);
                return;
            }

            monitor.Step(1);

            foreach (ReferenceRepositoryEntry re in newRep.Repositories)
            {
                Uri              refRepUri = new Uri(absUri, re.Url);
                string           refRepUrl = refRepUri.ToString();
                RepositoryRecord refRep    = FindRepositoryRecord(refRepUrl);
                if (refRep == null)
                {
                    refRep = RegisterRepository(refRepUrl, true);
                }
                if (refRep.LastModified < re.LastModified)
                {
                    UpdateRepository(monitor, refRepUri, refRep);
                }
            }
            monitor.EndTask();
            rr.UpdateCachedRepository(newRep);
        }
        public void UpdateRepository(IProgressStatus statusMonitor, string url)
        {
            repoList = null;

            IProgressMonitor monitor = ProgressStatusMonitor.GetProgressMonitor(statusMonitor);

            monitor.BeginTask("Updating repositories", service.Configuration.Repositories.Count);
            try {
                int num = service.Configuration.Repositories.Count;
                for (int n = 0; n < num; n++)
                {
                    RepositoryRecord rr = (RepositoryRecord)service.Configuration.Repositories [n];
                    if ((url == null || rr.Url == url) && !rr.IsReference)
                    {
                        UpdateRepository(monitor, new Uri(rr.Url), rr);
                    }
                    monitor.Step(1);
                }
            } finally {
                monitor.EndTask();
            }
            service.SaveConfiguration();
        }
Esempio n. 26
0
        public XcodeSyncBackContext GetChanges(IProgressMonitor monitor, NSObjectInfoService infoService, DotNetProject project)
        {
            var ctx        = new XcodeSyncBackContext(projectDir, syncTimeCache, infoService, project);
            var needsSync  = new List <XcodeSyncedItem> (items.Where(i => i.NeedsSyncBack(ctx)));
            var knownFiles = GetKnownFiles();

            ScanForAddedFiles(ctx, knownFiles, projectDir, null);

            if (needsSync.Count > 0)
            {
                monitor.BeginStepTask(GettextCatalog.GetString("Synchronizing Xcode project changes"), needsSync.Count, 1);
                for (int i = 0; i < needsSync.Count; i++)
                {
                    var item = needsSync [i];
                    item.SyncBack(ctx);
                    monitor.Step(1);
                }

                monitor.Log.WriteLine(GettextCatalog.GetPluralString("Synchronized {0} file", "Synchronized {0} files", needsSync.Count), needsSync.Count);
                monitor.EndTask();
            }

            return(ctx);
        }
Esempio n. 27
0
        static IAsyncOperation BuildPackages(ICollection packages)
        {
            IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor(true);

            // Run the deploy command in a background thread to avoid
            // deadlocks with the gui thread

            System.Threading.Thread t = new System.Threading.Thread(
                delegate() {
                using (mon) {
                    mon.BeginTask("Creating packages", packages.Count);
                    foreach (Package p in packages)
                    {
                        DeployService.BuildPackage(mon, p);
                        mon.Step(1);
                    }
                    mon.EndTask();
                }
            });
            t.IsBackground = true;
            t.Start();

            return(mon.AsyncOperation);
        }
        public Translation AddNewTranslation(string isoCode, IProgressMonitor monitor)
        {
            try {
                Translation tr = new Translation(this, isoCode);
                translations.Add(tr);
                string templateFile    = Path.Combine(this.BaseDirectory, "messages.po");
                string translationFile = GetFileName(isoCode);
                if (!File.Exists(templateFile))
                {
                    CreateDefaultCatalog(monitor);
                }
                File.Copy(templateFile, translationFile);

                monitor.ReportSuccess(String.Format(GettextCatalog.GetString("Language '{0}' successfully added."), isoCode));
                monitor.Step(1);
                this.Save(monitor);
                return(tr);
            } catch (Exception e) {
                monitor.ReportError(String.Format(GettextCatalog.GetString("Language '{0}' could not be added: "), isoCode), e);
                return(null);
            } finally {
                monitor.EndTask();
            }
        }
Esempio n. 29
0
        protected override void DoClean(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            var cfg = GetConfiguration(configuration) as DProjectConfiguration;

            // delete obj/res files
            monitor.BeginTask("Delete intermediate files", Files.Count);
            foreach (var f in Files)
            {
                try {
                    if (File.Exists(f.LastGenOutput))
                    {
                        File.Delete(f.LastGenOutput);
                    }
                } catch (Exception ex) {
                    monitor.ReportError("Error while removing " + f, ex);
                } finally {
                    f.LastGenOutput = string.Empty;
                    monitor.Step(1);
                }
            }
            monitor.EndTask();

            // delete target file
            monitor.BeginTask("Delete output file", 1);

            if (File.Exists(cfg.CompiledOutputName))
            {
                File.Delete(cfg.CompiledOutputName);
            }

            DeleteSupportFiles(monitor, cfg.Selector);

            monitor.EndTask();

            monitor.ReportSuccess("Cleanup successful!");
        }
Esempio n. 30
0
		public static void Initialize (IProgressMonitor monitor)
		{
			Counters.Initialization.Trace ("Creating Workbench");
			workbench = new Workbench ();
			Counters.Initialization.Trace ("Creating Root Workspace");
			workspace = new RootWorkspace ();
			Counters.Initialization.Trace ("Creating Services");
			projectOperations = new ProjectOperations ();
			helpOperations = new HelpOperations ();
			commandService = new CommandManager ();
			ideServices = new IdeServices ();
			CustomToolService.Init ();
			AutoTestService.Start (commandService, Preferences.EnableAutomatedTesting);
			
			commandService.CommandTargetScanStarted += CommandServiceCommandTargetScanStarted;
			commandService.CommandTargetScanFinished += CommandServiceCommandTargetScanFinished;

			KeyBindingService.LoadBindingsFromExtensionPath ("/MonoDevelop/Ide/KeyBindingSchemes");
			KeyBindingService.LoadCurrentBindings ("MD2");

			commandService.CommandError += delegate (object sender, CommandErrorArgs args) {
				MessageService.ShowException (args.Exception, args.ErrorMessage);
			};
			
			FileService.ErrorHandler = FileServiceErrorHandler;
		
			monitor.BeginTask (GettextCatalog.GetString("Loading Workbench"), 5);
			Counters.Initialization.Trace ("Loading Commands");
			
			commandService.LoadCommands ("/MonoDevelop/Ide/Commands");
			monitor.Step (1);

			Counters.Initialization.Trace ("Initializing Workbench");
			workbench.Initialize (monitor);
			monitor.Step (1);
			
			InternalLog.EnableErrorNotification ();
			
			monitor.Step (1);

			Counters.Initialization.Trace ("Restoring Workbench State");
			workbench.Show ("SharpDevelop.Workbench.WorkbenchMemento");
			monitor.Step (1);
			
			Counters.Initialization.Trace ("Flushing GUI events");
			DispatchService.RunPendingEvents ();
			Counters.Initialization.Trace ("Flushed GUI events");
			
			MessageService.RootWindow = workbench.RootWindow;
		
			commandService.EnableIdleUpdate = true;
			
			// Default file format
			MonoDevelop.Projects.Services.ProjectServiceLoaded += delegate(object sender, EventArgs e) {
				((ProjectService)sender).DefaultFileFormatId = IdeApp.Preferences.DefaultProjectFileFormat;
			};
			
			IdeApp.Preferences.DefaultProjectFileFormatChanged += delegate {
				IdeApp.Services.ProjectService.DefaultFileFormatId = IdeApp.Preferences.DefaultProjectFileFormat;
			};

			// Perser service initialization
			MonoDevelop.Projects.Dom.Parser.ProjectDomService.TrackFileChanges = true;
			MonoDevelop.Projects.Dom.Parser.ProjectDomService.ParseProgressMonitorFactory = new ParseProgressMonitorFactory (); 

			
			// Startup commands
			Counters.Initialization.Trace ("Running Startup Commands");
			AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Ide/StartupHandlers", OnExtensionChanged);
			monitor.EndTask ();

			// Set initial run flags
			Counters.Initialization.Trace ("Upgrading Settings");

			if (PropertyService.Get("MonoDevelop.Core.FirstRun", false)) {
				isInitialRun = true;
				PropertyService.Set ("MonoDevelop.Core.FirstRun", false);
				PropertyService.Set ("MonoDevelop.Core.LastRunVersion", BuildVariables.PackageVersion);
				PropertyService.Set ("MonoDevelop.Core.LastRunVersion", CurrentRevision);
				PropertyService.SaveProperties ();
			}

			string lastVersion = PropertyService.Get ("MonoDevelop.Core.LastRunVersion", "1.9.1");
			int lastRevision = PropertyService.Get ("MonoDevelop.Core.LastRunRevision", 0);
			if (lastRevision != CurrentRevision && !isInitialRun) {
				isInitialRunAfterUpgrade = true;
				if (lastRevision == 0) {
					switch (lastVersion) {
						case "1.0": lastRevision = 1; break;
						case "2.0": lastRevision = 2; break;
						case "2.2": lastRevision = 3; break;
						case "2.2.1": lastRevision = 4; break;
					}
				}
				upgradedFromRevision = lastRevision;
				PropertyService.Set ("MonoDevelop.Core.LastRunVersion", BuildVariables.PackageVersion);
				PropertyService.Set ("MonoDevelop.Core.LastRunRevision", CurrentRevision);
				PropertyService.SaveProperties ();
			}
			
			// The ide is now initialized

			isInitialized = true;
			
			if (isInitialRun) {
				try {
					OnInitialRun ();
				} catch (Exception e) {
					LoggingService.LogError ("Error found while initializing the IDE", e);
				}
			}

			if (isInitialRunAfterUpgrade) {
				try {
					OnUpgraded (upgradedFromRevision);
				} catch (Exception e) {
					LoggingService.LogError ("Error found while initializing the IDE", e);
				}
			}
			
			if (initializedEvent != null)
				initializedEvent (null, EventArgs.Empty);
			
			// load previous combine
			if ((bool)PropertyService.Get("SharpDevelop.LoadPrevProjectOnStartup", false)) {
				RecentOpen recentOpen = Workbench.RecentOpen;

				if (recentOpen.RecentProjectsCount > 0) { 
					IdeApp.Workspace.OpenWorkspaceItem(recentOpen.RecentProjects.First ().ToString()).WaitForCompleted ();
				}
			}
			
			commandService.CommandSelected += OnCommandSelected;
			commandService.CommandDeselected += OnCommandDeselected;
			
			//FIXME: we should really make this on-demand. consumers can display a "loading help cache" message like VS
			MonoDevelop.Projects.HelpService.AsyncInitialize ();
			
			UpdateInstrumentationIcon ();
			IdeApp.Preferences.EnableInstrumentationChanged += delegate {
				UpdateInstrumentationIcon ();
			};
			AutoTestService.NotifyEvent ("MonoDevelop.Ide.IdeStart");
		}
Esempio n. 31
0
		// Note: This method may throw TimeoutException or AppleScriptException
		public void UpdateProject (IProgressMonitor monitor, List<XcodeSyncedItem> allItems, XcodeProject emptyProject)
		{
			items = allItems;
			
			monitor.BeginTask (GettextCatalog.GetString ("Updating Xcode project for {0}...", name), items.Count);
			
			var ctx = new XcodeSyncContext (projectDir, syncTimeCache);
			
			var toRemove = new HashSet<string> (itemMap.Keys);
			var toClose = new HashSet<string> ();
			var syncList = new List<XcodeSyncedItem> ();
			bool updateProject = false;
			
			foreach (var item in items) {
				bool needsSync = item.NeedsSyncOut (monitor, ctx);
				if (needsSync)
					syncList.Add (item);
				
				var files = item.GetTargetRelativeFileNames ();
				foreach (var file in files) {
					toRemove.Remove (file);
					
					if (!itemMap.ContainsKey (file)) {
						monitor.Log.WriteLine ("'{0}' needs to be updated.", file);
						updateProject = true;
					} else if (needsSync) {
						monitor.Log.WriteLine ("'{0}' needs to be closed.", file);
						toClose.Add (file);
					}
					
					itemMap[file] = item;
				}
			}
			updateProject = updateProject || toRemove.Any ();
			
			bool removedOldProject = false;
			if (updateProject) {
				if (pendingProjectWrite == null && ProjectExists ()) {
					monitor.Log.WriteLine ("A project file needs to be updated, closing and removing old project.");
					CloseProject ();
					DeleteXcproj (monitor);
					removedOldProject = true;
				}
			} else {
				foreach (var f in toClose)
					CloseFile (monitor, projectDir.Combine (f));
			}
			
			foreach (var f in toRemove) {
				itemMap.Remove (f);
				syncTimeCache.Remove (f);
				var path = projectDir.Combine (f);
				if (File.Exists (path))
					File.Delete (path);
			}
			
			if (removedOldProject) {
				HackRelocateProject (monitor);
				ctx.ProjectDir = projectDir;
			}
			
			foreach (var item in items) {
				if (updateProject)
					item.AddToProject (emptyProject, projectDir);
			}
			
			foreach (var item in syncList) {
				item.SyncOut (monitor, ctx);
				monitor.Step (1);
			}
			
			if (updateProject) {
				monitor.Log.WriteLine ("Queued write of '{0}'.", xcproj);
				pendingProjectWrite = emptyProject;
			}

			monitor.EndTask ();
			monitor.ReportSuccess (GettextCatalog.GetString ("Xcode project updated."));
		}
Esempio n. 32
0
		public XcodeSyncBackContext GetChanges (IProgressMonitor monitor, NSObjectInfoService infoService, DotNetProject project)
		{
			var ctx = new XcodeSyncBackContext (projectDir, syncTimeCache, infoService, project);
			var needsSync = new List<XcodeSyncedItem> (items.Where (i => i.NeedsSyncBack (monitor, ctx)));
			var knownFiles = GetKnownFiles ();
			
			if (Directory.Exists (projectDir)) {
				monitor.BeginTask ("Scanning for newly-added files in the Xcode project...", 0);
				ScanForAddedFiles (monitor, ctx, knownFiles, projectDir, null);
				monitor.EndTask ();
			}
			
			if (needsSync.Count > 0) {
				monitor.BeginStepTask (GettextCatalog.GetString ("Synchronizing changes made to known files in Xcode back to MonoDevelop..."), needsSync.Count, 1);
				for (int i = 0; i < needsSync.Count; i++) {
					var item = needsSync [i];
					item.SyncBack (monitor, ctx);
					monitor.Step (1);
				}
				monitor.EndTask ();
			}
			
			return ctx;
		}
Esempio n. 33
0
		public override void Revert (FilePath[] localPaths, bool recurse, IProgressMonitor monitor)
		{
			foreach (var group in localPaths.GroupBy (f => GetRepository (f))) {
				var repository = group.Key;
				var files = group.ToArray ();

			var c = GetHeadCommit (repository);
			RevTree tree = c != null ? c.Tree : null;
			
			List<FilePath> changedFiles = new List<FilePath> ();
			List<FilePath> removedFiles = new List<FilePath> ();
			
			monitor.BeginTask (GettextCatalog.GetString ("Reverting files"), 3);
			monitor.BeginStepTask (GettextCatalog.GetString ("Reverting files"), files.Length, 2);
			
			DirCache dc = repository.LockDirCache ();
			DirCacheBuilder builder = dc.Builder ();
			
			try {
				HashSet<string> entriesToRemove = new HashSet<string> ();
				HashSet<string> foldersToRemove = new HashSet<string> ();
				
				// Add the new entries
				foreach (FilePath fp in files) {
					string p = repository.ToGitPath (fp);
					
					// Register entries to be removed from the index
					if (Directory.Exists (fp))
						foldersToRemove.Add (p);
					else
						entriesToRemove.Add (p);
					
					TreeWalk tw = tree != null ? TreeWalk.ForPath (repository, p, tree) : null;
					if (tw == null) {
						// Removed from the index
					}
					else {
						// Add new entries
						
						TreeWalk r;
						if (tw.IsSubtree) {
							// It's a directory. Make sure we remove existing index entries of this directory
							foldersToRemove.Add (p);
							
							// We have to iterate through all folder files. We need a new iterator since the
							// existing rw is not recursive
							r = new NGit.Treewalk.TreeWalk(repository);
							r.Reset (tree);
							r.Filter = PathFilterGroup.CreateFromStrings(new string[]{p});
							r.Recursive = true;
							r.Next ();
						} else {
							r = tw;
						}
						
						do {
							// There can be more than one entry if reverting a whole directory
							string rpath = repository.FromGitPath (r.PathString);
							DirCacheEntry e = new DirCacheEntry (r.PathString);
							e.SetObjectId (r.GetObjectId (0));
							e.FileMode = r.GetFileMode (0);
							if (!Directory.Exists (Path.GetDirectoryName (rpath)))
								Directory.CreateDirectory (rpath);
							DirCacheCheckout.CheckoutEntry (repository, rpath, e);
							builder.Add (e);
							changedFiles.Add (rpath);
						} while (r.Next ());
					}
					monitor.Step (1);
				}
				
				// Add entries we want to keep
				int count = dc.GetEntryCount ();
				for (int n=0; n<count; n++) {
					DirCacheEntry e = dc.GetEntry (n);
					string path = e.PathString;
					if (!entriesToRemove.Contains (path) && !foldersToRemove.Any (f => IsSubpath (f,path)))
						builder.Add (e);
				}
				
				builder.Commit ();
			}
			catch {
				dc.Unlock ();
				throw;
			}
			
			monitor.EndTask ();
			monitor.BeginTask (null, files.Length);

			foreach (FilePath p in changedFiles) {
				FileService.NotifyFileChanged (p);
				monitor.Step (1);
			}
			foreach (FilePath p in removedFiles) {
				FileService.NotifyFileRemoved (p);
				monitor.Step (1);
			}
			monitor.EndTask ();
			}
		}
Esempio n. 34
0
		public void Merge (string branch, bool saveLocalChanges, IProgressMonitor monitor)
		{
			IEnumerable<DiffEntry> statusList = null;
			Stash stash = null;
			StashCollection stashes = GetStashes (RootRepository);
			monitor.BeginTask (null, 4);
			
			try {
				// Get a list of files that are different in the target branch
				statusList = GitUtil.GetChangedFiles (RootRepository, branch);
				monitor.Step (1);
				
				if (saveLocalChanges) {
					monitor.BeginTask (GettextCatalog.GetString ("Merging"), 3);
					monitor.Log.WriteLine (GettextCatalog.GetString ("Saving local changes"));
					using (var gm = new GitMonitor (monitor))
						stash = stashes.Create (gm, GetStashName ("_tmp_"));
					monitor.Step (1);
				}
				
				// Apply changes
				
				ObjectId branchId = RootRepository.Resolve (branch);
				
				NGit.Api.Git git = new NGit.Api.Git (RootRepository);
				MergeCommandResult mergeResult = git.Merge ().SetStrategy (MergeStrategy.RESOLVE).Include (branchId).Call ();
				if (mergeResult.GetMergeStatus () == MergeStatus.CONFLICTING || mergeResult.GetMergeStatus () == MergeStatus.FAILED) {
					var conflicts = mergeResult.GetConflicts ();
					bool commit = true;
					if (conflicts != null) {
						foreach (string conflictFile in conflicts.Keys) {
							ConflictResult res = ResolveConflict (RootRepository.FromGitPath (conflictFile));
							if (res == ConflictResult.Abort) {
								GitUtil.HardReset (RootRepository, GetHeadCommit (RootRepository));
								commit = false;
								break;
							} else if (res == ConflictResult.Skip) {
								Revert (RootRepository.FromGitPath (conflictFile), false, monitor);
								break;
							}
						}
					}
					if (commit)
						git.Commit ().Call ();
				}
				
			} finally {
				if (saveLocalChanges)
					monitor.Step (1);
				
				// Restore local changes
				if (stash != null) {
					monitor.Log.WriteLine (GettextCatalog.GetString ("Restoring local changes"));
					using (var gm = new GitMonitor (monitor))
						stash.Apply (gm);
					stashes.Remove (stash);
					monitor.EndTask ();
				}
			}
			monitor.Step (1);
			
			// Notify changes
			if (statusList != null)
				NotifyFileChanges (monitor, statusList);
			
			monitor.EndTask ();
		}
Esempio n. 35
0
		public void Rebase (string upstreamRef, bool saveLocalChanges, IProgressMonitor monitor)
		{
			StashCollection stashes = GitUtil.GetStashes (RootRepository);
			Stash stash = null;
			
			try
			{
				if (saveLocalChanges) {
					monitor.BeginTask (GettextCatalog.GetString ("Rebasing"), 3);
					monitor.Log.WriteLine (GettextCatalog.GetString ("Saving local changes"));
					using (var gm = new GitMonitor (monitor))
						stash = stashes.Create (gm, GetStashName ("_tmp_"));
					monitor.Step (1);
				}
				
				NGit.Api.Git git = new NGit.Api.Git (RootRepository);
				RebaseCommand rebase = git.Rebase ();
				rebase.SetOperation (RebaseCommand.Operation.BEGIN);
				rebase.SetUpstream (upstreamRef);
				
				var gmonitor = new GitMonitor (monitor);
				rebase.SetProgressMonitor (gmonitor);
				
				bool aborted = false;
				
				try {
					var result = rebase.Call ();
					while (!aborted && result.GetStatus () == RebaseResult.Status.STOPPED) {
						rebase = git.Rebase ();
						rebase.SetProgressMonitor (gmonitor);
						rebase.SetOperation (RebaseCommand.Operation.CONTINUE);
						bool commitChanges = true;
						var conflicts = GitUtil.GetConflictedFiles (RootRepository);
						foreach (string conflictFile in conflicts) {
							ConflictResult res = ResolveConflict (RootRepository.FromGitPath (conflictFile));
							if (res == ConflictResult.Abort) {
								aborted = true;
								commitChanges = false;
								rebase.SetOperation (RebaseCommand.Operation.ABORT);
								break;
							} else if (res == ConflictResult.Skip) {
								rebase.SetOperation (RebaseCommand.Operation.SKIP);
								commitChanges = false;
								break;
							}
						}
						if (commitChanges) {
							NGit.Api.AddCommand cmd = git.Add ();
							foreach (string conflictFile in conflicts)
								cmd.AddFilepattern (conflictFile);
							cmd.Call ();
						}
						result = rebase.Call ();
					}
				} catch {
					if (!aborted) {
						rebase = git.Rebase ();
						rebase.SetOperation (RebaseCommand.Operation.ABORT);
						rebase.SetProgressMonitor (gmonitor);
						rebase.Call ();
					}
					throw;
				} finally {
					gmonitor.Dispose ();
				}
				
			} finally {
				if (saveLocalChanges)
					monitor.Step (1);
				
				// Restore local changes
				if (stash != null) {
					monitor.Log.WriteLine (GettextCatalog.GetString ("Restoring local changes"));
					using (var gm = new GitMonitor (monitor))
						stash.Apply (gm);
					stashes.Remove (stash);
					monitor.EndTask ();
				}
			}			
		}
Esempio n. 36
0
		public override void Update (FilePath[] localPaths, bool recurse, IProgressMonitor monitor)
		{
			IEnumerable<DiffEntry> statusList = null;
			
			monitor.BeginTask (GettextCatalog.GetString ("Updating"), 5);
			
			// Fetch remote commits
			string remote = GetCurrentRemote ();
			if (remote == null)
				throw new InvalidOperationException ("No remotes defined");
			monitor.Log.WriteLine (GettextCatalog.GetString ("Fetching from '{0}'", remote));
			RemoteConfig remoteConfig = new RemoteConfig (RootRepository.GetConfig (), remote);
			Transport tn = Transport.Open (RootRepository, remoteConfig);
			using (var gm = new GitMonitor (monitor))
				tn.Fetch (gm, null);
			monitor.Step (1);
			
			string upstreamRef = GitUtil.GetUpstreamSource (RootRepository, GetCurrentBranch ());
			if (upstreamRef == null)
				upstreamRef = GetCurrentRemote () + "/" + GetCurrentBranch ();
			
			if (GitService.UseRebaseOptionWhenPulling)
				Rebase (upstreamRef, GitService.StashUnstashWhenUpdating, monitor);
			else
				Merge (upstreamRef, GitService.StashUnstashWhenUpdating, monitor);

			monitor.Step (1);
			
			// Notify changes
			if (statusList != null)
				NotifyFileChanges (monitor, statusList);
			
			monitor.EndTask ();
		}
Esempio n. 37
0
		public override void MoveDirectory (FilePath localSrcPath, FilePath localDestPath, bool force, IProgressMonitor monitor)
		{
			VersionInfo[] versionedFiles = GetDirectoryVersionInfo (localSrcPath, false, true);
			base.MoveDirectory (localSrcPath, localDestPath, force, monitor);
			monitor.BeginTask ("Moving files", versionedFiles.Length);
			foreach (VersionInfo vif in versionedFiles) {
				if (vif.IsDirectory)
					continue;
				FilePath newDestPath = vif.LocalPath.ToRelative (localSrcPath).ToAbsolute (localDestPath);
				Add (newDestPath, false, monitor);
				monitor.Step (1);
			}
			monitor.EndTask ();
		}
Esempio n. 38
0
        public IEnumerable <SearchResult> FindAll(Scope scope, IProgressMonitor monitor, string pattern, string replacePattern, FilterOptions filter)
        {
            if (filter.RegexSearch)
            {
                RegexOptions regexOptions = RegexOptions.Compiled;
                if (!filter.CaseSensitive)
                {
                    regexOptions |= RegexOptions.IgnoreCase;
                }
                regex = new Regex(pattern, regexOptions);
            }
            IsRunning         = true;
            FoundMatchesCount = SearchedFilesCount = 0;
            monitor.BeginTask(scope.GetDescription(filter, pattern, replacePattern), 50);
            try {
                int totalWork = scope.GetTotalWork(filter);
                int step      = Math.Max(1, totalWork / 50);


                var contents = new List <Tuple <FileProvider, string, List <SearchResult> > >();
                foreach (var provider in scope.GetFiles(monitor, filter))
                {
                    try {
                        contents.Add(Tuple.Create(provider, provider.ReadString(), new List <SearchResult> ()));
                    } catch (FileNotFoundException) {
                        MessageService.ShowError(string.Format(GettextCatalog.GetString("File {0} not found.")), provider.FileName);
                    }
                }

                var results = new List <SearchResult>();
                Parallel.ForEach(contents, content => {
                    if (monitor.IsCancelRequested)
                    {
                        return;
                    }
                    try {
                        Interlocked.Increment(ref searchedFilesCount);
                        content.Item3.AddRange(FindAll(monitor, content.Item1, content.Item2, pattern, replacePattern, filter));
                        lock (results) {
                            results.AddRange(content.Item3);
                        }
                        FoundMatchesCount += content.Item3.Count;
                        if (searchedFilesCount % step == 0)
                        {
                            monitor.Step(1);
                        }
                    } catch (Exception e) {
                        LoggingService.LogError("Exception during search.", e);
                    }
                });

                if (replacePattern != null)
                {
                    foreach (var content in contents)
                    {
                        if (content.Item3.Count == 0)
                        {
                            continue;
                        }
                        try {
                            content.Item1.BeginReplace(content.Item2);
                            Replace(content.Item1, content.Item3, replacePattern);
                            content.Item1.EndReplace();
                        } catch (Exception e) {
                            LoggingService.LogError("Exception during replace.", e);
                        }
                    }
                }

                return(results);
            } finally {
                monitor.EndTask();
                IsRunning = false;
            }
        }
        //FIXME: Check whether autogen.sh is required or not
        protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
        {
            Project project = entry as Project;

            if (project == null)
            {
                return(base.Build(monitor, entry, configuration));
            }

            MakefileData data = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;

            if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty(data.BuildTargetName))
            {
                return(base.Build(monitor, entry, configuration));
            }

            //FIXME: Gen autofoo ? autoreconf?

            string output   = String.Empty;
            int    exitCode = 0;

            monitor.BeginTask(GettextCatalog.GetString("Building {0}", project.Name), 1);
            try
            {
                string baseDir = project.BaseDirectory;
                string args    = string.Format("-j {0} {1}", data.ParallelProcesses, data.BuildTargetName);

                StringWriter  swOutput      = new StringWriter();
                LogTextWriter chainedOutput = new LogTextWriter();
                chainedOutput.ChainWriter(monitor.Log);
                chainedOutput.ChainWriter(swOutput);

                ProcessWrapper process = Runtime.ProcessService.StartProcess("make",
                                                                             args,
                                                                             baseDir,
                                                                             chainedOutput,
                                                                             chainedOutput,
                                                                             null);
                process.WaitForOutput();

                exitCode = process.ExitCode;
                output   = swOutput.ToString();
                chainedOutput.Close();
                swOutput.Close();
                monitor.Step(1);
            }
            catch (Exception e)
            {
                monitor.ReportError(GettextCatalog.GetString("Project could not be built: "), e);
                return(null);
            }
            finally
            {
                monitor.EndTask();
            }

            TempFileCollection tf = new TempFileCollection();
            Regex regexError      = data.GetErrorRegex(false);
            Regex regexWarning    = data.GetWarningRegex(false);

            BuildResult cr = ParseOutput(tf, output, project.BaseDirectory, regexError, regexWarning);

            if (exitCode != 0 && cr.FailedBuildCount == 0)
            {
                cr.AddError(GettextCatalog.GetString("Build failed. See Build Output panel."));
            }

            return(cr);
        }
Esempio n. 40
0
        /// <summary>
        ///   Sign the native libraries inside the bundle.
        /// </summary>
        /// <param name = 'monitor'>The progress monitor.</param>
        /// <param name = 'project'>The project.</param>
        /// <param name = 'maker'>The bundle maker.</param>
        public static void SignNativeBinaries(IProgressMonitor monitor, MonobjcProject project, BundleMaker maker)
        {
            if (project.Signing && !String.IsNullOrEmpty(project.SigningIdentity)) {
                String[] files = Directory.GetFiles (maker.MacOSDirectory, "*.dylib");
                if (files == null || files.Count() == 0) {
                    return;
                }

                monitor.BeginTask (GettextCatalog.GetString ("Signing native libraries..."), files.Length);

                foreach (String file in files) {
                    using (StringWriter outputWriter = new StringWriter()) {
                        using (StringWriter errorWriter = new StringWriter()) {
                            CodeSign.PerformSigning (file, project.SigningIdentity, outputWriter, errorWriter);
                            LoggingService.LogInfo ("CodeSign returns: " + outputWriter.ToString ());
                        }
                    }
                    monitor.Step (1);
                }

                monitor.EndTask ();
            }
        }
Esempio n. 41
0
        /// <summary>
        ///   Embeds the XIB files.
        /// </summary>
        /// <param name = 'monitor'>The progress monitor.</param>
        /// <param name = 'project'>The project.</param>
        /// <param name = 'maker'>The bundle maker.</param>
        /// <param name = 'result'>The build result.</param>
        public static void EmbedXIBFiles(IProgressMonitor monitor, MonobjcProject project, BuildResult result)
        {
            XibCompiler xibCompiler = new XibCompiler ();
            IEnumerable<FilePair> files = project.GetIBFiles (Constants.EmbeddedInterfaceDefinition, null);
            if (files == null || files.Count() == 0) {
                return;
            }

            monitor.BeginTask (GettextCatalog.GetString ("Embed XIB files..."), files.Count ());
            foreach (FilePair pair in files) {
                // If the destination file is a place-holder, change its dates
                FileInfo sourceInfo = new FileInfo (pair.Source);
                FileInfo destInfo = new FileInfo (pair.Destination);
                if (destInfo.Length == 0) {
                    DateTime dateTime = sourceInfo.CreationTime.Subtract (new TimeSpan (0, 0, 1));
                    File.SetCreationTime (pair.Destination, dateTime);
                    File.SetLastAccessTime (pair.Destination, dateTime);
                    File.SetLastWriteTime (pair.Destination, dateTime);
                }

                FilePath relativeFile = pair.Source.ToRelative (project.BaseDirectory);
                monitor.Log.WriteLine (GettextCatalog.GetString ("Compiling {0}", relativeFile));
                xibCompiler.Logger = new BuildLogger (pair.Source, monitor, result);
                xibCompiler.Compile (pair.Source, pair.DestinationDir);

                monitor.Step (1);
            }
            monitor.EndTask ();
        }
Esempio n. 42
0
 /// <summary>
 /// Copies the Monobjc assemblies.
 /// </summary>
 /// <param name="monitor">The monitor.</param>
 /// <param name="project">The project.</param>
 /// <param name="configuration">The configuration.</param>
 /// <param name="maker">The maker.</param>
 public static void CopyMonobjcAssemblies(IProgressMonitor monitor, MonobjcProject project, ConfigurationSelector configuration, BundleMaker maker)
 {
     IEnumerable<String> assemblies = project.ProjectMonobjcAssemblies.Select (a => a.GetReferencedFileNames (configuration) [0]);
     monitor.BeginTask (GettextCatalog.GetString ("Copying Monobjc assemblies..."), assemblies.Count ());
     foreach (String assembly in assemblies) {
         String filename = Path.GetFileName (assembly);
         monitor.Log.WriteLine (GettextCatalog.GetString ("Copying {0}", filename));
         File.Copy (assembly, Path.Combine (maker.ResourcesFolder, filename), true);
         monitor.Step (1);
     }
     monitor.EndTask ();
 }
		//FIXME: Check whether autogen.sh is required or not
		protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
		{
			Project project = entry as Project;
			if (project == null)
				return base.Build (monitor, entry, configuration);

			MakefileData data = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
			if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.BuildTargetName))
				return base.Build (monitor, entry, configuration);

			//FIXME: Gen autofoo ? autoreconf?

			string output = String.Empty;
			int exitCode = 0;
			monitor.BeginTask (GettextCatalog.GetString ("Building {0}", project.Name), 1);
			try {
				string baseDir = project.BaseDirectory;
				StringBuilder args = new StringBuilder ();
				
				if (data.RelativeMakeCommand.EndsWith ("make", StringComparison.OrdinalIgnoreCase))
					args.AppendFormat (" -j {0}", data.ParallelProcesses, data.BuildTargetName);
				args.AppendFormat (" {0}", data.BuildTargetName);
	
				StringWriter swOutput = new StringWriter ();
				LogTextWriter chainedOutput = new LogTextWriter ();
				chainedOutput.ChainWriter (monitor.Log);
				chainedOutput.ChainWriter (swOutput);
				
				ProcessWrapper process = Runtime.ProcessService.StartProcess (data.AbsoluteMakeCommand, 
						args.ToString (), 
						baseDir, 
						chainedOutput, 
						chainedOutput, 
						null);
				process.WaitForOutput ();

				exitCode = process.ExitCode;
				output = swOutput.ToString ();
				chainedOutput.Close ();
				swOutput.Close ();
				monitor.Step (1);
			} catch (Exception e) {
				monitor.ReportError (GettextCatalog.GetString ("Project could not be built: "), e);
				return null;
			} finally {
				monitor.EndTask ();
			}

			TempFileCollection tf = new TempFileCollection ();
			Regex regexError = data.GetErrorRegex (false);
			Regex regexWarning = data.GetWarningRegex (false);

			BuildResult cr = ParseOutput (tf, output, project.BaseDirectory, regexError, regexWarning);
			if (exitCode != 0 && cr.FailedBuildCount == 0)
				cr.AddError (GettextCatalog.GetString ("Build failed. See Build Output panel."));
			else
				entry.SetNeedsBuilding (false, configuration);

			return cr;
		}
		protected override void Execute (IProgressMonitor monitor, SolutionEntityItem entry, ExecutionContext context, ConfigurationSelector configuration)
		{
			Project project = entry as Project;
			if (project == null) {
				base.Execute (monitor, entry, context, configuration);
				return;
			}

			MakefileData data = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
			if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.ExecuteTargetName)) {
				base.Execute (monitor, entry, context, configuration);
				return;
			}

			IConsole console = context.ConsoleFactory.CreateConsole (true);
			monitor.BeginTask (GettextCatalog.GetString ("Executing {0}", project.Name), 1);
			try
			{
				ProcessWrapper process = Runtime.ProcessService.StartProcess (data.AbsoluteMakeCommand,
						data.ExecuteTargetName,
						project.BaseDirectory,
						console.Out,
						console.Error,
						null);
				process.WaitForOutput ();

				monitor.Log.WriteLine (GettextCatalog.GetString ("The application exited with code: {0}", process.ExitCode));
				monitor.Step (1);
			} catch (Exception e) {
				monitor.ReportError (GettextCatalog.GetString ("Project could not be executed: "), e);
				return;
			} finally {
				monitor.EndTask ();
				console.Dispose ();
			}
		}
Esempio n. 45
0
 /// <summary>
 ///   Copies the content files.
 /// </summary>
 /// <param name = 'monitor'>The progress monitor.</param>
 /// <param name = 'project'>The project.</param>
 /// <param name = 'configuration'>The configuration.</param>
 /// <param name = 'maker'>The bundle maker.</param>
 public static void CopyOutputFiles(IProgressMonitor monitor, MonobjcProject project, ConfigurationSelector configuration, BundleMaker maker)
 {
     IEnumerable<FilePair> files = project.GetOutputFiles (configuration, maker.ResourcesFolder);
     if (files == null || files.Count() == 0) {
         return;
     }
     monitor.BeginTask (GettextCatalog.GetString ("Copying output files..."), files.Count ());
     foreach (FilePair pair in files) {
         monitor.Log.WriteLine (GettextCatalog.GetString ("Copying {0}", pair.Source.ToRelative (project.BaseDirectory)));
         pair.Copy (false);
         monitor.Step (1);
     }
     monitor.EndTask ();
 }
Esempio n. 46
0
		public Translation AddNewTranslation (string isoCode, IProgressMonitor monitor)
		{
			try {
				Translation tr = new Translation (this, isoCode);
				translations.Add (tr);
				string templateFile    = Path.Combine (this.BaseDirectory, "messages.po");
				string translationFile = GetFileName (isoCode);
				if (!File.Exists (templateFile)) 
					CreateDefaultCatalog (monitor);
				File.Copy (templateFile, translationFile);
				
				monitor.ReportSuccess (String.Format (GettextCatalog.GetString ("Language '{0}' successfully added."), isoCode));
				monitor.Step (1);
				this.Save (monitor);
				return tr;
			} catch (Exception e) {
				monitor.ReportError (String.Format ( GettextCatalog.GetString ("Language '{0}' could not be added: "), isoCode), e);
				return null;
			} finally {
				monitor.EndTask ();
			}
		}
Esempio n. 47
0
 /// <summary>
 /// Combines the artwork.
 /// </summary>
 public static void EncryptContentFiles(IProgressMonitor monitor, MonobjcProject project, ConfigurationSelector configuration, BundleMaker maker)
 {
     IEnumerable<FilePair> files = project.GetEncryptedContentFiles (configuration, maker.ResourcesFolder);
     if (files == null || files.Count() == 0) {
         return;
     }
     Aes provider = FileEncrypter.GetProvider (project.EncryptionSeed);
     monitor.BeginTask (GettextCatalog.GetString ("Encrypting content files..."), files.Count ());
     foreach (FilePair pair in files) {
         monitor.Log.WriteLine (GettextCatalog.GetString ("Encrypting {0}", pair.Source.ToRelative (project.BaseDirectory)));
         pair.Encrypt(provider);
         monitor.Step (1);
     }
     monitor.EndTask ();
 }
Esempio n. 48
0
		void CreateDefaultCatalog (IProgressMonitor monitor)
		{
			IFileScanner[] scanners = TranslationService.GetFileScanners ();
			
			Catalog catalog = new Catalog (this);
			List<Project> projects = new List<Project> ();
			foreach (Project p in ParentSolution.GetAllProjects ()) {
				if (IsIncluded (p))
					projects.Add (p);
			}
			foreach (Project p in projects) {
				monitor.Log.WriteLine (GettextCatalog.GetString ("Scanning project {0}...", p.Name));
				foreach (ProjectFile file in p.Files) {
					if (!File.Exists (file.FilePath))
						continue;
					if (file.Subtype == Subtype.Code) {
						string mimeType = DesktopService.GetMimeTypeForUri (file.FilePath);
						foreach (IFileScanner fs in scanners) {
							if (fs.CanScan (this, catalog, file.FilePath, mimeType))
								fs.UpdateCatalog (this, catalog, monitor, file.FilePath);
						}
					}
				}
				if (monitor.IsCancelRequested)
					return;
				monitor.Step (1);
			}
			catalog.Save (Path.Combine (this.BaseDirectory, "messages.po"));
		}
Esempio n. 49
0
 /// <summary>
 ///   Compiles the XIB files.
 /// </summary>
 /// <param name = 'monitor'>The progress monitor.</param>
 /// <param name = 'project'>The project.</param>
 /// <param name = 'maker'>The bundle maker.</param>
 /// <param name = 'result'>The build result.</param>
 public static void CompileXIBFiles(IProgressMonitor monitor, MonobjcProject project, BundleMaker maker, BuildResult result)
 {
     XibCompiler xibCompiler = new XibCompiler ();
     IEnumerable<FilePair> files = project.GetIBFiles (Constants.InterfaceDefinition, maker.ResourcesFolder);
     if (files == null || files.Count() == 0) {
         return;
     }
     List<FilePair> pairs = new List<FilePair> (files);
     monitor.BeginTask (GettextCatalog.GetString ("Compiling XIB files..."), files.Count ());
     foreach (FilePair pair in pairs) {
         monitor.Log.WriteLine (GettextCatalog.GetString ("Compiling {0}", pair.Source.ToRelative (project.BaseDirectory)));
         xibCompiler.Logger = new BuildLogger (pair.Source, monitor, result);
         xibCompiler.Compile (pair.Source, pair.DestinationDir);
         monitor.Step (1);
     }
     monitor.EndTask ();
 }
Esempio n. 50
0
		public void UpdateTranslations (IProgressMonitor monitor, params Translation[] translations)
		{
			monitor.BeginTask (null, Translations.Count + 1);
			
			try {
				List<Project> projects = new List<Project> ();
				foreach (Project p in ParentSolution.GetAllProjects ()) {
					if (IsIncluded (p))
						projects.Add (p);
				}
				monitor.BeginTask (GettextCatalog.GetString ("Updating message catalog"), projects.Count);
				CreateDefaultCatalog (monitor);
				monitor.Log.WriteLine (GettextCatalog.GetString ("Done"));
			} finally { 
				monitor.EndTask ();
				monitor.Step (1);
			}
			if (monitor.IsCancelRequested) {
				monitor.Log.WriteLine (GettextCatalog.GetString ("Operation cancelled."));
				return;
			}
			
			Dictionary<string, bool> isIncluded = new Dictionary<string, bool> ();
			foreach (Translation translation in translations) {
				isIncluded[translation.IsoCode] = true;
			}
			foreach (Translation translation in this.Translations) {
				if (!isIncluded.ContainsKey (translation.IsoCode))
					continue;
				string poFileName  = translation.PoFile;
				monitor.BeginTask (GettextCatalog.GetString ("Updating {0}", translation.PoFile), 1);
				try {
					var pb = new ProcessArgumentBuilder ();
					pb.Add ("-U");
					pb.AddQuoted (poFileName);
					pb.Add ("-v");
					pb.AddQuoted (this.BaseDirectory.Combine ("messages.po"));
					
					var process = Runtime.ProcessService.StartProcess (Translation.GetTool ("msgmerge"),
						pb.ToString (), this.BaseDirectory, monitor.Log, monitor.Log, null);
					process.WaitForOutput ();
				}
				catch (System.ComponentModel.Win32Exception) {
					var msg = GettextCatalog.GetString ("Did not find msgmerge. Please ensure that gettext tools are installed.");
					monitor.ReportError (msg, null);
				}
				catch (Exception ex) {
					monitor.ReportError (GettextCatalog.GetString ("Could not update file {0}", translation.PoFile), ex);
				}
				finally {
					monitor.EndTask ();
					monitor.Step (1);
				}
				if (monitor.IsCancelRequested) {
					monitor.Log.WriteLine (GettextCatalog.GetString ("Operation cancelled."));
					return;
				}
			}
		}
Esempio n. 51
0
        public IEnumerable <SearchResult> FindAll(Scope scope, IProgressMonitor monitor, string pattern, string replacePattern, FilterOptions filter)
        {
            if (filter.RegexSearch)
            {
                RegexOptions regexOptions = RegexOptions.Compiled;
                if (!filter.CaseSensitive)
                {
                    regexOptions |= RegexOptions.IgnoreCase;
                }
                regex = new Regex(pattern, regexOptions);
            }
            IsRunning         = true;
            FoundMatchesCount = SearchedFilesCount = 0;
            monitor.BeginTask(scope.GetDescription(filter, pattern, replacePattern), 50);
            try {
                int    totalWork = scope.GetTotalWork(filter);
                int    step      = Math.Max(1, totalWork / 50);
                string content;
                var    results = new System.Collections.Concurrent.ConcurrentBag <SearchResult>();

                Parallel.ForEach(scope.GetFiles(monitor, filter), provider => {
                    if (monitor.IsCancelRequested)
                    {
                        return;
                    }
                    Interlocked.Increment(ref searchedFilesCount);
                    try {
                        content = provider.ReadString();
                        if (replacePattern != null)
                        {
                            provider.BeginReplace(content);
                        }
                    } catch (System.IO.FileNotFoundException) {
                        Application.Invoke(delegate {
                            MessageService.ShowError(string.Format(GettextCatalog.GetString("File {0} not found.")), provider.FileName);
                        });
                        return;
                    }
                    foreach (SearchResult result in FindAll(monitor, provider, content, pattern, replacePattern, filter))
                    {
                        if (monitor.IsCancelRequested)
                        {
                            return;
                        }
                        FoundMatchesCount++;
                        results.Add(result);
                    }
                    if (replacePattern != null)
                    {
                        provider.EndReplace();
                    }
                    if (searchedFilesCount % step == 0)
                    {
                        monitor.Step(1);
                    }
                });
                return(results);
            } finally {
                monitor.EndTask();
                IsRunning = false;
            }
        }
Esempio n. 52
0
		public void SwitchToBranch (IProgressMonitor monitor, string branch)
		{
			monitor.BeginTask (GettextCatalog.GetString ("Switching to branch {0}", branch), GitService.StashUnstashWhenSwitchingBranches ? 4 : 2);
			
			// Get a list of files that are different in the target branch
			IEnumerable<DiffEntry> statusList = GitUtil.GetChangedFiles (RootRepository, branch);
			
			StashCollection stashes = null;
			Stash stash = null;
			
			if (GitService.StashUnstashWhenSwitchingBranches) {
				stashes = GitUtil.GetStashes (RootRepository);
				
				// Remove the stash for this branch, if exists
				string currentBranch = GetCurrentBranch ();
				stash = GetStashForBranch (stashes, currentBranch);
				if (stash != null)
					stashes.Remove (stash);
				
				// Create a new stash for the branch. This allows switching branches
				// without losing local changes
				using (var gm = new GitMonitor (monitor))
					stash = stashes.Create (gm, GetStashName (currentBranch));
			
				monitor.Step (1);
			}
			
			// Switch to the target branch
			DirCache dc = RootRepository.LockDirCache ();
			try {
				RevWalk rw = new RevWalk (RootRepository);
				ObjectId branchHeadId = RootRepository.Resolve (branch);
				if (branchHeadId == null)
					throw new InvalidOperationException ("Branch head commit not found");
				
				RevCommit branchCommit = rw.ParseCommit (branchHeadId);
				DirCacheCheckout checkout = new DirCacheCheckout (RootRepository, null, dc, branchCommit.Tree);
				checkout.Checkout ();
				
				RefUpdate u = RootRepository.UpdateRef(Constants.HEAD);
				u.Link ("refs/heads/" + branch);
				monitor.Step (1);
			} catch {
				dc.Unlock ();
				if (GitService.StashUnstashWhenSwitchingBranches) {
					// If something goes wrong, restore the work tree status
					using (var gm = new GitMonitor (monitor))
						stash.Apply (gm);
					stashes.Remove (stash);
				}
				throw;
			}
			
			// Restore the branch stash
			
			if (GitService.StashUnstashWhenSwitchingBranches) {
				stash = GetStashForBranch (stashes, branch);
				if (stash != null) {
					using (var gm = new GitMonitor (monitor))
						stash.Apply (gm);
					stashes.Remove (stash);
				}
				monitor.Step (1);
			}
			
			// Notify file changes
			
			NotifyFileChanges (monitor, statusList);
			
			if (BranchSelectionChanged != null)
				BranchSelectionChanged (this, EventArgs.Empty);
			
			monitor.EndTask ();
		}
 public override void Step(int work)
 {
     base.Step(work);
     statusMonitor.Step(work);
 }
Esempio n. 54
0
		void NotifyFileChanges (IProgressMonitor monitor, IEnumerable<DiffEntry> statusList)
		{
			List<DiffEntry> changes = new List<DiffEntry> (statusList);

			// Files added to source branch not present to target branch.
			var removed = changes.Where (c => c.GetChangeType () == DiffEntry.ChangeType.ADD).Select (c => GetRepository (c.GetNewPath ()).FromGitPath (c.GetNewPath ())).ToList ();
			var modified = changes.Where (c => c.GetChangeType () != DiffEntry.ChangeType.ADD).Select (c => GetRepository (c.GetNewPath ()).FromGitPath (c.GetNewPath ())).ToList ();
			
			monitor.BeginTask (GettextCatalog.GetString ("Updating solution"), removed.Count + modified.Count);
			
			FileService.NotifyFilesChanged (modified);
			monitor.Step (modified.Count);
			
			FileService.NotifyFilesRemoved (removed);
			monitor.Step (removed.Count);
			
			monitor.EndTask ();
		}
		protected override void Clean (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
		{
			Project proj = entry as Project;
			if (proj == null) {
				base.Clean (monitor, entry, configuration);
				return;
			}

			MakefileData data = proj.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
			if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.CleanTargetName)) {
				base.Clean (monitor, entry, configuration); 
				return;
			}

			monitor.BeginTask (GettextCatalog.GetString ("Cleaning project"), 1);
			try {
				string baseDir = proj.BaseDirectory;
	
				ProcessWrapper process = Runtime.ProcessService.StartProcess (data.AbsoluteMakeCommand, 
						data.CleanTargetName, 
						baseDir, 
						monitor.Log, 
						monitor.Log, 
						null);
				process.WaitForOutput ();

				if (process.ExitCode > 0)
					throw new Exception ( GettextCatalog.GetString ("An unspecified error occurred while running '{0} {1}'", data.AbsoluteMakeCommand, data.CleanTargetName) );

				monitor.Step (1);
			} catch (Exception e) {
				monitor.ReportError (GettextCatalog.GetString ("Project could not be cleaned: "), e);
				return;
			} finally {
				monitor.EndTask ();
			}
			monitor.ReportSuccess (GettextCatalog.GetString ("Project successfully cleaned"));
		}
        public Makefile Deploy(AutotoolsContext ctx, SolutionItem entry, IProgressMonitor monitor)
        {
            generateAutotools = ctx.MakefileType == MakefileType.AutotoolsMakefile;

            monitor.BeginTask(GettextCatalog.GetString(
                                  "Creating {0} for Solution {1}",
                                  generateAutotools ? "Makefile.am" : "Makefile", entry.Name), 1);

            Makefile      solutionMakefile = new Makefile();
            StringBuilder solutionTop      = new StringBuilder();

            try
            {
                SolutionFolder solutionFolder  = (SolutionFolder)entry;
                string         targetDirectory = solutionFolder.BaseDirectory;

                StringBuilder subdirs = new StringBuilder();
                subdirs.Append("#Warning: This is an automatically generated file, do not edit!\n");

                if (!generateAutotools)
                {
                    solutionTop.AppendFormat("top_srcdir={0}\n", FileService.AbsoluteToRelativePath(
                                                 entry.BaseDirectory, ctx.TargetSolution.BaseDirectory));
                    solutionTop.Append("include $(top_srcdir)/config.make\n");
                    solutionTop.Append("include $(top_srcdir)/Makefile.include\n");
                    solutionTop.Append("include $(top_srcdir)/rules.make\n\n");
                    solutionTop.Append("#include $(top_srcdir)/custom-hooks.make\n\n");
                }

                ArrayList children = new ArrayList();
                foreach (SolutionConfiguration config in solutionFolder.ParentSolution.Configurations)
                {
                    if (!ctx.IsSupportedConfiguration(config.Id))
                    {
                        continue;
                    }

                    if (generateAutotools)
                    {
                        subdirs.AppendFormat("if {0}\n", "ENABLE_" + ctx.EscapeAndUpperConfigName(config.Id));
                    }
                    else
                    {
                        subdirs.AppendFormat("ifeq ($(CONFIG),{0})\n", ctx.EscapeAndUpperConfigName(config.Id));
                    }

                    subdirs.Append(" SUBDIRS = ");

                    foreach (SolutionItem ce in CalculateSubDirOrder(ctx, solutionFolder, config))
                    {
                        string baseDirectory;
                        if (!(ce is SolutionEntityItem) && !(ce is SolutionFolder))
                        {
                            continue;
                        }

                        // Ignore projects which can't be deployed
                        IMakefileHandler handler = AutotoolsContext.GetMakefileHandler(ce, ctx.MakefileType);
                        if (handler == null)
                        {
                            continue;
                        }

                        baseDirectory = ce.BaseDirectory;

                        if (solutionFolder.BaseDirectory == baseDirectory)
                        {
                            subdirs.Append(" . ");
                        }
                        else
                        {
                            if (!baseDirectory.StartsWith(solutionFolder.BaseDirectory))
                            {
                                throw new Exception(GettextCatalog.GetString(
                                                        "Child projects must be in sub-directories of their parent"));
                            }

                            // add the subdirectory to the list
                            string path = FileService.AbsoluteToRelativePath(targetDirectory, baseDirectory);
                            if (path.StartsWith("." + Path.DirectorySeparatorChar))
                            {
                                path = path.Substring(2);
                            }

                            AutotoolsContext.CheckSpaces(path);
                            subdirs.Append(" ");
                            subdirs.Append(AutotoolsContext.EscapeStringForAutomake(path));
                        }

                        if (!children.Contains(ce))
                        {
                            children.Add(ce);
                        }
                    }
                    subdirs.Append("\nendif\n");
                }
                solutionTop.Append(subdirs.ToString());

                string includedProject = null;

                // deploy recursively
                foreach (SolutionItem ce in children)
                {
                    IMakefileHandler handler = AutotoolsContext.GetMakefileHandler(ce, ctx.MakefileType);
                    Makefile         makefile;
                    string           outpath;
                    if (handler != null && handler.CanDeploy(ce, ctx.MakefileType))
                    {
                        ctx.RegisterBuiltProject(ce);
                        makefile = handler.Deploy(ctx, ce, monitor);

                        if (targetDirectory == ce.BaseDirectory)
                        {
                            if (includedProject != null)
                            {
                                throw new Exception(GettextCatalog.GetString(
                                                        "More than 1 project in the same directory as the top-level solution is not supported."));
                            }

                            // project is in the solution directory
                            string projectMakefileName = ce.Name + ".make";
                            includedProject = String.Format("include {0}", projectMakefileName);
                            outpath         = Path.Combine(targetDirectory, projectMakefileName);
                            ctx.AddGeneratedFile(outpath);

                            if (!generateAutotools)
                            {
                                solutionMakefile.SetVariable("EXTRA_DIST", projectMakefileName);
                            }
                        }
                        else
                        {
                            makefile.AppendToVariable("EXTRA_DIST", generateAutotools ? String.Empty : "Makefile");
                            outpath = Path.Combine(ce.BaseDirectory, "Makefile");
                            if (generateAutotools)
                            {
                                ctx.AddAutoconfFile(outpath);
                                outpath = outpath + ".am";
                            }
                            else
                            {
                                makefile.Append("install: install-local\nuninstall: uninstall-local\nclean: clean-local\n");
                                if (ce is SolutionFolder)
                                {
                                    //non TargetCombine
                                    makefile.Append("dist-local: dist-local-recursive\n");
                                }
                                else
                                {
                                    makefile.Append("include $(top_srcdir)/rules.make\n");
                                }
                            }
                            ctx.AddGeneratedFile(outpath);
                        }

                        StreamWriter writer = new StreamWriter(outpath);
                        makefile.Write(writer);
                        writer.Close();
                    }
                    else
                    {
                        monitor.Log.WriteLine("Project '{0}' skipped.", ce.Name);
                    }
                }

                if (includedProject != null)
                {
                    solutionTop.Append(GettextCatalog.GetString("\n# Include project specific makefile\n"));
                    solutionTop.Append(includedProject);
                }

                if (generateAutotools)
                {
                    solutionMakefile.Append(solutionTop.ToString());
                }
                else
                {
                    TemplateEngine templateEngine = new TemplateEngine();
                    templateEngine.Variables ["MAKEFILE_SOLUTION_TOP"] = solutionTop.ToString();

                    Stream       stream = ctx.GetTemplateStream("Makefile.solution.template");
                    StreamReader reader = new StreamReader(stream);
                    StringWriter sw     = new StringWriter();

                    templateEngine.Process(reader, sw);
                    reader.Close();

                    solutionMakefile.Append(sw.ToString());

                    if (solutionFolder.IsRoot)
                    {
                        // Emit dist and distcheck targets only for TargetCombine
                        reader = new StreamReader(Path.Combine(ctx.TemplateDir, "make-dist.targets"));
                        solutionMakefile.Append(reader.ReadToEnd());
                        reader.Close();
                    }
                }

                monitor.Step(1);
            }
            finally
            {
                monitor.EndTask();
            }
            return(solutionMakefile);
        }
		protected override SolutionEntityItem LoadSolutionItem (IProgressMonitor monitor, string fileName)
		{
			SolutionEntityItem entry = base.LoadSolutionItem (monitor, fileName);
			if (entry == null)
				return null;
			
			Project project = entry as Project;
			if (project == null)
				return entry;

			//Project
			MakefileData data = entry.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
			if (data == null)
				return entry;

			monitor.BeginTask (GettextCatalog.GetString ("Updating project from Makefile"), 1);
			try { 
				data.OwnerProject = project;
				if (data.SupportsIntegration)
					data.UpdateProject (monitor, false);
				monitor.Step (1);
			} catch (Exception e) {
				monitor.ReportError (GettextCatalog.GetString (
					"Error loading Makefile for project {0}", project.Name), e);
			} finally {
				monitor.EndTask ();
			}

			entry.SetNeedsBuilding (false);
			return entry;
		}
Esempio n. 58
0
		public void Save (IProgressMonitor monitor)
		{
			if (HasSlnData && !SavingSolution && Item.ParentSolution != null) {
				// The project has data that has to be saved in the solution, but the solution is not being saved. Do it now.
				monitor.BeginTask (null, 2);
				SaveItem (monitor);
				monitor.Step (1);
				Solution sol = Item.ParentSolution;
				SolutionFormat.SlnFileFormat.WriteFile (sol.FileName, sol, SolutionFormat, false, monitor);
				sol.NeedsReload = false;
				monitor.EndTask ();
			} else
				SaveItem (monitor);
		}
Esempio n. 59
0
		public void TransferFiles (IProgressMonitor monitor, Project sourceProject, FilePath sourcePath, Project targetProject,
		                           FilePath targetPath, bool removeFromSource, bool copyOnlyProjectFiles)
		{
			// When transfering directories, targetPath is the directory where the source
			// directory will be transfered, including the destination directory or file name.
			// For example, if sourcePath is /a1/a2/a3 and targetPath is /b1/b2, the
			// new folder or file will be /b1/b2
			
			if (targetProject == null)
				throw new ArgumentNullException ("targetProject");

			if (!targetPath.IsChildPathOf (targetProject.BaseDirectory))
				throw new ArgumentException ("Invalid project folder: " + targetPath);

			if (sourceProject != null && !sourcePath.IsChildPathOf (sourceProject.BaseDirectory))
				throw new ArgumentException ("Invalid project folder: " + sourcePath);
				
			if (copyOnlyProjectFiles && sourceProject == null)
				throw new ArgumentException ("A source project must be specified if copyOnlyProjectFiles is True");
			
			bool sourceIsFolder = Directory.Exists (sourcePath);

			bool movingFolder = (removeFromSource && sourceIsFolder && (
					!copyOnlyProjectFiles ||
					IsDirectoryHierarchyEmpty (sourcePath)));

			// We need to remove all files + directories from the source project
			// but when dealing with the VCS addins we need to process only the
			// files so we do not create a 'file' in the VCS which corresponds
			// to a directory in the project and blow things up.
			List<ProjectFile> filesToRemove = null;
			List<ProjectFile> filesToMove = null;
			try {
				//get the real ProjectFiles
				if (sourceProject != null) {
					if (sourceIsFolder) {
						var virtualPath = sourcePath.ToRelative (sourceProject.BaseDirectory);
						// Grab all the child nodes of the folder we just dragged/dropped
						filesToRemove = sourceProject.Files.GetFilesInVirtualPath (virtualPath).ToList ();
						// Add the folder itself so we can remove it from the soruce project if its a Move operation
						var folder = sourceProject.Files.Where (f => f.ProjectVirtualPath == virtualPath).FirstOrDefault ();
						if (folder != null)
							filesToRemove.Add (folder);
					} else {
						filesToRemove = new List<ProjectFile> ();
						var pf = sourceProject.Files.GetFileWithVirtualPath (sourceProject.GetRelativeChildPath (sourcePath));
						if (pf != null)
							filesToRemove.Add (pf);
					}
				}
				//get all the non-project files and create fake ProjectFiles
				if (!copyOnlyProjectFiles || sourceProject == null) {
					var col = new List<ProjectFile> ();
					GetAllFilesRecursive (sourcePath, col);
					if (sourceProject != null) {
						var names = new HashSet<string> (filesToRemove.Select (f => sourceProject.BaseDirectory.Combine (f.ProjectVirtualPath).ToString ()));
						foreach (var f in col)
							if (names.Add (f.Name))
							    filesToRemove.Add (f);
					} else {
						filesToRemove = col;
					}
				}
			} catch (Exception ex) {
				monitor.ReportError (GettextCatalog.GetString ("Could not get any file from '{0}'.", sourcePath), ex);
				return;
			}
			
			// Strip out all the directories to leave us with just the files.
			filesToMove = filesToRemove.Where (f => f.Subtype != Subtype.Directory).ToList ();
			
			// If copying a single file, bring any grouped children along
			ProjectFile sourceParent = null;
			if (filesToMove.Count == 1 && sourceProject != null) {
				var pf = filesToMove[0];
				if (pf != null && pf.HasChildren)
					foreach (ProjectFile child in pf.DependentChildren)
						filesToMove.Add (child);
				sourceParent = pf;
			}
			
			// Ensure that the destination folder is created, even if no files
			// are copied
			
			try {
				if (sourceIsFolder && !Directory.Exists (targetPath) && !movingFolder)
					FileService.CreateDirectory (targetPath);
			} catch (Exception ex) {
				monitor.ReportError (GettextCatalog.GetString ("Could not create directory '{0}'.", targetPath), ex);
				return;
			}

			// Transfer files
			// If moving a folder, do it all at once
			
			if (movingFolder) {
				try {
					FileService.MoveDirectory (sourcePath, targetPath);
				} catch (Exception ex) {
					monitor.ReportError (GettextCatalog.GetString ("Directory '{0}' could not be moved.", sourcePath), ex);
					return;
				}
			}
			
			monitor.BeginTask (GettextCatalog.GetString ("Copying files..."), filesToMove.Count);
			
			ProjectFile targetParent = null;
			foreach (ProjectFile file in filesToMove) {
				bool fileIsLink = file.Project != null && file.IsLink;
				
				var sourceFile = fileIsLink
					? file.Project.BaseDirectory.Combine (file.ProjectVirtualPath)
					: file.FilePath;
				
				FilePath newFile;
				if (sourceIsFolder)
					newFile = targetPath.Combine (sourceFile.ToRelative (sourcePath));
				else if (sourceFile == sourcePath)
					newFile = targetPath;
				else if (sourceFile.ParentDirectory != targetPath.ParentDirectory)
					newFile = targetPath.ParentDirectory.Combine (sourceFile.ToRelative (sourcePath.ParentDirectory));
				else
					newFile = GetTargetCopyName (sourceFile, false);
				
				if (!movingFolder && !fileIsLink) {
					try {
						FilePath fileDir = newFile.ParentDirectory;
						if (!Directory.Exists (fileDir) && !file.IsLink)
							FileService.CreateDirectory (fileDir);
						if (removeFromSource)
							FileService.MoveFile (sourceFile, newFile);
						else
							FileService.CopyFile (sourceFile, newFile);
					} catch (Exception ex) {
						monitor.ReportError (GettextCatalog.GetString ("File '{0}' could not be created.", newFile), ex);
						monitor.Step (1);
						continue;
					}
				}
				
				if (sourceProject != null) {
					if (fileIsLink) {
						var linkFile = (ProjectFile) file.Clone ();
						if (movingFolder) {
							var abs = linkFile.Link.ToAbsolute (sourceProject.BaseDirectory);
							var relSrc = abs.ToRelative (sourcePath);
							var absTarg = relSrc.ToAbsolute (targetPath);
							linkFile.Link = absTarg.ToRelative (targetProject.BaseDirectory);
						} else {
							linkFile.Link = newFile.ToRelative (targetProject.BaseDirectory);
						}
						targetProject.Files.Add (linkFile);
					} else if (targetProject.Files.GetFile (newFile) == null) {
						ProjectFile projectFile = (ProjectFile) file.Clone ();
						projectFile.Name = newFile;
						if (targetParent == null) {
							if (file == sourceParent)
								targetParent = projectFile;
						} else if (sourceParent != null) {
							if (projectFile.DependsOn == sourceParent.Name)
								projectFile.DependsOn = targetParent.Name;
						}
						targetProject.Files.Add (projectFile);
					}
				}
				
				monitor.Step (1);
			}
			
			if (removeFromSource) {
				// Remove all files and directories under 'sourcePath'
				foreach (var v in filesToRemove)
					sourceProject.Files.Remove (v);
			}
			
			var pfolder = sourcePath.ParentDirectory;
			
			// If this was the last item in the folder, make sure we keep
			// a reference to the folder, so it is not deleted from the tree.
			if (removeFromSource && sourceProject != null && pfolder.CanonicalPath != sourceProject.BaseDirectory.CanonicalPath && pfolder.IsChildPathOf (sourceProject.BaseDirectory)) {
				pfolder = pfolder.ToRelative (sourceProject.BaseDirectory);
				if (!sourceProject.Files.GetFilesInVirtualPath (pfolder).Any ()) {
					var folderFile = new ProjectFile (sourceProject.BaseDirectory.Combine (pfolder));
					folderFile.Subtype = Subtype.Directory;
					sourceProject.Files.Add (folderFile);
				}
			}
			
			monitor.EndTask ();
		}
Esempio n. 60
0
        public static void Initialize(IProgressMonitor monitor)
        {
            Counters.Initialization.Trace("Creating Workbench");
            workbench = new Workbench();
            Counters.Initialization.Trace("Creating Root Workspace");
            workspace = new RootWorkspace();
            Counters.Initialization.Trace("Creating Services");
            projectOperations = new ProjectOperations();
            helpOperations    = new HelpOperations();
            commandService    = new CommandManager();
            ideServices       = new IdeServices();
            CustomToolService.Init();
            AutoTestService.Start(commandService, Preferences.EnableAutomatedTesting);

            commandService.CommandTargetScanStarted  += CommandServiceCommandTargetScanStarted;
            commandService.CommandTargetScanFinished += CommandServiceCommandTargetScanFinished;
            commandService.KeyBindingFailed          += KeyBindingFailed;

            KeyBindingService.LoadBindingsFromExtensionPath("/MonoDevelop/Ide/KeyBindingSchemes");
            KeyBindingService.LoadCurrentBindings("MD2");

            commandService.CommandError += delegate(object sender, CommandErrorArgs args) {
                LoggingService.LogInternalError(args.ErrorMessage, args.Exception);
            };

            FileService.ErrorHandler = FileServiceErrorHandler;

            monitor.BeginTask(GettextCatalog.GetString("Loading Workbench"), 5);
            Counters.Initialization.Trace("Loading Commands");

            commandService.LoadCommands("/MonoDevelop/Ide/Commands");
            monitor.Step(1);

            Counters.Initialization.Trace("Initializing Workbench");
            workbench.Initialize(monitor);
            monitor.Step(1);

            InternalLog.EnableErrorNotification();

            MonoDevelop.Ide.WelcomePage.WelcomePageService.Initialize();
            MonoDevelop.Ide.WelcomePage.WelcomePageService.ShowWelcomePage();

            monitor.Step(1);

            Counters.Initialization.Trace("Restoring Workbench State");
            workbench.Show("SharpDevelop.Workbench.WorkbenchMemento");
            monitor.Step(1);

            Counters.Initialization.Trace("Flushing GUI events");
            DispatchService.RunPendingEvents();
            Counters.Initialization.Trace("Flushed GUI events");

            MessageService.RootWindow = workbench.RootWindow;

            commandService.EnableIdleUpdate = true;

            // Perser service initialization
            TypeSystemService.TrackFileChanges            = true;
            TypeSystemService.ParseProgressMonitorFactory = new ParseProgressMonitorFactory();

            Customizer.OnIdeInitialized();

            // Startup commands
            Counters.Initialization.Trace("Running Startup Commands");
            AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/StartupHandlers", OnExtensionChanged);
            monitor.Step(1);
            monitor.EndTask();

            // Set initial run flags
            Counters.Initialization.Trace("Upgrading Settings");

            if (PropertyService.Get("MonoDevelop.Core.FirstRun", false))
            {
                isInitialRun = true;
                PropertyService.Set("MonoDevelop.Core.FirstRun", false);
                PropertyService.Set("MonoDevelop.Core.LastRunVersion", BuildInfo.Version);
                PropertyService.Set("MonoDevelop.Core.LastRunRevision", CurrentRevision);
                PropertyService.SaveProperties();
            }

            string lastVersion  = PropertyService.Get("MonoDevelop.Core.LastRunVersion", "1.9.1");
            int    lastRevision = PropertyService.Get("MonoDevelop.Core.LastRunRevision", 0);

            if (lastRevision != CurrentRevision && !isInitialRun)
            {
                isInitialRunAfterUpgrade = true;
                if (lastRevision == 0)
                {
                    switch (lastVersion)
                    {
                    case "1.0": lastRevision = 1; break;

                    case "2.0": lastRevision = 2; break;

                    case "2.2": lastRevision = 3; break;

                    case "2.2.1": lastRevision = 4; break;
                    }
                }
                upgradedFromRevision = lastRevision;
                PropertyService.Set("MonoDevelop.Core.LastRunVersion", BuildInfo.Version);
                PropertyService.Set("MonoDevelop.Core.LastRunRevision", CurrentRevision);
                PropertyService.SaveProperties();
            }

            // The ide is now initialized

            isInitialized = true;

            if (isInitialRun)
            {
                try {
                    OnInitialRun();
                } catch (Exception e) {
                    LoggingService.LogError("Error found while initializing the IDE", e);
                }
            }

            if (isInitialRunAfterUpgrade)
            {
                try {
                    OnUpgraded(upgradedFromRevision);
                } catch (Exception e) {
                    LoggingService.LogError("Error found while initializing the IDE", e);
                }
            }

            if (initializedEvent != null)
            {
                initializedEvent(null, EventArgs.Empty);
                initializedEvent = null;
            }

            //FIXME: we should really make this on-demand. consumers can display a "loading help cache" message like VS
            MonoDevelop.Projects.HelpService.AsyncInitialize();

            UpdateInstrumentationIcon();
            IdeApp.Preferences.EnableInstrumentationChanged += delegate {
                UpdateInstrumentationIcon();
            };
            AutoTestService.NotifyEvent("MonoDevelop.Ide.IdeStart");
        }