view tests/fakemergerecord.py @ 51724:a3dc962cac62

typing: add type hints to `mercurial.policy` Mostly trivial, but this seems like the logical module to use to inject the hints from `cext`, `pure`, etc, given that this file has the fallback policy. This is a first step. There doesn't appear to be a predefined type for a module in py3.7, so those are omitted for now.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 20 Jul 2024 17:03:30 -0400
parents 6000f5b25c9b
children
line wrap: on
line source

# Extension to write out fake unsupported records into the merge state
#
#


from mercurial import (
    mergestate as mergestatemod,
    registrar,
)

cmdtable = {}
command = registrar.command(cmdtable)


@command(
    b'fakemergerecord',
    [
        (b'X', b'mandatory', None, b'add a fake mandatory record'),
        (b'x', b'advisory', None, b'add a fake advisory record'),
    ],
    '',
)
def fakemergerecord(ui, repo, *pats, **opts):
    with repo.wlock():
        ms = mergestatemod.mergestate.read(repo)
        records = ms._makerecords()
        if opts.get('mandatory'):
            records.append((b'X', b'mandatory record'))
        if opts.get('advisory'):
            records.append((b'x', b'advisory record'))
        ms._writerecords(records)