Merge changes from topic 'resource-servlet'

* changes:
  Serve GWT UI from ResourceServlet
  ResourceServlet: Stream large files, bypassing the cache
  ResourceServlet: Respect existing cache headers
  Rename StaticServlet to SiteStaticDirectoryServlet
  Refactor static content serving
diff --git a/.buckconfig b/.buckconfig
index 7b75225..51318f3 100644
--- a/.buckconfig
+++ b/.buckconfig
@@ -1,5 +1,4 @@
 [alias]
-  all = //:all
   api = //:api
   api_deploy = //tools/maven:api_deploy
   api_install = //tools/maven:api_install
diff --git a/.buckversion b/.buckversion
index ab18d5d..9daac2c 100644
--- a/.buckversion
+++ b/.buckversion
@@ -1 +1 @@
-7e153d4a69044d059288d353fc1a442e07cbea58
+1b03b4313b91b634bd604fc3487a05f877e59dee
diff --git a/BUCK b/BUCK
index 82f1d72..c986874 100644
--- a/BUCK
+++ b/BUCK
@@ -23,19 +23,7 @@
   '//gerrit-plugin-gwtui:gwtui-api-javadoc',
 ]
 
-genrule(
+zip_file(
   name = 'api',
-  cmd = 'echo done >$OUT',
-  deps = API_DEPS,
-  out = '__fake.api__',
-)
-
-genrule(
-  name = 'all',
-  cmd = 'echo done >$OUT',
-  deps = [
-    ':api',
-    ':release',
-  ],
-  out = '__fake.all__',
+  srcs = API_DEPS,
 )
diff --git a/Documentation/BUCK b/Documentation/BUCK
index dfac617..126bf1f 100644
--- a/Documentation/BUCK
+++ b/Documentation/BUCK
@@ -3,8 +3,8 @@
 include_defs('//tools/git.defs')
 
 DOC_DIR = 'Documentation'
-JSUI = ['//gerrit-gwtui:ui_module']
-MAIN = ['//gerrit-pgm:pgm'] + JSUI
+JSUI = '//gerrit-gwtui:ui_module'
+MAIN = '//gerrit-pgm:pgm'
 SRCS = glob(['*.txt'], excludes = ['licenses.txt'])
 
 genasciidoc(
@@ -30,16 +30,19 @@
 
 genrule(
   name = 'licenses.txt',
-  cmd = '$(exe :gen_licenses) --asciidoc ' + ' '.join(MAIN) + ' >$OUT',
-  deps = MAIN,
+  cmd = '$(exe :gen_licenses) --asciidoc '
+    + '--classpath $(classpath %s) ' % MAIN
+    + '--classpath $(classpath %s) ' % JSUI
+    + MAIN + ' ' + JSUI + ' >$OUT',
   out = 'licenses.txt',
 )
 
 # Required by Google for gerrit-review.
 genrule(
   name = 'js_licenses.txt',
-  cmd = '$(exe :gen_licenses) --partial ' + ' '.join(JSUI) + ' >$OUT',
-  deps = JSUI,
+  cmd = '$(exe :gen_licenses) --partial '
+    + '--classpath $(classpath %s) ' % JSUI
+    + JSUI + ' >$OUT',
   out = 'js_licenses.txt',
 )
 
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index e7b7cdc..db52a1b 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -3031,7 +3031,7 @@
 be specified using standard time unit abbreviations ('ms', 'sec',
 'min', etc.).
 +
-Default is 2 minutes. If no unit is specified, milliseconds
+Default is 4 minutes. If no unit is specified, milliseconds
 is assumed.
 
 [[receive.trustedKey]]receive.trustedKey::
@@ -3427,7 +3427,7 @@
 than the total number of threads allocated in sshd.threads, then the
 value of sshd.threads is increased to accommodate the requested value.
 +
-By default, 0.
+By default is 1 on single core node, 2 otherwise.
 
 [[sshd.streamThreads]]sshd.streamThreads::
 +
diff --git a/Documentation/dev-buck.txt b/Documentation/dev-buck.txt
index 7d30a91..10f3319 100644
--- a/Documentation/dev-buck.txt
+++ b/Documentation/dev-buck.txt
@@ -275,15 +275,6 @@
   buck-out/gen/release/release.war
 ----
 
-[[all]]
-=== Combined build target
-
-To build release and api targets, a combined build target is provided:
-
-----
-  buck build all
-----
-
 [[tests]]
 == Running Unit Tests
 
diff --git a/Documentation/gen_licenses.py b/Documentation/gen_licenses.py
index 8b2d096..db3480b 100755
--- a/Documentation/gen_licenses.py
+++ b/Documentation/gen_licenses.py
@@ -28,6 +28,7 @@
 parser = argparse.ArgumentParser()
 parser.add_argument('--asciidoc', action='store_true')
 parser.add_argument('--partial', action='store_true')
+parser.add_argument('--classpath', action='append')
 parser.add_argument('targets', nargs='+')
 args = parser.parse_args()
 
@@ -41,6 +42,7 @@
   graph = defaultdict(list)
   while not path.isfile('.buckconfig'):
     chdir('..')
+  # TODO(davido): use passed in classpath from Buck instead
   p = Popen(
     ['buck', 'audit', 'classpath', '--dot'] + args.targets,
     stdout = PIPE)
diff --git a/Documentation/rest-api-accounts.txt b/Documentation/rest-api-accounts.txt
index 6920c4c..ad19046 100644
--- a/Documentation/rest-api-accounts.txt
+++ b/Documentation/rest-api-accounts.txt
@@ -1259,6 +1259,7 @@
     "ignore_whitespace": "IGNORE_ALL",
     "intraline_difference": true,
     "line_length": 100,
+    "cursor_blink_rate": 500,
     "show_tabs": true,
     "show_whitespace_errors": true,
     "syntax_highlighting": true,
@@ -1288,6 +1289,7 @@
     "ignore_whitespace": "IGNORE_ALL",
     "intraline_difference": true,
     "line_length": 100,
+    "cursor_blink_rate": 500,
     "show_line_endings": true,
     "show_tabs": true,
     "show_whitespace_errors": true,
@@ -1672,6 +1674,9 @@
 Whether intraline differences should be highlighted.
 |`line_length`                 ||
 Number of characters that should be displayed in one line.
+|`cursor_blink_rate`           ||
+Half-period in milliseconds used for cursor blinking.
+Setting it to 0 disables cursor blinking.
 |`manual_review`               |not set if `false`|
 Whether the 'Reviewed' flag should not be set automatically on a patch
 when it is viewed.
@@ -1704,6 +1709,8 @@
 |'hide_empty_pane'             |not set if `false`|
 Whether empty panes should be hidden. The left pane is empty when a
 file was added; the right pane is empty when a file was deleted.
+|`match_brackets`              |not set if `false`|
+Whether matching brackets should be highlighted.
 |===========================================
 
 [[diff-preferences-input]]
diff --git a/README.md b/README.md
index 573042d..f5b929d 100644
--- a/README.md
+++ b/README.md
@@ -51,7 +51,7 @@
 Install [Buck](http://facebook.github.io/buck/setup/install.html) and run the following:
 
         git clone --recursive https://gerrit.googlesource.com/gerrit
-        cd gerrit && buck build all
+        cd gerrit && buck build release
 
 ## Install binary packages (Deb/Rpm)
 
diff --git a/ReleaseNotes/ReleaseNotes-2.12.txt b/ReleaseNotes/ReleaseNotes-2.12.txt
index 4a266e9..c6efb46 100644
--- a/ReleaseNotes/ReleaseNotes-2.12.txt
+++ b/ReleaseNotes/ReleaseNotes-2.12.txt
@@ -10,6 +10,10 @@
 Important Notes
 ---------------
 
+*WARNING:* This release contains schema changes.  To upgrade:
+----
+  java -jar gerrit.war init -d site_path
+----
 
 *WARNING:* Upgrading to 2.12.x requires the server be first upgraded to 2.8 (or
 2.9) and then to 2.12.x. If you are upgrading from 2.8.x or later, you may ignore
@@ -21,21 +25,262 @@
 startup failure described in
 link:https://code.google.com/p/gerrit/issues/detail?id=3084[Issue 3084].
 
+*WARNING:* The Solr secondary index is no longer supported. With this release
+the only supported secondary index is Lucene.
+
 
 Release Highlights
 ------------------
 
-* TODO
+This release includes the following new features. See the sections below for
+further details.
+
+* New "Submit Whole Topic" / "Submitted Together" workflow.
+
+* Support for GPG Keys and signed pushes.
 
 
 New Features
 ------------
 
+New Change Submission Workflow
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+* New "Submit Whole Topic" setting.
++
+When the
+link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/config-gerrit.html#change.submitWholeTopic[
+`change.submitWholeTopic`] setting is enabled, all changes belonging to the same
+topic will be submitted at the same time.
++
+This setting is disabled by default.
+
+* Submission of changes may include ancestors.
++
+If a change is submitted that has submittable ancestor changes, those changes
+will also be submitted.
+
+* The merge queue is removed.
++
+Changes that cannot be submitted due to missing dependencies will no longer
+enter the "Submitted, Merge Pending" state.
+
+
+GPG Keys and Signed Pushes
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+* TODO: Details
+
+
+Secondary Index
+~~~~~~~~~~~~~~~
+
+* link:http://code.google.com/p/gerrit/issues/detail?id=3333[Issue 3333]:
+Support searching for changes by author and committer.
++
+Changes are indexed by the git author and committer of the latest patch set,
+and can be searched with the `author:` and `committer:` operators.
++
+Changes are matched on either the exact whole email address, or on parts of the
+name or email address.
+
+* Add `from:` search operator to match by owner of change or author of comments.
+
+* Add `commentby:` search operator to search byt author of comments.
+
+* Change the `topic:` search operator to search by the exact topic name.
+
+* Add `intopic:` search operator to search by topics containing the search term.
+
+* link:http://code.google.com/p/gerrit/issues/detail?id=3291[Issue 3291]:
+Add `has:edit` search operator to match changes that have change edits on them.
+
+* Allow configuration of maximum query size.
++
+link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/config-gerrit.html#index.maxTerms[
+`index.maxTerms`] can be set to limit the number of leaf index terms.
+
+* Expose Lucene index writers for plugins.
++
+Plugins can now be written to allow runtime reconfiguration of various Lucene
+performance related parameters.
+
+* Make Lucene index writers auto-commit writers.
++
+Plugins can now temporarily turn on auto-committing in situations where it makes
+sense to enforce all changes to be written to disk ASAP.
+
+
+UI
+~~
+
+General
+^^^^^^^
+
+* Edit and diff preferences can be modified from the user preferences screen.
++
+Previously it was only possible to edit these preferences from the actual
+diff and edit screens.
+
+* Add "Edits" to My dashboard menu.
+
+Project Screen
+^^^^^^^^^^^^^^
+
+* New tab to list the project's tags, similar to the branch list.
+
+
+Inline Editor
+^^^^^^^^^^^^^
+
+* Store and load edit preferences in git.
++
+Edit preferences are stored and loaded to/from the `All-Users` repository.
+
+* Add 'auto close brackets' feature.
+
+* Add 'match brackets' feature.
+
+* Make the cursor blink rate customizable.
+
+* Add support for Emacs and Vim key maps.
+
+
+Change Screen
+^^^^^^^^^^^^^
+
+* Show file size increase/decrease for binary files.
+
+* Show uploader if different from change owner.
+
+* Show push certificate status.
+
+
+Side-By-Side Diff
+^^^^^^^^^^^^^^^^^
+
+* link:http://code.google.com/p/gerrit/issues/detail?id=3293[Issue 3293]:
+Add syntax highlighting for Puppet.
+
+* link:http://code.google.com/p/gerrit/issues/detail?id=3447[Issue 3447]:
+Add syntax highlighting for VHDL.
+
+
+API
+~~~
+
+Several new APIs are added.
+
+Accounts
+^^^^^^^^
+
+* Suggest accounts.
+
+Tags
+^^^^
+
+* List tags.
+
+* Get tag.
+
+
+REST API
+~~~~~~~~
+
+New REST API endpoints and new options on existing endpoints.
+
+Tags
+^^^^
+
+* Support filtering by substring and regex in the list tags endpoint.
+
+* Support pagination with `--start` and `--end` in the list tags endpoint.
+
+
+Other
+~~~~~
+
+* Add support for SSH ZLib Compression.
++
+To enable compression use the
+link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/config-gerrit.html#sshd.enableCompression[
+`sshd.enableCompression` setting].
+
+* link:http://code.google.com/p/gerrit/issues/detail?id=2061[Issue 2061]
+Add Support for `git-upload-archive`.
++
+This allows use the standard `git archive` command to create an archive
+of the content of a repository.
+
+* Add a background job to automatically abandon inactive changes.
++
+The
+link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/config-gerrit.html#changeCleanup[
+changeCleanup] configuration can be set to periodically check for inactive
+changes and automatically abandon them.
+
+* Add support for the
+link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/database-setup.html#createdb_db2[
+DB2 database].
+
+* Add support for the
+link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/database-setup.html#createdb_derby[
+Apache Derby database].
+
+* Download commands plugin: Use commit IDs for download commands when change refs are hidden.
++
+Git has a configuration option to hide refs from the initial advertisement
+(`uploadpack.hideRefs`). This option can be used to hide the change refs from
+the client. As consequence this prevented fetching changes by change ref from
+working.
++
+Setting `download.checkForHiddenChangeRefs` in the `gerrit.config` to true
+allows the download commands plugin to check for hidden change refs.
+
+Bug Fixes
+---------
+
 * TODO
 
 
 Upgrades
 --------
 
