# HG changeset patch # User Pierre-Yves David # Date 1500831336 -7200 # Node ID 7d86d88b2fa8e190bdf0c5cc69aa428c2821be2c # Parent 4dd84054ebbb644ddf46cb43f5cec7d7ee13a6e2 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. diff -r 4dd84054ebbb -r 7d86d88b2fa8 hgext3rd/evolve/rewriteutil.py --- 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 can be rewritten + + 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 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 "