This code is quite specific and we are about to add more of it for revlog-v2
(and other derived version). So we move this code in a dedicated module in
mercurial/revlogutils/. This looks like a good fit.
The diff is huge because I used hg copy to create the new file so that we keep
the history of the censor code.