Merge branch 'stable-2.8'
* stable-2.8: Fix jdbc code: Both PreparedStatements must be closed in any case SideBySide2: Let CodeMirror handle "contextmenu" event SideBySide2: Restore some old keybindings and fix help popup Add --project and --branch parameters on the topic-changed hook
This commit is contained in:
@@ -126,7 +126,7 @@ topic-changed
|
|||||||
Called whenever a change's topic is changed from the Web UI or via the REST API.
|
Called whenever a change's topic is changed from the Web UI or via the REST API.
|
||||||
|
|
||||||
====
|
====
|
||||||
topic-changed --change <change id> --changer <changer> --old-topic <old topic> --new-topic <new topic>
|
topic-changed --change <change id> --project <project name> --branch <branch> --changer <changer> --old-topic <old topic> --new-topic <new topic>
|
||||||
====
|
====
|
||||||
|
|
||||||
cla-signed
|
cla-signed
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public abstract class KeyCommand implements KeyPressHandler {
|
|||||||
public static final int M_CTRL = 1 << 16;
|
public static final int M_CTRL = 1 << 16;
|
||||||
public static final int M_ALT = 2 << 16;
|
public static final int M_ALT = 2 << 16;
|
||||||
public static final int M_META = 4 << 16;
|
public static final int M_META = 4 << 16;
|
||||||
|
public static final int M_SHIFT = 8 << 16;
|
||||||
|
|
||||||
public static boolean same(final KeyCommand a, final KeyCommand b) {
|
public static boolean same(final KeyCommand a, final KeyCommand b) {
|
||||||
return a.getClass() == b.getClass() && a.helpText.equals(b.helpText);
|
return a.getClass() == b.getClass() && a.helpText.equals(b.helpText);
|
||||||
@@ -58,6 +59,9 @@ public abstract class KeyCommand implements KeyPressHandler {
|
|||||||
if ((keyMask & M_META) == M_META) {
|
if ((keyMask & M_META) == M_META) {
|
||||||
modifier(b, KeyConstants.I.keyMeta());
|
modifier(b, KeyConstants.I.keyMeta());
|
||||||
}
|
}
|
||||||
|
if ((keyMask & M_SHIFT) == M_SHIFT) {
|
||||||
|
modifier(b, KeyConstants.I.keyShift());
|
||||||
|
}
|
||||||
|
|
||||||
final char c = (char) (keyMask & 0xffff);
|
final char c = (char) (keyMask & 0xffff);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public interface KeyConstants extends Constants {
|
|||||||
String keyCtrl();
|
String keyCtrl();
|
||||||
String keyAlt();
|
String keyAlt();
|
||||||
String keyMeta();
|
String keyMeta();
|
||||||
|
String keyShift();
|
||||||
String keyEnter();
|
String keyEnter();
|
||||||
String keyEsc();
|
String keyEsc();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,6 @@ thenOtherKey = then
|
|||||||
keyCtrl = Ctrl
|
keyCtrl = Ctrl
|
||||||
keyAlt = Alt
|
keyAlt = Alt
|
||||||
keyMeta = Meta
|
keyMeta = Meta
|
||||||
|
keyShift = Shift
|
||||||
keyEnter = Enter
|
keyEnter = Enter
|
||||||
keyEsc = Esc
|
keyEsc = Esc
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ import com.google.gwtexpui.globalkey.client.KeyCommandSet;
|
|||||||
import com.google.gwtexpui.globalkey.client.ShowHelpCommand;
|
import com.google.gwtexpui.globalkey.client.ShowHelpCommand;
|
||||||
|
|
||||||
import net.codemirror.lib.CodeMirror;
|
import net.codemirror.lib.CodeMirror;
|
||||||
import net.codemirror.lib.CodeMirror.EventHandler;
|
|
||||||
import net.codemirror.lib.CodeMirror.GutterClickHandler;
|
import net.codemirror.lib.CodeMirror.GutterClickHandler;
|
||||||
import net.codemirror.lib.CodeMirror.LineClassWhere;
|
import net.codemirror.lib.CodeMirror.LineClassWhere;
|
||||||
import net.codemirror.lib.CodeMirror.LineHandle;
|
import net.codemirror.lib.CodeMirror.LineHandle;
|
||||||
@@ -111,7 +110,6 @@ public class SideBySide2 extends Screen {
|
|||||||
|
|
||||||
private CodeMirror cmA;
|
private CodeMirror cmA;
|
||||||
private CodeMirror cmB;
|
private CodeMirror cmB;
|
||||||
private CodeMirror lastFocused;
|
|
||||||
private ScrollSynchronizer scrollingGlue;
|
private ScrollSynchronizer scrollingGlue;
|
||||||
private HandlerRegistration resizeHandler;
|
private HandlerRegistration resizeHandler;
|
||||||
private JsArray<CommentInfo> publishedBase;
|
private JsArray<CommentInfo> publishedBase;
|
||||||
@@ -279,17 +277,9 @@ public class SideBySide2 extends Screen {
|
|||||||
cm.on("focus", new Runnable() {
|
cm.on("focus", new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
lastFocused = cm;
|
|
||||||
updateActiveLine(cm).run();
|
updateActiveLine(cm).run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cm.on("contextmenu", new EventHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(CodeMirror instance, NativeEvent event) {
|
|
||||||
CodeMirror.setObjectProperty(event, "codemirrorIgnore", true);
|
|
||||||
lastFocused.focus();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cm.addKeyMap(KeyMap.create()
|
cm.addKeyMap(KeyMap.create()
|
||||||
.on("'a'", upToChange(true))
|
.on("'a'", upToChange(true))
|
||||||
.on("'u'", upToChange(false))
|
.on("'u'", upToChange(false))
|
||||||
@@ -316,12 +306,30 @@ public class SideBySide2 extends Screen {
|
|||||||
(header.hasNext() ? header.next : header.up).go();
|
(header.hasNext() ? header.next : header.up).go();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on("Shift-Alt-/", new Runnable() {
|
.on("Shift-/", new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
new ShowHelpCommand().onKeyPress(null);
|
new ShowHelpCommand().onKeyPress(null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.on("Ctrl-F", new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
CodeMirror.handleVimKey(cm, "/");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on("Space", new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
CodeMirror.handleVimKey(cm, "<PageDown>");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on("Ctrl-A", new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
cm.execCommand("selectAll");
|
||||||
|
}
|
||||||
|
})
|
||||||
.on("N", maybeNextVimSearch(cm))
|
.on("N", maybeNextVimSearch(cm))
|
||||||
.on("P", diffChunkNav(cm, true))
|
.on("P", diffChunkNav(cm, true))
|
||||||
.on("Shift-O", openClosePublished(cm))
|
.on("Shift-O", openClosePublished(cm))
|
||||||
@@ -336,9 +344,13 @@ public class SideBySide2 extends Screen {
|
|||||||
keysNavigation.add(new UpToChangeCommand2(revision, 0, 'u'));
|
keysNavigation.add(new UpToChangeCommand2(revision, 0, 'u'));
|
||||||
keysNavigation.add(new NoOpKeyCommand(0, 'j', PatchUtil.C.lineNext()));
|
keysNavigation.add(new NoOpKeyCommand(0, 'j', PatchUtil.C.lineNext()));
|
||||||
keysNavigation.add(new NoOpKeyCommand(0, 'k', PatchUtil.C.linePrev()));
|
keysNavigation.add(new NoOpKeyCommand(0, 'k', PatchUtil.C.linePrev()));
|
||||||
|
keysNavigation.add(new NoOpKeyCommand(0, 'n', PatchUtil.C.chunkNext2()));
|
||||||
|
keysNavigation.add(new NoOpKeyCommand(0, 'p', PatchUtil.C.chunkPrev2()));
|
||||||
|
|
||||||
keysAction = new KeyCommandSet(Gerrit.C.sectionActions());
|
keysAction = new KeyCommandSet(Gerrit.C.sectionActions());
|
||||||
keysAction.add(new NoOpKeyCommand(0, 'o', PatchUtil.C.expandComment()));
|
keysAction.add(new NoOpKeyCommand(0, 'o', PatchUtil.C.expandComment()));
|
||||||
|
keysAction.add(new NoOpKeyCommand(
|
||||||
|
KeyCommand.M_SHIFT, 'o', PatchUtil.C.expandAllCommentsOnCurrentLine()));
|
||||||
keysAction.add(new KeyCommand(0, 'r', PatchUtil.C.toggleReviewed()) {
|
keysAction.add(new KeyCommand(0, 'r', PatchUtil.C.toggleReviewed()) {
|
||||||
@Override
|
@Override
|
||||||
public void onKeyPress(KeyPressEvent event) {
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
|
|||||||
@@ -45,10 +45,13 @@ public interface PatchConstants extends Constants {
|
|||||||
String lineNext();
|
String lineNext();
|
||||||
String chunkPrev();
|
String chunkPrev();
|
||||||
String chunkNext();
|
String chunkNext();
|
||||||
|
String chunkPrev2();
|
||||||
|
String chunkNext2();
|
||||||
String commentPrev();
|
String commentPrev();
|
||||||
String commentNext();
|
String commentNext();
|
||||||
String fileList();
|
String fileList();
|
||||||
String expandComment();
|
String expandComment();
|
||||||
|
String expandAllCommentsOnCurrentLine();
|
||||||
|
|
||||||
String toggleReviewed();
|
String toggleReviewed();
|
||||||
String markAsReviewedAndGoToNext();
|
String markAsReviewedAndGoToNext();
|
||||||
|
|||||||
@@ -27,10 +27,13 @@ linePrev = Previous line
|
|||||||
lineNext = Next line
|
lineNext = Next line
|
||||||
chunkPrev = Previous diff chunk or comment
|
chunkPrev = Previous diff chunk or comment
|
||||||
chunkNext = Next diff chunk or comment
|
chunkNext = Next diff chunk or comment
|
||||||
|
chunkPrev2 = Previous diff chunk
|
||||||
|
chunkNext2 = Next diff chunk or search result
|
||||||
commentPrev = Previous comment
|
commentPrev = Previous comment
|
||||||
commentNext = Next comment
|
commentNext = Next comment
|
||||||
fileList = Browse files in patch set
|
fileList = Browse files in patch set
|
||||||
expandComment = Expand or collapse comment
|
expandComment = Expand or collapse comment
|
||||||
|
expandAllCommentsOnCurrentLine = Expand or collapse all comments on current line
|
||||||
|
|
||||||
toggleReviewed = Toggle the reviewed flag
|
toggleReviewed = Toggle the reviewed flag
|
||||||
markAsReviewedAndGoToNext = Mark patch as reviewed and go to next unreviewed patch
|
markAsReviewedAndGoToNext = Mark patch as reviewed and go to next unreviewed patch
|
||||||
|
|||||||
@@ -277,11 +277,6 @@ public class CodeMirror extends JavaScriptObject {
|
|||||||
return this.display.scrollbarV;
|
return this.display.scrollbarV;
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
public static final native void setObjectProperty(JavaScriptObject obj,
|
|
||||||
String name, boolean value) /*-{
|
|
||||||
obj[name] = value;
|
|
||||||
}-*/;
|
|
||||||
|
|
||||||
public static final native KeyMap cloneKeyMap(String name) /*-{
|
public static final native KeyMap cloneKeyMap(String name) /*-{
|
||||||
var i = $wnd.CodeMirror.keyMap[name];
|
var i = $wnd.CodeMirror.keyMap[name];
|
||||||
var o = {};
|
var o = {};
|
||||||
@@ -291,6 +286,10 @@ public class CodeMirror extends JavaScriptObject {
|
|||||||
return o;
|
return o;
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
|
public final native void execCommand(String cmd) /*-{
|
||||||
|
this.execCommand(cmd);
|
||||||
|
}-*/;
|
||||||
|
|
||||||
public static final native void addKeyMap(String name, KeyMap km) /*-{
|
public static final native void addKeyMap(String name, KeyMap km) /*-{
|
||||||
$wnd.CodeMirror.keyMap[name] = km;
|
$wnd.CodeMirror.keyMap[name] = km;
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ class Loader {
|
|||||||
private static void initVimKeys() {
|
private static void initVimKeys() {
|
||||||
// TODO: Better custom keybindings, remove temporary navigation hacks.
|
// TODO: Better custom keybindings, remove temporary navigation hacks.
|
||||||
KeyMap km = CodeMirror.cloneKeyMap("vim");
|
KeyMap km = CodeMirror.cloneKeyMap("vim");
|
||||||
for (String s : new String[] {"A", "C", "O", "R", "U", "Ctrl-C"}) {
|
for (String s : new String[] {
|
||||||
|
"A", "C", "O", "R", "U", "Ctrl-C", "Ctrl-O"}) {
|
||||||
km.remove(s);
|
km.remove(s);
|
||||||
}
|
}
|
||||||
CodeMirror.addKeyMap("vim_ro", km);
|
CodeMirror.addKeyMap("vim_ro", km);
|
||||||
|
|||||||
@@ -582,6 +582,8 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
|||||||
|
|
||||||
final List<String> args = new ArrayList<String>();
|
final List<String> args = new ArrayList<String>();
|
||||||
addArg(args, "--change", event.change.id);
|
addArg(args, "--change", event.change.id);
|
||||||
|
addArg(args, "--project", event.change.project);
|
||||||
|
addArg(args, "--branch", event.change.branch);
|
||||||
addArg(args, "--changer", getDisplayName(account));
|
addArg(args, "--changer", getDisplayName(account));
|
||||||
addArg(args, "--old-topic", oldTopic);
|
addArg(args, "--old-topic", oldTopic);
|
||||||
addArg(args, "--new-topic", event.change.topic);
|
addArg(args, "--new-topic", event.change.topic);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class Schema_74 extends SchemaVersion {
|
|||||||
// Grab all the groups since we don't have the cache available
|
// Grab all the groups since we don't have the cache available
|
||||||
HashMap<AccountGroup.Id, AccountGroup.UUID> allGroups =
|
HashMap<AccountGroup.Id, AccountGroup.UUID> allGroups =
|
||||||
new HashMap<AccountGroup.Id, AccountGroup.UUID>();
|
new HashMap<AccountGroup.Id, AccountGroup.UUID>();
|
||||||
for( AccountGroup ag : db.accountGroups().all() ) {
|
for (AccountGroup ag : db.accountGroups().all()) {
|
||||||
allGroups.put(ag.getId(), ag.getGroupUUID());
|
allGroups.put(ag.getId(), ag.getGroupUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,54 +58,58 @@ public class Schema_74 extends SchemaVersion {
|
|||||||
|
|
||||||
// Iterate over all entries in account_group_includes
|
// Iterate over all entries in account_group_includes
|
||||||
Statement oldGroupIncludesStmt = conn.createStatement();
|
Statement oldGroupIncludesStmt = conn.createStatement();
|
||||||
ResultSet oldGroupIncludes = oldGroupIncludesStmt.
|
try {
|
||||||
executeQuery("SELECT * FROM account_group_includes");
|
ResultSet oldGroupIncludes = oldGroupIncludesStmt.
|
||||||
while (oldGroupIncludes.next()) {
|
executeQuery("SELECT * FROM account_group_includes");
|
||||||
AccountGroup.Id oldGroupId =
|
while (oldGroupIncludes.next()) {
|
||||||
new AccountGroup.Id(oldGroupIncludes.getInt("group_id"));
|
AccountGroup.Id oldGroupId =
|
||||||
AccountGroup.Id oldIncludeId =
|
new AccountGroup.Id(oldGroupIncludes.getInt("group_id"));
|
||||||
new AccountGroup.Id(oldGroupIncludes.getInt("include_id"));
|
AccountGroup.Id oldIncludeId =
|
||||||
AccountGroup.UUID uuidFromIncludeId = allGroups.get(oldIncludeId);
|
new AccountGroup.Id(oldGroupIncludes.getInt("include_id"));
|
||||||
|
AccountGroup.UUID uuidFromIncludeId = allGroups.get(oldIncludeId);
|
||||||
|
|
||||||
// If we've got an include, but the group no longer exists, don't bother converting
|
// If we've got an include, but the group no longer exists, don't bother converting
|
||||||
if (uuidFromIncludeId == null) {
|
if (uuidFromIncludeId == null) {
|
||||||
ui.message("Skipping group_id = \"" + oldIncludeId.get() +
|
ui.message("Skipping group_id = \"" + oldIncludeId.get() +
|
||||||
"\", not a current group");
|
"\", not a current group");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the new include entry
|
// Create the new include entry
|
||||||
AccountGroupById destIncludeEntry = new AccountGroupById(
|
AccountGroupById destIncludeEntry = new AccountGroupById(
|
||||||
new AccountGroupById.Key(oldGroupId, uuidFromIncludeId));
|
new AccountGroupById.Key(oldGroupId, uuidFromIncludeId));
|
||||||
|
|
||||||
// Iterate over all the audits (for this group)
|
// Iterate over all the audits (for this group)
|
||||||
PreparedStatement oldAuditsQuery = conn.prepareStatement(
|
PreparedStatement oldAuditsQueryStmt = conn.prepareStatement(
|
||||||
"SELECT * FROM account_group_includes_audit WHERE group_id=? AND include_id=?");
|
"SELECT * FROM account_group_includes_audit WHERE group_id=? AND include_id=?");
|
||||||
oldAuditsQuery.setInt(1, oldGroupId.get());
|
try {
|
||||||
oldAuditsQuery.setInt(2, oldIncludeId.get());
|
oldAuditsQueryStmt.setInt(1, oldGroupId.get());
|
||||||
ResultSet oldGroupIncludeAudits = oldAuditsQuery.executeQuery();
|
oldAuditsQueryStmt.setInt(2, oldIncludeId.get());
|
||||||
while (oldGroupIncludeAudits.next()) {
|
ResultSet oldGroupIncludeAudits = oldAuditsQueryStmt.executeQuery();
|
||||||
Account.Id addedBy = new Account.Id(oldGroupIncludeAudits.getInt("added_by"));
|
while (oldGroupIncludeAudits.next()) {
|
||||||
int removedBy = oldGroupIncludeAudits.getInt("removed_by");
|
Account.Id addedBy = new Account.Id(oldGroupIncludeAudits.getInt("added_by"));
|
||||||
|
int removedBy = oldGroupIncludeAudits.getInt("removed_by");
|
||||||
// Create the new audit entry
|
|
||||||
AccountGroupByIdAud destAuditEntry =
|
// Create the new audit entry
|
||||||
new AccountGroupByIdAud(destIncludeEntry, addedBy,
|
AccountGroupByIdAud destAuditEntry =
|
||||||
oldGroupIncludeAudits.getTimestamp("added_on"));
|
new AccountGroupByIdAud(destIncludeEntry, addedBy,
|
||||||
|
oldGroupIncludeAudits.getTimestamp("added_on"));
|
||||||
// If this was a "removed on" entry, note that
|
|
||||||
if (removedBy > 0) {
|
// If this was a "removed on" entry, note that
|
||||||
destAuditEntry.removed(new Account.Id(removedBy),
|
if (removedBy > 0) {
|
||||||
oldGroupIncludeAudits.getTimestamp("removed_on"));
|
destAuditEntry.removed(new Account.Id(removedBy),
|
||||||
|
oldGroupIncludeAudits.getTimestamp("removed_on"));
|
||||||
|
}
|
||||||
|
newIncludeAudits.add(destAuditEntry);
|
||||||
|
}
|
||||||
|
newIncludes.add(destIncludeEntry);
|
||||||
|
} finally {
|
||||||
|
oldAuditsQueryStmt.close();
|
||||||
}
|
}
|
||||||
newIncludeAudits.add(destAuditEntry);
|
|
||||||
}
|
}
|
||||||
newIncludes.add(destIncludeEntry);
|
} finally {
|
||||||
oldAuditsQuery.close();
|
oldGroupIncludesStmt.close();
|
||||||
oldGroupIncludeAudits.close();
|
|
||||||
}
|
}
|
||||||
oldGroupIncludes.close();
|
|
||||||
oldGroupIncludesStmt.close();
|
|
||||||
|
|
||||||
// Now insert all of the new entries to the database
|
// Now insert all of the new entries to the database
|
||||||
db.accountGroupById().insert(newIncludes);
|
db.accountGroupById().insert(newIncludes);
|
||||||
|
|||||||
Reference in New Issue
Block a user