+* Upgrade Asciidoctor to 1.5.2
+
+* Upgrade AutoValue to 1.1
+
+* Upgrade Bouncy Castle to 1.52
+
+* Upgrade CodeMirror to 5.7
+
 * Upgrade gson to 2.3.1
 
+* Upgrade guava to 19.0-RC2
+
+* Upgrade gwtorm to 1.14-20-gec13fdc
+
+* Upgrade H2 to 1.3.176
+
+* Upgrade httpcomponents to 4.4.1
+
+* Upgrade jetty to 9.2.12.v20150709
+
+* Upgrade JGit to 4.0.1.201506240215-r.94-g39dc898
+
+* Upgrade joda-time to 2.8
+
+* Upgrade JRuby to 1.7.18
+
+* Upgrade jsch to 0.1.53
+
+* Upgrade JUnit to 4.11
+
+* Upgrade Lucene to 5.3.0
+
+* Upgrade Prolog Cafe 1.4.1
+
+* Upgrade servlet API to 8.0.24
+
+* Upgrade Truth to version 0.27
+
diff --git a/contrib/convertkey/BUCK b/contrib/convertkey/BUCK
new file mode 100644
index 0000000..752f82a
--- /dev/null
+++ b/contrib/convertkey/BUCK
@@ -0,0 +1,20 @@
+include_defs('//lib/maven.defs')
+
+java_library(
+  name = 'convertkey__lib',
+  srcs = glob(['src/main/java/**/*.java']),
+  deps = [
+    '//lib:jsch',
+    '//lib/bouncycastle:bcprov',
+    '//lib/bouncycastle:bcpkix',
+    '//lib/log:nop',
+    '//lib/mina:sshd',
+  ],
+)
+
+java_binary(
+  name = 'convertkey',
+  deps = [':convertkey__lib'],
+  main_class = 'com.googlesource.gerrit.convertkey.ConvertKey',
+)
+
diff --git a/contrib/convertkey/src/main/java/com/googlesource/gerrit/convertkey/ConvertKey.java b/contrib/convertkey/src/main/java/com/googlesource/gerrit/convertkey/ConvertKey.java
new file mode 100644
index 0000000..5c6ef58
--- /dev/null
+++ b/contrib/convertkey/src/main/java/com/googlesource/gerrit/convertkey/ConvertKey.java
@@ -0,0 +1,73 @@
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.convertkey;
+
+import com.jcraft.jsch.HostKey;
+import com.jcraft.jsch.JSchException;
+
+import org.apache.sshd.common.util.Buffer;
+import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
+
+import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.security.KeyPair;
+import java.security.GeneralSecurityException;
+
+public class ConvertKey {
+  public static void main(String[] args)
+      throws GeneralSecurityException, JSchException, IOException {
+    SimpleGeneratorHostKeyProvider p;
+
+    if (args.length != 1) {
+      System.err.println("Error: requires path to the SSH host key");
+      return;
+    } else {
+      File file = new File(args[0]);
+      if (!file.exists() || !file.isFile() || !file.canRead()) {
+        System.err.println("Error: ssh key should exist and be readable");
+        return;
+      }
+    }
+
+    p = new SimpleGeneratorHostKeyProvider();
+    // Gerrit's SSH "simple" keys are always RSA.
+    p.setPath(args[0]);
+    p.setAlgorithm("RSA");
+    Iterable<KeyPair> keys = p.loadKeys(); // forces the key to generate.
+    for (KeyPair k : keys) {
+      System.out.println("Public Key (" + k.getPublic().getAlgorithm() + "):");
+      // From Gerrit's SshDaemon class; use JSch to get the public
+      // key/type
+      final Buffer buf = new Buffer();
+      buf.putRawPublicKey(k.getPublic());
+      final byte[] keyBin = buf.getCompactData();
+      HostKey pub = new HostKey("localhost", keyBin);
+      System.out.println(pub.getType() + " " + pub.getKey());
+      System.out.println("Private Key:");
+      // Use Bouncy Castle to write the private key back in PEM format
+      // (PKCS#1)
+      // http://stackoverflow.com/questions/25129822/export-rsa-public-key-to-pem-string-using-java
+      StringWriter privout = new StringWriter();
+      JcaPEMWriter privWriter = new JcaPEMWriter(privout);
+      privWriter.writeObject(k.getPrivate());
+      privWriter.close();
+      System.out.println(privout);
+    }
+  }
+
+}
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/account/DiffPreferencesIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/account/DiffPreferencesIT.java
index 5550cb6..5b2e7ba 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/account/DiffPreferencesIT.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/account/DiffPreferencesIT.java
@@ -22,20 +22,11 @@
 import com.google.gerrit.extensions.client.DiffPreferencesInfo;
 import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace;
 import com.google.gerrit.extensions.client.Theme;
-import com.google.gerrit.testutil.ConfigSuite;
 
 import org.apache.http.HttpStatus;
