Per discussion with nbjoerg in IRC.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
Per discussion with nbjoerg in IRC.
| No Linters Available |
| No Unit Test Coverage |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/rewriteutil.py (14 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| 509346b09128 | e272c904bed9 | Matt Harbison | Aug 25 2020, 11:18 PM |
| Status | Author | Revision | |
|---|---|---|---|
| Closed | mharbison72 | ||
| Closed | mharbison72 | ||
| Closed | mharbison72 | ||
| Closed | mharbison72 | ||
| Closed | mharbison72 |
| node, | node, | ||||
| obsolete, | obsolete, | ||||
| obsutil, | obsutil, | ||||
| revset, | revset, | ||||
| scmutil, | scmutil, | ||||
| ) | ) | ||||
| sha1re = re.compile(br'\b[0-9a-f]{6,40}\b') | NODE_RE = re.compile(br'\b[0-9a-f]{6,64}\b') | ||||
| def precheck(repo, revs, action=b'rewrite'): | def precheck(repo, revs, action=b'rewrite'): | ||||
| """check if revs can be rewritten | """check if revs can be rewritten | ||||
| action is used to control the error message. | action is used to control the error message. | ||||
| Make sure this function is called after taking the lock. | Make sure this function is called after taking the lock. | ||||
| """ | """ | ||||
| For commands that update a series of commits in the current transaction, the | For commands that update a series of commits in the current transaction, the | ||||
| new obsolete markers can be considered by setting ``pending`` to a mapping | new obsolete markers can be considered by setting ``pending`` to a mapping | ||||
| of ``pending[oldnode] = [successor_node1, successor_node2,..]``. | of ``pending[oldnode] = [successor_node1, successor_node2,..]``. | ||||
| """ | """ | ||||
| if not pending: | if not pending: | ||||
| pending = {} | pending = {} | ||||
| cache = {} | cache = {} | ||||
| sha1s = re.findall(sha1re, commitmsg) | hashes = re.findall(NODE_RE, commitmsg) | ||||
| unfi = repo.unfiltered() | unfi = repo.unfiltered() | ||||
| for sha1 in sha1s: | for h in hashes: | ||||
| fullnode = scmutil.resolvehexnodeidprefix(unfi, sha1) | fullnode = scmutil.resolvehexnodeidprefix(unfi, h) | ||||
| if fullnode is None: | if fullnode is None: | ||||
| continue | continue | ||||
| ctx = unfi[fullnode] | ctx = unfi[fullnode] | ||||
| if not ctx.obsolete(): | if not ctx.obsolete(): | ||||
| successors = pending.get(fullnode) | successors = pending.get(fullnode) | ||||
| if successors is None: | if successors is None: | ||||
| continue | continue | ||||
| # obsutil.successorssets() returns a list of list of nodes | # obsutil.successorssets() returns a list of list of nodes | ||||
| successors = [successors] | successors = [successors] | ||||
| else: | else: | ||||
| successors = obsutil.successorssets(repo, ctx.node(), cache=cache) | successors = obsutil.successorssets(repo, ctx.node(), cache=cache) | ||||
| # We can't make any assumptions about how to update the hash if the | # We can't make any assumptions about how to update the hash if the | ||||
| # cset in question was split or diverged. | # cset in question was split or diverged. | ||||
| if len(successors) == 1 and len(successors[0]) == 1: | if len(successors) == 1 and len(successors[0]) == 1: | ||||
| newsha1 = node.hex(successors[0][0]) | newhash = node.hex(successors[0][0]) | ||||
| commitmsg = commitmsg.replace(sha1, newsha1[: len(sha1)]) | commitmsg = commitmsg.replace(h, newhash[: len(h)]) | ||||
| else: | else: | ||||
| repo.ui.note( | repo.ui.note( | ||||
| _( | _( | ||||
| b'The stale commit message reference to %s could ' | b'The stale commit message reference to %s could ' | ||||
| b'not be updated\n' | b'not be updated\n' | ||||
| ) | ) | ||||
| % sha1 | % h | ||||
| ) | ) | ||||
| return commitmsg | return commitmsg | ||||