##// END OF EJS Templates
histedit: break _histedit function into smaller pieces...
Kostia Balytskyi -
r28134:df206e03 default
parent child Browse files
Show More
@@ -982,7 +982,16 b' def histedit(ui, repo, *freeargs, **opts'
982 finally:
982 finally:
983 release(state.lock, state.wlock)
983 release(state.lock, state.wlock)
984
984
985 def _histedit(ui, repo, state, *freeargs, **opts):
985 def _getgoal(opts):
986 if opts.get('continue'):
987 return 'continue'
988 if opts.get('abort'):
989 return 'abort'
990 if opts.get('edit_plan'):
991 return 'edit-plan'
992 return 'new'
993
994 def _validateargs(ui, repo, state, freeargs, opts, goal, rules, revs):
986 # TODO only abort if we try to histedit mq patches, not just
995 # TODO only abort if we try to histedit mq patches, not just
987 # blanket if mq patches are applied somewhere
996 # blanket if mq patches are applied somewhere
988 mq = getattr(repo, 'mq', None)
997 mq = getattr(repo, 'mq', None)
@@ -991,28 +1000,21 b' def _histedit(ui, repo, state, *freeargs'
991
1000
992 # basic argument incompatibility processing
1001 # basic argument incompatibility processing
993 outg = opts.get('outgoing')
1002 outg = opts.get('outgoing')
994 cont = opts.get('continue')
995 editplan = opts.get('edit_plan')
1003 editplan = opts.get('edit_plan')
996 abort = opts.get('abort')
1004 abort = opts.get('abort')
997 force = opts.get('force')
1005 force = opts.get('force')
998 rules = opts.get('commands', '')
999 revs = opts.get('rev', [])
1000 goal = 'new' # This invocation goal, in new, continue, abort
1001 if force and not outg:
1006 if force and not outg:
1002 raise error.Abort(_('--force only allowed with --outgoing'))
1007 raise error.Abort(_('--force only allowed with --outgoing'))
1003 if cont:
1008 if goal == 'continue':
1004 if any((outg, abort, revs, freeargs, rules, editplan)):
1009 if any((outg, abort, revs, freeargs, rules, editplan)):
1005 raise error.Abort(_('no arguments allowed with --continue'))
1010 raise error.Abort(_('no arguments allowed with --continue'))
1006 goal = 'continue'
1011 elif goal == 'abort':
1007 elif abort:
1008 if any((outg, revs, freeargs, rules, editplan)):
1012 if any((outg, revs, freeargs, rules, editplan)):
1009 raise error.Abort(_('no arguments allowed with --abort'))
1013 raise error.Abort(_('no arguments allowed with --abort'))
1010 goal = 'abort'
1014 elif goal == 'edit-plan':
1011 elif editplan:
1012 if any((outg, revs, freeargs)):
1015 if any((outg, revs, freeargs)):
1013 raise error.Abort(_('only --commands argument allowed with '
1016 raise error.Abort(_('only --commands argument allowed with '
1014 '--edit-plan'))
1017 '--edit-plan'))
1015 goal = 'edit-plan'
1016 else:
1018 else:
1017 if os.path.exists(os.path.join(repo.path, 'histedit-state')):
1019 if os.path.exists(os.path.join(repo.path, 'histedit-state')):
1018 raise error.Abort(_('history edit already in progress, try '
1020 raise error.Abort(_('history edit already in progress, try '
@@ -1034,8 +1036,13 b' def _histedit(ui, repo, state, *freeargs'
1034 raise error.Abort(
1036 raise error.Abort(
1035 _('histedit requires exactly one ancestor revision'))
1037 _('histedit requires exactly one ancestor revision'))
1036
1038
1039 def _histedit(ui, repo, state, *freeargs, **opts):
1040 goal = _getgoal(opts)
1041 revs = opts.get('rev', [])
1042 rules = opts.get('commands', '')
1043 state.keep = opts.get('keep', False)
1037
1044
1038 state.keep = opts.get('keep', False)
1045 _validateargs(ui, repo, state, freeargs, opts, goal, rules, revs)
1039
1046
1040 # rebuild state
1047 # rebuild state
1041 if goal == 'continue':
1048 if goal == 'continue':
General Comments 0
You need to be logged in to leave comments. Login now