topic: implement dirstate.topic() and dirstate.tns()
The implementations closely follow the implementation of dirstate.branch(),
including dirstate.setbranch(), from before a6e0b7d4ae9d. So far in this patch
we don't write topics or topic namespaces in a transaction. But we do have tr
argument in settopic() and settns() because it's easier to introduce it now
(even though it's simply ignored).
Also because of the branch implementation in core, topic and tns values on disk now have a '\n' character at the end.