-import org.eclipse.jgit.lib.Config;
 import org.junit.Test;
 
 public class DiffPreferencesIT extends AbstractDaemonTest {
-  @ConfigSuite.Config
-  public static Config readFromGitConfig() {
-    Config cfg = new Config();
-    cfg.setBoolean("user", null, "readPrefsFromGit", true);
-    return cfg;
-  }
-
   @Test
   public void getDiffPreferencesOfNonExistingAccount_NotFound()
       throws Exception {
@@ -56,6 +47,7 @@
     assertThat(o.context).isEqualTo(d.context);
     assertThat(o.tabSize).isEqualTo(d.tabSize);
     assertThat(o.lineLength).isEqualTo(d.lineLength);
+    assertThat(o.cursorBlinkRate).isEqualTo(d.cursorBlinkRate);
     assertThat(o.expandAllComments).isNull();
     assertThat(o.intralineDifference).isEqualTo(d.intralineDifference);
     assertThat(o.manualReview).isNull();
@@ -71,6 +63,7 @@
     assertThat(o.hideLineNumbers).isNull();
     assertThat(o.renderEntireFile).isNull();
     assertThat(o.hideEmptyPane).isNull();
+    assertThat(o.matchBrackets).isNull();
     assertThat(o.ignoreWhitespace).isEqualTo(d.ignoreWhitespace);
     assertThat(o.theme).isEqualTo(d.theme);
   }
@@ -83,6 +76,7 @@
     i.context *= -1;
     i.tabSize *= -1;
     i.lineLength *= -1;
+    i.cursorBlinkRate = 500;
     i.theme = Theme.MIDNIGHT;
     i.ignoreWhitespace = Whitespace.IGNORE_ALL;
     i.expandAllComments ^= true;
@@ -100,6 +94,7 @@
     i.hideLineNumbers ^= true;
     i.renderEntireFile ^= true;
     i.hideEmptyPane ^= true;
+    i.matchBrackets ^= true;
 
     RestResponse r = adminSession.put("/accounts/" + admin.email
         + "/preferences.diff", i);
@@ -110,6 +105,7 @@
     assertThat(o.context).isEqualTo(i.context);
     assertThat(o.tabSize).isEqualTo(i.tabSize);
     assertThat(o.lineLength).isEqualTo(i.lineLength);
+    assertThat(o.cursorBlinkRate).isEqualTo(i.cursorBlinkRate);
     assertThat(o.expandAllComments).isEqualTo(i.expandAllComments);
     assertThat(o.intralineDifference).isNull();
     assertThat(o.manualReview).isEqualTo(i.manualReview);
@@ -125,6 +121,7 @@
     assertThat(o.hideLineNumbers).isEqualTo(i.hideLineNumbers);
     assertThat(o.renderEntireFile).isEqualTo(i.renderEntireFile);
     assertThat(o.hideEmptyPane).isEqualTo(i.hideEmptyPane);
+    assertThat(o.matchBrackets).isEqualTo(i.matchBrackets);
     assertThat(o.ignoreWhitespace).isEqualTo(i.ignoreWhitespace);
     assertThat(o.theme).isEqualTo(i.theme);
 
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/ssh/CreateProjectIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/ssh/CreateProjectIT.java
new file mode 100644
index 0000000..a779136
--- /dev/null
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/ssh/CreateProjectIT.java
@@ -0,0 +1,56 @@
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.acceptance.ssh;
+
+import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assert_;
+
+import com.google.gerrit.acceptance.AbstractDaemonTest;
+import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.server.project.ProjectState;
+
+import org.junit.Test;
+
+public class CreateProjectIT extends AbstractDaemonTest {
+
+  @Test
+  public void withValidGroupName() throws Exception {
+    String newGroupName = "newGroup";
+    adminSession.put("/groups/" + newGroupName);
+    String newProjectName = "newProject";
+    sshSession.exec("gerrit create-project --branch master --owner "
+        + newGroupName + " " + newProjectName);
+    assert_().withFailureMessage(sshSession.getError())
+        .that(sshSession.hasError()).isFalse();
+    ProjectState projectState =
+        projectCache.get(new Project.NameKey(newProjectName));
+    assertThat(projectState).isNotNull();
+  }
+
+  @Test
+  public void withInvalidGroupName() throws Exception {
+    String newGroupName = "newGroup";
+    adminSession.put("/groups/" + newGroupName);
+    String wrongGroupName = "newG";
+    String newProjectName = "newProject";
+    sshSession.exec("gerrit create-project --branch master --owner "
+        + wrongGroupName + " " + newProjectName);
+    assert_().withFailureMessage(sshSession.getError())
+        .that(sshSession.hasError()).isTrue();
+    ProjectState projectState =
+        projectCache.get(new Project.NameKey(newProjectName));
+    assertThat(projectState).isNull();
+  }
+}
diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/client/DiffPreferencesInfo.java b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/client/DiffPreferencesInfo.java
index c488bd7..703f7b3 100644
--- a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/client/DiffPreferencesInfo.java
+++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/client/DiffPreferencesInfo.java
@@ -42,6 +42,7 @@
   public Integer context;
   public Integer tabSize;
   public Integer lineLength;
+  public Integer cursorBlinkRate;
   public Boolean expandAllComments;
   public Boolean intralineDifference;
   public Boolean manualReview;
@@ -54,6 +55,7 @@
   public Boolean hideLineNumbers;
   public Boolean renderEntireFile;
   public Boolean hideEmptyPane;
+  public Boolean matchBrackets;
   public Theme theme;
   public Whitespace ignoreWhitespace;
   public Boolean retainHeader;
@@ -65,6 +67,7 @@
     i.context = DEFAULT_CONTEXT;
     i.tabSize = DEFAULT_TAB_SIZE;
     i.lineLength = DEFAULT_LINE_LENGTH;
+    i.cursorBlinkRate = 0;
     i.ignoreWhitespace = Whitespace.IGNORE_NONE;
     i.theme = Theme.DEFAULT;
     i.expandAllComments = false;
@@ -82,6 +85,7 @@
     i.hideLineNumbers = false;
     i.renderEntireFile = false;
     i.hideEmptyPane = false;
+    i.matchBrackets = false;
     return i;
   }
-}
\ No newline at end of file
+}
diff --git a/gerrit-gwtui-common/BUCK b/gerrit-gwtui-common/BUCK
index ef4de82..436714a 100644
--- a/gerrit-gwtui-common/BUCK
+++ b/gerrit-gwtui-common/BUCK
@@ -49,7 +49,6 @@
 genrule(
   name = 'diffy_image_files_ln',
   cmd = 'ln -s $(location :diffy_image_files) $OUT',
-  deps = [':diffy_image_files'],
   out = 'diffy_images.jar',
 )
 
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties
index 4580aea..0944448 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties
@@ -32,9 +32,6 @@
 myMenuUrl = URL
 myMenuReset = Reset
 
-changeScreenOldUi = Old Screen
-changeScreenNewUi = New Screen
-
 tabAccountSummary = Profile
 tabAgreements = Agreements
 tabContactInformation = Contact Information
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/DiffPreferences.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/DiffPreferences.java
index 9a8e90c..7d543d8 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/DiffPreferences.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/DiffPreferences.java
@@ -28,6 +28,7 @@
     p.ignoreWhitespace(in.ignoreWhitespace);
     p.tabSize(in.tabSize);
     p.lineLength(in.lineLength);
+    p.cursorBlinkRate(in.cursorBlinkRate);
     p.context(in.context);
     p.intralineDifference(in.intralineDifference);
     p.showLineEndings(in.showLineEndings);
@@ -45,6 +46,7 @@
     p.retainHeader(in.retainHeader);
     p.skipUncommented(in.skipUncommented);
     p.skipDeleted(in.skipDeleted);
+    p.matchBrackets(in.matchBrackets);
     return p;
   }
 
@@ -52,6 +54,7 @@
     p.context = context();
     p.tabSize = tabSize();
     p.lineLength = lineLength();
+    p.cursorBlinkRate = cursorBlinkRate();
     p.expandAllComments = expandAllComments();
     p.intralineDifference = intralineDifference();
     p.manualReview = manualReview();
@@ -67,6 +70,7 @@
     p.hideLineNumbers = hideLineNumbers();
     p.renderEntireFile = renderEntireFile();
     p.hideEmptyPane = hideEmptyPane();
+    p.matchBrackets = matchBrackets();
     p.theme = theme();
     p.ignoreWhitespace = ignoreWhitespace();
   }
@@ -105,6 +109,10 @@
     return get("line_length", 100);
   }
 
+  public final int cursorBlinkRate() {
+    return get("cursor_blink_rate", 0);
+  }
+
   public final boolean showLineNumbers() {
     return !hideLineNumbers();
   }
@@ -116,6 +124,7 @@
   public final native void tabSize(int t) /*-{ this.tab_size = t }-*/;
   public final native void lineLength(int c) /*-{ this.line_length = c }-*/;
   public final native void context(int c) /*-{ this.context = c }-*/;
+  public final native void cursorBlinkRate(int r) /*-{ this.cursor_blink_rate = r }-*/;
   public final native void intralineDifference(boolean i) /*-{ this.intraline_difference = i }-*/;
   public final native void showLineEndings(boolean s) /*-{ this.show_line_endings = s }-*/;
   public final native void showTabs(boolean s) /*-{ this.show_tabs = s }-*/;
@@ -127,10 +136,11 @@
   public final native void expandAllComments(boolean e) /*-{ this.expand_all_comments = e }-*/;
   public final native void manualReview(boolean r) /*-{ this.manual_review = r }-*/;
   public final native void renderEntireFile(boolean r) /*-{ this.render_entire_file = r }-*/;
-  public final native void hideEmptyPane(boolean s) /*-{ this.hide_empty_pane = s }-*/;
   public final native void retainHeader(boolean r) /*-{ this.retain_header = r }-*/;
+  public final native void hideEmptyPane(boolean s) /*-{ this.hide_empty_pane = s }-*/;
   public final native void skipUncommented(boolean s) /*-{ this.skip_uncommented = s }-*/;
   public final native void skipDeleted(boolean s) /*-{ this.skip_deleted = s }-*/;
+  public final native void matchBrackets(boolean m) /*-{ this.match_brackets = m }-*/;
   public final native boolean intralineDifference() /*-{ return this.intraline_difference || false }-*/;
   public final native boolean showLineEndings() /*-{ return this.show_line_endings || false }-*/;
   public final native boolean showTabs() /*-{ return this.show_tabs || false }-*/;
