Serialize TagSetHolder with protobuf

TagSetHolder and TagSet have some slightly exotic properties:
  * A subclass of AtomicReference<ObjectId> with additional fields,
    CachedRef.
  * An ObjectIdOwnerMap, which requires a custom subclass of ObjectId
    with additional fields.
  * BitSets.
  * Volatile field references.

However, it still boils down to collections of value types, so the
resulting TagSetProto structure is pretty straightforward.

The most annoying thing is that the AtomicReference and ObjectId
subclasses can't reasonably implement equals(), so the tests need to
have more detailed assertions which reach into what would otherwise be
private fields.

While we're in there, eliminate the intermediate EntryVal class, which
was serving no purpose other than to hold the readObject/writeObject
methods for Java serialization.

It is quite possible that this change will be slower to deserialize than
using Java serialization, since it was previously able to directly
deserialize the internal data structures, whereas we now have to build
these structures piece by piece. However, as with the rest of the
serialization code, we assume that proto is good enough until proven
otherwise.

Beyond that, we don't attempt to further rework the tag cache types or
the cache as a whole. In particular:
  * Continue to use volatile types to handle incrementally updating
    specific cache entries.
  * Using composition instead of inheritance for CachedRef is out of
    scope. However, note that using protobuf for serialization means
    that we can make this change without flushing the cache.
  * Using a less exotic type than ObjectIdOwnerMap would probably
    require some benchmarking to prove that it's worth making the
    change.

Change-Id: I08623b3f51ef1a0541559bbb2360c0d06a9de9d4
diff --git a/proto/cache.proto b/proto/cache.proto
index a826f8c..33f9143 100644
--- a/proto/cache.proto
+++ b/proto/cache.proto
@@ -193,3 +193,29 @@
   string submit_type = 3;
   bool content_merge = 4;
 }
+
+// Serialized form of com.google.gerrit.server.query.git.TagSetHolder.
+// Next ID: 3
+message TagSetHolderProto {
+  string project_name = 1;
+
+  // Next ID: 4
+  message TagSetProto {
+    string project_name = 1;
+
+    // Next ID: 3
+    message CachedRefProto {
+      bytes id = 1;
+      int32 flag = 2;
+    }
+    map<string, CachedRefProto> ref = 2;
+
+    // Next ID: 3
+    message TagProto {
+      bytes id = 1;
+      bytes flags = 2;
+    }
+    repeated TagProto tag = 3;
+  }
+  TagSetProto tags = 2;
+}