From e4ee4299cdac04df6d2caf4ba243f8b04ef97e2b Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Fri, 5 Jun 2015 10:31:11 +0000 Subject: [PATCH 1/9] Fixed issue with clients in fallback saving reverting code --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 65bce44d..a3745426 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "c9.ide.run": "#cc9d80f8bb", "c9.ide.run.build": "#ad45874c88", "c9.ide.run.debug.xdebug": "#3b1520f83d", - "c9.ide.save": "#a03709ef3f", + "c9.ide.save": "#abaa26f320", "c9.ide.terminal.monitor": "#b0b4d03280", "c9.ide.theme.flat": "#b1d65fa9bb", "c9.ide.threewaymerge": "#229382aa0b", From 427d344fac2636139f5623bced9aa16bf069905e Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Fri, 5 Jun 2015 13:19:13 +0000 Subject: [PATCH 2/9] Before save is called check tab conflicts are resolved --- package.json | 2 +- plugins/c9.ide.watcher/gui.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index a3745426..241b12b2 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "c9.ide.run": "#cc9d80f8bb", "c9.ide.run.build": "#ad45874c88", "c9.ide.run.debug.xdebug": "#3b1520f83d", - "c9.ide.save": "#abaa26f320", + "c9.ide.save": "#75fc15aafb", "c9.ide.terminal.monitor": "#b0b4d03280", "c9.ide.theme.flat": "#b1d65fa9bb", "c9.ide.threewaymerge": "#229382aa0b", diff --git a/plugins/c9.ide.watcher/gui.js b/plugins/c9.ide.watcher/gui.js index 6bf4147a..9828e971 100644 --- a/plugins/c9.ide.watcher/gui.js +++ b/plugins/c9.ide.watcher/gui.js @@ -102,6 +102,9 @@ define(function(require, exports, module) { save.on("beforeSave", function(e) { e.document.meta.$savingValue = e.save; + if (e.tab.classList.contains("conflict")) { + showChangeDialog(e.tab); + } }, plugin); save.on("afterSave", function(e) { @@ -367,9 +370,7 @@ define(function(require, exports, module) { else { changedPaths[path].tab.document.undoManager.bookmark(-2); changedPaths[path].resolve(); - showChangeDialog(); } - checkEmptyQueue(); } @@ -382,7 +383,6 @@ define(function(require, exports, module) { else { getLatestValue(path, function(err, path, data) { updateChangedPath(err, path, data); - showChangeDialog(); }); } @@ -408,7 +408,6 @@ define(function(require, exports, module) { getLatestValue(path, function(err, path, data) { mergeChangedPath(err, path, data); - showChangeDialog(); }); } From c18b75f30332c294aeb598808608c2e1afdc50bb Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Fri, 5 Jun 2015 13:27:39 +0000 Subject: [PATCH 3/9] Don't need beforeSaveAll any more --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 241b12b2..f2b73564 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "c9.ide.run": "#cc9d80f8bb", "c9.ide.run.build": "#ad45874c88", "c9.ide.run.debug.xdebug": "#3b1520f83d", - "c9.ide.save": "#75fc15aafb", + "c9.ide.save": "#58b8616a88", "c9.ide.terminal.monitor": "#b0b4d03280", "c9.ide.theme.flat": "#b1d65fa9bb", "c9.ide.threewaymerge": "#229382aa0b", From 90baf8a7270267b14afae981f0173f5a8faa551a Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Mon, 8 Jun 2015 14:36:31 +0000 Subject: [PATCH 4/9] Change current call of showChangeDialog to show it for all changed paths as it no longer calls itself recursively --- plugins/c9.ide.watcher/gui.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/c9.ide.watcher/gui.js b/plugins/c9.ide.watcher/gui.js index 9828e971..5d5a0a3c 100644 --- a/plugins/c9.ide.watcher/gui.js +++ b/plugins/c9.ide.watcher/gui.js @@ -232,8 +232,12 @@ define(function(require, exports, module) { if (!tabManager.findTab(path)) // drat! tab is gone return; - // Show dialog - showChangeDialog(); + // Show dialogs for changed tabs + for (path in changedPaths) { + tab = changedPaths[path].tab; + data = changedPaths[path].data; + showChangeDialog(tab, data); + } } function checkByStatOrContents() { From ab84c52a13761450e22a3af3b96a525541f1acaf Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Mon, 8 Jun 2015 14:58:45 +0000 Subject: [PATCH 5/9] Passing path to resolve function to fix race condition with global path variable --- plugins/c9.ide.watcher/gui.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/c9.ide.watcher/gui.js b/plugins/c9.ide.watcher/gui.js index 5d5a0a3c..69138545 100644 --- a/plugins/c9.ide.watcher/gui.js +++ b/plugins/c9.ide.watcher/gui.js @@ -186,7 +186,7 @@ define(function(require, exports, module) { return; } - function resolve() { + function resolve(path) { console.log("[watchers] resolved change event without dialog", path); doc.tab.classList.remove("conflict"); delete doc.meta.$merge; @@ -340,12 +340,12 @@ define(function(require, exports, module) { var doc = tab.document; doc.setBookmarkedValue(data, true); doc.meta.timestamp = Date.now() - settings.timeOffset; - changedPaths[path].resolve(); + changedPaths[path].resolve(path); } function mergeChangedPath(err, path, data) { merge(changedPaths[path].tab, data); - changedPaths[path].resolve(); + changedPaths[path].resolve(path); } function showChangeDialog(tab, data) { @@ -368,12 +368,12 @@ define(function(require, exports, module) { if (all) { for (var id in changedPaths) { changedPaths[id].tab.document.undoManager.bookmark(-2); - changedPaths[id].resolve(); + changedPaths[id].resolve(path); } } else { changedPaths[path].tab.document.undoManager.bookmark(-2); - changedPaths[path].resolve(); + changedPaths[path].resolve(path); } checkEmptyQueue(); } From 194f578b9dd623ed67cb46bdf9818541fd4d8c32 Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Tue, 9 Jun 2015 09:27:01 +0000 Subject: [PATCH 6/9] Minor bug fix --- plugins/c9.ide.watcher/gui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/c9.ide.watcher/gui.js b/plugins/c9.ide.watcher/gui.js index 69138545..abe09de6 100644 --- a/plugins/c9.ide.watcher/gui.js +++ b/plugins/c9.ide.watcher/gui.js @@ -368,7 +368,7 @@ define(function(require, exports, module) { if (all) { for (var id in changedPaths) { changedPaths[id].tab.document.undoManager.bookmark(-2); - changedPaths[id].resolve(path); + changedPaths[id].resolve(id); } } else { From 809393434b974010daa5d46f03238bd83cd06f34 Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Wed, 10 Jun 2015 14:24:08 +0000 Subject: [PATCH 7/9] Resolve has knowledge of it's own path already :) --- plugins/c9.ide.watcher/gui.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/c9.ide.watcher/gui.js b/plugins/c9.ide.watcher/gui.js index abe09de6..bf5717fe 100644 --- a/plugins/c9.ide.watcher/gui.js +++ b/plugins/c9.ide.watcher/gui.js @@ -186,11 +186,11 @@ define(function(require, exports, module) { return; } - function resolve(path) { + function resolve() { console.log("[watchers] resolved change event without dialog", path); doc.tab.classList.remove("conflict"); delete doc.meta.$merge; - delete changedPaths[path]; + delete changedPaths[this.tab.path]; } var doc = tab.document; @@ -340,12 +340,12 @@ define(function(require, exports, module) { var doc = tab.document; doc.setBookmarkedValue(data, true); doc.meta.timestamp = Date.now() - settings.timeOffset; - changedPaths[path].resolve(path); + changedPaths[path].resolve(); } function mergeChangedPath(err, path, data) { merge(changedPaths[path].tab, data); - changedPaths[path].resolve(path); + changedPaths[path].resolve(); } function showChangeDialog(tab, data) { @@ -368,12 +368,12 @@ define(function(require, exports, module) { if (all) { for (var id in changedPaths) { changedPaths[id].tab.document.undoManager.bookmark(-2); - changedPaths[id].resolve(id); + changedPaths[id].resolve(); } } else { changedPaths[path].tab.document.undoManager.bookmark(-2); - changedPaths[path].resolve(path); + changedPaths[path].resolve(); } checkEmptyQueue(); } From f62b3eb5f27a310135d6e8cc8f11b6403f677c02 Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Wed, 10 Jun 2015 14:25:13 +0000 Subject: [PATCH 8/9] Fix console log --- plugins/c9.ide.watcher/gui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/c9.ide.watcher/gui.js b/plugins/c9.ide.watcher/gui.js index bf5717fe..24c06175 100644 --- a/plugins/c9.ide.watcher/gui.js +++ b/plugins/c9.ide.watcher/gui.js @@ -187,7 +187,7 @@ define(function(require, exports, module) { } function resolve() { - console.log("[watchers] resolved change event without dialog", path); + console.log("[watchers] resolved change event without dialog", this.tab.path); doc.tab.classList.remove("conflict"); delete doc.meta.$merge; delete changedPaths[this.tab.path]; From 22f46d3c3d0a3936df9ae0f683503eccf9b6328a Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Wed, 10 Jun 2015 14:33:30 +0000 Subject: [PATCH 9/9] Fixed race condition --- plugins/c9.ide.watcher/gui.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/c9.ide.watcher/gui.js b/plugins/c9.ide.watcher/gui.js index 24c06175..b50cabfc 100644 --- a/plugins/c9.ide.watcher/gui.js +++ b/plugins/c9.ide.watcher/gui.js @@ -187,10 +187,10 @@ define(function(require, exports, module) { } function resolve() { - console.log("[watchers] resolved change event without dialog", this.tab.path); + console.log("[watchers] resolved change event without dialog", path); doc.tab.classList.remove("conflict"); delete doc.meta.$merge; - delete changedPaths[this.tab.path]; + delete changedPaths[path]; } var doc = tab.document; @@ -233,9 +233,9 @@ define(function(require, exports, module) { return; // Show dialogs for changed tabs - for (path in changedPaths) { - tab = changedPaths[path].tab; - data = changedPaths[path].data; + for (var changedPath in changedPaths) { + tab = changedPaths[changedPath].tab; + data = changedPaths[changedPath].data; showChangeDialog(tab, data); } }