view tests/fakemergerecord.py @ 47428:54849b65dc5f

cmdutil: make checknotesize() work on str-keyed opts Since this patch changes the behavior of the function, I consider it a bonus if the signature also changes so that extensions can detect which version they're dealing with (for the record, I don't have any such extensions). Therefore, I also dropped an unused `ui` argument and renamed the function to use snake_case. Differential Revision: https://phab.mercurial-scm.org/D10859
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 10 Jun 2021 14:25:16 -0700
parents b7808443ed6a
children 6000f5b25c9b
line wrap: on
line source

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

from __future__ import absolute_import

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)