Mercurial > hg
comparison hgext/histedit.py @ 43933:bde97bee321f
histedit: use rewriteutil.precheck() instead of reimplementing it
We have had this nice utility since 490df753894d (rewriteutil: add a
precheck function to check if revs can be rewritten, 2017-11-24). We
got two callers soon thereafter, in 98f97eb20597 (rewriteutil: use
precheck() in uncommit and amend commands, 2017-11-28). It's about
time we use it in other places.
rewriteutil.precheck() looks unfortunate for i18n (it seems to rely on
an English verb for the action making sense in other languages), but
hopefully not bad enough that we should avoid using it.
Differential Revision: https://phab.mercurial-scm.org/D7684
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 17 Dec 2019 10:53:51 -0800 |
parents | 29adf0a087a1 |
children | 801b8d314791 |
comparison
equal
deleted
inserted
replaced
43932:9fb9f3a5cad7 | 43933:bde97bee321f |
---|---|
228 node, | 228 node, |
229 obsolete, | 229 obsolete, |
230 pycompat, | 230 pycompat, |
231 registrar, | 231 registrar, |
232 repair, | 232 repair, |
233 rewriteutil, | |
233 scmutil, | 234 scmutil, |
234 state as statemod, | 235 state as statemod, |
235 util, | 236 util, |
236 ) | 237 ) |
237 from mercurial.utils import ( | 238 from mercurial.utils import ( |
2304 """select and validate the set of revision to edit | 2305 """select and validate the set of revision to edit |
2305 | 2306 |
2306 When keep is false, the specified set can't have children.""" | 2307 When keep is false, the specified set can't have children.""" |
2307 revs = repo.revs(b'%n::%n', old, new) | 2308 revs = repo.revs(b'%n::%n', old, new) |
2308 if revs and not keep: | 2309 if revs and not keep: |
2309 if not obsolete.isenabled( | 2310 rewriteutil.precheck(repo, revs, b'edit') |
2310 repo, obsolete.allowunstableopt | |
2311 ) and repo.revs(b'(%ld::) - (%ld)', revs, revs): | |
2312 raise error.Abort( | |
2313 _( | |
2314 b'can only histedit a changeset together ' | |
2315 b'with all its descendants' | |
2316 ) | |
2317 ) | |
2318 if repo.revs(b'(%ld) and merge()', revs): | 2311 if repo.revs(b'(%ld) and merge()', revs): |
2319 raise error.Abort(_(b'cannot edit history that contains merges')) | 2312 raise error.Abort(_(b'cannot edit history that contains merges')) |
2320 root = repo[revs.first()] # list is already sorted by repo.revs() | |
2321 if not root.mutable(): | |
2322 raise error.Abort( | |
2323 _(b'cannot edit public changeset: %s') % root, | |
2324 hint=_(b"see 'hg help phases' for details"), | |
2325 ) | |
2326 return pycompat.maplist(repo.changelog.node, revs) | 2313 return pycompat.maplist(repo.changelog.node, revs) |
2327 | 2314 |
2328 | 2315 |
2329 def ruleeditor(repo, ui, actions, editcomment=b""): | 2316 def ruleeditor(repo, ui, actions, editcomment=b""): |
2330 """open an editor to edit rules | 2317 """open an editor to edit rules |