from stgit.commands.common import *
from stgit.utils import *
+from stgit.out import *
from stgit.config import GitConfigException
from stgit import stack, git
Check the 'git fetch' documentation for the <repository> format."""
+directory = DirectoryHasRepository()
options = [make_option('-n', '--nopush',
help = 'do not push the patches back after pulling',
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):
"""Pull the changes from a remote repository
"""
- policy = config.get('branch.%s.stgit.pull-policy' % crt_series.get_branch()) or \
+ policy = config.get('branch.%s.stgit.pull-policy' % crt_series.get_name()) or \
config.get('stgit.pull-policy')
if policy == 'rebase':
check_conflicts()
check_head_top_equal()
- if policy == 'pull':
- must_rebase = 0
- elif policy == 'fetch-rebase':
- must_rebase = 1
- elif policy == 'rebase':
- must_rebase = 1
- else:
+ if policy not in ['pull', 'fetch-rebase', 'rebase']:
raise GitConfigException, 'Unsupported pull-policy "%s"' % policy
- applied = prepare_rebase(real_rebase=must_rebase, force=options.force)
+ applied = prepare_rebase()
# pull the remote changes
if policy == 'pull':
- print 'Pulling from "%s"...' % repository
+ out.info('Pulling from "%s"' % repository)
git.pull(repository)
elif policy == 'fetch-rebase':
- print 'Fetching from "%s"...' % repository
+ out.info('Fetching from "%s"' % repository)
git.fetch(repository)
- rebase(git.fetch_head())
+ 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())