@@ -146,6 +156,7 @@
   public final native boolean retainHeader() /*-{ return this.retain_header || false }-*/;
   public final native boolean skipUncommented() /*-{ return this.skip_uncommented || false }-*/;
   public final native boolean skipDeleted() /*-{ return this.skip_deleted || false }-*/;
+  public final native boolean matchBrackets() /*-{ return this.match_brackets || false }-*/;
 
   private final native void setThemeRaw(String i) /*-{ this.theme = i }-*/;
   private final native void setIgnoreWhitespaceRaw(String i) /*-{ this.ignore_whitespace = i }-*/;
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.java
index 455a643..91baf90 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.java
@@ -14,12 +14,13 @@
 
 package com.google.gerrit.client.diff;
 
-import static com.google.gerrit.reviewdb.client.AccountDiffPreference.DEFAULT_CONTEXT;
-import static com.google.gerrit.reviewdb.client.AccountDiffPreference.WHOLE_FILE_CONTEXT;
-import static com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace.IGNORE_ALL;
-import static com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace.IGNORE_LEADING_AND_TRAILING;
-import static com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace.IGNORE_NONE;
-import static com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace.IGNORE_TRAILING;
+import static com.google.gerrit.extensions.client.DiffPreferencesInfo.DEFAULT_CONTEXT;
+import static com.google.gerrit.extensions.client.DiffPreferencesInfo.WHOLE_FILE_CONTEXT;
+import static com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace.IGNORE_ALL;
+import static com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace.IGNORE_LEADING_AND_TRAILING;
+import static com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace.IGNORE_NONE;
+import static com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace.IGNORE_TRAILING;
+
 import static com.google.gwt.event.dom.client.KeyCodes.KEY_ESCAPE;
 
 import com.google.gerrit.client.Gerrit;
@@ -85,6 +86,7 @@
   @UiField NpIntTextBox tabWidth;
   @UiField NpIntTextBox lineLength;
   @UiField NpIntTextBox context;
+  @UiField NpIntTextBox cursorBlinkRate;
   @UiField CheckBox contextEntireFile;
   @UiField ToggleButton intralineDifference;
   @UiField ToggleButton syntaxHighlighting;
@@ -99,6 +101,7 @@
   @UiField ToggleButton manualReview;
   @UiField ToggleButton expandAllComments;
   @UiField ToggleButton renderEntireFile;
+  @UiField ToggleButton matchBrackets;
   @UiField ListBox theme;
   @UiField Element modeLabel;
   @UiField ListBox mode;
@@ -172,6 +175,7 @@
       lineLength.setEnabled(true);
       lineLength.setIntValue(prefs.lineLength());
     }
+    cursorBlinkRate.setIntValue(prefs.cursorBlinkRate());
     syntaxHighlighting.setValue(prefs.syntaxHighlighting());
     whitespaceErrors.setValue(prefs.showWhitespaceErrors());
     showTabs.setValue(prefs.showTabs());
@@ -189,6 +193,7 @@
     autoHideDiffTableHeader.setValue(!prefs.autoHideDiffTableHeader());
     manualReview.setValue(prefs.manualReview());
     expandAllComments.setValue(prefs.expandAllComments());
+    matchBrackets.setValue(prefs.matchBrackets());
     setTheme(prefs.theme());
 
     if (view == null || view.canRenderEntireFile(prefs)) {
@@ -342,6 +347,20 @@
     }
   }
 
+  @UiHandler("cursorBlinkRate")
+  void onCursoBlinkRate(ValueChangeEvent<String> e) {
+    String v = e.getValue();
+    if (v != null && v.length() > 0) {
+      // A negative value hides the cursor entirely:
+      // don't let user shoot himself in the foot.
+      prefs.cursorBlinkRate(Math.max(0, Integer.parseInt(v)));
+      view.getCmFromSide(DisplaySide.A).setOption("cursorBlinkRate",
+          prefs.cursorBlinkRate());
+      view.getCmFromSide(DisplaySide.B).setOption("cursorBlinkRate",
+          prefs.cursorBlinkRate());
+    }
+  }
+
   @UiHandler("showTabs")
   void onShowTabs(ValueChangeEvent<Boolean> e) {
     prefs.showTabs(e.getValue());
@@ -465,6 +484,15 @@
     }
   }
 
