With comm (and sort) you can select lines that are common, a only, b only in any combination with tab markers of which is which.
Man Page for comm (opensolaris Section 1) - The UNIX and Linux Forums Think of the files as sets of lines, and comm can tell you, for files sorted unique, what is a not b, a and b or b not a.
Now, if there is a multilevel structure within the file, you need to preprocess it so detail lines have category prefixes, like "# R:" above. If order is important after "# R:", you need to number the lines in each group, but that will accentuate minor differences.
Diff can process two files for differences and provides options for several flavors of output. There is even a diff3 so if you have a common starting point and files 2 developers made from it, you can merge their changes using the -e output into ex, to make the fourth corner. Of course, if they changed the same lines, it has more trouble -- time to have a local coding standard or a diff-friendly code beautifier.