Mercurial > evolve
changeset 2777:7d86d88b2fa8
rewriteutil: add a precheck function to validate rewrite beforehand
For now this only checks for changeset mutability and this is only used by
'checkfold'. We'll expand the checking and usage as we go.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 23 Jul 2017 19:35:36 +0200 |
parents | 4dd84054ebbb |
children | 766b38594ded |
files | hgext3rd/evolve/rewriteutil.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/rewriteutil.py Mon Jul 24 04:41:31 2017 +0200 +++ b/hgext3rd/evolve/rewriteutil.py Sun Jul 23 19:35:36 2017 +0200 @@ -31,6 +31,14 @@ compat, ) +def precheck(repo, revs, action='rewrite'): + """check if <revs> can be rewritten + + <action> can be used to control the commit message. + """ + if repo.revs('%ld and public()', revs): + raise error.Abort(_("cannot %s public revisions") % action) + def bookmarksupdater(repo, oldid, tr): """Return a callable update(newid) updating the current bookmark and bookmarks bound to oldid to newid. @@ -54,6 +62,7 @@ def foldcheck(repo, revs): """check that <revs> can be folded""" + precheck(repo, revs, action='fold') roots = repo.revs('roots(%ld)', revs) if len(roots) > 1: raise error.Abort(_("cannot fold non-linear revisions "