+  @UiHandler("matchBrackets")
+  void onMatchBrackets(ValueChangeEvent<Boolean> e) {
+    prefs.matchBrackets(e.getValue());
+    view.getCmFromSide(DisplaySide.A).setOption("matchBrackets",
+        prefs.matchBrackets());
+    view.getCmFromSide(DisplaySide.B).setOption("matchBrackets",
+        prefs.matchBrackets());
+  }
+
   @UiHandler("theme")
   void onTheme(@SuppressWarnings("unused") ChangeEvent e) {
     final Theme newTheme = getSelectedTheme();
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.ui.xml b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.ui.xml
index da744c4..a2202ab 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.ui.xml
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/PreferencesBox.ui.xml
@@ -196,6 +196,12 @@
           or <g:CheckBox ui:field='contextEntireFile'>entire file</g:CheckBox></ui:msg></td>
       </tr>
       <tr>
+        <th><ui:msg>Cursor Blink Rate</ui:msg></th>
+        <td><x:NpIntTextBox ui:field='cursorBlinkRate'
+            visibleLength='4'
+            alignment='RIGHT'/></td>
+      </tr>
+      <tr>
         <th><ui:msg>Intraline Difference</ui:msg></th>
         <td><g:ToggleButton ui:field='intralineDifference'>
           <g:upFace><ui:msg>Hide</ui:msg></g:upFace>
@@ -284,6 +290,13 @@
         </g:ToggleButton></td>
       </tr>
       <tr>
+        <th><ui:msg>Match Brackets</ui:msg></th>
+        <td><g:ToggleButton ui:field='matchBrackets'>
+          <g:upFace><ui:msg>Off</ui:msg></g:upFace>
+          <g:downFace><ui:msg>On</ui:msg></g:downFace>
+        </g:ToggleButton></td>
+      </tr>
+      <tr>
         <td></td>
         <td>
           <g:Button ui:field='apply' styleName='{style.apply}'>
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/SideBySide.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/SideBySide.java
index eb902ad..8b47835 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/SideBySide.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/diff/SideBySide.java
@@ -636,7 +636,7 @@
       Element parent) {
     return CodeMirror.create(parent, Configuration.create()
       .set("readOnly", true)
-      .set("cursorBlinkRate", 0)
+      .set("cursorBlinkRate", prefs.cursorBlinkRate())
       .set("cursorHeight", 0.85)
       .set("lineNumbers", prefs.showLineNumbers())
       .set("tabSize", prefs.tabSize())
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/HostPageServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/HostPageServlet.java
index 76d2cdb..ab3728e 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/HostPageServlet.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/HostPageServlet.java
@@ -43,7 +43,6 @@
 import com.google.gwtexpui.server.CacheHeaders;
 import com.google.gwtjsonrpc.server.JsonServlet;
 import com.google.gwtjsonrpc.server.RPCServletUtils;
-import com.google.gwtorm.server.OrmException;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 import com.google.inject.Singleton;
@@ -250,8 +249,7 @@
   private DiffPreferencesInfo getDiffPreferences(IdentifiedUser user) {
     try {
       return getDiff.apply(new AccountResource(user));
-    } catch (AuthException | OrmException | ConfigInvalidException
-        | IOException e) {
+    } catch (AuthException | ConfigInvalidException | IOException e) {
       log.warn("Cannot query account diff preferences", e);
     }
     return DiffPreferencesInfo.defaults();
diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/AccountDiffPreference.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/AccountDiffPreference.java
deleted file mode 100644
index cc0cbf0..0000000
--- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/AccountDiffPreference.java
+++ /dev/null
@@ -1,338 +0,0 @@
-// Copyright (C) 2010 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.reviewdb.client;
-
-import com.google.gerrit.extensions.client.Theme;
-import com.google.gwtorm.client.Column;
-
-/** Diff formatting preferences of an account */
-public class AccountDiffPreference {
-
-  /** Default number of lines of context. */
-  public static final short DEFAULT_CONTEXT = 10;
-
-  /** Context setting to display the entire file. */
-  public static final short WHOLE_FILE_CONTEXT = -1;
-
-  /** Typical valid choices for the default context setting. */
-  public static final short[] CONTEXT_CHOICES =
-      {3, 10, 25, 50, 75, 100, WHOLE_FILE_CONTEXT};
-
-  public static enum Whitespace implements CodedEnum {
-    IGNORE_NONE('N'), //
-    IGNORE_TRAILING('E'), //
-    IGNORE_LEADING_AND_TRAILING('S'), //
-    IGNORE_ALL('A');
-
-    private final char code;
-
-    private Whitespace(final char c) {
-      code = c;
-    }
-
-    @Override
-    public char getCode() {
-      return code;
-    }
-
-    public static Whitespace forCode(final char c) {
-      for (final Whitespace s : Whitespace.values()) {
-        if (s.code == c) {
-          return s;
-        }
-      }
-      return null;
-    }
-  }
-
-  public static AccountDiffPreference createDefault(Account.Id accountId) {
-    AccountDiffPreference p = new AccountDiffPreference(accountId);
-    p.setIgnoreWhitespace(Whitespace.IGNORE_NONE);
-    p.setTheme(Theme.DEFAULT);
-    p.setTabSize(8);
-    p.setLineLength(100);
-    p.setSyntaxHighlighting(true);
-    p.setShowWhitespaceErrors(true);
-    p.setShowLineEndings(true);
-    p.setIntralineDifference(true);
-    p.setShowTabs(true);
-    p.setContext(DEFAULT_CONTEXT);
-    p.setManualReview(false);
-    p.setHideEmptyPane(false);
-    p.setAutoHideDiffTableHeader(true);
-    return p;
-  }
-
-  @Column(id = 1, name = Column.NONE)
-  protected Account.Id accountId;
-
-  @Column(id = 2)
-  protected char ignoreWhitespace;
-
-  @Column(id = 3)
-  protected int tabSize;
-
-  @Column(id = 4)
-  protected int lineLength;
-
-  @Column(id = 5)
-  protected boolean syntaxHighlighting;
-
-  @Column(id = 6)
-  protected boolean showWhitespaceErrors;
-
-  @Column(id = 7)
-  protected boolean intralineDifference;
-
-  @Column(id = 8)
-  protected boolean showTabs;
-
-  /** Number of lines of context when viewing a patch. */
-  @Column(id = 9)
-  protected short context;
-
-  @Column(id = 10)
-  protected boolean skipDeleted;
-
-  @Column(id = 11)
-  protected boolean skipUncommented;
-
-  @Column(id = 12)
-  protected boolean expandAllComments;
-
-  @Column(id = 13)
-  protected boolean retainHeader;
-
-  @Column(id = 14)
-  protected boolean manualReview;
-
-  @Column(id = 15)
-  protected boolean showLineEndings;
-
-  @Column(id = 16)
-  protected boolean hideTopMenu;
-
-  @Column(id = 17)
-  protected boolean hideLineNumbers;
-
-  @Column(id = 18)
-  protected boolean renderEntireFile;
-
-  @Column(id = 19, length = 20, notNull = false)
-  protected String theme;
-
-  @Column(id = 20)
-  protected boolean hideEmptyPane;
-
-  @Column(id = 21)
-  protected boolean autoHideDiffTableHeader;
-
-  protected AccountDiffPreference() {
-  }
-
-  public AccountDiffPreference(Account.Id accountId) {
-    this.accountId = accountId;
-  }
-
-  public AccountDiffPreference(AccountDiffPreference p) {
-    this.accountId = p.accountId;
-    this.ignoreWhitespace = p.ignoreWhitespace;
-    this.tabSize = p.tabSize;
-    this.lineLength = p.lineLength;
-    this.syntaxHighlighting = p.syntaxHighlighting;
-    this.showWhitespaceErrors = p.showWhitespaceErrors;
-    this.showLineEndings = p.showLineEndings;
-    this.intralineDifference = p.intralineDifference;
-    this.showTabs = p.showTabs;
-    this.skipDeleted = p.skipDeleted;
-    this.skipUncommented = p.skipUncommented;
-    this.expandAllComments = p.expandAllComments;
-    this.context = p.context;
-    this.retainHeader = p.retainHeader;
-    this.manualReview = p.manualReview;
-    this.hideTopMenu = p.hideTopMenu;
-    this.hideLineNumbers = p.hideLineNumbers;
-    this.renderEntireFile = p.renderEntireFile;
-    this.hideEmptyPane = p.hideEmptyPane;
-    this.autoHideDiffTableHeader = p.autoHideDiffTableHeader;
-  }
-
-  public Account.Id getAccountId() {
-    return accountId;
-  }
-
-  public Whitespace getIgnoreWhitespace() {
-    return Whitespace.forCode(ignoreWhitespace);
-  }
-
-  public void setIgnoreWhitespace(Whitespace ignoreWhitespace) {
-    this.ignoreWhitespace = ignoreWhitespace.getCode();
-  }
-
-  public int getTabSize() {
-    return tabSize;
-  }
-
-  public void setTabSize(int tabSize) {
-    this.tabSize = tabSize;
-  }
-
-  public int getLineLength() {
-    return lineLength;
-  }
-
-  public void setLineLength(int lineLength) {
-    this.lineLength = lineLength;
-  }
-
-  public boolean isSyntaxHighlighting() {
-    return syntaxHighlighting;
-  }
-
-  public void setSyntaxHighlighting(boolean syntaxHighlighting) {
-    this.syntaxHighlighting = syntaxHighlighting;
-  }
-
-  public boolean isShowWhitespaceErrors() {
-    return showWhitespaceErrors;
-  }
-
-  public void setShowWhitespaceErrors(boolean showWhitespaceErrors) {
-    this.showWhitespaceErrors = showWhitespaceErrors;
-  }
-
-  public boolean isShowLineEndings() {
-    return showLineEndings;
-  }
-
-  public void setShowLineEndings(boolean showLineEndings) {
-    this.showLineEndings = showLineEndings;
-  }
-
-  public boolean isIntralineDifference() {
-    return intralineDifference;
-  }
-
-  public void setIntralineDifference(boolean intralineDifference) {
-    this.intralineDifference = intralineDifference;
-  }
-
-  public boolean isShowTabs() {
-    return showTabs;
-  }
-
-  public void setShowTabs(boolean showTabs) {
-    this.showTabs = showTabs;
-  }
-
-  /** Get the number of lines of context when viewing a patch. */
-  public short getContext() {
-    return context;
-  }
-
-  /** Set the number of lines of context when viewing a patch. */
-  public void setContext(final short context) {
-    assert 0 <= context || context == WHOLE_FILE_CONTEXT;
-    this.context = context;
-  }
-
-  public boolean isSkipDeleted() {
-    return skipDeleted;
-  }
-
-  public void setSkipDeleted(boolean skip) {
-    skipDeleted = skip;
-  }
-
-  public boolean isSkipUncommented() {
-    return skipUncommented;
-  }
-
-  public void setSkipUncommented(boolean skip) {
-    skipUncommented = skip;
-  }
-
-  public boolean isExpandAllComments() {
-    return expandAllComments;
-  }
-
-  public void setExpandAllComments(boolean expand) {
-    expandAllComments = expand;
-  }
-
-  public boolean isRetainHeader() {
-    return retainHeader;
-  }
-
-  public void setRetainHeader(boolean retain) {
-    retainHeader = retain;
-  }
-
-  public boolean isManualReview() {
-    return manualReview;
-  }
-
-  public void setManualReview(boolean manual) {
-    manualReview = manual;
-  }
-
-  public boolean isHideTopMenu() {
-    return hideTopMenu;
-  }
-
-  public void setHideTopMenu(boolean hide) {
-    hideTopMenu = hide;
-  }
-
-  public boolean isHideLineNumbers() {
-    return hideLineNumbers;
-  }
-
-  public void setHideLineNumbers(boolean hide) {
-    hideLineNumbers = hide;
-  }
-
-  public boolean isRenderEntireFile() {
-    return renderEntireFile;
-  }
-
-  public void setRenderEntireFile(boolean render) {
-    renderEntireFile = render;
-  }
-
-  public Theme getTheme() {
-    return theme != null ? Theme.valueOf(theme) : null;
-  }
-
-  public void setTheme(Theme theme) {
-    this.theme = theme != null ? theme.name() : null;
-  }
-
-  public boolean isHideEmptyPane() {
-    return hideEmptyPane;
-  }
-
-  public void setHideEmptyPane(boolean hideEmptyPane) {
-    this.hideEmptyPane = hideEmptyPane;
-  }
-
-  public void setAutoHideDiffTableHeader(boolean hide) {
-    autoHideDiffTableHeader = hide;
-  }
-
-  public boolean isAutoHideDiffTableHeader() {
-    return autoHideDiffTableHeader;
-  }
-}
diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/server/AccountDiffPreferenceAccess.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/server/AccountDiffPreferenceAccess.java
deleted file mode 100644
index 499cb77..0000000
--- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/server/AccountDiffPreferenceAccess.java
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2010 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.reviewdb.server;
-
-import com.google.gerrit.reviewdb.client.Account;
-import com.google.gerrit.reviewdb.client.AccountDiffPreference;
-import com.google.gwtorm.server.Access;
-import com.google.gwtorm.server.OrmException;
-import com.google.gwtorm.server.PrimaryKey;
-
-public interface AccountDiffPreferenceAccess extends Access<AccountDiffPreference, Account.Id> {
-
-  @Override
-  @PrimaryKey("accountId")
-  AccountDiffPreference get(Account.Id key) throws OrmException;
-
-}
diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/server/ReviewDb.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/server/ReviewDb.java
index 37dcc59..a63e638 100644
--- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/server/ReviewDb.java
+++ b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/server/ReviewDb.java
@@ -68,8 +68,7 @@
   @Relation(id = 13)
   AccountGroupMemberAuditAccess accountGroupMembersAudit();
 
-  @Relation(id = 17)
-  AccountDiffPreferenceAccess accountDiffPreferences();
+  //Deleted @Relation(id = 17)
 
   @Relation(id = 18)
   StarredChangeAccess starredChanges();
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/GetDiffPreferences.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/GetDiffPreferences.java
index d2d6bf2..be87ae7 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/account/GetDiffPreferences.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/GetDiffPreferences.java
@@ -20,22 +20,16 @@
 import com.google.gerrit.extensions.restapi.AuthException;
 import com.google.gerrit.extensions.restapi.RestReadView;
 import com.google.gerrit.reviewdb.client.Account;
-import com.google.gerrit.reviewdb.client.AccountDiffPreference;
-import com.google.gerrit.reviewdb.server.ReviewDb;
 import com.google.gerrit.server.CurrentUser;
 import com.google.gerrit.server.config.AllUsersName;
-import com.google.gerrit.server.config.GerritServerConfig;
 import com.google.gerrit.server.git.GitRepositoryManager;
 import com.google.gerrit.server.git.UserConfigSections;
-import com.google.gerrit.server.patch.PatchListKey;
-import com.google.gwtorm.server.OrmException;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 import com.google.inject.Singleton;
 
 import org.eclipse.jgit.errors.ConfigInvalidException;
 import org.eclipse.jgit.errors.RepositoryNotFoundException;
-import org.eclipse.jgit.lib.Config;
 import org.eclipse.jgit.lib.Repository;
 
 import java.io.IOException;
@@ -43,36 +37,28 @@
 @Singleton
 public class GetDiffPreferences implements RestReadView<AccountResource> {
   private final Provider<CurrentUser> self;
-  private final Provider<ReviewDb> db;
   private final Provider<AllUsersName> allUsersName;
   private final GitRepositoryManager gitMgr;
-  private final boolean readFromGit;
 
   @Inject
   GetDiffPreferences(Provider<CurrentUser> self,
-      Provider<ReviewDb> db,
-      @GerritServerConfig Config cfg,
       Provider<AllUsersName> allUsersName,
       GitRepositoryManager gitMgr) {
     this.self = self;
-    this.db = db;
     this.allUsersName = allUsersName;
     this.gitMgr = gitMgr;
-    readFromGit = cfg.getBoolean("user", null, "readPrefsFromGit", false);
   }
 
   @Override
   public DiffPreferencesInfo apply(AccountResource rsrc)
-      throws AuthException, OrmException, ConfigInvalidException, IOException {
+      throws AuthException, ConfigInvalidException, IOException {
     if (self.get() != rsrc.getUser()
         && !self.get().getCapabilities().canAdministrateServer()) {
       throw new AuthException("restricted to administrator");
     }
 
-    Account.Id userId = rsrc.getUser().getAccountId();
-    return readFromGit
-        ? readFromGit(userId, gitMgr, allUsersName.get(), null)
-        : readFromDb(userId);
+    Account.Id id = rsrc.getUser().getAccountId();
+    return readFromGit(id, gitMgr, allUsersName.get(), null);
   }
 
   static DiffPreferencesInfo readFromGit(Account.Id id,
@@ -89,65 +75,4 @@
       return prefs;
     }
   }
-
-  private DiffPreferencesInfo readFromDb(Account.Id id)
-      throws OrmException {
-    AccountDiffPreference a = db.get().accountDiffPreferences().get(id);
-    return nullify(initFromDb(a));
-  }
-
-  static DiffPreferencesInfo initFromDb(AccountDiffPreference a) {
-    DiffPreferencesInfo prefs = DiffPreferencesInfo.defaults();
-    if (a != null) {
-      prefs.context = (int)a.getContext();
-      prefs.expandAllComments = a.isExpandAllComments();
-      prefs.hideLineNumbers = a.isHideLineNumbers();
-      prefs.hideTopMenu = a.isHideTopMenu();
-      prefs.ignoreWhitespace = PatchListKey.WHITESPACE_TYPES.inverse().get(
-          a.getIgnoreWhitespace().getCode());
-      prefs.intralineDifference = a.isIntralineDifference();
-      prefs.lineLength = a.getLineLength();
-      prefs.manualReview = a.isManualReview();
-      prefs.renderEntireFile = a.isRenderEntireFile();
-      prefs.retainHeader = a.isRetainHeader();
-      prefs.showLineEndings = a.isShowLineEndings();
-      prefs.showTabs = a.isShowTabs();
-      prefs.showWhitespaceErrors = a.isShowWhitespaceErrors();
-      prefs.skipDeleted = a.isSkipDeleted();
-      prefs.skipUncommented = a.isSkipUncommented();
-      prefs.syntaxHighlighting = a.isSyntaxHighlighting();
-      prefs.tabSize = a.getTabSize();
-      prefs.theme = a.getTheme();
-      prefs.hideEmptyPane = a.isHideEmptyPane();
-      prefs.autoHideDiffTableHeader = a.isAutoHideDiffTableHeader();
-    }
-
-    return prefs;
-  }
-
-  private static DiffPreferencesInfo nullify(DiffPreferencesInfo prefs) {
-    prefs.expandAllComments = b(prefs.expandAllComments);
-    prefs.hideLineNumbers = b(prefs.hideLineNumbers);
-    prefs.hideTopMenu = b(prefs.hideTopMenu);
-    prefs.intralineDifference = b(prefs.intralineDifference);
-    prefs.manualReview = b(prefs.manualReview);
-    prefs.renderEntireFile = b(prefs.renderEntireFile);
-    prefs.retainHeader = b(prefs.retainHeader);
-    prefs.showLineEndings = b(prefs.showLineEndings);
-    prefs.showTabs = b(prefs.showTabs);
-    prefs.showWhitespaceErrors = b(prefs.showWhitespaceErrors);
-    prefs.skipDeleted = b(prefs.skipDeleted);
-    prefs.skipUncommented = b(prefs.skipUncommented);
-    prefs.syntaxHighlighting = b(prefs.syntaxHighlighting);
-    prefs.hideEmptyPane = b(prefs.hideEmptyPane);
-    prefs.autoHideDiffTableHeader = b(prefs.autoHideDiffTableHeader);
-    return prefs;
-  }
-
-  private static Boolean b(Boolean b) {
-    if (b == null) {
-      return null;
-    }
-    return b ? Boolean.TRUE : null;
-  }
 }
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/SetDiffPreferences.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/SetDiffPreferences.java
index 7b4d133..e14791c 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/account/SetDiffPreferences.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/SetDiffPreferences.java
@@ -14,7 +14,6 @@
 
 package com.google.gerrit.server.account;
 
-import static com.google.gerrit.server.account.GetDiffPreferences.initFromDb;
 import static com.google.gerrit.server.account.GetDiffPreferences.readFromGit;
 import static com.google.gerrit.server.config.ConfigUtil.loadSection;
 import static com.google.gerrit.server.config.ConfigUtil.storeSection;
@@ -24,16 +23,11 @@
 import com.google.gerrit.extensions.restapi.BadRequestException;
 import com.google.gerrit.extensions.restapi.RestModifyView;
 import com.google.gerrit.reviewdb.client.Account;
-import com.google.gerrit.reviewdb.client.AccountDiffPreference;
-import com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace;
-import com.google.gerrit.reviewdb.server.ReviewDb;
 import com.google.gerrit.server.CurrentUser;
 import com.google.gerrit.server.config.AllUsersName;
-import com.google.gerrit.server.config.GerritServerConfig;
 import com.google.gerrit.server.git.GitRepositoryManager;
 import com.google.gerrit.server.git.MetaDataUpdate;
 import com.google.gerrit.server.git.UserConfigSections;
-import com.google.gerrit.server.patch.PatchListKey;
 import com.google.gwtorm.server.OrmException;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
@@ -41,34 +35,26 @@
 
 import org.eclipse.jgit.errors.ConfigInvalidException;
 import org.eclipse.jgit.errors.RepositoryNotFoundException;
-import org.eclipse.jgit.lib.Config;
 
 import java.io.IOException;
-import java.util.Collections;
 
 @Singleton
 public class SetDiffPreferences implements
     RestModifyView<AccountResource, DiffPreferencesInfo> {
   private final Provider<CurrentUser> self;
-  private final Provider<ReviewDb> db;
   private final Provider<MetaDataUpdate.User> metaDataUpdateFactory;
   private final AllUsersName allUsersName;
   private final GitRepositoryManager gitMgr;
-  private final boolean readFromGit;
 
   @Inject
   SetDiffPreferences(Provider<CurrentUser> self,
-      Provider<ReviewDb> db,
-      @GerritServerConfig Config cfg,
       Provider<MetaDataUpdate.User> metaDataUpdateFactory,
       AllUsersName allUsersName,
       GitRepositoryManager gitMgr) {
     this.self = self;
-    this.db = db;
     this.metaDataUpdateFactory = metaDataUpdateFactory;
     this.allUsersName = allUsersName;
     this.gitMgr = gitMgr;
-    readFromGit = cfg.getBoolean("user", null, "readPrefsFromGit", false);
   }
 
   @Override
@@ -84,40 +70,23 @@
       throw new BadRequestException("input must be provided");
     }
 
-    Account.Id userId = rsrc.getUser().getAccountId();
-    DiffPreferencesInfo n = readFromGit
-        ? readFromGit(userId, gitMgr, allUsersName, in)
-        : merge(initFromDb(db.get().accountDiffPreferences().get(userId)), in);
-    DiffPreferencesInfo out = writeToGit(n, userId);
-    writeToDb(n, userId);
-    return out;
-  }
-
-  private void writeToDb(DiffPreferencesInfo in, Account.Id id)
-      throws OrmException {
-    db.get().accounts().beginTransaction(id);
-    try {
-      AccountDiffPreference p = db.get().accountDiffPreferences().get(id);
-      p = initAccountDiffPreferences(p, in, id);
-      db.get().accountDiffPreferences().upsert(Collections.singleton(p));
-      db.get().commit();
-    } finally {
-      db.get().rollback();
-    }
+    Account.Id id = rsrc.getUser().getAccountId();
+    return writeToGit(readFromGit(id, gitMgr, allUsersName, in), id);
   }
 
   private DiffPreferencesInfo writeToGit(DiffPreferencesInfo in,
-      Account.Id useId) throws RepositoryNotFoundException, IOException,
+      Account.Id userId) throws RepositoryNotFoundException, IOException,
           ConfigInvalidException {
     MetaDataUpdate md = metaDataUpdateFactory.get().create(allUsersName);
 
-    VersionedAccountPreferences prefs;
     DiffPreferencesInfo out = new DiffPreferencesInfo();
     try {
-      prefs = VersionedAccountPreferences.forUser(useId);
+      VersionedAccountPreferences prefs = VersionedAccountPreferences.forUser(
+          userId);
       prefs.load(md);
+      DiffPreferencesInfo defaults = DiffPreferencesInfo.defaults();
       storeSection(prefs.getConfig(), UserConfigSections.DIFF, null, in,
-          DiffPreferencesInfo.defaults());
+          defaults);
       prefs.commit(md);
       loadSection(prefs.getConfig(), UserConfigSections.DIFF, null, out,
           DiffPreferencesInfo.defaults(), null);
@@ -126,112 +95,4 @@
     }
     return out;
   }
-
-  // TODO(davido): Remove manual merging in follow-up change
-  private DiffPreferencesInfo merge(DiffPreferencesInfo n,
-      DiffPreferencesInfo i) {
-    if (i.context != null) {
-      n.context = i.context;
-    }
-    if (i.expandAllComments != null) {
-      n.expandAllComments = i.expandAllComments;
-    }
-    if (i.hideLineNumbers != null) {
-      n.hideLineNumbers = i.hideLineNumbers;
-    }
-    if (i.hideTopMenu != null) {
-      n.hideTopMenu = i.hideTopMenu;
-    }
-    if (i.ignoreWhitespace != null) {
-      n.ignoreWhitespace = i.ignoreWhitespace;
-    }
-    if (i.intralineDifference != null) {
-      n.intralineDifference = i.intralineDifference;
-    }
-    if (i.lineLength != null) {
-      n.lineLength = i.lineLength;
-    }
-    if (i.manualReview != null) {
-      n.manualReview = i.manualReview;
-    }
-    if (i.renderEntireFile != null) {
-      n.renderEntireFile = i.renderEntireFile;
-    }
-    if (i.retainHeader != null) {
-      n.retainHeader = i.retainHeader;
-    }
-    if (i.showLineEndings != null) {
-      n.showLineEndings = i.showLineEndings;
-    }
-    if (i.showTabs != null) {
-      n.showTabs = i.showTabs;
-    }
-    if (i.showWhitespaceErrors != null) {
-      n.showWhitespaceErrors = i.showWhitespaceErrors;
-    }
-    if (i.skipDeleted != null) {
-      n.skipDeleted = i.skipDeleted;
-    }
-    if (i.skipUncommented != null) {
-      n.skipUncommented = i.skipUncommented;
-    }
-    if (i.syntaxHighlighting != null) {
-      n.syntaxHighlighting = i.syntaxHighlighting;
-    }
-    if (i.tabSize != null) {
-      n.tabSize = i.tabSize;
-    }
-    if (i.theme != null) {
-      n.theme = i.theme;
-    }
-    if (i.hideEmptyPane != null) {
-      n.hideEmptyPane = i.hideEmptyPane;
-    }
-    if (i.autoHideDiffTableHeader != null) {
-      n.autoHideDiffTableHeader = i.autoHideDiffTableHeader;
-    }
-    return n;
-  }
-
-  private static AccountDiffPreference initAccountDiffPreferences(
-      AccountDiffPreference a, DiffPreferencesInfo i, Account.Id id) {
-    if (a == null) {
-      a = AccountDiffPreference.createDefault(id);
-    }
-    int context = i.context == null
-        ? DiffPreferencesInfo.DEFAULT_CONTEXT
-        :  i.context;
-    a.setContext((short)context);
-    a.setExpandAllComments(b(i.expandAllComments));
-    a.setHideLineNumbers(b(i.hideLineNumbers));
-    a.setHideTopMenu(b(i.hideTopMenu));
-    a.setIgnoreWhitespace(i.ignoreWhitespace == null
-        ? Whitespace.IGNORE_NONE
-        : Whitespace.forCode(
-            PatchListKey.WHITESPACE_TYPES.get(i.ignoreWhitespace)));
-    a.setIntralineDifference(b(i.intralineDifference));
-    a.setLineLength(i.lineLength == null
-        ? DiffPreferencesInfo.DEFAULT_LINE_LENGTH
-        : i.lineLength);
-    a.setManualReview(b(i.manualReview));
-    a.setRenderEntireFile(b(i.renderEntireFile));
-    a.setRetainHeader(b(i.retainHeader));
-    a.setShowLineEndings(b(i.showLineEndings));
-    a.setShowTabs(b(i.showTabs));
-    a.setShowWhitespaceErrors(b(i.showWhitespaceErrors));
-    a.setSkipDeleted(b(i.skipDeleted));
-    a.setSkipUncommented(b(i.skipUncommented));
-    a.setSyntaxHighlighting(b(i.syntaxHighlighting));
-    a.setTabSize(i.tabSize == null
-        ? DiffPreferencesInfo.DEFAULT_TAB_SIZE
-        : i.tabSize);
-    a.setTheme(i.theme);
-    a.setHideEmptyPane(b(i.hideEmptyPane));
-    a.setAutoHideDiffTableHeader(b(i.autoHideDiffTableHeader));
-    return a;
-  }
-
-  private static boolean b(Boolean b) {
-    return b == null ? false : b;
-  }
 }
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/SetPreferences.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/SetPreferences.java
index d355dae..569d128 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/account/SetPreferences.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/SetPreferences.java
@@ -80,7 +80,7 @@
   private final Provider<CurrentUser> self;
   private final AccountCache cache;
   private final Provider<ReviewDb> db;
-  private final MetaDataUpdate.User metaDataUpdateFactory;
+  private final Provider<MetaDataUpdate.User> metaDataUpdateFactory;
   private final AllUsersName allUsersName;
   private final DynamicMap<DownloadScheme> downloadSchemes;
 
@@ -88,7 +88,7 @@
   SetPreferences(Provider<CurrentUser> self,
       AccountCache cache,
       Provider<ReviewDb> db,
-      MetaDataUpdate.User metaDataUpdateFactory,
+      Provider<MetaDataUpdate.User> metaDataUpdateFactory,
       AllUsersName allUsersName,
       DynamicMap<DownloadScheme> downloadSchemes) {
     this.self = self;
@@ -114,7 +114,7 @@
     Account.Id accountId = rsrc.getUser().getAccountId();
     AccountGeneralPreferences p;
     VersionedAccountPreferences versionedPrefs;
-    MetaDataUpdate md = metaDataUpdateFactory.create(allUsersName);
+    MetaDataUpdate md = metaDataUpdateFactory.get().create(allUsersName);
     db.get().accounts().beginTransaction(accountId);
     try {
       Account a = db.get().accounts().get(accountId);
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/args4j/AccountGroupUUIDHandler.java b/gerrit-server/src/main/java/com/google/gerrit/server/args4j/AccountGroupUUIDHandler.java
index 406ca58..674fe08 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/args4j/AccountGroupUUIDHandler.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/args4j/AccountGroupUUIDHandler.java
@@ -43,7 +43,7 @@
   public final int parseArguments(final Parameters params)
       throws CmdLineException {
     final String n = params.getParameter(0);
-    final GroupReference group = GroupBackends.findBestSuggestion(groupBackend, n);
+    GroupReference group = GroupBackends.findExactSuggestion(groupBackend, n);
     if (group == null) {
       throw new CmdLineException(owner, "Group \"" + n + "\" does not exist");
     }
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/AsyncReceiveCommits.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/AsyncReceiveCommits.java
index 5952568..899b06a 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/git/AsyncReceiveCommits.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/AsyncReceiveCommits.java
@@ -72,7 +72,7 @@
     long getTimeoutMillis(@GerritServerConfig final Config cfg) {
       return ConfigUtil.getTimeUnit(
           cfg, "receive", null, "timeout",
-          TimeUnit.MINUTES.toMillis(2),
+          TimeUnit.MINUTES.toMillis(4),
           TimeUnit.MILLISECONDS);
     }
   }
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/SchemaVersion.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/SchemaVersion.java
index 1c29988..27df9a5c 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/SchemaVersion.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/SchemaVersion.java
@@ -32,7 +32,7 @@
 /** A version of the database schema. */
 public abstract class SchemaVersion {
   /** The current schema version. */
-  public static final Class<Schema_114> C = Schema_114.class;
+  public static final Class<Schema_115> C = Schema_115.class;
 
   public static int getBinaryVersion() {
     return guessVersion(C);
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_115.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_115.java
new file mode 100644
index 0000000..920160b
--- /dev/null
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_115.java
@@ -0,0 +1,178 @@
+// Copyright (C) 2015 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.schema;
+
+import static com.google.gerrit.server.config.ConfigUtil.storeSection;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import com.google.gerrit.extensions.client.DiffPreferencesInfo;
+import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace;
+import com.google.gerrit.extensions.client.Theme;
+import com.google.gerrit.reviewdb.client.Account;
+import com.google.gerrit.reviewdb.server.ReviewDb;
+import com.google.gerrit.server.GerritPersonIdent;
+import com.google.gerrit.server.account.VersionedAccountPreferences;
+import com.google.gerrit.server.config.AllUsersName;
+import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
+import com.google.gerrit.server.git.GitRepositoryManager;
+import com.google.gerrit.server.git.MetaDataUpdate;
+import com.google.gerrit.server.git.UserConfigSections;
+import com.google.gerrit.server.patch.PatchListKey;
+import com.google.gwtorm.jdbc.JdbcSchema;
+import com.google.gwtorm.server.OrmException;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+import org.eclipse.jgit.errors.ConfigInvalidException;
+import org.eclipse.jgit.lib.BatchRefUpdate;
+import org.eclipse.jgit.lib.NullProgressMonitor;
+import org.eclipse.jgit.lib.PersonIdent;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevWalk;
+
+import java.io.IOException;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Schema_115 extends SchemaVersion {
+  private final GitRepositoryManager mgr;
+  private final AllUsersName allUsersName;
+  private final PersonIdent serverUser;
+
+  @Inject
+  Schema_115(Provider<Schema_114> prior,
+      GitRepositoryManager mgr,
+      AllUsersName allUsersName,
+      @GerritPersonIdent PersonIdent serverUser) {
+    super(prior);
+    this.mgr = mgr;
+    this.allUsersName = allUsersName;
+    this.serverUser = serverUser;
+  }
+
+  @Override
+  protected void migrateData(ReviewDb db, UpdateUI ui)
+      throws OrmException, SQLException {
+    Map<Account.Id, DiffPreferencesInfo> imports = new HashMap<>();
+    try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
+        ResultSet rs = stmt.executeQuery(
+          "SELECT "
+          + "id, "
+          + "context, "
+          + "expand_all_comments, "
+          + "hide_line_numbers, "
+          + "hide_top_menu, "
+          + "ignore_whitespace, "
+          + "intraline_difference, "
+          + "line_length, "
+          + "manual_review, "
+          + "render_entire_file, "
+          + "retain_header, "
+          + "show_line_endings, "
+          + "show_tabs, "
+          + "show_whitespace_errors, "
+          + "skip_deleted, "
+          + "skip_uncommented, "
+          + "syntax_highlighting, "
+          + "tab_size, "
+          + "theme, "
+          + "hide_empty_pane, "
+          + "auto_hide_diff_table_header "
+          + "FROM account_diff_preferences")) {
+        while (rs.next()) {
+          Account.Id accountId = new Account.Id(rs.getInt(1));
+          DiffPreferencesInfo prefs = new DiffPreferencesInfo();
+          prefs.context = (int)rs.getShort(2);
+          prefs.expandAllComments = toBoolean(rs.getString(3));
+          prefs.hideLineNumbers = toBoolean(rs.getString(4));
+          prefs.hideTopMenu = toBoolean(rs.getString(5));
+          // Enum with char as value
+          prefs.ignoreWhitespace = toWhitespace(rs.getString(6));
+          prefs.intralineDifference = toBoolean(rs.getString(7));
+          prefs.lineLength = rs.getInt(8);
+          prefs.manualReview = toBoolean(rs.getString(9));
+          prefs.renderEntireFile = toBoolean(rs.getString(10));
+          prefs.retainHeader = toBoolean(rs.getString(11));
+          prefs.showLineEndings = toBoolean(rs.getString(12));
+          prefs.showTabs = toBoolean(rs.getString(13));
+          prefs.showWhitespaceErrors = toBoolean(rs.getString(14));
+          prefs.skipDeleted = toBoolean(rs.getString(15));
+          prefs.skipUncommented = toBoolean(rs.getString(16));
+          prefs.syntaxHighlighting = toBoolean(rs.getString(17));
+          prefs.tabSize = rs.getInt(18);
+          // Enum with name as values; can be null
+          prefs.theme = toTheme(rs.getString(19));
+          prefs.hideEmptyPane = toBoolean(rs.getString(20));
+          prefs.autoHideDiffTableHeader = toBoolean(rs.getString(21));
+          imports.put(accountId, prefs);
+        }
+    }
+
+    if (imports.isEmpty()) {
+      return;
+    }
+
+    try (Repository git = mgr.openRepository(allUsersName);
+        RevWalk rw = new RevWalk(git)) {
+      BatchRefUpdate bru = git.getRefDatabase().newBatchUpdate();
+      MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED,
+          allUsersName, git, bru);
+      md.getCommitBuilder().setAuthor(serverUser);
+      md.getCommitBuilder().setCommitter(serverUser);
+
+      for (Map.Entry<Account.Id, DiffPreferencesInfo> e : imports.entrySet()) {
+        VersionedAccountPreferences p =
+            VersionedAccountPreferences.forUser(e.getKey());
+        p.load(md);
+        storeSection(p.getConfig(), UserConfigSections.DIFF, null,
+            e.getValue(), DiffPreferencesInfo.defaults());
+        p.commit(md);
+      }
+
+      bru.execute(rw, NullProgressMonitor.INSTANCE);
+    } catch (ConfigInvalidException | IOException ex) {
+      throw new OrmException(ex);
+    }
+  }
+
+  private static Theme toTheme(String v) {
+    if (v == null) {
+      return Theme.DEFAULT;
+    }
+    return Theme.valueOf(v);
+  }
+
+  private static Whitespace toWhitespace(String v) {
+    Preconditions.checkNotNull(v);
+    if (v.isEmpty()) {
+      return Whitespace.IGNORE_NONE;
+    }
+    Whitespace r = PatchListKey.WHITESPACE_TYPES.inverse().get(v.charAt(0));
+    if (r == null) {
+      throw new IllegalArgumentException("Cannot find Whitespace type for: "
+          + v);
+    }
+    return r;
+  }
+
+  private static boolean toBoolean(String v) {
+    Preconditions.checkState(!Strings.isNullOrEmpty(v));
+    return v.equals("Y");
+  }
+}
diff --git a/gerrit-server/src/test/java/com/google/gerrit/testutil/DisabledReviewDb.java b/gerrit-server/src/test/java/com/google/gerrit/testutil/DisabledReviewDb.java
index 9acae6d..c526cea 100644
--- a/gerrit-server/src/test/java/com/google/gerrit/testutil/DisabledReviewDb.java
+++ b/gerrit-server/src/test/java/com/google/gerrit/testutil/DisabledReviewDb.java
@@ -15,7 +15,6 @@
 package com.google.gerrit.testutil;
 
 import com.google.gerrit.reviewdb.server.AccountAccess;
-import com.google.gerrit.reviewdb.server.AccountDiffPreferenceAccess;
 import com.google.gerrit.reviewdb.server.AccountExternalIdAccess;
 import com.google.gerrit.reviewdb.server.AccountGroupAccess;
 import com.google.gerrit.reviewdb.server.AccountGroupByIdAccess;
@@ -125,11 +124,6 @@
   }
 
   @Override
-  public AccountDiffPreferenceAccess accountDiffPreferences() {
-    throw new Disabled();
-  }
-
-  @Override
   public StarredChangeAccess starredChanges() {
     throw new Disabled();
   }
diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/CommandExecutorQueueProvider.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/CommandExecutorQueueProvider.java
index bafb9ee..f78aba4 100644
--- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/CommandExecutorQueueProvider.java
+++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/CommandExecutorQueueProvider.java
@@ -35,7 +35,7 @@
       final WorkQueue queues) {
     final int cores = Runtime.getRuntime().availableProcessors();
     poolSize = config.getInt("sshd", "threads", 3 * cores / 2);
-    batchThreads = config.getInt("sshd", "batchThreads", 0);
+    batchThreads = config.getInt("sshd", "batchThreads", cores == 1 ? 1 : 2);
     if (batchThreads > poolSize) {
       poolSize += batchThreads;
     }
diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/StreamEvents.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/StreamEvents.java
index 3f7914e..379f1b9 100644
--- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/StreamEvents.java
+++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/StreamEvents.java
@@ -95,6 +95,11 @@
     public void cancel() {
       onExit(0);
     }
+
+    @Override
+    public String toString() {
+      return "Stream Events (" + currentUser.getAccount().getUserName() + ")";
+    }
   };
 
   /** True if {@link #droppedOutputEvent} needs to be sent. */
