Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mercurial repo: lockfile should contain hash and not Mercurial "revision" #2536

Closed
paugier opened this issue Jan 4, 2024 · 2 comments · Fixed by frostming/unearth#91
Closed
Labels
🐛 bug Something isn't working

Comments

@paugier
Copy link

paugier commented Jan 4, 2024

When using a Mercurial repository for a dependency, the lockfile currently contains something like:

[[package]]
name = "transonic"
version = "0.5.3"
requires_python = ">= 3.9"
hg = "https://foss.heptapod.net/fluiddyn/transonic"
ref = "default"
revision = "679"
[...]

However, it is wrong to save a Mercurial "revision" (obtained with something like hg log -r default -T "{rev}") because it is only a local identification of a commit (not valid for other clones). Instead PDM should save the hash of the commit (obtained with hg log -r default -T "{node}").

This can lead to some bugs when trying to create an environment from the lockfile:

Retry failed jobs
  ✖ Install transonic 0.5.3 failed

ERRORS:
add transonic failed:
Traceback (most recent call last):
  File 
"/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/concurrent/futures/threa
d.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File 
"/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pdm/instal
lers/synchronizers.py", line 286, in install_candidate
    self.manager.install(can)
  File 
"/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pdm/instal
lers/manager.py", line 34, in install
    dist_info = installer(str(prepared.build()), self.environment, 
prepared.direct_url())
  File 
"/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pdm/models
/candidates.py", line 403, in build
    self.obtain(allow_all=False)
  File 
"/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pdm/models
/candidates.py", line 458, in obtain
    self._unpack(validate_hashes=not allow_all)
  File 
"/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pdm/models
/candidates.py", line 472, in _unpack
    result = finder.download_and_unpack(
  File 
"/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/unearth/fi
nder.py", line 421, in download_and_unpack
    file = unpack_link(
  File 
"/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/unearth/pr
eparer.py", line 311, in unpack_link
    backend.fetch(link, location)
  File 
"/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/unearth/vc
s/base.py", line 152, in fetch
    return self.fetch_new(location, url, rev, args)
  File 
"/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/unearth/vc
s/hg.py", line 35, in fetch_new
    self.run_command(
  File 
"/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/unearth/vc
s/base.py", line 78, in run_command
    raise UnpackError(e.output) from None
unearth.errors.UnpackError: abort: unknown revision '679'
@paugier paugier added the 🐛 bug Something isn't working label Jan 4, 2024
@paugier
Copy link
Author

paugier commented Jan 4, 2024

A workaround is to manually correct the lockfile with the hash instead of the revision number.

Where is the code that gets this revision number for Mercurial repository? In PDM?

@paugier
Copy link
Author

paugier commented Jan 4, 2024

Would it be enough to change ["parents", "--template={rev}"], to ["parents", "--template={node}"], in this line https://github.com/frostming/unearth/blob/main/src/unearth/vcs/hg.py#L49C38-L49C41 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant