The first patch just refactor some functions in order to have a more clean rebase.py. The second one instead adds an option that allows to detach part of a branch during a rebase. This option was required in issue1950.