Read about our upcoming Code of Conduct on this issue

Commit aa76967c authored by Pierre-Yves David's avatar Pierre-Yves David 🐙
Browse files

split: use precheck to validate revision

This gives us standard check and standard error message.
parent b5a48e4aeec6
......@@ -126,6 +126,7 @@ Changelog
- amend: add a --extract flag to move change back to the working copy
(same as uncommit, but accessible through the amend commit)
- split: now properly refuse to split public changeset
- uncommit: add support for --current-date and --current-user option
- fold: add support for --current-date and --current-user option
- metaedit: add support for --current-date and --current-user option
......
......@@ -781,14 +781,9 @@ def cmdsplit(ui, repo, *revs, **opts):
lock = repo.lock()
rev = scmutil.revsingle(repo, revarg[0])
cmdutil.bailifchanged(repo)
rewriteutil.precheck(repo, [rev], action='split')
tr = repo.transaction('split')
ctx = repo[rev]
disallowunstable = not obsolete.isenabled(repo,
obsolete.allowunstableopt)
if disallowunstable:
# XXX We should check head revs
if repo.revs("(%d::) - %d", rev, rev):
raise error.Abort(_("cannot split commit: %s not a head") % ctx)
if len(ctx.parents()) > 1:
raise error.Abort(_("cannot split merge commits"))
......
......@@ -131,10 +131,21 @@ Cannot split a commit with uncommitted changes
$ hg split
abort: uncommitted changes
[255]
Split a revision specified with -r
$ hg up "desc(_c)" -C
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Cannot split public changeset
$ hg phase --rev 'desc("_a")'
0: draft
$ hg phase --rev 'desc("_a")' --public
$ hg split --rev 'desc("_a")'
abort: cannot split public changesets: 135f39f4bd78
(see 'hg help phases' for details)
[255]
$ hg phase --rev 'desc("_a")' --draft --force
Split a revision specified with -r
$ echo "change to b" >> _b
$ hg amend -m "_cprim"
2 new unstable changesets
......@@ -338,7 +349,8 @@ Cannot split a commit that is not a head if instability is not allowed
> evolutioncommands=split
> EOF
$ hg split -r "desc(split3)"
abort: cannot split commit: ead2066d1dbf not a head
abort: split will orphan 4 descendants
(see 'hg help evolution.instability')
[255]
Changing evolution level to createmarkers
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment