Skip to content

Commit

Permalink
Updated based on threads
Browse files Browse the repository at this point in the history
  • Loading branch information
perseoGI committed Jan 16, 2025
1 parent c3936d7 commit eb29a17
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
6 changes: 3 additions & 3 deletions conan/cli/commands/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def lock_create(conan_api, parser, subparser, *args):
clean=args.lockfile_clean)
conanfile_path = os.path.dirname(graph.root.path) \
if graph.root.path and args.lockfile_out is None else cwd
conan_api.lockfile.save_lockfile(lockfile, args.lockfile_out or LOCKFILE, conanfile_path)
conan_api.lockfile.save_lockfile(lockfile, args.lockfile_out or "conan.lock", conanfile_path)


@conan_subcommand()
Expand Down Expand Up @@ -187,7 +187,7 @@ def lock_update(conan_api, parser, subparser, *args):
@conan_subcommand()
def lock_upgrade(conan_api, parser, subparser, *args):
"""
Upgrade requires, build-requires or python-requires from an existing lockfile given a conanfile
(Experimental) Upgrade requires, build-requires or python-requires from an existing lockfile given a conanfile
or a reference.
"""
common_graph_args(subparser)
Expand Down Expand Up @@ -244,4 +244,4 @@ def lock_upgrade(conan_api, parser, subparser, *args):

lockfile = conan_api.lockfile.update_lockfile(lockfile, graph, args.lockfile_packages,
clean=args.lockfile_clean)
conan_api.lockfile.save_lockfile(lockfile, args.lockfile_out or LOCKFILE)
conan_api.lockfile.save_lockfile(lockfile, args.lockfile_out or "conan.lock")
44 changes: 43 additions & 1 deletion test/integration/lockfile/test_user_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

from conan.test.assets.genconanfile import GenConanfile
from conan.test.utils.tools import TestClient
from conan.test.utils.tools import NO_SETTINGS_PACKAGE_ID, TestClient


def test_user_overrides():
Expand Down Expand Up @@ -420,4 +420,46 @@ def test_lock_upgrade_path(self):
assert "libb/1.1" in lock
assert "libc/1.0" in lock

def test_lock_upgrade_transitives(self):
c = TestClient(light=True)
c.save({"liba/conanfile.py": GenConanfile("liba"),
"libb/conanfile.py": GenConanfile("libb").with_requires("libc/[<2.0]"),
"libc/conanfile.py": GenConanfile("libc")})
c.run(f"export liba --version=1.0")
c.run(f"export libc --version=1.0")
c.run(f"create libb --version=1.0 --build=missing")
c.save(
{
f"conanfile.py": GenConanfile()
.with_requires(f"liba/[>=1.0 <2]")
.with_requires("libb/[<1.2]")
}
)

c.run("lock create .")
lock = c.load("conan.lock")
assert "liba/1.0" in lock
assert "libb/1.0" in lock
assert "libc/1.0" in lock

c.run(f"export libc --version=1.1")
c.save({"libb/conanfile.py": GenConanfile("libb").with_requires("libc/[>1.0]")})
c.run(f"create libb --version=1.1 --build=missing")
c.run("lock upgrade . --update-requires=libb/[*]")
lock = c.load("conan.lock")
assert "liba/1.0" in lock
assert "libb/1.1" in lock
assert "libc/1.1" in lock # TODO

c.save({"libb/conanfile.py": GenConanfile("libb").with_requires("libc/[<2.0]").with_requires("libd/[<2.0]"),
"libd/conanfile.py": GenConanfile("libd")})

c.run(f"export libd --version=1.0")
c.run(f"create libb --version=1.1 --build=missing")
c.run("lock upgrade . --update-requires=libb/[*]")

lock = c.load("conan.lock")
assert "liba/1.0" in lock
assert "libb/1.1" in lock
assert "libc/1.0" in lock
assert "libd/1.0" in lock

0 comments on commit eb29a17

Please sign in to comment.