anchor.diff:                                         occurrence=required, opts=[]}]},
                       {{msg,t2}, [#field{name=b, fnum=1, type=uint32,
                                          occurrence=required, opts=[]}]}]).
  +
  +merge_msg_test() ->
  +    {m1, [{a, 20},
  +          {b, 22},
  +          {c, 13},
  +          {d, [11,12, 21,22]},
  +          {e, {m2, [{x, 210},
  +                    {y, [111,112, 211,212]}]}}]} =
  +        merge_msgs({m1, [{a, 10},
  +                         {b, undefined},
  +                         {c, 13},
  +                         {d, [11,12]},
  +                         {e, {m2, [{x, 110},
  +                                   {y, [111, 112]}]}}]},
  +                   {m1, [{a, 20},             %% overwrites integers
  +                         {b, 22},             %% overwrites undefined
  +                         {c, undefined},      %% undefined does not overwrite
  +                         {d, [21,22]},        %% sequences appends
  +                         {e, {m2, [{x, 210},  %% merging recursively
  +                                   {y, [211, 212]}]}}]},
  +                   [{{msg,m1}, [#field{name=a,fnum=1, type=uint32,
  +                                       occurrence=required, opts=[]},
  +                                #field{name=b,fnum=2, type=uint32,
  +                                       occurrence=optional, opts=[]},
  +                                #field{name=c,fnum=3, type=uint32,
  +                                       occurrence=optional, opts=[]},
  +                                #field{name=d,fnum=4, type=uint32,
  +                                       occurrence=repeated, opts=[]},
  +                                #field{name=e,fnum=5, type={msg,m2},
  +                                       occurrence=optional, opts=[]}]},
  +                    {{msg,m2}, [#field{name=x, fnum=1, type=uint32,
  +                                       occurrence=optional, opts=[]},
  +                                #field{name=y, fnum=w, type=uint32,
  +                                       occurrence=repeated, opts=[]}]}]).
  
positive.code:         undefined ->
              replace_field(FName, NewMsg, Fields);
          {FMsgName, _PrevFields} = PrevMsg ->
              MergedMsg = merge_msg(PrevMsg, NewMsg, MsgDefs),
              replace_field(FName, MergedMsg, Fields)
      end.
  
  merge_msg({MsgName, PrevFields}, {MsgName, NewFields}, MsgDefs) ->
      MsgDef = keyfetch({msg,MsgName}, MsgDefs),
      {MsgName,
       lists:foldl(
  
negative.code:     replace_field(FName, [NewElem | PrevElems], Fields).
  
  append_seqs(Seq1, Seq2) ->
      Seq1 ++ Seq2.
  
  
  decode_varint(Bin) -> de_vi(Bin, 0, 0).
  