]> Cypherpunks repositories - gostls13.git/commit
cmd/go: implement -reuse for Mercurial repos
authorRuss Cox <rsc@golang.org>
Tue, 19 Aug 2025 19:27:39 +0000 (15:27 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 11 Nov 2025 15:21:02 +0000 (07:21 -0800)
commit426ef30ecf2d2b6eadd962358884ed68220b9cc5
tree1a9b8246de6309f2ca84b7744cb2ed6114d66d10
parent5241d114f55cfa69a4bf8f2051f5d83d1f618859
cmd/go: implement -reuse for Mercurial repos

When we added -reuse in CL 411398, we only handled Git repos.
This was partly because we were focused on Git traffic,
partly because Git is the dominant module VCS, and
partly because I couldn't see how to retrieve the metadata needed
in other version control systems.

This CL adds -reuse support for Mercurial, the second
most popular VCS for modules, now that I see how to
implement it. Although the Mercurial command line does
not have sufficient information, the Mercurial Python API does,
so we ship and invoke a Mercurial extension written in Python
that can compute a hash of the remote repo without downloading
it entirely, as well as resolve a remote name to a hash or check
the continued existence of a hash. Then we can avoid
downloading the repo at all if it hasn't changed since the last check
or if the specific reference we need still resolves or exists.

Fixes #75119.

Change-Id: Ia47d89b15c1091c44efef9d325270fc400a412c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/718382
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
12 files changed:
lib/hg/goreposum.py [new file with mode: 0644]
src/cmd/go/internal/modfetch/cache.go
src/cmd/go/internal/modfetch/codehost/codehost.go
src/cmd/go/internal/modfetch/codehost/git_test.go
src/cmd/go/internal/modfetch/codehost/vcs.go
src/cmd/go/internal/modfetch/coderepo.go
src/cmd/go/internal/modload/build.go
src/cmd/go/internal/vcweb/vcweb.go
src/cmd/go/testdata/script/reuse_git.txt
src/cmd/go/testdata/script/reuse_hg.txt
src/cmd/go/testdata/vcstest/hg/prefixtagtests.txt
src/cmd/go/testdata/vcstest/hg/tagtests.txt