##// END OF EJS Templates
histedit: break _histedit function into smaller pieces (add _newaction)...
Kostia Balytskyi -
r28132:2d09a400 default
parent child Browse files
Show More
@@ -1035,7 +1035,6 b' def _histedit(ui, repo, state, *freeargs'
1035 _('histedit requires exactly one ancestor revision'))
1035 _('histedit requires exactly one ancestor revision'))
1036
1036
1037
1037
1038 replacements = []
1039 state.keep = opts.get('keep', False)
1038 state.keep = opts.get('keep', False)
1040 supportsmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt)
1039 supportsmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt)
1041
1040
@@ -1050,56 +1049,7 b' def _histedit(ui, repo, state, *freeargs'
1050 _abortaction(ui, repo, state)
1049 _abortaction(ui, repo, state)
1051 return
1050 return
1052 else:
1051 else:
1053 cmdutil.checkunfinished(repo)
1052 _newaction(ui, repo, state, revs, freeargs, opts)
1054 cmdutil.bailifchanged(repo)
1055
1056 topmost, empty = repo.dirstate.parents()
1057 if outg:
1058 if freeargs:
1059 remote = freeargs[0]
1060 else:
1061 remote = None
1062 root = findoutgoing(ui, repo, remote, force, opts)
1063 else:
1064 rr = list(repo.set('roots(%ld)', scmutil.revrange(repo, revs)))
1065 if len(rr) != 1:
1066 raise error.Abort(_('The specified revisions must have '
1067 'exactly one common root'))
1068 root = rr[0].node()
1069
1070 revs = between(repo, root, topmost, state.keep)
1071 if not revs:
1072 raise error.Abort(_('%s is not an ancestor of working directory') %
1073 node.short(root))
1074
1075 ctxs = [repo[r] for r in revs]
1076 if not rules:
1077 comment = geteditcomment(node.short(root), node.short(topmost))
1078 actions = [pick(state, r) for r in revs]
1079 rules = ruleeditor(repo, ui, actions, comment)
1080 else:
1081 if rules == '-':
1082 f = sys.stdin
1083 else:
1084 f = open(rules)
1085 rules = f.read()
1086 f.close()
1087 actions = parserules(rules, state)
1088 warnverifyactions(ui, repo, actions, state, ctxs)
1089
1090 parentctxnode = repo[root].parents()[0].node()
1091
1092 state.parentctxnode = parentctxnode
1093 state.actions = actions
1094 state.topmost = topmost
1095 state.replacements = replacements
1096
1097 # Create a backup so we can always abort completely.
1098 backupfile = None
1099 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
1100 backupfile = repair._bundle(repo, [parentctxnode], [topmost], root,
1101 'histedit')
1102 state.backupfile = backupfile
1103
1053
1104 # preprocess rules so that we can hide inner folds from the user
1054 # preprocess rules so that we can hide inner folds from the user
1105 # and only show one editor
1055 # and only show one editor
@@ -1228,6 +1178,62 b' def _editplanaction(ui, repo, state, rul'
1228 state.actions = actions
1178 state.actions = actions
1229 state.write()
1179 state.write()
1230
1180
1181 def _newaction(ui, repo, state, revs, freeargs, opts):
1182 outg = opts.get('outgoing')
1183 rules = opts.get('commands', '')
1184 force = opts.get('force')
1185
1186 cmdutil.checkunfinished(repo)
1187 cmdutil.bailifchanged(repo)
1188
1189 topmost, empty = repo.dirstate.parents()
1190 if outg:
1191 if freeargs:
1192 remote = freeargs[0]
1193 else:
1194 remote = None
1195 root = findoutgoing(ui, repo, remote, force, opts)
1196 else:
1197 rr = list(repo.set('roots(%ld)', scmutil.revrange(repo, revs)))
1198 if len(rr) != 1:
1199 raise error.Abort(_('The specified revisions must have '
1200 'exactly one common root'))
1201 root = rr[0].node()
1202
1203 revs = between(repo, root, topmost, state.keep)
1204 if not revs:
1205 raise error.Abort(_('%s is not an ancestor of working directory') %
1206 node.short(root))
1207
1208 ctxs = [repo[r] for r in revs]
1209 if not rules:
1210 comment = geteditcomment(node.short(root), node.short(topmost))
1211 actions = [pick(state, r) for r in revs]
1212 rules = ruleeditor(repo, ui, actions, comment)
1213 else:
1214 if rules == '-':
1215 f = sys.stdin
1216 else:
1217 f = open(rules)
1218 rules = f.read()
1219 f.close()
1220 actions = parserules(rules, state)
1221 warnverifyactions(ui, repo, actions, state, ctxs)
1222
1223 parentctxnode = repo[root].parents()[0].node()
1224
1225 state.parentctxnode = parentctxnode
1226 state.actions = actions
1227 state.topmost = topmost
1228 state.replacements = []
1229
1230 # Create a backup so we can always abort completely.
1231 backupfile = None
1232 if not obsolete.isenabled(repo, obsolete.createmarkersopt):
1233 backupfile = repair._bundle(repo, [parentctxnode], [topmost], root,
1234 'histedit')
1235 state.backupfile = backupfile
1236
1231 def bootstrapcontinue(ui, state, opts):
1237 def bootstrapcontinue(ui, state, opts):
1232 repo = state.repo
1238 repo = state.repo
1233 if state.actions:
1239 if state.actions:
General Comments 0
You need to be logged in to leave comments. Login now