diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py --- a/mercurial/rewriteutil.py +++ b/mercurial/rewriteutil.py @@ -49,10 +49,13 @@ def _formatrevs(repo, revs, maxrevs=4): return summary -def precheck(repo, revs, action=b'rewrite'): +def precheck(repo, revs, action=b'rewrite', check_divergence=True): """check if revs can be rewritten action is used to control the error message. + check_divergence allows skipping the divergence checks in cases like adding + a prune marker (A, ()) to obsstore (which can't be diverging). + Make sure this function is called after taking the lock. """ if nullrev in revs: @@ -85,6 +88,9 @@ def precheck(repo, revs, action=b'rewrit hint=hint, ) + if not check_divergence: + return + if not obsolete.isenabled(repo, obsolete.allowdivergenceopt): new_divergence = _find_new_divergence(repo, revs) if new_divergence: