suffix += 1
patchname = '%s-%d' % (patchname, suffix)
return patchname
+
+def prepare_rebase():
+ # pop all patches
+ applied = crt_series.get_applied()
+ if len(applied) > 0:
+ print 'Popping all applied patches...',
+ sys.stdout.flush()
+ crt_series.pop_patch(applied[0])
+ print 'done'
+ return applied
+
+def rebase(target):
+ if target == git.get_head():
+ print 'Already at "%s", no need for rebasing.' % target
+ return
+
+ print 'Rebasing to "%s"...' % target
+ git.reset(tree_id = git_id(target))
+
+def post_rebase(applied, nopush, merged):
+ # push the patches back
+ if not nopush:
+ push_patches(applied, merged)
check_conflicts()
check_head_top_equal()
- # pop all patches
- applied = crt_series.get_applied()
- if len(applied) > 0:
- print 'Popping all applied patches...',
- sys.stdout.flush()
- crt_series.pop_patch(applied[0])
- print 'done'
+ applied = prepare_rebase()
# pull the remote changes
print 'Pulling from "%s"...' % repository
git.fetch(repository)
if (config.get('stgit.pull-does-rebase') == 'yes'):
- fetch_head = git.fetch_head()
- if fetch_head != git.get_head():
- print 'rebasing to "%s"...' % fetch_head
- git.reset(tree_id = fetch_head)
- print 'done'
-
- # push the patches back
- if not options.nopush:
- push_patches(applied, options.merged)
+ rebase(git.fetch_head())
+
+ post_rebase(applied, options.nopush, options.merged)
# maybe tidy up
if config.get('stgit.keepoptimized') == 'yes':
check_conflicts()
check_head_top_equal()
- # pop all patches
- applied = crt_series.get_applied()
- if len(applied) > 0:
- print 'Popping all applied patches...',
- sys.stdout.flush()
- crt_series.pop_patch(applied[0])
- print 'done'
-
- print 'Rebasing to "%s"...' % args[0]
- git.reset(tree_id = git_id(args[0]))
-
- # push the patches back
- if not options.nopush:
- push_patches(applied, options.merged)
+ applied = prepare_rebase()
+ rebase(args[0])
+ post_rebase(applied, options.nopush, options.merged)
print_crt_patch()