annotate mercurial/rewriteutil.py @ 52095:3e7b9357bbb8

tests: add coverage to for `HGCB_BUNDLE_BASENAME` with special characters Per request on IRC, to show the behavior of dropping the quoting of `HGCB_BUNDLE_BASENAME` in the next commit. This current failure is basically the same error and output that currently happens on Windows with any path (even without the embedded quote). The only difference is Windows doesn't print the `cp: cannot stat ...` line.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 21 Oct 2024 15:24:55 -0400
parents f4733654f144
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35242
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
1 # rewriteutil.py - utility functions for rewriting changesets
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
2 #
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
3 # Copyright 2017 Octobus <contact@octobus.net>
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
4 #
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
5 # This software may be used and distributed according to the terms of the
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
6 # GNU General Public License version 2 or any later version.
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
7
51863
f4733654f144 typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents: 50928
diff changeset
8 from __future__ import annotations
35242
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
9
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
10 import re
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
11
35243
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
12 from .i18n import _
46113
59fa3890d40a node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents: 45853
diff changeset
13 from .node import (
59fa3890d40a node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents: 45853
diff changeset
14 hex,
59fa3890d40a node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents: 45853
diff changeset
15 nullrev,
59fa3890d40a node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents: 45853
diff changeset
16 )
35243
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
17
35242
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
18 from . import (
35243
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
19 error,
47069
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
20 node,
35242
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
21 obsolete,
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
22 obsutil,
35242
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
23 revset,
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
24 scmutil,
35242
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
25 )
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
26
43075
57875cf423c9 style: run a patched black on a subset of mercurial
Augie Fackler <augie@google.com>
parents: 40636
diff changeset
27
45427
78861610ded8 rewriteutil: relax the sha1 hash references to handle future hash types
Matt Harbison <matt_harbison@yahoo.com>
parents: 45425
diff changeset
28 NODE_RE = re.compile(br'\b[0-9a-f]{6,64}\b')
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
29
50643
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
30 # set of extra entry that should survive a rebase-like operation, extensible by extensions
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
31 retained_extras_on_rebase = {
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
32 b'source',
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
33 b'intermediate-source',
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
34 }
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
35
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
36
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
37 def preserve_extras_on_rebase(old_ctx, new_extra):
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
38 """preserve the relevant `extra` entry from old_ctx on rebase-like operation"""
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
39 new_extra.update(
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
40 (key, value)
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
41 for key, value in old_ctx.extra().items()
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
42 if key in retained_extras_on_rebase
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
43 )
cbcbf63b6dbf rewrite: simplify the `retained_extras` extra logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49084
diff changeset
44
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
45
47069
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
46 def _formatrevs(repo, revs, maxrevs=4):
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
47 """returns a string summarizing revisions in a decent size
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
48
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
49 If there are few enough revisions, we list them all. Otherwise we display a
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
50 summary of the form:
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
51
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
52 1ea73414a91b and 5 others
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
53 """
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
54 tonode = repo.changelog.node
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
55 numrevs = len(revs)
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
56 if numrevs < maxrevs:
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
57 shorts = [node.short(tonode(r)) for r in revs]
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
58 summary = b', '.join(shorts)
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
59 else:
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
60 first = revs.first()
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
61 summary = _(b'%s and %d others')
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
62 summary %= (node.short(tonode(first)), numrevs - 1)
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
63 return summary
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
64
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
65
48991
d4752aeb20f1 precheck: fix false warning about content-divergence creation
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 47787
diff changeset
66 def precheck(repo, revs, action=b'rewrite', check_divergence=True):
35243
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
67 """check if revs can be rewritten
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
68 action is used to control the error message.
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
69
48991
d4752aeb20f1 precheck: fix false warning about content-divergence creation
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 47787
diff changeset
70 check_divergence allows skipping the divergence checks in cases like adding
d4752aeb20f1 precheck: fix false warning about content-divergence creation
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 47787
diff changeset
71 a prune marker (A, ()) to obsstore (which can't be diverging).
d4752aeb20f1 precheck: fix false warning about content-divergence creation
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 47787
diff changeset
72
35243
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
73 Make sure this function is called after taking the lock.
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
74 """
46113
59fa3890d40a node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents: 45853
diff changeset
75 if nullrev in revs:
47015
7001f92e0ee9 rewriteutil: replace "null changeset" by "the null revision" in error message
Martin von Zweigbergk <martinvonz@google.com>
parents: 46113
diff changeset
76 msg = _(b"cannot %s the null revision") % action
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43075
diff changeset
77 hint = _(b"no changeset checked out")
45853
b4694ef45db5 errors: raise more specific errors from rewriteutil
Martin von Zweigbergk <martinvonz@google.com>
parents: 45711
diff changeset
78 raise error.InputError(msg, hint=hint)
35243
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
79
50928
d718eddf01d9 safehasattr: drop usage in favor of hasattr
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50643
diff changeset
80 if any(hasattr(r, 'rev') for r in revs):
47016
8ad2f43fe37b rewriteutil: add devel warning if precheck is called with contexts
Martin von Zweigbergk <martinvonz@google.com>
parents: 47015
diff changeset
81 repo.ui.develwarn(b"rewriteutil.precheck called with ctx not revs")
8ad2f43fe37b rewriteutil: add devel warning if precheck is called with contexts
Martin von Zweigbergk <martinvonz@google.com>
parents: 47015
diff changeset
82 revs = (r.rev() for r in revs)
8ad2f43fe37b rewriteutil: add devel warning if precheck is called with contexts
Martin von Zweigbergk <martinvonz@google.com>
parents: 47015
diff changeset
83
35243
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
84 if len(repo[None].parents()) > 1:
47020
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
85 raise error.StateError(
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
86 _(b"cannot %s changesets while merging") % action
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
87 )
35243
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
88
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43075
diff changeset
89 publicrevs = repo.revs(b'%ld and public()', revs)
35243
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
90 if publicrevs:
47069
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
91 summary = _formatrevs(repo, publicrevs)
5b6dd0d9171b rewriteutil: give examples of public changesets that can't be rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47020
diff changeset
92 msg = _(b"cannot %s public changesets: %s") % (action, summary)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43075
diff changeset
93 hint = _(b"see 'hg help phases' for details")
45853
b4694ef45db5 errors: raise more specific errors from rewriteutil
Martin von Zweigbergk <martinvonz@google.com>
parents: 45711
diff changeset
94 raise error.InputError(msg, hint=hint)
35243
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
95
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
96 newunstable = disallowednewunstable(repo, revs)
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
97 if newunstable:
47018
7a90fddb13b0 rewriteutil: point to help about instability when rewriting creates orphan
Martin von Zweigbergk <martinvonz@google.com>
parents: 47016
diff changeset
98 hint = _(b"see 'hg help evolution.instability'")
7a90fddb13b0 rewriteutil: point to help about instability when rewriting creates orphan
Martin von Zweigbergk <martinvonz@google.com>
parents: 47016
diff changeset
99 raise error.InputError(
47070
d90f6237b3aa rewriteutil: say how many commits would become orphan if commit is rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47069
diff changeset
100 _(b"cannot %s changeset, as that will orphan %d descendants")
d90f6237b3aa rewriteutil: say how many commits would become orphan if commit is rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47069
diff changeset
101 % (action, len(newunstable)),
d90f6237b3aa rewriteutil: say how many commits would become orphan if commit is rewritten
Martin von Zweigbergk <martinvonz@google.com>
parents: 47069
diff changeset
102 hint=hint,
47018
7a90fddb13b0 rewriteutil: point to help about instability when rewriting creates orphan
Martin von Zweigbergk <martinvonz@google.com>
parents: 47016
diff changeset
103 )
35243
490df753894d rewriteutil: add a precheck function to check if revs can be rewritten
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35242
diff changeset
104
48991
d4752aeb20f1 precheck: fix false warning about content-divergence creation
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 47787
diff changeset
105 if not check_divergence:
d4752aeb20f1 precheck: fix false warning about content-divergence creation
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 47787
diff changeset
106 return
d4752aeb20f1 precheck: fix false warning about content-divergence creation
Sushil khanchi <sushilkhanchi97@gmail.com>
parents: 47787
diff changeset
107
47020
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
108 if not obsolete.isenabled(repo, obsolete.allowdivergenceopt):
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
109 new_divergence = _find_new_divergence(repo, revs)
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
110 if new_divergence:
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
111 local_ctx, other_ctx, base_ctx = new_divergence
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
112 msg = _(
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
113 b'cannot %s %s, as that creates content-divergence with %s'
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
114 ) % (
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
115 action,
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
116 local_ctx,
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
117 other_ctx,
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
118 )
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
119 if local_ctx.rev() != base_ctx.rev():
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
120 msg += _(b', from %s') % base_ctx
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
121 if repo.ui.verbose:
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
122 if local_ctx.rev() != base_ctx.rev():
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
123 msg += _(
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
124 b'\n changeset %s is a successor of ' b'changeset %s'
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
125 ) % (local_ctx, base_ctx)
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
126 msg += _(
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
127 b'\n changeset %s already has a successor in '
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
128 b'changeset %s\n'
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
129 b' rewriting changeset %s would create '
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
130 b'"content-divergence"\n'
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
131 b' set experimental.evolution.allowdivergence=True to '
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
132 b'skip this check'
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
133 ) % (base_ctx, other_ctx, local_ctx)
47375
8125bcd28a5c rewriteutil: add pointer to help text when rewrite would cause divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47271
diff changeset
134 raise error.InputError(
8125bcd28a5c rewriteutil: add pointer to help text when rewrite would cause divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47271
diff changeset
135 msg,
8125bcd28a5c rewriteutil: add pointer to help text when rewrite would cause divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47271
diff changeset
136 hint=_(
8125bcd28a5c rewriteutil: add pointer to help text when rewrite would cause divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47271
diff changeset
137 b"see 'hg help evolution.instability' for details on content-divergence"
8125bcd28a5c rewriteutil: add pointer to help text when rewrite would cause divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47271
diff changeset
138 ),
8125bcd28a5c rewriteutil: add pointer to help text when rewrite would cause divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47271
diff changeset
139 )
47020
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
140 else:
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
141 raise error.InputError(
47271
055f7b9f2307 rewriteutil: add pointer to help text when rewrite would cause divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47070
diff changeset
142 msg,
055f7b9f2307 rewriteutil: add pointer to help text when rewrite would cause divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47070
diff changeset
143 hint=_(
055f7b9f2307 rewriteutil: add pointer to help text when rewrite would cause divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47070
diff changeset
144 b"add --verbose for details or see "
055f7b9f2307 rewriteutil: add pointer to help text when rewrite would cause divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47070
diff changeset
145 b"'hg help evolution.instability'"
055f7b9f2307 rewriteutil: add pointer to help text when rewrite would cause divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47070
diff changeset
146 ),
47020
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
147 )
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
148
43075
57875cf423c9 style: run a patched black on a subset of mercurial
Augie Fackler <augie@google.com>
parents: 40636
diff changeset
149
35242
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
150 def disallowednewunstable(repo, revs):
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
151 """Checks whether editing the revs will create new unstable changesets and
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
152 are we allowed to create them.
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
153
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
154 To allow new unstable changesets, set the config:
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
155 `experimental.evolution.allowunstable=True`
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
156 """
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
157 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
158 if allowunstable:
27d5c2d2db2b rewriteutil: add utility function to check if we can create new unstable cset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff changeset
159 return revset.baseset()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43075
diff changeset
160 return repo.revs(b"(%ld::) - %ld", revs, revs)
45122
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
161
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
162
47020
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
163 def _find_new_divergence(repo, revs):
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
164 obsrevs = repo.revs(b'%ld and obsolete()', revs)
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
165 for r in obsrevs:
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
166 div = find_new_divergence_from(repo, repo[r])
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
167 if div:
47553
debc29900b97 rewriteutil: look up common predecessor on unfiltered repo
Martin von Zweigbergk <martinvonz@google.com>
parents: 47375
diff changeset
168 return (repo[r], repo[div[0]], repo.unfiltered()[div[1]])
47020
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
169 return None
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
170
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
171
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
172 def find_new_divergence_from(repo, ctx):
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
173 """return divergent revision if rewriting an obsolete cset (ctx) will
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
174 create divergence
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
175
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
176 Returns (<other node>, <common ancestor node>) or None
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
177 """
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
178 if not ctx.obsolete():
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
179 return None
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
180 # We need to check two cases that can cause divergence:
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
181 # case 1: the rev being rewritten has a non-obsolete successor (easily
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
182 # detected by successorssets)
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
183 sset = obsutil.successorssets(repo, ctx.node())
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
184 if sset:
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
185 return (sset[0][0], ctx.node())
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
186 else:
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
187 # case 2: one of the precursors of the rev being revived has a
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
188 # non-obsolete successor (we need divergentsets for this)
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
189 divsets = obsutil.divergentsets(repo, ctx)
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
190 if divsets:
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
191 nsuccset = divsets[0][b'divergentnodes']
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
192 prec = divsets[0][b'commonpredecessor']
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
193 return (nsuccset[0], prec)
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
194 return None
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
195
ba6881c6a178 rewriteutil: check for divergence
Martin von Zweigbergk <martinvonz@google.com>
parents: 47019
diff changeset
196
45122
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
197 def skip_empty_successor(ui, command):
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
198 empty_successor = ui.config(b'rewrite', b'empty-successor')
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
199 if empty_successor == b'skip':
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
200 return True
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
201 elif empty_successor == b'keep':
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
202 return False
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
203 else:
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
204 raise error.ConfigError(
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
205 _(
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
206 b"%s doesn't know how to handle config "
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
207 b"rewrite.empty-successor=%s (only 'skip' and 'keep' are "
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
208 b"supported)"
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
209 )
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
210 % (command, empty_successor)
a391d0710f22 rewriteutil: add utility to check whether empty successors should be skipped
Manuel Jacob <me@manueljacob.de>
parents: 43077
diff changeset
211 )
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
212
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
213
45425
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
214 def update_hash_refs(repo, commitmsg, pending=None):
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
215 """Replace all obsolete commit hashes in the message with the current hash.
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
216
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
217 If the obsolete commit was split or is divergent, the hash is not replaced
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
218 as there's no way to know which successor to choose.
45425
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
219
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
220 For commands that update a series of commits in the current transaction, the
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
221 new obsolete markers can be considered by setting ``pending`` to a mapping
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
222 of ``pending[oldnode] = [successor_node1, successor_node2,..]``.
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
223 """
45425
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
224 if not pending:
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
225 pending = {}
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
226 cache = {}
45427
78861610ded8 rewriteutil: relax the sha1 hash references to handle future hash types
Matt Harbison <matt_harbison@yahoo.com>
parents: 45425
diff changeset
227 hashes = re.findall(NODE_RE, commitmsg)
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
228 unfi = repo.unfiltered()
45427
78861610ded8 rewriteutil: relax the sha1 hash references to handle future hash types
Matt Harbison <matt_harbison@yahoo.com>
parents: 45425
diff changeset
229 for h in hashes:
47787
48da5c325750 rewriteutil: fix crash when a rewritten message references f{6,64}
Augie Fackler <augie@google.com>
parents: 47553
diff changeset
230 try:
48da5c325750 rewriteutil: fix crash when a rewritten message references f{6,64}
Augie Fackler <augie@google.com>
parents: 47553
diff changeset
231 fullnode = scmutil.resolvehexnodeidprefix(unfi, h)
49060
532b649c1deb rebase: while rewriting desc hashes, ignore ambiguous prefix "hashes"
Kyle Lippincott <spectral@google.com>
parents: 48991
diff changeset
232 except (error.WdirUnsupported, error.AmbiguousPrefixLookupError):
532b649c1deb rebase: while rewriting desc hashes, ignore ambiguous prefix "hashes"
Kyle Lippincott <spectral@google.com>
parents: 48991
diff changeset
233 # Someone has an fffff... or some other prefix that's ambiguous in a
532b649c1deb rebase: while rewriting desc hashes, ignore ambiguous prefix "hashes"
Kyle Lippincott <spectral@google.com>
parents: 48991
diff changeset
234 # commit message we're rewriting. Don't try rewriting that.
47787
48da5c325750 rewriteutil: fix crash when a rewritten message references f{6,64}
Augie Fackler <augie@google.com>
parents: 47553
diff changeset
235 continue
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
236 if fullnode is None:
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
237 continue
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
238 ctx = unfi[fullnode]
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
239 if not ctx.obsolete():
45425
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
240 successors = pending.get(fullnode)
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
241 if successors is None:
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
242 continue
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
243 # obsutil.successorssets() returns a list of list of nodes
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
244 successors = [successors]
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
245 else:
f7e293e0475f rewriteutil: also consider pending obsoletes when updating hashes in messages
Matt Harbison <matt_harbison@yahoo.com>
parents: 45424
diff changeset
246 successors = obsutil.successorssets(repo, ctx.node(), cache=cache)
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
247
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
248 # We can't make any assumptions about how to update the hash if the
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
249 # cset in question was split or diverged.
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
250 if len(successors) == 1 and len(successors[0]) == 1:
45711
3d68b47e461b rewriteutil: handle dropped commits when updating description hashes
Matt Harbison <matt_harbison@yahoo.com>
parents: 45427
diff changeset
251 successor = successors[0][0]
3d68b47e461b rewriteutil: handle dropped commits when updating description hashes
Matt Harbison <matt_harbison@yahoo.com>
parents: 45427
diff changeset
252 if successor is not None:
46113
59fa3890d40a node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents: 45853
diff changeset
253 newhash = hex(successor)
45711
3d68b47e461b rewriteutil: handle dropped commits when updating description hashes
Matt Harbison <matt_harbison@yahoo.com>
parents: 45427
diff changeset
254 commitmsg = commitmsg.replace(h, newhash[: len(h)])
3d68b47e461b rewriteutil: handle dropped commits when updating description hashes
Matt Harbison <matt_harbison@yahoo.com>
parents: 45427
diff changeset
255 else:
3d68b47e461b rewriteutil: handle dropped commits when updating description hashes
Matt Harbison <matt_harbison@yahoo.com>
parents: 45427
diff changeset
256 repo.ui.note(
3d68b47e461b rewriteutil: handle dropped commits when updating description hashes
Matt Harbison <matt_harbison@yahoo.com>
parents: 45427
diff changeset
257 _(
3d68b47e461b rewriteutil: handle dropped commits when updating description hashes
Matt Harbison <matt_harbison@yahoo.com>
parents: 45427
diff changeset
258 b'The stale commit message reference to %s could '
3d68b47e461b rewriteutil: handle dropped commits when updating description hashes
Matt Harbison <matt_harbison@yahoo.com>
parents: 45427
diff changeset
259 b'not be updated\n(The referenced commit was dropped)\n'
3d68b47e461b rewriteutil: handle dropped commits when updating description hashes
Matt Harbison <matt_harbison@yahoo.com>
parents: 45427
diff changeset
260 )
3d68b47e461b rewriteutil: handle dropped commits when updating description hashes
Matt Harbison <matt_harbison@yahoo.com>
parents: 45427
diff changeset
261 % h
3d68b47e461b rewriteutil: handle dropped commits when updating description hashes
Matt Harbison <matt_harbison@yahoo.com>
parents: 45427
diff changeset
262 )
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
263 else:
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
264 repo.ui.note(
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
265 _(
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
266 b'The stale commit message reference to %s could '
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
267 b'not be updated\n'
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
268 )
45427
78861610ded8 rewriteutil: relax the sha1 hash references to handle future hash types
Matt Harbison <matt_harbison@yahoo.com>
parents: 45425
diff changeset
269 % h
45424
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
270 )
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
271
0a57ef4b3bdb rewriteutil: extract evolve code used to replace obsolete hashes in commits
Matt Harbison <matt_harbison@yahoo.com>
parents: 45122
diff changeset
272 return commitmsg