conan lock update

$ conan lock update -h
usage: conan lock update [-h] [-v [V]] [-cc CORE_CONF] [--requires REQUIRES]
                         [--build-requires BUILD_REQUIRES]
                         [--python-requires PYTHON_REQUIRES]
                         [--config-requires CONFIG_REQUIRES]
                         [--lockfile-out LOCKFILE_OUT] [--lockfile LOCKFILE]

Update requires, build-requires or python-requires from an existing lockfile.
References that matches the arguments package names will be replaced by the
arguments. References can be supplied with and without revisions like "--
requires=pkg/version",

options:
  -h, --help            show this help message and exit
  -v [V]                Level of detail of the output. Valid options from less
                        verbose to more verbose: -vquiet, -verror, -vwarning,
                        -vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
                        -vvv or -vtrace
  -cc CORE_CONF, --core-conf CORE_CONF
                        Define core configuration, overwriting global.conf
                        values. E.g.: -cc core:non_interactive=True
  --requires REQUIRES   Update references to lockfile.
  --build-requires BUILD_REQUIRES
                        Update build-requires from lockfile
  --python-requires PYTHON_REQUIRES
                        Update python-requires from lockfile
  --config-requires CONFIG_REQUIRES
                        Update config-requires from lockfile
  --lockfile-out LOCKFILE_OUT
                        Filename of the created lockfile
  --lockfile LOCKFILE   Filename of the input lockfile

conan lock update 命令能够更新现有 lockfile 中的 requiresbuild_requirespython_requiresconfig_requires 项目。

例如,如果我们有以下 conan.lock

$ cat conan.lock
{
    "version": "0.5",
    "requires": [
        "math/1.0#85d927a4a067a531b1a9c7619522c015%1702683583.3411012",
        "engine/1.0#fd2b006646a54397c16a1478ac4111ac%1702683583.3544693"
    ],
    "build_requires": [
        "cmake/1.0#85d927a4a067a531b1a9c7619522c015%1702683583.3411012",
        "ninja/1.0#fd2b006646a54397c16a1478ac4111ac%1702683583.3544693"
    ],
    "python_requires": [
        "mytool/1.0#85d927a4a067a531b1a9c7619522c015%1702683583.3411012",
        "othertool/1.0#fd2b006646a54397c16a1478ac4111ac%1702683583.3544693"
    ]
}

conan lock update 命令

$ conan lock update --requires=math/1.1 --build-requires=cmake/1.1

将生成以下 conan.lock

$ cat conan.lock
{
    "version": "0.5",
    "requires": [
        "math/1.1",
        "engine/1.0#fd2b006646a54397c16a1478ac4111ac%1702683583.3544693"
    ],
    "build_requires": [
        "cmake/1.1",
        "ninja/1.0#fd2b006646a54397c16a1478ac4111ac%1702683583.3544693"
    ],
    "python_requires": [
        "mytool/1.0#85d927a4a067a531b1a9c7619522c015%1702683583.3411012",
        "othertool/1.0#fd2b006646a54397c16a1478ac4111ac%1702683583.3544693"
    ]
}

该命令将替换与提供的参数值匹配的相同包名称的现有锁定引用。如果提供的引用在 lockfile 中不存在,则将添加它们(与 conan lock add 命令相同)。

此命令类似于执行 conan lock remove 后跟 conan lock add 命令。