tag: factor out contains traversal

Other "--contains" traversals can benefit from the same
speedups that "tag --contains" has received. This code was
not originally made generically available because it has
some gross corners that make it easy to use it in a wrong or
unsafe way. This patch moves the code to commit.[ch] and
attempts to clean up those corners. Specifically:

  1. The "contains" function is renamed to "commit_contains",
     to more clearly indicate what it does.

  2. The original calling convention was to simply call
     "contains", which would magically cache intermediate
     results in the object flag bits. Now there are "start"
     and "finish" functions, which make it more clear that
     multiple invocations of "contains" inside a
     start/finish pair affect each other.

  3. From a modularity standpoint, these functions would
     ideally operate on a "struct contains_context" which
     contained the intermediate state. But like most
     traversals, we keep our state in the global commit
     object flags, which means we can only run one
     "contains" traversal at a time.  Therefore, the start
     function will notice and abort when a second
     simultaneous traversal is begun.

  4. The cached state reflects the results for a particular
     set of needle commits. With the original interface,
     there was nothing to prevent calling "contains" with a
     new set of needles, which would produce incoherent
     results. Now, the needles are provided once by the
     start function (which, as noted above, will die if
     invoked twice without an intervening finish).

  5. The original implementation abused UNINTERESTING and
     TMP_MARK. Instead, we define new flags to avoid
     conflict with existing revision flags.

  6. The original implementation just left the global object
     flags smudged. This is OK for "tag --contains", but not
     for general use. The "finish" function now clears our
     object flags after use.
wip