##// END OF EJS Templates
split: use rewriteutil.precheck() instead of reimplementing it...
Martin von Zweigbergk -
r44387:2349a60f default
parent child Browse files
Show More
@@ -22,11 +22,10 b' from mercurial import ('
22 22 commands,
23 23 error,
24 24 hg,
25 obsolete,
26 phases,
27 25 pycompat,
28 26 registrar,
29 27 revsetlang,
28 rewriteutil,
30 29 scmutil,
31 30 )
32 31
@@ -77,45 +76,26 b' def split(ui, repo, *revs, **opts):'
77 76
78 77 rev = revs.first()
79 78 ctx = repo[rev]
79 # Handle nullid specially here (instead of leaving for precheck()
80 # below) so we get a nicer message and error code.
80 81 if rev is None or ctx.node() == nullid:
81 82 ui.status(_(b'nothing to split\n'))
82 83 return 1
83 84 if ctx.node() is None:
84 85 raise error.Abort(_(b'cannot split working directory'))
85 86
86 # rewriteutil.precheck is not very useful here because:
87 # 1. null check is done above and it's more friendly to return 1
88 # instead of abort
89 # 2. mergestate check is done below by cmdutil.bailifchanged
90 # 3. unstable check is more complex here because of --rebase
91 #
92 # So only "public" check is useful and it's checked directly here.
93 if ctx.phase() == phases.public:
94 raise error.Abort(
95 _(b'cannot split public changeset'),
96 hint=_(b"see 'hg help phases' for details"),
97 )
98
99 descendants = list(repo.revs(b'(%d::) - (%d)', rev, rev))
100 alloworphaned = obsolete.isenabled(repo, obsolete.allowunstableopt)
101 87 if opts.get(b'rebase'):
102 88 # Skip obsoleted descendants and their descendants so the rebase
103 89 # won't cause conflicts for sure.
90 descendants = list(repo.revs(b'(%d::) - (%d)', rev, rev))
104 91 torebase = list(
105 92 repo.revs(
106 93 b'%ld - (%ld & obsolete())::', descendants, descendants
107 94 )
108 95 )
109 if not alloworphaned and len(torebase) != len(descendants):
110 raise error.Abort(
111 _(b'split would leave orphaned changesets behind')
112 )
113 96 else:
114 if not alloworphaned and descendants:
115 raise error.Abort(
116 _(b'cannot split changeset with children without rebase')
117 )
118 torebase = ()
97 torebase = []
98 rewriteutil.precheck(repo, [rev] + torebase, b'split')
119 99
120 100 if len(ctx.parents()) > 1:
121 101 raise error.Abort(_(b'cannot split a merge changeset'))
@@ -77,7 +77,7 b' Cannot split a public changeset'
77 77
78 78 $ hg phase --public -r 'all()'
79 79 $ hg split .
80 abort: cannot split public changeset
80 abort: cannot split public changesets
81 81 (see 'hg help phases' for details)
82 82 [255]
83 83
@@ -466,7 +466,7 b' Split a non-head without rebase'
466 466 $ cd $TESTTMP/d
467 467 #if obsstore-off
468 468 $ runsplit -r 1 --no-rebase
469 abort: cannot split changeset with children without rebase
469 abort: cannot split changeset with children
470 470 [255]
471 471 #else
472 472 $ runsplit -r 1 --no-rebase >/dev/null
@@ -517,7 +517,7 b' Split a non-head with obsoleted descenda'
517 517 $ eval `hg tags -T '{tag}={node}\n'`
518 518 $ rm .hg/localtags
519 519 $ hg split $B --config experimental.evolution=createmarkers
520 abort: split would leave orphaned changesets behind
520 abort: cannot split changeset with children
521 521 [255]
522 522 $ cat > $TESTTMP/messages <<EOF
523 523 > Split B
General Comments 0
You need to be logged in to leave comments. Login now