- print 'Pulling from "%s"...' % location
- git.pull(location, options.head, options.tag)
- print 'done'
-
- # push the patches back
- if options.nopush:
- applied = []
- for p in applied:
- print 'Pushing patch "%s"...' % p,
- sys.stdout.flush()
- crt_series.push_patch(p)
- if crt_series.empty_patch(p):
- print 'done (empty patch)'
- else:
- print 'done'
+ if policy == 'pull':
+ out.info('Pulling from "%s"' % repository)
+ git.pull(repository)
+ elif policy == 'fetch-rebase':
+ out.info('Fetching from "%s"' % repository)
+ git.fetch(repository)
+ try:
+ target = git.fetch_head()
+ except git.GitException:
+ out.error('Could not find the remote head to rebase onto, pushing any patches back...')
+ post_rebase(applied, False, False)
+ raise CmdException, 'Could not find the remote head to rebase onto - fix branch.%s.merge in .git/config' % crt_series.get_name()
+
+ rebase(target)
+ elif policy == 'rebase':
+ rebase(crt_series.get_parent_branch())
+
+ post_rebase(applied, options.nopush, options.merged)
+
+ # maybe tidy up
+ if config.get('stgit.keepoptimized') == 'yes':
+ git.repack()