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