Inheritance: UrlBasedRepository
		public static void ShowMergeDialog (GitRepository repo, bool rebasing)
		{
			var dlg = new MergeDialog (repo, rebasing);
			try {
				if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) {
					dlg.Hide ();
					if (rebasing) {
						using (ProgressMonitor monitor = VersionControlService.GetProgressMonitor (GettextCatalog.GetString ("Rebasing branch '{0}'...", dlg.SelectedBranch))) {
							if (dlg.IsRemote)
								repo.Fetch (monitor, dlg.RemoteName);
							repo.Rebase (dlg.SelectedBranch, dlg.StageChanges ? GitUpdateOptions.SaveLocalChanges : GitUpdateOptions.None, monitor);
						}
					} else {
						using (ProgressMonitor monitor = VersionControlService.GetProgressMonitor (GettextCatalog.GetString ("Merging branch '{0}'...", dlg.SelectedBranch))) {
							if (dlg.IsRemote)
								repo.Fetch (monitor, dlg.RemoteName);
							repo.Merge (dlg.SelectedBranch, dlg.StageChanges ? GitUpdateOptions.SaveLocalChanges : GitUpdateOptions.None, monitor, FastForwardStrategy.NoFastForward);
						}
					}
				}
			} finally {
				dlg.Destroy ();
				dlg.Dispose ();
			}
		}
		public override Repository GetRepositoryReference (FilePath path, string id)
		{
			GitRepository repo;
			if (!repositories.TryGetValue (path.CanonicalPath, out repo) || repo.Disposed)
				repositories [path.CanonicalPath] = repo = new GitRepository (this, path, null);
			return repo;
		}
		public EditBranchDialog (GitRepository repo, string name, string tracking)
		{
			this.Build ();
			this.repo = repo;
			oldName = name;
			currentTracking = tracking;

			this.UseNativeContextMenus ();

			comboStore = new ListStore (typeof(string), typeof(Xwt.Drawing.Image), typeof (string), typeof(string));
			comboSources.Model = comboStore;
			var crp = new CellRendererImage ();
			comboSources.PackStart (crp, false);
			comboSources.AddAttribute (crp, "image", 1);
			var crt = new CellRendererText ();
			comboSources.PackStart (crt, true);
			comboSources.AddAttribute (crt, "text", 2);

			SemanticModelAttribute modelAttr = new SemanticModelAttribute ("comboStore__Branch", "comboStore__Icon", "comboStore__Name", "comboStore__Tracking");
			TypeDescriptor.AddAttributes (comboStore, modelAttr);

			foreach (Branch b in repo.GetBranches ()) {
				AddValues (b.FriendlyName, ImageService.GetIcon ("vc-branch", IconSize.Menu), "refs/heads/");
			}

			foreach (Remote r in repo.GetRemotes ()) {
				foreach (string b in repo.GetRemoteBranches (r.Name))
					AddValues (r.Name + "/" + b, ImageService.GetIcon ("vc-repository", IconSize.Menu), "refs/remotes/");
			}

			entryName.Text = name;
			checkTrack.Active = !string.IsNullOrEmpty (tracking);

			UpdateStatus ();
		}
Exemple #4
0
		public MergeDialog (GitRepository repo, bool rebasing)
		{
			this.Build ();
			
			this.repo = repo;
			this.rebasing = rebasing;
			
			store = new TreeStore (typeof(string), typeof(Gdk.Pixbuf), typeof (string), typeof(string));
			tree.Model = store;
			
			CellRendererPixbuf crp = new CellRendererPixbuf ();
			TreeViewColumn col = new TreeViewColumn ();
			col.PackStart (crp, false);
			col.AddAttribute (crp, "pixbuf", 1);
			CellRendererText crt = new CellRendererText ();
			col.PackStart (crt, true);
			col.AddAttribute (crt, "text", 2);
			tree.AppendColumn (col);
			
			tree.Selection.Changed += HandleTreeSelectionChanged;
			
			if (rebasing) {
				labelHeader.Text = GettextCatalog.GetString ("Select the branch to which to rebase:");
				checkStage.Label = GettextCatalog.GetString ("Stash/unstash local changes before/after rebasing");
			}
			
			checkStage.Active = true;
			
			Fill ();
		}
		public MergeDialog (GitRepository repo, bool rebasing)
		{
			this.Build ();

			this.UseNativeContextMenus ();

			this.repo = repo;
			this.rebasing = rebasing;

			store = new TreeStore (typeof(string), typeof(Xwt.Drawing.Image), typeof (string), typeof(string));
			tree.Model = store;

			var crp = new CellRendererImage ();
			var col = new TreeViewColumn ();
			col.PackStart (crp, false);
			col.AddAttribute (crp, "image", 1);
			var crt = new CellRendererText ();
			col.PackStart (crt, true);
			col.AddAttribute (crt, "text", 2);
			tree.AppendColumn (col);

			tree.Selection.Changed += HandleTreeSelectionChanged;

			if (rebasing) {
				labelHeader.Text = GettextCatalog.GetString ("Select the branch to which to rebase:");
				checkStage.Label = GettextCatalog.GetString ("Stash/unstash local changes before/after rebasing");
				buttonOk.Label = GettextCatalog.GetString ("Rebase");
			}

			checkStage.Active = true;

			Fill ();
		}
		public GitConfigurationDialog (GitRepository repo)
		{
			this.Build ();
			this.repo = repo;
			this.HasSeparator = false;
			
			// Branches list
			
			storeBranches = new ListStore (typeof(Branch), typeof(string), typeof(string), typeof(string));
			listBranches.Model = storeBranches;
			listBranches.HeadersVisible = true;
			
			listBranches.AppendColumn (GettextCatalog.GetString ("Branch"), new CellRendererText (), "markup", 1);
			listBranches.AppendColumn (GettextCatalog.GetString ("Tracking"), new CellRendererText (), "text", 2);
			
			// Sources tree
			
			storeRemotes = new TreeStore (typeof(RemoteSource), typeof(string), typeof(string), typeof(string), typeof(string));
			treeRemotes.Model = storeRemotes;
			treeRemotes.HeadersVisible = true;
			
			treeRemotes.AppendColumn ("Remote Source / Branch", new CellRendererText (), "markup", 1);
			treeRemotes.AppendColumn ("Url", new CellRendererText (), "text", 2);
			
			// Fill data
			
			FillBranches ();
			FillRemotes ();
		}
		public static void Push (GitRepository repo)
		{
			var dlg = new PushDialog (repo);
			try {
				if (MessageService.RunCustomDialog (dlg) != (int) Gtk.ResponseType.Ok)
					return;

				string remote = dlg.SelectedRemote;
				string branch = dlg.SelectedRemoteBranch ?? repo.GetCurrentBranch ();

				ProgressMonitor monitor = VersionControlService.GetProgressMonitor (GettextCatalog.GetString ("Pushing changes..."), VersionControlOperationType.Push);
				ThreadPool.QueueUserWorkItem (delegate {
					try {
						repo.Push (monitor, remote, branch);
					} catch (Exception ex) {
						monitor.ReportError (ex.Message, ex);
					} finally {
						monitor.Dispose ();
					}
				});
			} finally {
				dlg.Destroy ();
				dlg.Dispose ();
			}
		}
Exemple #8
0
		public static void SwitchToBranch (GitRepository repo, string branch)
		{
			IdeApp.Workbench.AutoReloadDocuments = true;
			try {
				repo.SwitchToBranch (branch);
			} finally {
				IdeApp.Workbench.AutoReloadDocuments = false;
			}
		}
		static void OnSolutionSaved (object o, EventArgs a)
		{
			Solution sol = (Solution)o;
			sol.Saved -= OnSolutionSaved;
			GitUtil.Init (sol.BaseDirectory, null, null);
			
			GitRepository gitRepo = new GitRepository (sol.BaseDirectory, null);
			gitRepo.Add (sol.GetItemFiles (true).ToArray (), false, new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor ());
		}
		public GitCommitDialogExtensionWidget (GitRepository repo)
		{
			this.Build ();

			bool hasRemote = repo.GetCurrentRemote () != null;
			if (!hasRemote) {
				checkPush.Sensitive = false;
				checkPush.TooltipText = GettextCatalog.GetString ("Pushing is only available for repositories with configured remotes.");
			}
		}
Exemple #11
0
		public override Repository GetRepositoryReference (FilePath path, string id)
		{
			if (path.IsEmpty || path.ParentDirectory.IsEmpty || path.IsNull || path.ParentDirectory.IsNull)
				return null;
			if (path.IsGitRepository ()) {
				GitRepository repo;
				if (!repositories.TryGetValue (path.CanonicalPath, out repo))
					repositories [path.CanonicalPath] = repo = new GitRepository (path, null);
				return repo;
			}
			return GetRepositoryReference (path.ParentDirectory, id);
		}
		public override Repository GetRepositoryReference (FilePath path, string id)
		{
			if (path.IsEmpty || path.ParentDirectory.IsEmpty || path.IsNull || path.ParentDirectory.IsNull)
				return null;
			if (System.IO.Directory.Exists (path.Combine (".git"))) {
				GitRepository repo;
				if (!repositories.TryGetValue (path.CanonicalPath, out repo))
					repositories [path.CanonicalPath] = repo = new GitRepository (path, null);
				return repo;
			}
			else
				return GetRepositoryReference (path.ParentDirectory, id);
		}
Exemple #13
0
		public static void ShowMergeDialog (GitRepository repo)
		{
			MergeDialog dlg = new MergeDialog (repo);
			try {
				if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) {
					dlg.Hide ();
					using (IProgressMonitor monitor = VersionControlService.GetProgressMonitor (GettextCatalog.GetString ("Merging branch '{0}'...", dlg.SelectedBranch))) {
						repo.Merge (dlg.SelectedBranch, monitor);
					}
				}
			} finally {
				dlg.Destroy ();
			}
		}
Exemple #14
0
		public PushDialog (GitRepository repo)
		{
			this.Build ();
			this.repo = repo;
			HasSeparator = false;
			
			changeList.DiffLoader = DiffLoader;
			
			List<string> list = new List<string> (repo.GetRemotes ().Select (r => r.Name));
			foreach (string s in list)
				remoteCombo.AppendText (s);
			remoteCombo.Active = list.IndexOf (repo.GetCurrentRemote ());
			
			UpdateChangeSet ();
		}
		public GitConfigurationDialog (GitRepository repo)
		{
			this.Build ();
			this.repo = repo;
			this.HasSeparator = false;
			
			// Branches list
			
			storeBranches = new ListStore (typeof(Branch), typeof(string), typeof(string), typeof(string));
			listBranches.Model = storeBranches;
			listBranches.HeadersVisible = true;
			
			listBranches.AppendColumn (GettextCatalog.GetString ("Branch"), new CellRendererText (), "markup", 1);
			listBranches.AppendColumn (GettextCatalog.GetString ("Tracking"), new CellRendererText (), "text", 2);

			listBranches.Selection.Changed += delegate {
				TreeIter it;
				if (!listBranches.Selection.GetSelected (out it))
					return;

				string currentBranch = repo.GetCurrentBranch ();
				var b = (Branch) storeBranches.GetValue (it, 0);
				buttonRemoveBranch.Sensitive = b.Name != currentBranch;
			};

			// Sources tree
			
			storeRemotes = new TreeStore (typeof(RemoteSource), typeof(string), typeof(string), typeof(string), typeof(string));
			treeRemotes.Model = storeRemotes;
			treeRemotes.HeadersVisible = true;
			
			treeRemotes.AppendColumn ("Remote Source / Branch", new CellRendererText (), "markup", 1);
			treeRemotes.AppendColumn ("Url", new CellRendererText (), "text", 2);

			// Tags list
			
			storeTags = new ListStore (typeof(string));
			listTags.Model = storeTags;
			listTags.HeadersVisible = true;

			listTags.AppendColumn (GettextCatalog.GetString ("Tag"), new CellRendererText (), "text", 0);

			// Fill data
			
			FillBranches ();
			FillRemotes ();
			FillTags ();
		}
		public StashManagerDialog (GitRepository repo)
		{
			this.Build ();
			stashes = repo.GetStashes ();
			
			store = new ListStore (typeof(Stash), typeof(string), typeof(string));
			list.Model = store;
			
			list.AppendColumn (GettextCatalog.GetString ("Date/Time"), new CellRendererText (), "text", 1);
			list.AppendColumn (GettextCatalog.GetString ("Comment"), new CellRendererText (), "text", 2);
			Fill ();
			TreeIter it;
			if (store.GetIterFirst (out it))
				list.Selection.SelectIter (it);
			UpdateButtons ();
		}
Exemple #17
0
		public static void Push (GitRepository repo)
		{
			PushDialog dlg = new PushDialog (repo);
			if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
				string remote = dlg.SelectedRemote;
				string branch = dlg.SelectedRemoteBranch;
				dlg.Destroy ();
				IProgressMonitor monitor = VersionControlService.GetProgressMonitor (GettextCatalog.GetString ("Pushing changes..."));
				System.Threading.ThreadPool.QueueUserWorkItem (delegate {
					try {
						repo.Push (monitor, remote, branch);
					} catch (Exception ex) {
						monitor.ReportError (ex.Message, ex);
					} finally {
						monitor.Dispose ();
					}
				});
			} else
				dlg.Destroy ();
		}
Exemple #18
0
		public static void Push (GitRepository repo)
		{
			PushDialog dlg = new PushDialog (repo);
			if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
				string remote = dlg.SelectedRemote;
				string branch = dlg.SelectedRemoteBranch;
				dlg.Destroy ();
				IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor ("Version Control", "md-version-control", false, true);
				System.Threading.ThreadPool.QueueUserWorkItem (delegate {
					try {
						repo.Push (monitor, remote, branch);
					} catch (Exception ex) {
						monitor.ReportError (ex.Message, ex);
					} finally {
						monitor.Dispose ();
					}
				});
			} else
				dlg.Destroy ();
		}
		virtual protected void OnInitializeRepository()
		{
			var item = GetItems()[0];

			var vcs = (from v in VersionControlService.GetVersionControlSystems()
				   where v is GitVersionControl
				   select v).FirstOrDefault();
			if (vcs != null && vcs.IsInstalled) {
				var rep = new GitRepository(vcs, item.Path);
				rep.Initialize();

				rep.Add(GetAllFiles(item.WorkspaceObject), false, null);

				if (item.WorkspaceObject is Solution)
					((Solution)item.WorkspaceObject).NeedsReload = true;
				else if (item.WorkspaceObject is Project)
					((Project)item.WorkspaceObject).NeedsReload = true;
				else
					System.Diagnostics.Debug.Assert(false, "Item should be either solution or project.");
			}
		}
Exemple #20
0
		public static void SwitchToBranch (GitRepository repo, string branch)
		{
			MessageDialogProgressMonitor monitor = new MessageDialogProgressMonitor (true, false, false, true);
			try {
				IdeApp.Workbench.AutoReloadDocuments = true;
				IdeApp.Workbench.LockGui ();
				System.Threading.ThreadPool.QueueUserWorkItem (delegate {
					try {
						repo.SwitchToBranch (monitor, branch);
					} catch (Exception ex) {
						monitor.ReportError ("Branch switch failed", ex);
					} finally {
						monitor.Dispose ();
					}
				});
				monitor.AsyncOperation.WaitForCompleted ();
			} finally {
				IdeApp.Workbench.AutoReloadDocuments = false;
				IdeApp.Workbench.UnlockGui ();
			}
		}
Exemple #21
0
		public MergeDialog (GitRepository repo)
		{
			this.Build ();
			
			this.repo = repo;
			
			store = new TreeStore (typeof(string), typeof(Gdk.Pixbuf), typeof (string), typeof(string));
			tree.Model = store;
			
			CellRendererPixbuf crp = new CellRendererPixbuf ();
			TreeViewColumn col = new TreeViewColumn ();
			col.PackStart (crp, false);
			col.AddAttribute (crp, "pixbuf", 1);
			CellRendererText crt = new CellRendererText ();
			col.PackStart (crt, true);
			col.AddAttribute (crt, "text", 2);
			tree.AppendColumn (col);
			
			tree.Selection.Changed += HandleTreeSelectionChanged;
			
			Fill ();
		}
		public EditBranchDialog (GitRepository repo, Branch branch, bool isNew)
		{
			this.Build ();
			this.repo =  repo;
			
			comboStore = new ListStore (typeof(string), typeof(Gdk.Pixbuf), typeof (string));
			comboSources.Model = comboStore;
			CellRendererPixbuf crp = new CellRendererPixbuf ();
			comboSources.PackStart (crp, false);
			comboSources.AddAttribute (crp, "pixbuf", 1);
			CellRendererText crt = new CellRendererText ();
			comboSources.PackStart (crt, true);
			comboSources.AddAttribute (crt, "text", 2);
			
			if (branch != null) {
				if (!isNew)
					oldName = branch.Name;
				currentTracking = branch.Tracking;
				entryName.Text = branch.Name;
				if (currentTracking != null)
					checkTrack.Active = true;
			}
			
			foreach (Branch b in repo.GetBranches ()) {
				AddValues (b.Name, ImageService.GetPixbuf ("vc-git-branch"));
			}
			
			foreach (string t in repo.GetTags ())
				AddValues (t, ImageService.GetPixbuf ("vc-git-tag"));
			
			foreach (RemoteSource r in repo.GetRemotes ()) {
				foreach (string b in repo.GetRemoteBranches (r.Name))
					AddValues (r.Name + "/" + b, ImageService.GetPixbuf ("md-web-search-icon"));
			}
				
			UpdateStatus ();
		}
		public EditBranchDialog (GitRepository repo, Branch branch, bool isNew)
		{
			this.Build ();
			this.repo =  repo;
			
			comboStore = new ListStore (typeof(string), typeof(Xwt.Drawing.Image), typeof (string));
			comboSources.Model = comboStore;
			var crp = new CellRendererImage ();
			comboSources.PackStart (crp, false);
			comboSources.AddAttribute (crp, "image", 1);
			var crt = new CellRendererText ();
			comboSources.PackStart (crt, true);
			comboSources.AddAttribute (crt, "text", 2);
			
			if (branch != null) {
				if (!isNew)
					oldName = branch.Name;
				currentTracking = branch.Tracking;
				entryName.Text = branch.Name;
				checkTrack.Active = currentTracking != null;
			}
			
			foreach (Branch b in repo.GetBranches ()) {
				AddValues (b.Name, ImageService.GetIcon ("vc-branch", IconSize.Menu));
			}
			
			foreach (string t in repo.GetTags ())
				AddValues (t, ImageService.GetIcon ("vc-tag", IconSize.Menu));
			
			foreach (RemoteSource r in repo.GetRemotes ()) {
				foreach (string b in repo.GetRemoteBranches (r.Name))
					AddValues (r.Name + "/" + b, ImageService.GetIcon ("vc-repository", IconSize.Menu));
			}
				
			UpdateStatus ();
		}
		public StashManagerDialog (GitRepository repo)
		{
			this.Build ();
			this.UseNativeContextMenus ();
			repository = repo;

			stashes = repo.GetStashes ();

			store = new ListStore (typeof(Stash), typeof(string), typeof(string));
			list.Model = store;
			list.SearchColumn = -1; // disable the interactive search

			list.AppendColumn (GettextCatalog.GetString ("Date/Time"), new CellRendererText (), "text", 1);
			list.AppendColumn (GettextCatalog.GetString ("Comment"), new CellRendererText (), "text", 2);
			Fill ();
			TreeIter it;
			if (store.GetIterFirst (out it))
				list.Selection.SelectIter (it);
			UpdateButtons ();

			list.Selection.Changed += delegate {
				UpdateButtons ();
			};
		}
		public static void ShowStashManager (GitRepository repo)
		{
			using (var dlg = new StashManagerDialog (repo))
				MessageService.ShowCustomDialog (dlg);
		}
Exemple #26
0
		public static void ShowConfigurationDialog (GitRepository repo)
		{
			var dlg = new GitConfigurationDialog (repo);
			MessageService.ShowCustomDialog (dlg);
		}
