+ def __address_or_alias(addr):
+ if not addr:
+ return None
+ if addr.find('@') >= 0:
+ # it's an e-mail address
+ return addr
+ alias = config.get('mail.alias.'+addr)
+ if alias:
+ # it's an alias
+ return alias
+ raise CmdException, 'unknown e-mail alias: %s' % addr
+
+ addr_list = [__address_or_alias(addr.strip())
+ for addr in addr_str.split(',')]
+ return ', '.join([addr for addr in addr_list if addr])
+
+def prepare_rebase(force=None):
+ if not force:
+ # Be sure we won't loose results of stg-(un)commit by error.
+ # Do not require an existing orig-base for compatibility with 0.12 and earlier.
+ origbase = crt_series._get_field('orig-base')
+ if origbase and crt_series.get_base() != origbase:
+ raise CmdException, 'Rebasing would possibly lose data'
+
+ # pop all patches
+ applied = crt_series.get_applied()
+ if len(applied) > 0:
+ out.start('Popping all applied patches')
+ crt_series.pop_patch(applied[0])
+ out.done()
+ return applied
+
+def rebase(target):
+ if target == git.get_head():
+ out.info('Already at "%s", no need for rebasing.' % target)
+ return
+ out.start('Rebasing to "%s"' % target)
+ git.reset(tree_id = git_id(target))
+ out.done()
+
+def post_rebase(applied, nopush, merged):
+ # memorize that we rebased to here
+ crt_series._set_field('orig-base', git.get_head())
+ # push the patches back
+ if not nopush:
+ push_patches(applied, merged)