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

login
register
mail settings
Submitter phabricator
Date Jan. 16, 2022, 3:53 p.m.
Message ID <differential-rev-PHID-DREV-6j5sevuxf47ok44sanz3-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50328/
State New
Headers show

Comments

phabricator - Jan. 16, 2022, 3:53 p.m.
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




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

Patch

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: