D12002: precheck: fix false warning about content-divergence creation

khanchi97 (Sushil khanchi) phabricator at mercurial-scm.org
Sun Jan 16 15:53:53 UTC 2022


khanchi97 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D12002

AFFECTED FILES
  mercurial/rewriteutil.py

CHANGE DETAILS

diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py
--- a/mercurial/rewriteutil.py
+++ b/mercurial/rewriteutil.py
@@ -49,7 +49,7 @@
     return summary
 
 
-def precheck(repo, revs, action=b'rewrite'):
+def precheck(repo, revs, action=b'rewrite', successors=None):
     """check if revs can be rewritten
     action is used to control the error message.
 
@@ -85,6 +85,10 @@
             hint=hint,
         )
 
+    # Adding a prune marker (A, ()) to obsstore can't be diverging
+    if action == b'prune' and not successors:
+        return
+
     if not obsolete.isenabled(repo, obsolete.allowdivergenceopt):
         new_divergence = _find_new_divergence(repo, revs)
         if new_divergence:



To: khanchi97, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list