[prev in list] [next in list] [prev in thread] [next in thread]
List: mono-patches
Subject: [Mono-patches] [mono/monodevelop] 8163356a: Fixed branch remove and
From: "Lluis Sanchez Gual (lluis () novell ! com)" <mono-patches () lists ! ximian ! com>
Date: 2011-03-31 23:43:45
Message-ID: 20110331234345.573652212B () mono ! ximian ! com
[Download RAW message or body]
Branch: refs/heads/master
Home: https://github.com/mono/monodevelop
Commit: 8163356a96db95b976f100fa9a5fb7a5ce239bdd
Author: Lluis Sanchez Gual <lluis@novell.com>
Date: 03/31/2011 19:42:20
URL: https://github.com/mono/monodevelop/commit/8163356a96db95b976f100fa9a5fb7a5ce239bdd
Fixed branch remove and rename operations
Changed paths:
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitConfigurationDialog.cs
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitConfigurationDialog.cs
===================================================================
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitConfigurationDialog.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitConfigurationDialog.cs
@@ -123,8 +123,13 @@ namespace MonoDevelop.VersionControl.Git
var dlg = new EditBranchDialog (repo, b, false);
try {
if (MessageService.RunCustomDialog (dlg) == (int) ResponseType.Ok) {
- if (dlg.BranchName != b.Name)
- repo.RenameBranch (b.Name, dlg.BranchName);
+ if (dlg.BranchName != b.Name) {
+ try {
+ repo.RenameBranch (b.Name, dlg.BranchName);
+ } catch (Exception ex) {
+ MessageService.ShowException (ex, GettextCatalog.GetString ("The branch could \
not be renamed")); + }
+ }
repo.SetBranchTrackSource (dlg.BranchName, dlg.TrackSource);
FillBranches ();
}
@@ -139,9 +144,16 @@ namespace MonoDevelop.VersionControl.Git
if (!listBranches.Selection.GetSelected (out it))
return;
Branch b = (Branch) storeBranches.GetValue (it, 0);
- if (MessageService.Confirm (GettextCatalog.GetString ("Are you sure you want to \
delete the branch '{0}'?", b.Name), AlertButton.Delete)) {
- repo.RemoveBranch (b.Name);
- FillBranches ();
+ string txt = null;
+ if (!repo.IsBranchMerged (b.Name))
+ txt = GettextCatalog.GetString ("WARNING: The branch has not yet been merged to \
HEAD"); + if (MessageService.Confirm (GettextCatalog.GetString ("Are you sure you \
want to delete the branch '{0}'?", b.Name), txt, AlertButton.Delete)) { + try {
+ repo.RemoveBranch (b.Name);
+ FillBranches ();
+ } catch (Exception ex) {
+ MessageService.ShowException (ex, GettextCatalog.GetString ("The branch could \
not be deleted")); + }
}
}
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
===================================================================
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
@@ -938,14 +938,14 @@ namespace MonoDevelop.VersionControl.Git
public void RemoveBranch (string name)
{
- RefUpdate updateRef = repo.UpdateRef ("refs/heads/" + name);
- updateRef.Delete ();
+ var git = new NGit.Api.Git (repo);
+ git.BranchDelete ().SetBranchNames (name).SetForce (true).Call ();
}
public void RenameBranch (string name, string newName)
{
- RefRename renameRef = repo.RenameRef ("refs/heads/" + name, "refs/heads/" + \
newName);
- renameRef.Rename ();
+ var git = new NGit.Api.Git (repo);
+ git.BranchRename ().SetOldName (name).SetNewName (newName).Call ();
}
public IEnumerable<RemoteSource> GetRemotes ()
@@ -954,6 +954,18 @@ namespace MonoDevelop.VersionControl.Git
foreach (RemoteConfig rc in RemoteConfig.GetAllRemoteConfigs (cfg))
yield return new RemoteSource (cfg, rc);
}
+
+ public bool IsBranchMerged (string branchName)
+ {
+ // check if a branch is merged into HEAD
+ RevWalk walk = new RevWalk(repo);
+ RevCommit tip = walk.ParseCommit(repo.Resolve(Constants.HEAD));
+ Ref currentRef = repo.GetRef(branchName);
+ if (currentRef == null)
+ return true;
+ RevCommit @base = walk.ParseCommit(repo.Resolve(branchName));
+ return walk.IsMergedInto(@base, tip);
+ }
public void RenameRemote (string name, string newName)
{
_______________________________________________
Mono-patches maillist - Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic