This can be overriden by a new --force flag.
Signed-off-by: Yann Dirson <ydirson@altern.org>
patchname = '%s-%d' % (patchname, suffix)
return patchname
-def prepare_rebase():
+def prepare_rebase(real_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:
action = 'store_true'),
make_option('-m', '--merged',
help = 'check for patches merged upstream',
+ action = 'store_true'),
+ make_option('--force',
+ help = 'force rebase even if the stack based was moved by (un)commits',
action = 'store_true')]
def func(parser, options, args):
check_conflicts()
check_head_top_equal()
- applied = prepare_rebase()
+ must_rebase = (config.get('stgit.pull-does-rebase') == 'yes')
+ applied = prepare_rebase(real_rebase=must_rebase, force=options.force)
# pull the remote changes
print 'Pulling from "%s"...' % repository
git.fetch(repository)
- if (config.get('stgit.pull-does-rebase') == 'yes'):
+ if must_rebase:
rebase(git.fetch_head())
post_rebase(applied, options.nopush, options.merged)
action = 'store_true'),
make_option('-m', '--merged',
help = 'check for patches merged upstream',
+ action = 'store_true'),
+ make_option('--force',
+ help = 'force rebase even if the stack based was moved by (un)commits',
action = 'store_true')]
def func(parser, options, args):
check_conflicts()
check_head_top_equal()
- applied = prepare_rebase()
+ applied = prepare_rebase(real_rebase=True, force=options.force)
rebase(args[0])
post_rebase(applied, options.nopush, options.merged)