Exemple #27
0
		internal void UnregisterRepo (GitRepository repo)
		{
			if (!repo.RootPath.IsNullOrEmpty)
				repositories.Remove (repo.RootPath.CanonicalPath);
		}
		async Task AddXwtFromGithubAsync (Solution solution, string newProjectName, bool createSubmodule, ProgressMonitor monitor)
		{
			try {
				var gitUrl = "https://github.com/" + (string.IsNullOrEmpty (Parameters ["XwtGithubRepository"]) ? Parameters ["XwtGithubRepository"] : "mono/xwt") + ".git";
				var gitBranch = Parameters ["XwtGithubBranch"];
				if (gitBranch == String.Empty)
					gitBranch = "master";
				var gitRepo = VersionControlService.GetRepository (solution) as GitRepository;
				var xwt_proj = solution.FindProjectByName ("Xwt") as DotNetProject;

				if (xwt_proj != null && xwt_proj.ItemId.ToUpper () != "{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}") {
					xwt_proj = null;
					foreach (var item in solution.GetAllProjectsWithFlavor<DotNetProjectExtension>()) {
						if (item.ItemId.ToUpper () == "{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}") {
							xwt_proj = item as DotNetProject;
							break;
						}
					}
				}

				var xwt_path = xwt_proj == null ? solution.BaseDirectory.Combine ("Xwt") : xwt_proj.BaseDirectory.ParentDirectory;

				monitor.BeginTask ("Configuring Xwt References...", 3);

				if (xwt_proj == null && !Directory.Exists (xwt_path)) {
					monitor.BeginTask ("Cloning Xwt into " + xwt_path + "...", 1);
					if (createSubmodule && gitRepo != null) {
						monitor.BeginTask ("Initializing Xwt submodule in " + xwt_path + "...", 1);

						var repo = new FileRepository (gitRepo.RootPath.Combine (".git"));
						var git = new Git (repo);

						try {
							using (var gm = new GitMonitor (monitor)) {
								var add_submodule = git.SubmoduleAdd ();
								add_submodule.SetPath ("Xwt");
								add_submodule.SetURI (gitUrl);
								add_submodule.SetProgressMonitor (gm);
								add_submodule.Call ();

								var submodule = new GitRepository (VersionControlService.GetVersionControlSystems ().First (id => id.Name == "Git"),
												   gitRepo.RootPath.Combine ("Xwt"), gitUrl);

								var submoduleRemote = submodule.GetCurrentRemote ();
								submodule.Fetch (monitor, submoduleRemote);
								if (submodule.GetCurrentBranch () != gitBranch) {
									submodule.CreateBranch (gitBranch, submoduleRemote + "/" + gitBranch, "refs/remotes/" + submoduleRemote + "/" + gitBranch);
									submodule.SwitchToBranch (monitor, gitBranch);
								}
							}
						} catch {
							Directory.Delete (xwt_path, true);
							throw;
						}

						monitor.EndTask ();
					} else {

						var repo = new GitRepository ();
						repo.Url = gitUrl;
						repo.Checkout (xwt_path, true, monitor);
						var remote = repo.GetCurrentRemote ();
						repo.Fetch (monitor, remote);
						if (repo.GetCurrentBranch () != gitBranch) {
							repo.CreateBranch (gitBranch, remote + "/" + gitBranch, "refs/remotes/" + remote + "/" + gitBranch);
							repo.SwitchToBranch (monitor, gitBranch);
						}
					}
					monitor.EndTask ();
				}

				SolutionFolder xwt_folder;
				if (xwt_proj != null)
					xwt_folder = xwt_proj.ParentFolder;
				else {
					xwt_folder = new SolutionFolder ();
					xwt_folder.Name = "Xwt";
				}
				solution.RootFolder.Items.Add (xwt_folder);
				monitor.Step (1);

				monitor.BeginTask ("Adding Xwt Projects to Solution...", 7);

				if (xwt_proj == null && File.Exists (xwt_path.Combine ("Xwt", "Xwt.csproj"))) {
					xwt_proj = await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt", "Xwt.csproj")
					) as DotNetProject;
				}
				if (xwt_proj == null)
					throw new InvalidOperationException ("Xwt project not found");

				monitor.Step (1);

				var xwt_gtk_proj = solution.FindProjectByName ("Xwt.Gtk") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk", "Xwt.Gtk.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_gtk_win_proj = solution.FindProjectByName ("Xwt.Gtk.Windows") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk.Windows", "Xwt.Gtk.Windows.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_gtk_mac_proj = solution.FindProjectByName ("Xwt.Gtk.Mac") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk.Mac", "Xwt.Gtk.Mac.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_gtk3_proj = solution.FindProjectByName ("Xwt.Gtk3") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk", "Xwt.Gtk3.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_wpf_proj = solution.FindProjectByName ("Xwt.WPF") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.WPF", "Xwt.WPF.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_mac_proj = solution.FindProjectByName ("Xwt.Mac") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Mac", "Xwt.Mac.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_xammac_proj = solution.FindProjectByName ("Xwt.XamMac") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.XamMac", "Xwt.XamMac.csproj")
					) as DotNetProject;


				monitor.EndTask ();
				monitor.Step (1);
				monitor.BeginTask ("Adding Xwt References...", solution.Items.Count);

				foreach (var item in solution.Items) {
					var project = item as DotNetProject;
					if (project != null) {
						if (project.Name == newProjectName ||
						    project.Name.StartsWith (newProjectName + ".", StringComparison.Ordinal))
							project.References.Add (ProjectReference.CreateProjectReference (xwt_proj));
						
						if (project.Name == newProjectName + ".Desktop") {
							if (Platform.IsWindows) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_wpf_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_win_proj));
							} else if (Platform.IsLinux) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk3_proj));
							} else if (Platform.IsMac) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_xammac_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_mac_proj));
							}
						}

						if (project.Name == newProjectName + ".Gtk2") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
							if (Platform.IsWindows) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_win_proj));
							} else if (Platform.IsMac) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_mac_proj));
							}
						}

						if (project.Name == newProjectName + ".Wpf") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_wpf_proj));
						}

						if (project.Name == newProjectName + ".Gtk3") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk3_proj));
						}

						if (project.Name == newProjectName + ".Mac") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_mac_proj));
						}

						if (project.Name == newProjectName + ".XamMac") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_xammac_proj));
						}
					}
					monitor.Step (1);
				}

				monitor.EndTask ();
				monitor.EndTask ();
				monitor.ReportSuccess ("Xwt Repository initialized successfully");

				await IdeApp.Workspace.SaveAsync (monitor);
			} catch (Exception e) {
				string msg = GettextCatalog.GetString ("Adding Xwt reference failed: ");
				monitor.ReportError (msg, e);
				MessageService.ShowError (msg, e);
			} finally {
				monitor.Dispose ();
			}
		}
		public async static Task<bool> SwitchToBranch (GitRepository repo, string branch)
		{
			var monitor = new MessageDialogProgressMonitor (true, false, false, true);
			try {
				IdeApp.Workbench.AutoReloadDocuments = true;
				IdeApp.Workbench.LockGui ();
				var t = await Task.Run (delegate {
					try {
						return repo.SwitchToBranch (monitor, branch);
					} catch (Exception ex) {
						monitor.ReportError (GettextCatalog.GetString ("Branch switch failed"), ex);
						return false;
					} finally {
						monitor.Dispose ();
					}
				});
				return t;
			} finally {
				IdeApp.Workbench.AutoReloadDocuments = false;
				IdeApp.Workbench.UnlockGui ();
			}
		}
		public static Task<bool> ApplyStash (GitRepository repo, int s)
		{
			var monitor = new MessageDialogProgressMonitor (true, false, false, true);
			var statusTracker = IdeApp.Workspace.GetFileStatusTracker ();
			var t = Task.Run (delegate {
				try {
					var res = repo.ApplyStash (monitor, s);
					ReportStashResult (res);
					return true;
				} catch (Exception ex) {
					string msg = GettextCatalog.GetString ("Stash operation failed.");
					monitor.ReportError (msg, ex);
					return false;
				}
				finally {
					monitor.Dispose ();
					statusTracker.Dispose ();
				}
			});
			return t;
		}