# HG changeset patch # User Siddharth Agarwal # Date 1461626682 25200 # Node ID 40d7b0c4abb121b3e325008060fa4eb9029eb4a2 # Parent 1b1c8c0ab20e6be3c30e77e6081cbc61effeed7c evolve: factor out check for creating unstable commits This check is pretty non-trivial, and we do it in two places already. We're going to do it in a third place soon. diff -r 1b1c8c0ab20e -r 40d7b0c4abb1 hgext/evolve.py --- a/hgext/evolve.py Mon Apr 25 16:24:42 2016 -0700 +++ b/hgext/evolve.py Mon Apr 25 16:24:42 2016 -0700 @@ -2509,9 +2509,8 @@ if not precs: raise error.Abort('nothing to prune') - if not obsolete.isenabled(repo, obsolete.allowunstableopt): - if repo.revs("(%ld::) - %ld", revs, revs): - raise error.Abort(_("cannot prune in the middle of a stack")) + if _disallowednewunstable(repo, revs): + raise error.Abort(_("cannot prune in the middle of a stack")) # defines successors changesets sucs = scmutil.revrange(repo, succs) @@ -3172,13 +3171,17 @@ raise error.Abort(_("cannot fold non-linear revisions " "(multiple heads given)")) head = repo[heads.first()] - disallowunstable = not obsolete.isenabled(repo, obsolete.allowunstableopt) - if disallowunstable: - if repo.revs("(%ld::) - %ld", revs, revs): - raise error.Abort(_("cannot fold chain not ending with a head "\ - "or with branching")) + if _disallowednewunstable(repo, revs): + raise error.Abort(_("cannot fold chain not ending with a head "\ + "or with branching")) return root, head +def _disallowednewunstable(repo, revs): + allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt) + if allowunstable: + return revset.baseset() + return repo.revs("(%ld::) - %ld", revs, revs) + @eh.wrapcommand('graft') def graftwrapper(orig, ui, repo, *revs, **kwargs): kwargs = dict(kwargs)