Unreviewed changes
4 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: lib/hg/goreposum.py
Insertions: 7, Deletions: 1.
@@ -15,6 +15,12 @@
# we will avoid re-cloning a server when there have been no
# changes at all.
#
+# Separately, this extension also adds a 'golookup' command that
+# returns the hash of a specific reference, like 'default' or a tag.
+# And golookup of a hash confirms that it still exists on the server.
+# We can use that to revalidate that specific versions still exist and
+# have the same meaning they did the last time we checked.
+#
# Usage:
#
# hg --config "extensions.goreposum=$GOROOT/lib/hg/goreposum.py" goreposum REPOURL
@@ -41,7 +47,7 @@
h.update(b' ')
h.update(r)
h.update(b'\n')
- if (b'bookmarks' in peer.listkeys(b'namespaces')) or True:
+ if (b'bookmarks' in peer.listkeys(b'namespaces')):
for name, rev in peer.listkeys(b'bookmarks').items():
h.update(name)
h.update(b'=')
```
```
The name of the file: src/cmd/go/internal/modfetch/codehost/vcs.go
Insertions: 6, Deletions: 8.
@@ -380,17 +380,15 @@
return strings.TrimSpace(string(out)), nil
}
-func (r *vcsRepo) origin(ctx context.Context, hash string, repoSum bool) *Origin {
+// repoSumOrigin returns an Origin containing a RepoSum.
+func (r *vcsRepo) repoSumOrigin(ctx context.Context) *Origin {
origin := &Origin{
VCS: r.cmd.vcs,
URL: r.remote,
- Hash: hash,
RepoSum: r.repoSum,
}
- if repoSum {
- r.repoSumOnce.Do(func() { r.loadRepoSum(ctx) })
- origin.RepoSum = r.repoSum
- }
+ r.repoSumOnce.Do(func() { r.loadRepoSum(ctx) })
+ origin.RepoSum = r.repoSum
return origin
}
@@ -446,7 +444,7 @@
r.tagsOnce.Do(func() { r.loadTags(ctx) })
tags := &Tags{
- Origin: r.origin(ctx, "", true),
+ Origin: r.repoSumOrigin(ctx),
List: []Tag{},
}
for tag := range r.tags {
@@ -513,7 +511,7 @@
func (r *vcsRepo) statLocal(ctx context.Context, rev string) (*RevInfo, error) {
out, err := Run(ctx, r.dir, r.cmd.statLocal(rev, r.remote))
if err != nil {
- info := &RevInfo{Origin: r.origin(ctx, "", true)}
+ info := &RevInfo{Origin: r.repoSumOrigin(ctx)}
return info, &UnknownRevisionError{Rev: rev}
}
info, err := r.cmd.parseStat(rev, string(out))
```
Change information
Commit message:
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
Files:
- A lib/hg/goreposum.py
- M src/cmd/go/internal/modfetch/cache.go
- M src/cmd/go/internal/modfetch/codehost/codehost.go
- M src/cmd/go/internal/modfetch/codehost/git_test.go
- M src/cmd/go/internal/modfetch/codehost/vcs.go
- M src/cmd/go/internal/modfetch/coderepo.go
- M src/cmd/go/internal/modload/build.go
- M src/cmd/go/internal/vcweb/vcweb.go
- M src/cmd/go/testdata/script/reuse_git.txt
- M src/cmd/go/testdata/script/reuse_hg.txt
- M src/cmd/go/testdata/vcstest/hg/prefixtagtests.txt
- M src/cmd/go/testdata/vcstest/hg/tagtests.txt
Change size: L
Delta: 12 files changed, 433 insertions(+), 248 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Michael Matloob, +1 by Michael Matloob
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI