summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorPiotr Janik2011-07-25 11:49:04 (EDT)
committer Szymon Brandys2011-07-25 11:49:04 (EDT)
commit44965908db08f7c402d5e9ee1c350e3c63e4562d (patch)
treecad35bceb15170fb1d2b168a7b7ea48a98b837c1
parent733cb113e8b5af695140084ece40892b368fa64a (diff)
downloadorg.eclipse.orion.client-44965908db08f7c402d5e9ee1c350e3c63e4562d.zip
org.eclipse.orion.client-44965908db08f7c402d5e9ee1c350e3c63e4562d.tar.gz
org.eclipse.orion.client-44965908db08f7c402d5e9ee1c350e3c63e4562d.tar.bz2
bug 351429 - Add git rebasev20110726-0200
https://bugs.eclipse.org/bugs/show_bug.cgi?id=351429
-rw-r--r--bundles/org.eclipse.orion.client.git/web/git/git-clone.js1
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/git-status-table.js180
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/gitClient.js33
-rw-r--r--bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js73
4 files changed, 278 insertions, 9 deletions
diff --git a/bundles/org.eclipse.orion.client.git/web/git/git-clone.js b/bundles/org.eclipse.orion.client.git/web/git/git-clone.js
index dda71aa..1f6778e 100644
--- a/bundles/org.eclipse.orion.client.git/web/git/git-clone.js
+++ b/bundles/org.eclipse.orion.client.git/web/git/git-clone.js
@@ -57,6 +57,7 @@ dojo.addOnLoad(function() {
commandService.registerCommandContribution("eclipse.openGitStatus", 2);
commandService.registerCommandContribution("eclipse.orion.git.fetch", 2);
commandService.registerCommandContribution("eclipse.orion.git.merge", 2);
+ commandService.registerCommandContribution("eclipse.orion.git.rebase", 2);
commandService.registerCommandContribution("eclipse.orion.git.push", 2);
commandService.registerCommandContribution("eclipse.orion.git.pushto", 3);
commandService.registerCommandContribution("eclipse.orion.git.resetIndex", 4);
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/git-status-table.js b/bundles/org.eclipse.orion.client.git/web/orion/git/git-status-table.js
index 47160ff..f9866a0 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/git-status-table.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/git-status-table.js
@@ -273,12 +273,14 @@ orion.GitCommitZoneRenderer = (function() {
}
GitCommitZoneRenderer.prototype = {
render: function (renderSeparator) {
- var headerTable = dojo.create("table", {width:"100%"},this._parentId);
+ this._commitZone = dojo.create("div", null, this._parentId, "last");
+
+ var headerTable = dojo.create("table", {width:"100%"}, this._commitZone);
var row = dojo.create("tr", null, headerTable);
var titleCol = dojo.create("td", {nowrap :true}, row, "last");
- var title = dojo.create("h2", {innerHTML: "Commit message:"}, titleCol, "last");
+ dojo.create("h2", {innerHTML: "Commit message:"}, titleCol, "last");
- var commitTable = dojo.create("table", null,this._parentId);
+ var commitTable = dojo.create("table", null, this._commitZone);
var commitRow = dojo.create("tr", null, commitTable);
var messageCol = dojo.create("td", {nowrap :true}, commitRow, "last");
dojo.create("textarea", {id:"commitMessage", COLS:40, ROWS:6}, messageCol, "last");
@@ -297,13 +299,65 @@ orion.GitCommitZoneRenderer = (function() {
dojo.create("input", {id:"amend", type:"checkbox" ,value: "Amend"}, actionCol2, "last");
actionCol2.appendChild(document.createTextNode(" Amend"));
if( renderSeparator)
- dojo.create("table", {width:"100%", height:"10px"},this._parentId);
- }
+ dojo.create("table", {width:"100%", height:"10px"}, this._commitZone);
+ },
+ show:function(){
+ this._commitZone.style.display = "";
+ },
+
+ hide:function(){
+ this._commitZone.style.display = "none";
+ }
};
return GitCommitZoneRenderer;
}());
+orion.GitRebaseZoneRenderer = (function() {
+ function GitRebaseZoneRenderer(serviceRegistry, parentId) {
+ this._registry = serviceRegistry;
+ this._parentId = parentId;
+ }
+ GitRebaseZoneRenderer.prototype = {
+ render: function (renderSeparator) {
+ this._rebaseZone = dojo.create("div", null, this._parentId, "last");
+
+ var headerTable = dojo.create("table", {width:"100%"}, this._rebaseZone);
+ var row = dojo.create("tr", null, headerTable);
+ var titleCol = dojo.create("td", {nowrap :true}, row, "last");
+ dojo.create("h2", {innerHTML: "Rebase in progress. Choose action:" }, titleCol, "last");
+
+ var commitTable = dojo.create("table", null, this._rebaseZone);
+ var commitRow = dojo.create("tr", null, commitTable);
+
+ var actionCol = dojo.create("td", {nowrap :true}, commitRow, "last");
+ var actionDiv = dojo.create("div", {style:"float: left;", align:"left"}, actionCol, "last");
+
+ this._cmdSpan = dojo.create("span", {id:"rebaseActions"}, actionDiv, "last");
+
+ if( renderSeparator)
+ dojo.create("table", {width:"100%", height:"10px"}, this._rebaseZone);
+ },
+
+ renderAction:function(){
+ dojo.place(document.createTextNode(""), this._cmdSpan, "only");
+ var self = this;
+ this._registry.getService("orion.page.command").then(function(service) {
+ service.renderCommands(self._cmdSpan, "dom", {type: "rebase"}, this, "image", null, null);
+ });
+ },
+
+ show:function(){
+ this._rebaseZone.style.display = "";
+ },
+
+ hide:function(){
+ this._rebaseZone.style.display = "none";
+ }
+ };
+ return GitRebaseZoneRenderer;
+}());
+
orion.GitLogTableRenderer = (function() {
function GitLogTableRenderer(controller ,serviceRegistry ,parentId , header , type ) {
this._controller = controller;
@@ -414,6 +468,8 @@ orion.GitStatusController = (function() {
this._stagedTableRenderer.render();
this._commitZoneRenderer = new orion.GitCommitZoneRenderer(serviceRegistry ,"statusZone");
this._commitZoneRenderer.render(true);
+ this._rebaseZoneRenderer = new orion.GitRebaseZoneRenderer(serviceRegistry, "statusZone");
+ this._rebaseZoneRenderer.render(true);
if(this._renderLog){
this._logTableRenderer = new orion.GitLogTableRenderer(this ,serviceRegistry ,"logZone" , "Recent commits on" , "gitLog");
this._logTableRenderer.render(true);
@@ -437,7 +493,6 @@ orion.GitStatusController = (function() {
commitBtn.onclick = function(evt){
self.commit();
};
-
}
GitStatusController.prototype = {
loadStatus: function(jsonData){
@@ -492,6 +547,22 @@ orion.GitStatusController = (function() {
}
this._statusService.setProgressMessage("");
+
+ // check if repository state contains REBASING
+ // (status could be: REBASING, REBASING_REBASING, REBASING_INTERACTIVE, REBASING_MERGE)
+ if (this._model.items.RepositoryState.indexOf("REBASING") != -1) {
+ this.rebaseState = true;
+ // show rebase panel
+ this._rebaseZoneRenderer.renderAction();
+ this._rebaseZoneRenderer.show();
+ this._commitZoneRenderer.hide();
+ }
+ else {
+ this.rebaseState = false;
+ // show commit panel
+ this._commitZoneRenderer.show();
+ this._rebaseZoneRenderer.hide();
+ }
},
_renderGlobalActions:function(){
@@ -808,6 +879,45 @@ orion.GitStatusController = (function() {
visibleWhen: function(item) {
return (self.hasStaged || self.hasUnstaged);
}
+ });
+
+ var rebaseContinueCommand = new mCommands.Command({
+ name: "Continue",
+ tooltip: "Continue rebase",
+ id: "orion.gitRebaseContinue",
+ callback: function(item) {
+ self._statusService.setProgressMessage("Continue rebase...");
+ return self.rebase("CONTINUE");
+ },
+ visibleWhen: function(item) {
+ return self.rebaseState;
+ }
+ });
+
+ var rebaseSkipCommand = new mCommands.Command({
+ name: "Skip patch",
+ tooltip: "Skip patch",
+ id: "orion.gitRebaseSkip",
+ callback: function(item) {
+ self._statusService.setProgressMessage("Skipping patch...");
+ return self.rebase("SKIP");
+ },
+ visibleWhen: function(item) {
+ return self.rebaseState;
+ }
+ });
+
+ var rebaseAbortCommand = new mCommands.Command({
+ name: "Abort",
+ tooltip: "Abort rebase",
+ id: "orion.gitRebaseAbort",
+ callback: function(item) {
+ self._statusService.setProgressMessage("Aborting rebase...");
+ return self.rebase("ABORT");
+ },
+ visibleWhen: function(item) {
+ return self.rebaseState;
+ }
});
this._registry.getService("orion.page.command").then(function(commandService) {
@@ -818,14 +928,21 @@ orion.GitStatusController = (function() {
commandService.addCommand(stageAllCommand, "object");
commandService.addCommand(unstageAllCommand, "object");
commandService.addCommand(unstageCommand, "object");
- commandService.addCommand(resetChangesCommand, "dom");
+ commandService.addCommand(resetChangesCommand, "dom");
+ commandService.addCommand(rebaseContinueCommand, "dom");
+ commandService.addCommand(rebaseSkipCommand, "dom");
+ commandService.addCommand(rebaseAbortCommand, "dom");
commandService.registerCommandContribution("orion.gitStage", 1);
commandService.registerCommandContribution("orion.gitCheckout", 2);
commandService.registerCommandContribution("orion.gitUnstage", 3);
commandService.registerCommandContribution("orion.sbsCompare", 4);
commandService.registerCommandContribution("orion.gitStageAll", 5);
commandService.registerCommandContribution("orion.gitUnstageAll", 6);
- commandService.registerCommandContribution("orion.gitResetChanges", 7 , "pageActions");
+ commandService.registerCommandContribution("orion.gitResetChanges", 7 , "pageActions");
+ commandService.registerCommandContribution("orion.gitRebaseContinue", 8, "rebaseActions");
+ commandService.registerCommandContribution("orion.gitRebaseSkip", 9, "rebaseActions");
+ commandService.registerCommandContribution("orion.gitRebaseAbort", 10, "rebaseActions");
+
});
},
@@ -1030,7 +1147,13 @@ orion.GitStatusController = (function() {
var display = [];
display.Severity = "Error";
display.HTML = false;
- display.Message = typeof(errorResponse.message) === "string" ? errorResponse.message : ioArgs.xhr.statusText;//dojo.fromJson(ioArgs.xhr.responseText).DetailedMessage;
+
+ try{
+ var resp = JSON.parse(errorResponse.responseText);
+ display.Message = resp.DetailedMessage ? resp.DetailedMessage : resp.Message;
+ }catch(Exception){
+ display.Message = typeof(errorResponse.message) === "string" ? errorResponse.message : ioArgs.xhr.statusText;//dojo.fromJson(ioArgs.xhr.responseText).DetailedMessage;
+ }
this._statusService.setProgressResult(display);
},
@@ -1153,6 +1276,45 @@ orion.GitStatusController = (function() {
amend = amendBtn.checked;
}
this.commitAll(this._curClone.HeadLocation, message , amend ?dojo.toJson({"Message":message,"Amend":"true"}): dojo.toJson({"Message":message}));
+ },
+
+ rebase: function(action){
+ var self = this;
+ self._registry.getService("orion.git.provider").then(
+ function(service) {
+ service.doRebase(self._curClone.HeadLocation, "", action,
+ function(jsonData, secondArg) {
+ if (jsonData.Result == "OK" || jsonData.Result == "ABORTED" || jsonData.Result == "FAST_FORWARD" || jsonData.Result == "UP_TO_DATE") {
+ var display = [];
+ display.Severity = "Ok";
+ display.HTML = false;
+ display.Message = jsonData.Result;
+ self._statusService.setProgressResult(display);
+ self.getGitStatus(self._url);
+ }
+ if (jsonData.Result == "STOPPED") {
+ var display = [];
+ display.Severity = "Warning";
+ display.HTML = false;
+ display.Message = jsonData.Result
+ + ". Repository still contains conflicts.";
+ self._statusService.setProgressResult(display);
+ self.getGitStatus(self._url);
+ }
+ else if (jsonData.Result == "FAILED_UNMERGED_PATHS") {
+ var display = [];
+ display.Severity = "Error";
+ display.HTML = false;
+ display.Message = jsonData.Result
+ + ". Repository contains unmerged paths. Resolve conflicts first.";
+ self._statusService.setProgressResult(display);
+ }
+ },
+ function(response, ioArgs){
+ self.handleServerErrors(response, ioArgs);
+ }
+ );
+ });
}
};
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 673510c..c87b6b9 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,39 @@ eclipse.GitService = (function() {
}
});
},
+ doRebase : function(gitHeadURI, commitName, operation, onLoad, onError) {
+ var service = this;
+ var postData = {};
+ postData.Rebase = commitName;
+ if (operation) postData.Operation = operation;
+
+ return dojo.xhrPost({
+ url : gitHeadURI,
+ headers : {
+ "Orion-Version" : "1"
+ },
+ postData : dojo.toJson(postData),
+ 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};
+ }
+ });
+ },
doPush : function(gitBranchURI, srcRef, force, onLoad, gitSshUsername, gitSshPassword, gitSshKnownHost, gitPrivateKey, gitPassphrase) {
var service = this;
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 6cdd145..9086369 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
@@ -627,6 +627,79 @@ var exports = {};
commandService.addCommand(mergeCommand, "dom");
commandService.addCommand(mergeCommand, "object");
+ var rebaseCommand = new mCommands.Command({
+ name : "Rebase",
+ id : "eclipse.orion.git.rebase",
+ callback: function(item) {
+ serviceRegistry.getService("orion.git.provider").then(function(gitService){
+ gitService.doRebase(item.HeadLocation, item.Name, "BEGIN",
+ function(jsonData, secondArg){
+ serviceRegistry.getService("orion.page.message").then(function(progressService) {
+ var display = [];
+ var statusLocation = item.HeadLocation.replace("commit/HEAD", "status");
+
+ if (jsonData.Result == "OK" || jsonData.Result == "FAST_FORWARD" || jsonData.Result == "UP_TO_DATE" ) {
+ // operation succeeded
+ display.Severity = "Ok";
+ display.HTML = false;
+ display.Message = jsonData.Result;
+ }
+ // handle special cases
+ else if (jsonData.Result == "STOPPED") {
+ display.Severity = "Warning";
+ display.HTML = true;
+ display.Message = "<span>" + jsonData.Result
+ + ". Some conflicts occurred. Please resolve them and continue, skip patch or abort rebasing."
+ + " Go to <a href=\"/git/git-status.html#"
+ + statusLocation +"\">Git Status page</a>.<span>";
+ }
+ else if (jsonData.Result == "FAILED_WRONG_REPOSITORY_STATE") {
+ display.Severity = "Error";
+ display.HTML = true;
+ display.Message = "<span>" + jsonData.Result
+ + ". Repository state is invalid (i.e. already during rebasing)."
+ + " Go to <a href=\"/git/git-status.html#"
+ + statusLocation +"\">Git Status page</a>.<span>";
+ }
+ else if (jsonData.Result == "FAILED_UNMERGED_PATHS") {
+ display.Severity = "Error";
+ display.HTML = true;
+ display.Message = "<span>" + jsonData.Result
+ + ". Repository contains unmerged paths."
+ + " Go to <a href=\"/git/git-status.html#"
+ + statusLocation +"\">Git Status page</a>.<span>";
+ }
+ else if (jsonData.Result == "FAILED_PENDING_CHANGES") {
+ display.Severity = "Error";
+ display.HTML = true;
+ display.Message = "<span>" + jsonData.Result
+ + ". Repository contains pending changes. Please commit or stash them."
+ + " Go to <a href=\"/git/git-status.html#"
+ + statusLocation +"\">Git Status page</a>.<span>";
+ }
+ // handle other cases
+ else {
+ display.Severity = "Warning";
+ display.HTML = true;
+ display.Message = "<span>" + jsonData.Result
+ + ". Go to <a href=\"/git/git-status.html#"
+ + statusLocation +"\">Git Status page</a>.<span>";
+ }
+ progressService.setProgressResult(display);
+ });
+ },
+ displayErrorOnStatus
+ );
+ });
+ },
+ visibleWhen : function(item) {
+ return item.Type === "RemoteTrackingBranch" || (item.Type === "Branch" && !item.Current);
+ }
+ });
+
+ commandService.addCommand(rebaseCommand, "dom");
+ commandService.addCommand(rebaseCommand, "object");
+
var pushCommand = new mCommands.Command({
name : "Push All",
image : "/git/images/push.gif",