diff --git a/gerrit-war/BUCK b/gerrit-war/BUCK
index 27b1f4a..d5c85ad 100644
--- a/gerrit-war/BUCK
+++ b/gerrit-war/BUCK
@@ -38,7 +38,6 @@
   name = 'webapp_assets',
   cmd = 'cd src/main/webapp; zip -qr $OUT .',
   srcs = glob(['src/main/webapp/**/*']),
-  deps = [],
   out = 'webapp_assets.zip',
   visibility = ['//:'],
 )
diff --git a/lib/bouncycastle/BUCK b/lib/bouncycastle/BUCK
index 0ce5817..21e6120 100644
--- a/lib/bouncycastle/BUCK
+++ b/lib/bouncycastle/BUCK
@@ -8,6 +8,7 @@
   name = 'bcprov',
   id = 'org.bouncycastle:bcprov-jdk15on:' + VERSION,
   sha1 = '88a941faf9819d371e3174b5ed56a3f3f7d73269',
+  unsign = True,
   license = 'DO_NOT_DISTRIBUTE', #'bouncycastle'
 )
 
@@ -23,6 +24,7 @@
   name = 'bcpkix',
   id = 'org.bouncycastle:bcpkix-jdk15on:' + VERSION,
   sha1 = 'b8ffac2bbc6626f86909589c8cc63637cc936504',
+  unsign = True,
   license = 'DO_NOT_DISTRIBUTE', #'bouncycastle'
   deps = [':bcprov'],
 )
diff --git a/lib/log/BUCK b/lib/log/BUCK
index b332f20..a5201f3 100644
--- a/lib/log/BUCK
+++ b/lib/log/BUCK
@@ -10,6 +10,14 @@
 )
 
 maven_jar(
+  name = 'nop',
+  id = 'org.slf4j:slf4j-nop:' + VER,
+  sha1 = '6cca9a3b999ff28b7a35ca762b3197cd7e4c2ad1',
+  license = 'slf4j',
+  deps = [':api'],
+)
+
+maven_jar(
   name = 'impl_log4j',
   id = 'org.slf4j:slf4j-log4j12:' + VER,
   sha1 = '58f588119ffd1702c77ccab6acb54bfb41bed8bd',
diff --git a/tools/BUCK b/tools/BUCK
index e311ff8..489dffc 100644
--- a/tools/BUCK
+++ b/tools/BUCK
@@ -45,7 +45,6 @@
   name = 'buck',
   cmd = 'echo buck=`which buck`>$OUT;' +
     ("echo PATH=\''%s'\' >>$OUT;" % shquote(os_path())),
-  deps = [],
   out = 'buck.properties',
   visibility = ['PUBLIC'],
 )