From 83e510bb911a3fa581791e0103c6fcd3bc013ca8 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 2 Jul 2024 11:29:19 +0200 Subject: [PATCH] conan lock update comand (#3784) * conan lock update comand * missing file --- reference/commands/lock.rst | 1 + reference/commands/lock/add.rst | 2 +- reference/commands/lock/remove.rst | 2 +- reference/commands/lock/update.rst | 64 ++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 reference/commands/lock/update.rst diff --git a/reference/commands/lock.rst b/reference/commands/lock.rst index b1ded5a17620..25c7c8aaf3a1 100644 --- a/reference/commands/lock.rst +++ b/reference/commands/lock.rst @@ -18,6 +18,7 @@ In addition to these commands, most of the Conan commands that compute a graph, - :doc:`conan lock remove `: Manually remove items from a lockfile - :doc:`conan lock create `: Evaluates a dependency graph and save a lockfile - :doc:`conan lock merge `: Merge several existing lockfiles into one. +- :doc:`conan lock update `: Manually update items from a lockfile .. autocommand:: diff --git a/reference/commands/lock/add.rst b/reference/commands/lock/add.rst index d90a6d7db306..1c6d87600f69 100644 --- a/reference/commands/lock/add.rst +++ b/reference/commands/lock/add.rst @@ -5,7 +5,7 @@ conan lock add :command: conan lock add -h -The ``conan lock add`` command is able to add a package version to an existing or new lockfile ``requires``, ``build_requires`` or ``python_requires``. +The ``conan lock add`` command is able to add a package version to an existing or new lockfile ``requires``, ``build_requires``, ``python_requires`` or ``config_requires``. For example, the following is able to create a lockfile (by default, named ``conan.lock``): diff --git a/reference/commands/lock/remove.rst b/reference/commands/lock/remove.rst index 59e1d7a5eb1a..af0d10df32f4 100644 --- a/reference/commands/lock/remove.rst +++ b/reference/commands/lock/remove.rst @@ -5,7 +5,7 @@ conan lock remove :command: conan lock remove -h -The ``conan lock remove`` command is able to remove ``requires``, ``build_requires`` or ``python_requires`` items from an existing lockfile. +The ``conan lock remove`` command is able to remove ``requires``, ``build_requires``, ``python_requires`` or ``config_requires`` items from an existing lockfile. For example, if we have the following ``conan.lock``: diff --git a/reference/commands/lock/update.rst b/reference/commands/lock/update.rst new file mode 100644 index 000000000000..5488bc02c913 --- /dev/null +++ b/reference/commands/lock/update.rst @@ -0,0 +1,64 @@ +conan lock update +================= + +.. autocommand:: + :command: conan lock update -h + + +The ``conan lock update`` command is able to update ``requires``, ``build_requires``, ``python_requires`` or ``config_requires`` items from an existing lockfile. + +For example, if we have the following ``conan.lock``: + +.. code-block:: bash + + $ 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" + ] + } + + + +The ``conan lock update`` command: + +.. code-block:: bash + + $ conan lock update --requires=math/1.1 --build-requires=cmake/1.1 + +Will result in the following ``conan.lock``: + +.. code-block:: bash + + $ 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" + ] + } + + +The command will replace existing locked references that matches the same package name with the provided argument values. +If the provided references does not exist in the lockfile, they will be added (same as ``conan lock add`` command). + +This command is similar to do a ``conan lock remove`` followed by a ``conan lock add`` command.