Sync from internal version:
          - packed repeated field support
          - more useful ErrRequiredNotSet
          - decoding simplification using append

R=r
CC=golang-dev
http://codereview.appspot.com/3337042
diff --git a/compiler/generator/generator.go b/compiler/generator/generator.go
index 9b34ad1..1a7ba8f 100644
--- a/compiler/generator/generator.go
+++ b/compiler/generator/generator.go
@@ -720,6 +720,7 @@
 //	wire encoding
 //	protocol tag number
 //	opt,req,rep for optional, required, or repeated
+//	packed whether the encoding is "packed" (optional; repeated primitives only)
 //	name= the original declared name
 //	enum= the name of the enum type if it is an enum-typed field.
 //	def= string representation of the default value, if any.
@@ -766,16 +767,21 @@
 		obj := g.ObjectNamed(proto.GetString(field.TypeName))
 		enum = ",enum=" + obj.PackageName() + "." + CamelCaseSlice(obj.TypeName())
 	}
+	packed := ""
+	if field.Options != nil && proto.GetBool(field.Options.Packed) {
+		packed = ",packed"
+	}
 	name := proto.GetString(field.Name)
 	if name == CamelCase(name) {
 		name = ""
 	} else {
 		name = ",name=" + name
 	}
-	return Quote(fmt.Sprintf("PB(%s,%d,%s%s%s%s)",
+	return Quote(fmt.Sprintf("PB(%s,%d,%s%s%s%s%s)",
 		wiretype,
 		proto.GetInt32(field.Number),
 		optrepreq,
+		packed,
 		name,
 		enum,
 		defaultValue))
diff --git a/compiler/testdata/test.pb.go.golden b/compiler/testdata/test.pb.go.golden
index 7860352..eb91210 100644
--- a/compiler/testdata/test.pb.go.golden
+++ b/compiler/testdata/test.pb.go.golden
@@ -104,6 +104,7 @@
 
 type Reply struct {
 	Found	[]*Reply_Entry	"PB(bytes,1,rep,name=found)"
+	CompactKeys	[]int32	"PB(varint,2,rep,packed,name=compact_keys)"
 	XXX_extensions		map[int32][]byte
 	XXX_unrecognized	[]byte
 }
diff --git a/compiler/testdata/test.proto b/compiler/testdata/test.proto
index dc323b8..b63658b 100644
--- a/compiler/testdata/test.proto
+++ b/compiler/testdata/test.proto
@@ -70,6 +70,7 @@
     }
   }
   repeated Entry found = 1;
+  repeated int32 compact_keys = 2 [packed=true];
   extensions 100 to max;
 }