rebase: rework extrafn handling to support multiple extrafns

This makes it possible to pass keepbranches and extrafn to rebase at
the same time, although nobody uses that functionality presently. This
is a precursor to keeping graft metadata.
rebase: preserve metadata from grafts of changes (issue4001)