| author | Piotr Janik | 2011-08-02 08:25:27 (EDT) |
|---|---|---|
| committer | Szymon Brandys | 2011-08-02 08:25:27 (EDT) |
| commit | 5954e4f7efe6dc1dde13758dc5a1d8987dd59918 (patch) (side-by-side diff) | |
| tree | b52d7653983646d1915257dbb3739a04b16a4d1a | |
| parent | ff8867ca40bc0b21e482681c16ccf80cca47873d (diff) | |
| download | org.eclipse.orion.client-5954e4f7efe6dc1dde13758dc5a1d8987dd59918.zip org.eclipse.orion.client-5954e4f7efe6dc1dde13758dc5a1d8987dd59918.tar.gz org.eclipse.orion.client-5954e4f7efe6dc1dde13758dc5a1d8987dd59918.tar.bz2 | |
bug 349727 - [client] git cherry-pick support UI
https://bugs.eclipse.org/bugs/show_bug.cgi?id=349727
3 files changed, 125 insertions, 0 deletions
diff --git a/bundles/org.eclipse.orion.client.git/web/git/git-log.js b/bundles/org.eclipse.orion.client.git/web/git/git-log.js index a0b8359..9d457d0 100644 --- a/bundles/org.eclipse.orion.client.git/web/git/git-log.js +++ b/bundles/org.eclipse.orion.client.git/web/git/git-log.js @@ -89,6 +89,7 @@ dojo.addOnLoad(function() { commandService.registerCommandContribution("eclipse.orion.git.pushForce", 100, "pageActions", "eclipse.gitGroup.page"); commandService.registerCommandContribution("eclipse.orion.git.switchToRemote", 100, "pageActions", "eclipse.gitGroup.page"); commandService.registerCommandContribution("eclipse.orion.git.addTag", 3); + commandService.registerCommandContribution("eclipse.orion.git.cherryPick", 3); loadResource(fileServiceReference, navigator); 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 2e7579d..03c8839 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 @@ -644,6 +644,38 @@ eclipse.GitService = (function() { } }); }, + doCherryPick : function(gitHeadURI, commitName, onLoad, onError) { + var service = this; + + return dojo.xhrPost({ + url : gitHeadURI, + headers : { + "Orion-Version" : "1" + }, + postData : dojo.toJson({ + "Cherry-Pick" : commitName + }), + handleAs : "json", + timeout : 5000, + load : function(jsonData, secondArg) { + if (onLoad) { + if (typeof onLoad === "function") + onLoad(jsonData, secondArg); + else + service._serviceRegistration.dispatchEvent(onLoad, + jsonData); + } + return {jsonData: jsonData, secondArg: secondArg}; + }, + error : function(error, ioArgs) { + if(onError) + onError(error, ioArgs); + mAuth.handleGetAuthenticationError(this, ioArgs); + console.error("HTTP status code: ", ioArgs.xhr.status); + return {error: error, ioArgs: ioArgs}; + } + }); + }, doRebase : function(gitHeadURI, commitName, operation, onLoad, onError) { var service = this; var postData = {}; 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 cff9c0b..aefa9b1 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 @@ -1002,6 +1002,98 @@ var exports = {}; }); commandService.addCommand(addTagCommand, "object"); + + var cherryPickCommand = new mCommands.Command({ + name : "Cherry-Pick", + id : "eclipse.orion.git.cherryPick", + + callback: function(item) { + var path = dojo.hash(); + serviceRegistry.getService("orion.git.provider").then( + function(service) { + var headLocation = item.Location.replace(item.Name, "HEAD"); + service.doCherryPick(headLocation, item.Name, + function(jsonData, secondArg){ + serviceRegistry.getService("orion.page.message").then(function(progressService) { + var display = []; + + // TODO we should not craft locations in the code + var statusLocation = item.Location.replace("commit/" + item.Name, "status"); + + if (jsonData.Result == "OK") { + // operation succeeded + display.Severity = "Ok"; + display.HTML = false; + display.Message = jsonData.Result; + + if (explorer.parentId === "explorer-tree") { + // refresh commit list + dojo.xhrGet({ + url : path, + headers : { + "Orion-Version" : "1" + }, + handleAs : "json", + timeout : 5000, + load : function(jsonData, secondArg) { + return jsonData; + }, + error : function(error, ioArgs) { + //handleGetAuthenticationError(this, ioArgs); + console.error("HTTP status code: ", ioArgs.xhr.status); + } + }).then(function(jsonData) { + if (jsonData.HeadLocation) { + // log view for remote + service.getLog(jsonData.HeadLocation, jsonData.Id, function(scopedCommitsJsonData, secondArd) { + explorer.renderer.setIncomingCommits(scopedCommitsJsonData); + explorer.loadCommitsList(jsonData.CommitLocation + "?page=1", jsonData, true); + }); + } else { + // log view for branch / all branches + service.getLog(path, "HEAD", function(scopedCommitsJsonData, secondArd) { + explorer.renderer.setOutgoingCommits(scopedCommitsJsonData); + explorer.loadCommitsList(path, jsonData, true); + }); + } + }); + } + } + // handle special cases + else if (jsonData.Result == "CONFLICTING") { + display.Severity = "Warning"; + display.HTML = true; + display.Message = "<span>" + jsonData.Result + + ". Some conflicts occurred. Go to <a href=\"/git/git-status.html#" + + statusLocation +"\">Git Status page</a>.<span>"; + } + else if (jsonData.Result == "FAILED") { + display.Severity = "Error"; + display.HTML = true; + display.Message = "<span>" + jsonData.Result + + ". Go to <a href=\"/git/git-status.html#" + + statusLocation +"\">Git Status page</a>.<span>"; + } + // handle other cases + else { + display.Severity = "Warning"; + display.HTML = false; + display.Message = jsonData.Result; + } + progressService.setProgressResult(display); + }); + }, + displayErrorOnStatus + ); + }); + + }, + visibleWhen : function(item) { + return item.Type === "Commit"; + } + }); + + commandService.addCommand(cherryPickCommand, "object"); }; exports.createStatusCommands = function(serviceRegistry, commandService, refreshStatusCallBack , cmdBaseNumber ,logNavigator, remoteNavigator, logPath) { |

