changeset 48822:d4752aeb20f1 stable

precheck: fix false warning about content-divergence creation Before this patch, if we try to `hg prune` (without any successors) an already obsoleted cset which has at least one successor, it would false warn about new content-divergence. As we know, pruning cset without any successors can not create any divergence. Differential Revision: https://phab.mercurial-scm.org/D12002
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Fri, 23 Jul 2021 13:42:12 +0530
parents d9ed7c5e915d
children 91a60031aba2 bde2e4ef968a
files mercurial/rewriteutil.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/rewriteutil.py	Thu Mar 24 12:27:21 2022 -0400
+++ b/mercurial/rewriteutil.py	Fri Jul 23 13:42:12 2021 +0530
@@ -49,10 +49,13 @@
     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 @@
             hint=hint,
         )
 
+    if not check_divergence:
+        return
+
     if not obsolete.isenabled(repo, obsolete.allowdivergenceopt):
         new_divergence = _find_new_divergence(repo, revs)
         if new_divergence: