public override bool OnBeginCommit(ChangeSet changeSet) { return true; #if UserNameEmailSupported // In this callback we check if the user information configured in Git // matches the user information configured in MonoDevelop. If the configurations // don't match, it shows a dialog asking the user what to do. MercurialRepository repo = (MercurialRepository) changeSet.Repository; if (!widget.CommitterIsAuthor) { if (widget.AuthorName.Length > 0) changeSet.ExtendedProperties ["Mercurial.AuthorName"] = widget.AuthorName; if (widget.AuthorMail.Length > 0) changeSet.ExtendedProperties ["Mercurial.AuthorEmail"] = widget.AuthorMail; } Solution sol = null; // Locate the solution to which the changes belong foreach (Solution s in IdeApp.Workspace.GetAllSolutions ()) { if (s.BaseDirectory == changeSet.BaseLocalPath || changeSet.BaseLocalPath.IsChildPathOf (s.BaseDirectory)) { sol = s; break; } } if (sol == null) return true; string val = sol.UserProperties.GetValue<string> ("MercurialUserInfo"); if (val == "UsingMD") { // If the solution is configured to use the MD configuration, make sure the Git config is up to date. string user; string email; repo.GetUserInfo (out user, out email); if (user != sol.AuthorInformation.Name || email != sol.AuthorInformation.Email) repo.SetUserInfo (sol.AuthorInformation.Name, sol.AuthorInformation.Email); } else if (val != "UsingGIT") { string user; string email; repo.GetUserInfo (out user, out email); if (user != sol.AuthorInformation.Name || email != sol.AuthorInformation.Email) { // There is a conflict. Ask the user what to do string gitInfo = GetDesc (user, email); string mdInfo = GetDesc (sol.AuthorInformation.Name, sol.AuthorInformation.Email); UserInfoConflictDialog dlg = new UserInfoConflictDialog (mdInfo, gitInfo); try { if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) { if (dlg.UseMonoDevelopConfig) { repo.SetUserInfo (sol.AuthorInformation.Name, sol.AuthorInformation.Email); sol.UserProperties.SetValue ("MercurialUserInfo", "UsingMD"); } else sol.UserProperties.SetValue ("MercurialUserInfo", "UsingGIT"); sol.SaveUserProperties (); } else return false; } finally { dlg.Destroy (); } } } return true; #endif }
public override bool OnBeginCommit(ChangeSet changeSet) { return(true); #if UserNameEmailSupported // In this callback we check if the user information configured in Git // matches the user information configured in MonoDevelop. If the configurations // don't match, it shows a dialog asking the user what to do. MercurialRepository repo = (MercurialRepository)changeSet.Repository; if (!widget.CommitterIsAuthor) { if (widget.AuthorName.Length > 0) { changeSet.ExtendedProperties ["Mercurial.AuthorName"] = widget.AuthorName; } if (widget.AuthorMail.Length > 0) { changeSet.ExtendedProperties ["Mercurial.AuthorEmail"] = widget.AuthorMail; } } Solution sol = null; // Locate the solution to which the changes belong foreach (Solution s in IdeApp.Workspace.GetAllSolutions()) { if (s.BaseDirectory == changeSet.BaseLocalPath || changeSet.BaseLocalPath.IsChildPathOf(s.BaseDirectory)) { sol = s; break; } } if (sol == null) { return(true); } string val = sol.UserProperties.GetValue <string> ("MercurialUserInfo"); if (val == "UsingMD") { // If the solution is configured to use the MD configuration, make sure the Git config is up to date. string user; string email; repo.GetUserInfo(out user, out email); if (user != sol.AuthorInformation.Name || email != sol.AuthorInformation.Email) { repo.SetUserInfo(sol.AuthorInformation.Name, sol.AuthorInformation.Email); } } else if (val != "UsingGIT") { string user; string email; repo.GetUserInfo(out user, out email); if (user != sol.AuthorInformation.Name || email != sol.AuthorInformation.Email) { // There is a conflict. Ask the user what to do string gitInfo = GetDesc(user, email); string mdInfo = GetDesc(sol.AuthorInformation.Name, sol.AuthorInformation.Email); UserInfoConflictDialog dlg = new UserInfoConflictDialog(mdInfo, gitInfo); try { if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok) { if (dlg.UseMonoDevelopConfig) { repo.SetUserInfo(sol.AuthorInformation.Name, sol.AuthorInformation.Email); sol.UserProperties.SetValue("MercurialUserInfo", "UsingMD"); } else { sol.UserProperties.SetValue("MercurialUserInfo", "UsingGIT"); } sol.SaveUserProperties(); } else { return(false); } } finally { dlg.Destroy(); } } } return(true); #endif }