##// END OF EJS Templates
histedit: use parse-error exception for parsing
timeless -
r27545:a67d2e05 default
parent child Browse files
Show More
@@ -365,7 +365,7 b' class histeditaction(object):'
365 365 try:
366 366 self.node = repo[ha].node()
367 367 except error.RepoError:
368 raise error.Abort(_('unknown changeset %s listed')
368 raise error.ParseError(_('unknown changeset %s listed')
369 369 % ha[:12])
370 370
371 371 def torule(self):
@@ -509,7 +509,7 b' def collapse(repo, first, last, commitop'
509 509 return None
510 510 for c in ctxs:
511 511 if not c.mutable():
512 raise error.Abort(
512 raise error.ParseError(
513 513 _("cannot fold into public change %s") % node.short(c.node()))
514 514 base = first.parents()[0]
515 515
@@ -633,7 +633,7 b' class fold(histeditaction):'
633 633 else:
634 634 c = repo[prev.node]
635 635 if not c.mutable():
636 raise error.Abort(
636 raise error.ParseError(
637 637 _("cannot fold into public change %s") % node.short(c.node()))
638 638
639 639
@@ -1207,11 +1207,11 b' def parserules(rules, state):'
1207 1207 actions = []
1208 1208 for r in rules:
1209 1209 if ' ' not in r:
1210 raise error.Abort(_('malformed line "%s"') % r)
1210 raise error.ParseError(_('malformed line "%s"') % r)
1211 1211 verb, rest = r.split(' ', 1)
1212 1212
1213 1213 if verb not in actiontable:
1214 raise error.Abort(_('unknown action "%s"') % verb)
1214 raise error.ParseError(_('unknown action "%s"') % verb)
1215 1215
1216 1216 action = actiontable[verb].fromrule(state, rest)
1217 1217 actions.append(action)
@@ -1220,7 +1220,7 b' def parserules(rules, state):'
1220 1220 def warnverifyactions(ui, repo, actions, state, ctxs):
1221 1221 try:
1222 1222 verifyactions(actions, state, ctxs)
1223 except error.Abort:
1223 except error.ParseError:
1224 1224 if repo.vfs.exists('histedit-last-edit.txt'):
1225 1225 ui.warn(_('warning: histedit rules saved '
1226 1226 'to: .hg/histedit-last-edit.txt\n'))
@@ -1242,21 +1242,23 b' def verifyactions(actions, state, ctxs):'
1242 1242 constraints = action.constraints()
1243 1243 for constraint in constraints:
1244 1244 if constraint not in _constraints.known():
1245 raise error.Abort(_('unknown constraint "%s"') % constraint)
1245 raise error.ParseError(_('unknown constraint "%s"') %
1246 constraint)
1246 1247
1247 1248 nodetoverify = action.nodetoverify()
1248 1249 if nodetoverify is not None:
1249 1250 ha = node.hex(nodetoverify)
1250 1251 if _constraints.noother in constraints and ha not in expected:
1251 raise error.Abort(
1252 raise error.ParseError(
1252 1253 _('may not use "%s" with changesets '
1253 1254 'other than the ones listed') % action.verb)
1254 1255 if _constraints.forceother in constraints and ha in expected:
1255 raise error.Abort(
1256 raise error.ParseError(
1256 1257 _('may not use "%s" with changesets '
1257 1258 'within the edited list') % action.verb)
1258 1259 if _constraints.noduplicates in constraints and ha in seen:
1259 raise error.Abort(_('duplicated command for changeset %s') %
1260 raise error.ParseError(_(
1261 'duplicated command for changeset %s') %
1260 1262 ha[:12])
1261 1263 seen.add(ha)
1262 1264 missing = sorted(expected - seen) # sort to stabilize output
@@ -1267,7 +1269,7 b' def verifyactions(actions, state, ctxs):'
1267 1269 # don't show in the edit-plan in the future
1268 1270 actions[:0] = drops
1269 1271 elif missing:
1270 raise error.Abort(_('missing rules for changeset %s') %
1272 raise error.ParseError(_('missing rules for changeset %s') %
1271 1273 missing[0][:12],
1272 1274 hint=_('use "drop %s" to discard, see also: '
1273 1275 '"hg help -e histedit.config"') % missing[0][:12])
@@ -158,7 +158,7 b' Test that missing revisions are detected'
158 158 > pick eb57da33312f 2 three
159 159 > pick 08d98a8350f3 4 five
160 160 > EOF
161 abort: missing rules for changeset c8e68270e35a
161 hg: parse error: missing rules for changeset c8e68270e35a
162 162 (use "drop c8e68270e35a" to discard, see also: "hg help -e histedit.config")
163 163 [255]
164 164
@@ -170,7 +170,7 b' Test that extra revisions are detected'
170 170 > pick c8e68270e35a 3 four
171 171 > pick 08d98a8350f3 4 five
172 172 > EOF
173 abort: may not use "pick" with changesets other than the ones listed
173 hg: parse error: may not use "pick" with changesets other than the ones listed
174 174 [255]
175 175
176 176 Test malformed line
@@ -181,7 +181,7 b' Test malformed line'
181 181 > pick c8e68270e35a 3 four
182 182 > pick 08d98a8350f3 4 five
183 183 > EOF
184 abort: malformed line "pickeb57da33312f2three"
184 hg: parse error: malformed line "pickeb57da33312f2three"
185 185 [255]
186 186
187 187 Test unknown changeset
@@ -192,7 +192,7 b' Test unknown changeset'
192 192 > pick c8e68270e35a 3 four
193 193 > pick 08d98a8350f3 4 five
194 194 > EOF
195 abort: unknown changeset 0123456789ab listed
195 hg: parse error: unknown changeset 0123456789ab listed
196 196 [255]
197 197
198 198 Test unknown command
@@ -203,7 +203,7 b' Test unknown command'
203 203 > pick c8e68270e35a 3 four
204 204 > pick 08d98a8350f3 4 five
205 205 > EOF
206 abort: unknown action "coin"
206 hg: parse error: unknown action "coin"
207 207 [255]
208 208
209 209 Test duplicated changeset
@@ -216,7 +216,7 b' So one is missing and one appear twice.'
216 216 > pick eb57da33312f 2 three
217 217 > pick 08d98a8350f3 4 five
218 218 > EOF
219 abort: duplicated command for changeset eb57da33312f
219 hg: parse error: duplicated command for changeset eb57da33312f
220 220 [255]
221 221
222 222 Test short version of command
@@ -229,7 +229,7 b' base on a previously picked changeset'
229 229 > base d273e35dcdf2 B
230 230 > pick b2f90fd8aa85 I
231 231 > EOF
232 abort: may not use "base" with changesets within the edited list
232 hg: parse error: may not use "base" with changesets within the edited list
233 233
234 234 $ hg --config experimental.histeditng=False histedit 5 --commands - 2>&1 << EOF | fixbundle
235 235 > base cd010b8cd998 A
@@ -238,7 +238,7 b' base on a previously picked changeset'
238 238 > pick b2f90fd8aa85 I
239 239 > pick e8c55b19d366 J
240 240 > EOF
241 abort: unknown action "base"
241 hg: parse error: unknown action "base"
242 242
243 243 $ hg tglog
244 244 @ 8:e8c55b19d366b335626e805484110d1d5f6f2ea3:draft 'J'
@@ -268,7 +268,7 b' try with --rev'
268 268 > pick de71b079d9ce e
269 269 > pick 38b92f448761 c
270 270 > EOF
271 abort: may not use "pick" with changesets other than the ones listed
271 hg: parse error: may not use "pick" with changesets other than the ones listed
272 272 $ hg log --graph
273 273 @ changeset: 7:803ef1c6fcfd
274 274 | tag: tip
@@ -152,7 +152,7 b' Drop the last changeset'
152 152 > pick cb9a9f314b8b a
153 153 > pick ee283cb5f2d5 e
154 154 > EOF
155 abort: missing rules for changeset a4f7421b80f7
155 hg: parse error: missing rules for changeset a4f7421b80f7
156 156 (use "drop a4f7421b80f7" to discard, see also: "hg help -e histedit.config")
157 157 $ hg --config histedit.dropmissing=True histedit cb9a9f314b8b --commands - 2>&1 << EOF | fixbundle
158 158 > pick cb9a9f314b8b a
@@ -459,7 +459,7 b' Attempting to fold a change into a publi'
459 459 > EOF
460 460 $ HGEDITOR="sh ../edit.sh" hg histedit 2
461 461 warning: histedit rules saved to: .hg/histedit-last-edit.txt
462 abort: cannot fold into public change 18aa70c8ad22
462 hg: parse error: cannot fold into public change 18aa70c8ad22
463 463 [255]
464 464 $ cat .hg/histedit-last-edit.txt
465 465 fold 0012be4a27ea 2 extend a
General Comments 0
You need to be logged in to leave comments. Login now