| author | Edyta Przymus | 2012-07-10 07:09:39 (EDT) |
|---|---|---|
| committer | Szymon Brandys | 2012-07-10 07:09:39 (EDT) |
| commit | 6595fd60247e825214c3475b9512cc6385cfd336 (patch) (side-by-side diff) | |
| tree | 49b546c74f19bc2f2158f1be334a4cdda3bfc5af | |
| parent | 3ea2e917b813095d6a7e71e8e11e08fe4b272ac6 (diff) | |
| download | org.eclipse.orion.client-6595fd60247e825214c3475b9512cc6385cfd336.zip org.eclipse.orion.client-6595fd60247e825214c3475b9512cc6385cfd336.tar.gz org.eclipse.orion.client-6595fd60247e825214c3475b9512cc6385cfd336.tar.bz2 | |
Bug 351432 - Add git merge --squashv20120710-1109
4 files changed, 81 insertions, 7 deletions
diff --git a/bundles/org.eclipse.orion.client.git/web/git/git-repository.js b/bundles/org.eclipse.orion.client.git/web/git/git-repository.js index 649458d..d82b222 100644 --- a/bundles/org.eclipse.orion.client.git/web/git/git-repository.js +++ b/bundles/org.eclipse.orion.client.git/web/git/git-repository.js @@ -79,6 +79,7 @@ mBootstrap.startup().then(function(core) { commandService.registerCommandContribution("itemLevelCommands", "eclipse.git.deleteClone", 1000); //$NON-NLS-1$ //$NON-NLS-0$ commandService.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.fetch", 500); //$NON-NLS-1$ //$NON-NLS-0$ commandService.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.merge", 600); //$NON-NLS-1$ //$NON-NLS-0$ + commandService.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.mergeSquash", 700); //$NON-NLS-1$ //$NON-NLS-0$ commandService.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.rebase", 700); //$NON-NLS-1$ //$NON-NLS-0$ commandService.registerCommandContribution("itemLevelCommands", "eclipse.orion.git.resetIndex", 800); //$NON-NLS-1$ //$NON-NLS-0$ commandService.registerCommandContribution("itemLevelCommands", "eclipse.removeRemote", 1000); //$NON-NLS-1$ //$NON-NLS-0$ diff --git a/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js b/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js index a84c2c4..36a55b4 100644 --- a/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js +++ b/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js @@ -338,10 +338,12 @@ define({ "Active Branch Log": "Git Log (Active Branch)",
"Show the log for the active local branch": "Show the log for the active local branch",
"Remote Branch Log": "Git Log (Remote Branch)",
- "Show the log for the corresponding remote tracking branch": "Show the log for the corresponding remote tracking branch",
+ "Show the log for the corresponding remote tracking branch": "Show the log for the corresponding remote tracking branch", "See Full Status" : "See Full Status",
"See the status" : "See the status",
"Choose target location" : "Choose target location",
"Default target location" : "Default target location",
- "Change..." : "Change..." -});
\ No newline at end of file + "Change..." : "Change...", + "Merge Squash": "Merge Squash",
+ "Squash the content of the branch to the index" : "Squash the content of the branch to the index" +}); diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitClient.js b/bundles/org.eclipse.orion.client.git/web/orion/git/gitClient.js index 379b611..66b2b79 100644 --- a/bundles/org.eclipse.orion.client.git/web/orion/git/gitClient.js +++ b/bundles/org.eclipse.orion.client.git/web/orion/git/gitClient.js @@ -589,7 +589,7 @@ eclipse.GitService = (function() { }); return clientDeferred; }, - doMerge : function(gitHeadURI, commitName) { + doMerge : function(gitHeadURI, commitName, squash) { var service = this; var clientDeferred = new dojo.Deferred(); dojo.xhrPost({ @@ -598,7 +598,8 @@ eclipse.GitService = (function() { "Orion-Version" : "1" //$NON-NLS-1$ //$NON-NLS-0$ }, postData : dojo.toJson({ - "Merge" : commitName //$NON-NLS-0$ + "Merge" : commitName, //$NON-NLS-0$ + "Squash" : squash }), handleAs : "json", //$NON-NLS-0$ timeout : 5000, diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js index 017604d..5f9b88e 100644 --- a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js +++ b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js @@ -974,7 +974,7 @@ var exports = {}; var item = data.items; var gitService = serviceRegistry.getService("orion.git.provider"); //$NON-NLS-0$ var progressService = serviceRegistry.getService("orion.page.message"); //$NON-NLS-0$ - gitService.doMerge(item.HeadLocation, item.Name).then(function(result){ + gitService.doMerge(item.HeadLocation, item.Name, false).then(function(result){ var display = []; if (result.jsonData && (result.jsonData.Result == "FAST_FORWARD" || result.jsonData.Result == "ALREADY_UP_TO_DATE")){ //$NON-NLS-1$ //$NON-NLS-0$ @@ -1033,6 +1033,76 @@ var exports = {}; } }); commandService.addCommand(mergeCommand); + + var mergeSquashCommand = new mCommands.Command({ + name : messages["Merge Squash"], + tooltip: messages["Squash the content of the branch to the index"], + imageClass: "git-sprite-merge", //$NON-NLS-0$ + spriteClass: "gitCommandSprite", //$NON-NLS-0$ + id : "eclipse.orion.git.mergeSquash", //$NON-NLS-0$ + callback: function(data) { + var item = data.items; + var gitService = serviceRegistry.getService("orion.git.provider"); //$NON-NLS-0$ + var progressService = serviceRegistry.getService("orion.page.message"); //$NON-NLS-0$ + gitService.doMerge(item.HeadLocation, item.Name, true).then(function(result){ + var display = []; + + if (result.jsonData && (result.jsonData.Result == "FAST_FORWARD_SQUASHED" || result.jsonData.Result == "ALREADY_UP_TO_DATE")){ //$NON-NLS-1$ //$NON-NLS-0$ + dojo.query(".treeTableRow").forEach(function(node, i) { //$NON-NLS-0$ + dojo.toggleClass(node, "incomingCommitsdRow", false); //$NON-NLS-0$ + }); + display.Severity = "Ok"; //$NON-NLS-0$ + display.HTML = false; + display.Message = result.jsonData.Result; + + dojo.hitch(explorer, explorer.changedItem)(item); + } else if(result.jsonData){ + var statusLocation = item.HeadLocation.replace("commit/HEAD", "status"); //$NON-NLS-1$ //$NON-NLS-0$ + + display.Severity = "Warning"; //$NON-NLS-0$ + display.HTML = true; + display.Message = "<span>" + result.jsonData.Result //$NON-NLS-0$ + + dojo.string.substitute(messages[". Go to ${0}."], ["<a href=\"" + require.toUrl(mGitUtil.statusUILocation) + "#" //$NON-NLS-2$ //$NON-NLS-1$ + + statusLocation +"\">"+messages["Git Status page"]+"</a>"])+"</span>"; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-0$ + } else if(result.error) { + var statusLocation = item.HeadLocation.replace("commit/HEAD", "status"); //$NON-NLS-1$ //$NON-NLS-0$ + display.Severity = "Error"; //$NON-NLS-0$ + if(result.error.responseText && JSON.parse(result.error.responseText)){ + var resp = JSON.parse(result.error.responseText); + display.Message = resp.DetailedMessage ? resp.DetailedMessage : resp.Message; + }else{ + display.Message = result.error.message; + } + display.HTML = true; + display.Message ="<span>" + display.Message + dojo.string.substitute(messages['. Go to ${0}.'], ["<a href=\"" + require.toUrl(mGitUtil.statusUILocation) + "#" //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-0$ + + statusLocation + "\">"+messages['Git Status page']+"</a>"])+"</span>"; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-0$ + } + + progressService.setProgressResult(display); + }, function (error, ioArgs) { + var display = []; + + var statusLocation = item.HeadLocation.replace("commit/HEAD", "status"); //$NON-NLS-1$ //$NON-NLS-0$ + + display.Severity = "Error"; //$NON-NLS-0$ + display.HTML = true; + display.Message = "<span>" + dojo.fromJson(ioArgs.xhr.responseText).DetailedMessage //$NON-NLS-0$ + + dojo.string.substitute(messages['. Go to ${0}.'], ["<a href=\"" + require.toUrl(mGitUtil.statusUILocation) + "#" //$NON-NLS-2$ //$NON-NLS-1$ + + statusLocation +"\">"+messages['Git Status page']+"</a>"])+".</span>"; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-0$ + serviceRegistry.getService("orion.page.message").setProgressResult(display); //$NON-NLS-0$ + }); + }, + visibleWhen : function(item) { + if (item.Type === "RemoteTrackingBranch") //$NON-NLS-0$ + return true; + if (item.Type === "Branch" && !item.Current) //$NON-NLS-0$ + return true; + if (item.Type === "Commit" && item.toRef && item.toRef.Type === "RemoteTrackingBranch") //$NON-NLS-1$ //$NON-NLS-0$ + return true; + return false; + } + }); + commandService.addCommand(mergeSquashCommand); var rebaseCommand = new mCommands.Command({ name : messages["Rebase"], @@ -1694,7 +1764,7 @@ var exports = {}; var item = data.items; var gitService = serviceRegistry.getService("orion.git.provider"); //$NON-NLS-0$ var progressService = serviceRegistry.getService("orion.page.message"); //$NON-NLS-0$ - gitService.doMerge(item.HeadLocation, item.Name).then(function(result){ + gitService.doMerge(item.HeadLocation, item.Name, false).then(function(result){ var display = []; if (result.jsonData && (result.jsonData.Result == "FAST_FORWARD" || result.jsonData.Result == "ALREADY_UP_TO_DATE")){ //$NON-NLS-1$ //$NON-NLS-0$ |

