Mercurial > hg
changeset 35242:27d5c2d2db2b
rewriteutil: add utility function to check if we can create new unstable cset
This patch adds a new file which will contain utility functions related to
rewritting changesets. It also adds a utility function to check if the
rewritting operation creates new unstable changesets and are we allowed to
create them.
This rewriteutil.py introduced in this patch and the utility functions added in
the upcoming patches exists in the evolve extension are being ported from there.
Differential Revision: https://phab.mercurial-scm.org/D1502
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 24 Nov 2017 03:40:33 +0530 |
parents | 2a99c5bfea47 |
children | 490df753894d |
files | mercurial/rewriteutil.py |
diffstat | 1 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/rewriteutil.py Fri Nov 24 03:40:33 2017 +0530 @@ -0,0 +1,25 @@ +# rewriteutil.py - utility functions for rewriting changesets +# +# Copyright 2017 Octobus <contact@octobus.net> +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2 or any later version. + +from __future__ import absolute_import + +from . import ( + obsolete, + revset, +) + +def disallowednewunstable(repo, revs): + """Checks whether editing the revs will create new unstable changesets and + are we allowed to create them. + + To allow new unstable changesets, set the config: + `experimental.evolution.allowunstable=True` + """ + allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt) + if allowunstable: + return revset.baseset() + return repo.revs("(%ld::) - %ld", revs, revs)