comparison mercurial/rewriteutil.py @ 49067:bde2e4ef968a

merge: stable into default
author Rapha?l Gom?s <rgomes@octobus.net>
date Tue, 29 Mar 2022 14:27:45 +0200
parents 6000f5b25c9b d4752aeb20f1
children ea98850a136e
comparison
equal deleted inserted replaced
49066:8d7eaff92f9c 49067:bde2e4ef968a
46 summary = _(b'%s and %d others') 46 summary = _(b'%s and %d others')
47 summary %= (node.short(tonode(first)), numrevs - 1) 47 summary %= (node.short(tonode(first)), numrevs - 1)
48 return summary 48 return summary
49 49
50 50
51 def precheck(repo, revs, action=b'rewrite'): 51 def precheck(repo, revs, action=b'rewrite', check_divergence=True):
52 """check if revs can be rewritten 52 """check if revs can be rewritten
53 action is used to control the error message. 53 action is used to control the error message.
54
55 check_divergence allows skipping the divergence checks in cases like adding
56 a prune marker (A, ()) to obsstore (which can't be diverging).
54 57
55 Make sure this function is called after taking the lock. 58 Make sure this function is called after taking the lock.
56 """ 59 """
57 if nullrev in revs: 60 if nullrev in revs:
58 msg = _(b"cannot %s the null revision") % action 61 msg = _(b"cannot %s the null revision") % action
81 raise error.InputError( 84 raise error.InputError(
82 _(b"cannot %s changeset, as that will orphan %d descendants") 85 _(b"cannot %s changeset, as that will orphan %d descendants")
83 % (action, len(newunstable)), 86 % (action, len(newunstable)),
84 hint=hint, 87 hint=hint,
85 ) 88 )
89
90 if not check_divergence:
91 return
86 92
87 if not obsolete.isenabled(repo, obsolete.allowdivergenceopt): 93 if not obsolete.isenabled(repo, obsolete.allowdivergenceopt):
88 new_divergence = _find_new_divergence(repo, revs) 94 new_divergence = _find_new_divergence(repo, revs)
89 if new_divergence: 95 if new_divergence:
90 local_ctx, other_ctx, base_ctx = new_divergence 96 local_ctx, other_ctx, base_ctx = new_divergence