diff --git a/lib/hg/goreposum.py b/lib/hg/goreposum.py
new file mode 100644
index 0000000..0d3ef80
--- /dev/null
+++ b/lib/hg/goreposum.py
@@ -0,0 +1,40 @@
+# Copyright 2025 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# Mercurial extension to add a 'goreposum' command that
+# computes a hash of a remote repo's tag state.
+# Tag definitions can come from the .hgtags file stored in
+# any head of any branch, and the server protocol does not
+# expose the tags directly. However, the protocol does expose
+# the hashes of all the branch heads, so we can use a hash of
+# all those branch names and heads as a conservative snapshot
+# of the entire remote repo state, and use that as the tag sum.
+# Any change on the server then invalidates the tag sum,
+# even if it didn't have anything to do with tags, but at least
+# we will avoid re-cloning a server when there have been no
+# changes at all.
+#
+# Usage:
+#
+# hg --config "extensions.goreposum=$GOROOT/lib/hg/goreposum.py" goreposum REPOURL
+
+import base64, hashlib, sys
+from mercurial import registrar, ui, hg, node
+from mercurial.i18n import _
+cmdtable = {}
+command = registrar.command(cmdtable)
+@command(b'goreposum', [], _('url'), norepo=True)
+def goreposum(ui, url):
+ h = hashlib.sha256()
+ for name, revs in hg.peer(ui, {}, url).branchmap().items():
+ h.update(name)
+ for r in revs:
+ h.update(b' ')
+ h.update(r)
+ h.update(b'\n')
+ print('r1:'+base64.standard_b64encode(h.digest()).decode('utf-8'))
+
+@command(b'golookup', [], _('url rev'), norepo=True)
+def golookup(ui, url, rev):
+ print(node.hex(hg.peer(ui, {}, url).lookup(rev)).decode('utf-8'))
diff --git a/src/cmd/go/internal/modfetch/codehost/codehost.go b/src/cmd/go/internal/modfetch/codehost/codehost.go
index edb87e4..08b1216 100644
--- a/src/cmd/go/internal/modfetch/codehost/codehost.go
+++ b/src/cmd/go/internal/modfetch/codehost/codehost.go
@@ -116,9 +116,12 @@
Ref string `json:",omitempty"`
// If RepoSum is non-empty, then the resolution of this module version
- // failed due to the repo being available but the version not being present.
- // This depends on the entire state of the repo, which RepoSum summarizes.
- // For Git, this is a hash of all the refs and their hashes.
+ // depends on the entire state of the repo, which RepoSum summarizes.
+ // For Git, this is a hash of all the refs and their hashes, and the RepoSum
+ // is only needed for module versions that don't exist.
+ // For Mercurial, this is a hash of all the branches and their heads' hashes,
+ // since the set of available tags is dervied from .hgtags files in those branches,
+ // and the RepoSum is used for all module versions, available and not,
RepoSum string `json:",omitempty"`
}
diff --git a/src/cmd/go/internal/modfetch/codehost/vcs.go b/src/cmd/go/internal/modfetch/codehost/vcs.go
index d803975..82db454 100644
--- a/src/cmd/go/internal/modfetch/codehost/vcs.go
+++ b/src/cmd/go/internal/modfetch/codehost/vcs.go
@@ -20,6 +20,7 @@
"time"
"cmd/go/internal/base"
+ "cmd/go/internal/cfg"
"cmd/go/internal/lockedfile"
"cmd/go/internal/str"
"cmd/internal/par"
@@ -80,6 +81,9 @@
fetchOnce sync.Once
fetchErr error
+
+ repoSumOnce sync.Once
+ repoSum string
}
func newVCSRepo(ctx context.Context, vcs, remote string, local bool) (Repo, error) {
@@ -129,6 +133,9 @@
return nil, err
}
_, err = Run(ctx, r.dir, cmd.init(r.remote))
+ if err == nil && cmd.postInit != nil {
+ err = cmd.postInit(ctx, r)
+ }
release()
if err != nil {
@@ -142,20 +149,26 @@
const vcsWorkDirType = "vcs1."
type vcsCmd struct {
- vcs string // vcs name "hg"
- init func(remote string) []string // cmd to init repo to track remote
- tags func(remote string) []string // cmd to list local tags
- tagRE *lazyregexp.Regexp // regexp to extract tag names from output of tags cmd
- branches func(remote string) []string // cmd to list local branches
- branchRE *lazyregexp.Regexp // regexp to extract branch names from output of tags cmd
- badLocalRevRE *lazyregexp.Regexp // regexp of names that must not be served out of local cache without doing fetch first
- statLocal func(rev, remote string) []string // cmd to stat local rev
- parseStat func(rev, out string) (*RevInfo, error) // cmd to parse output of statLocal
- fetch []string // cmd to fetch everything from remote
- latest string // name of latest commit on remote (tip, HEAD, etc)
- readFile func(rev, file, remote string) []string // cmd to read rev's file
- readZip func(rev, subdir, remote, target string) []string // cmd to read rev's subdir as zip file
- doReadZip func(ctx context.Context, dst io.Writer, workDir, rev, subdir, remote string) error // arbitrary function to read rev's subdir as zip file
+ vcs string // vcs name "hg"
+ init func(remote string) []string // cmd to init repo to track remote
+ postInit func(context.Context, *vcsRepo) error // func to init repo after .init runs
+ repoSum func(remote string) []string // cmd to calculate reposum of remote repo
+ tags func(remote string) []string // cmd to list local tags
+ tagsNeedsFetch bool // run fetch before tags
+ tagRE *lazyregexp.Regexp // regexp to extract tag names from output of tags cmd
+ branches func(remote string) []string // cmd to list local branches
+ branchesNeedsFetch bool // run branches before tags
+ branchRE *lazyregexp.Regexp // regexp to extract branch names from output of tags cmd
+ badLocalRevRE *lazyregexp.Regexp // regexp of names that must not be served out of local cache without doing fetch first
+ statLocal func(rev, remote string) []string // cmd to stat local rev
+ parseStat func(rev, out string) (*RevInfo, error) // func to parse output of statLocal
+ fetch []string // cmd to fetch everything from remote
+ latest string // name of latest commit on remote (tip, HEAD, etc)
+ readFile func(rev, file, remote string) []string // cmd to read rev's file
+ readZip func(rev, subdir, remote, target string) []string // cmd to read rev's subdir as zip file
+
+ // arbitrary function to read rev's subdir as zip file
+ doReadZip func(ctx context.Context, dst io.Writer, workDir, rev, subdir, remote string) error
}
var re = lazyregexp.New
@@ -163,18 +176,29 @@
var vcsCmds = map[string]*vcsCmd{
"hg": {
vcs: "hg",
- init: func(remote string) []string {
- return []string{"hg", "clone", "-U", "--", remote, "."}
+ repoSum: func(remote string) []string {
+ return []string{
+ "hg",
+ "--config=extensions.goreposum=" + filepath.Join(cfg.GOROOT, "lib/hg/goreposum.py"),
+ "goreposum",
+ remote,
+ }
},
+ init: func(remote string) []string {
+ return []string{"hg", "init", "."}
+ },
+ postInit: hgAddRemote,
tags: func(remote string) []string {
return []string{"hg", "tags", "-q"}
},
- tagRE: re(`(?m)^[^\n]+$`),
+ tagsNeedsFetch: true,
+ tagRE: re(`(?m)^[^\n]+$`),
branches: func(remote string) []string {
return []string{"hg", "branches", "-c", "-q"}
},
- branchRE: re(`(?m)^[^\n]+$`),
- badLocalRevRE: re(`(?m)^(tip)$`),
+ branchesNeedsFetch: true,
+ branchRE: re(`(?m)^[^\n]+$`),
+ badLocalRevRE: re(`(?m)^(tip)$`),
statLocal: func(rev, remote string) []string {
return []string{"hg", "log", "-l1", "-r", rev, "--template", "{node} {date|hgdate} {tags}"}
},
@@ -276,6 +300,10 @@
}
func (r *vcsRepo) loadTags(ctx context.Context) {
+ if r.cmd.tagsNeedsFetch {
+ r.fetchOnce.Do(func() { r.fetch(ctx) })
+ }
+
out, err := Run(ctx, r.dir, r.cmd.tags(r.remote))
if err != nil {
return
@@ -296,6 +324,10 @@
return
}
+ if r.cmd.branchesNeedsFetch {
+ r.fetchOnce.Do(func() { r.fetch(ctx) })
+ }
+
out, err := Run(ctx, r.dir, r.cmd.branches(r.remote))
if err != nil {
return
@@ -310,7 +342,49 @@
}
}
+func (r *vcsRepo) loadRepoSum(ctx context.Context) {
+ if r.cmd.repoSum == nil {
+ return
+ }
+ out, err := Run(ctx, r.dir, r.cmd.repoSum(r.remote))
+ if err != nil {
+ return
+ }
+ r.repoSum = strings.TrimSpace(string(out))
+}
+
+func (r *vcsRepo) origin(ctx context.Context, hash string) *Origin {
+ r.repoSumOnce.Do(func() { r.loadRepoSum(ctx) })
+ origin := &Origin{
+ VCS: r.cmd.vcs,
+ URL: r.remote,
+ Hash: hash,
+ RepoSum: r.repoSum,
+ }
+ return origin
+}
+
func (r *vcsRepo) CheckReuse(ctx context.Context, old *Origin, subdir string) error {
+ if old == nil {
+ return fmt.Errorf("missing origin")
+ }
+ if old.VCS != r.cmd.vcs || old.URL != r.remote {
+ return fmt.Errorf("origin moved from %v %q to %v %q", old.VCS, old.URL, r.cmd.vcs, r.remote)
+ }
+ if old.Subdir != subdir {
+ return fmt.Errorf("origin moved from %v %q %q to %v %q %q", old.VCS, old.URL, old.Subdir, r.cmd.vcs, r.remote, subdir)
+ }
+
+ r.repoSumOnce.Do(func() { r.loadRepoSum(ctx) })
+ if r.repoSum != "" {
+ if old.RepoSum == "" {
+ return fmt.Errorf("non-specific origin")
+ }
+ if old.RepoSum != r.repoSum {
+ return fmt.Errorf("repo changed")
+ }
+ return nil
+ }
return fmt.Errorf("vcs %s: CheckReuse: %w", r.cmd.vcs, errors.ErrUnsupported)
}
@@ -323,14 +397,8 @@
r.tagsOnce.Do(func() { r.loadTags(ctx) })
tags := &Tags{
- // None of the other VCS provide a reasonable way to compute TagSum
- // without downloading the whole repo, so we only include VCS and URL
- // in the Origin.
- Origin: &Origin{
- VCS: r.cmd.vcs,
- URL: r.remote,
- },
- List: []Tag{},
+ Origin: r.origin(ctx, ""),
+ List: []Tag{},
}
for tag := range r.tags {
if strings.HasPrefix(tag, prefix) {
@@ -372,7 +440,7 @@
}
info, err := r.statLocal(ctx, rev)
if err != nil {
- return nil, err
+ return info, err
}
if !revOK {
info.Version = info.Name
@@ -393,9 +461,11 @@
}
func (r *vcsRepo) statLocal(ctx context.Context, rev string) (*RevInfo, error) {
+ r.repoSumOnce.Do(func() { r.loadRepoSum(ctx) })
out, err := Run(ctx, r.dir, r.cmd.statLocal(rev, r.remote))
if err != nil {
- return nil, &UnknownRevisionError{Rev: rev}
+ info := &RevInfo{Origin: r.origin(ctx, "")}
+ return info, &UnknownRevisionError{Rev: rev}
}
info, err := r.cmd.parseStat(rev, string(out))
if err != nil {
@@ -406,6 +476,7 @@
}
info.Origin.VCS = r.cmd.vcs
info.Origin.URL = r.remote
+ info.Origin.RepoSum = r.repoSum
return info, nil
}
@@ -521,6 +592,11 @@
return d.File.Close()
}
+func hgAddRemote(ctx context.Context, r *vcsRepo) error {
+ // Write .hg/hgrc with remote URL in it.
+ return os.WriteFile(filepath.Join(r.dir, ".hg/hgrc"), []byte(fmt.Sprintf("[paths]\ndefault = %s\n", r.remote)), 0666)
+}
+
func hgParseStat(rev, out string) (*RevInfo, error) {
f := strings.Fields(out)
if len(f) < 3 {
@@ -545,9 +621,7 @@
sort.Strings(tags)
info := &RevInfo{
- Origin: &Origin{
- Hash: hash,
- },
+ Origin: &Origin{Hash: hash},
Name: hash,
Short: ShortenSHA1(hash),
Time: time.Unix(t, 0).UTC(),
@@ -630,9 +704,7 @@
version = hash // extend to full hash
}
info := &RevInfo{
- Origin: &Origin{
- Hash: hash,
- },
+ Origin: &Origin{Hash: hash},
Name: hash,
Short: ShortenSHA1(hash),
Time: t,
diff --git a/src/cmd/go/internal/vcweb/vcweb.go b/src/cmd/go/internal/vcweb/vcweb.go
index 4b4e127..98d39a3 100644
--- a/src/cmd/go/internal/vcweb/vcweb.go
+++ b/src/cmd/go/internal/vcweb/vcweb.go
@@ -199,8 +199,10 @@
defer func() {
if v := recover(); v != nil {
- debug.PrintStack()
- s.logger.Fatal(v)
+ if v == http.ErrAbortHandler {
+ panic(v)
+ }
+ s.logger.Fatalf("panic serving %s: %v\n%s", req.URL, v, debug.Stack())
}
}()
diff --git a/src/cmd/go/testdata/script/reuse_hg.txt b/src/cmd/go/testdata/script/reuse_hg.txt
index 42516ce..6d85b87 100644
--- a/src/cmd/go/testdata/script/reuse_hg.txt
+++ b/src/cmd/go/testdata/script/reuse_hg.txt
@@ -1,360 +1,344 @@
-skip # still git
-
[short] skip
-[!git] skip
+[!exec:hg] skip
env GO111MODULE=on
env GOPROXY=direct
env GOSUMDB=off
-# go mod download with the pseudo-version should invoke git but not have a TagSum or Ref.
-go mod download -x -json vcs-test.golang.org/git/hell...@v0.0.0-20170922010558-fc3a09f3dc5c
-stderr 'git( .*)* fetch'
+# go mod download with the pseudo-version should invoke hg but not have a TagSum or Ref. RepoSum is OK.
+go mod download -x -json vcs-test.golang.org/hg/hell...@v0.0.0-20170922011414-e483a7d9f8c9
+stderr 'hg( .*)* pull'
cp stdout hellopseudo.json
! stdout '"(Query|TagPrefix|TagSum|Ref)"'
-stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/hello"'
-stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
-! stdout '"RepoSum"'
+stdout '"Version": "v0.0.0-20170922011414-e483a7d9f8c9"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/hello"'
+stdout '"Hash": "e483a7d9f8c9b4bc57430bdd8f81f0a65e4011c0"'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
go clean -modcache
-# go mod download vcstest/hello should invoke git, print origin info
-go mod download -x -json vcs-test.golang.org/git/hello.git@latest
-stderr 'git( .*)* fetch'
+# go mod download hg/hello should invoke hg, print origin info
+go mod download -x -json vcs-test.golang.org/hg/hello.hg@latest
+stderr 'hg( .*)* pull'
cp stdout hello.json
-stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/hello"'
+stdout '"Version": "v0.0.0-20170922011414-e483a7d9f8c9"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/hello"'
stdout '"Query": "latest"'
! stdout '"TagPrefix"'
-stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
-stdout '"Ref": "HEAD"'
-stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
-! stdout '"RepoSum"'
+! stdout '"TagSum"'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
+stdout '"Hash": "e483a7d9f8c9b4bc57430bdd8f81f0a65e4011c0"'
-# pseudo-version again should not invoke git fetch (it has the version from the @latest query)
+# pseudo-version again should not invoke hg pull (it has the version from the @latest query)
# but still be careful not to include a TagSum or a Ref, especially not Ref set to HEAD,
# which is easy to do when reusing the cached version from the @latest query.
-go mod download -x -json vcs-test.golang.org/git/hell...@v0.0.0-20170922010558-fc3a09f3dc5c
-! stderr 'git( .*)* fetch'
+go mod download -x -json vcs-test.golang.org/hg/hell...@v0.0.0-20170922011414-e483a7d9f8c9
+! stderr 'hg( .*)* (pull|clone)'
cp stdout hellopseudo2.json
cmpenv hellopseudo.json hellopseudo2.json
-# go mod download vcstest/hello@hash needs to check TagSum to find pseudoversion base.
-go mod download -x -json vcs-test.golang.org/git/hello.git@fc3a09f3dc5c
-! stderr 'git( .*)* fetch'
+# go mod download hg/hello@hash needs to hg pull to find pseudoversion base.
+go mod download -x -json vcs-test.golang.org/hg/hello.hg@e483a7d9f8c9
+stderr 'hg( .*)* pull'
cp stdout hellohash.json
-stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
-stdout '"Query": "fc3a09f3dc5c"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/hello"'
-stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
-stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
-! stdout '"RepoSum"'
+stdout '"Version": "v0.0.0-20170922011414-e483a7d9f8c9"'
+stdout '"Query": "e483a7d9f8c9"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/hello"'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
+stdout '"Hash": "e483a7d9f8c9b4bc57430bdd8f81f0a65e4011c0"'
-# go mod download vcstest/hello/v9 should fail, still print origin info
-! go mod download -x -json vcs-test.golang.org/git/hello.git/v9@latest
+# go mod download hg/hello/v9 should fail, still print origin info
+! go mod download -x -json vcs-test.golang.org/hg/hello.hg/v9@latest
cp stdout hellov9.json
stdout '"Version": "latest"'
stdout '"Error":.*no matching versions'
! stdout '"TagPrefix"'
-stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
-stdout '"Ref": "HEAD"'
-stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
-! stdout 'RepoSum'
+! stdout '"TagSum"'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
+stdout '"Hash": "e483a7d9f8c9b4bc57430bdd8f81f0a65e4011c0"'
-# go mod download vcstest/hello/sub/v9 should also fail, print origin info with TagPrefix
-! go mod download -x -json vcs-test.golang.org/git/hello.git/sub/v9@latest
+# go mod download hg/hello/sub/v9 should also fail, print origin info
+! go mod download -x -json vcs-test.golang.org/hg/hello.hg/sub/v9@latest
cp stdout hellosubv9.json
stdout '"Version": "latest"'
stdout '"Error":.*no matching versions'
-stdout '"TagPrefix": "sub/"'
-stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
-stdout '"Ref": "HEAD"'
-stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
-! stdout 'RepoSum'
+! stdout '"TagPrefix"'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
+stdout '"Hash": "e483a7d9f8c9b4bc57430bdd8f81f0a65e4011c0"'
-# go mod download vcstest/hello@nonexist should fail, still print origin info
-! go mod download -x -json vcs-test.golang.org/git/hello.git@nonexist
+# go mod download hg/hello@nonexist should fail, still print origin info
+! go mod download -x -json vcs-test.golang.org/hg/hello.hg@nonexist
cp stdout hellononexist.json
stdout '"Version": "nonexist"'
stdout '"Error":.*unknown revision nonexist'
-stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
! stdout '"(TagPrefix|TagSum|Ref|Hash)"'
-# go mod download vcstest/hello@1234567890123456789012345678901234567890 should fail, still print origin info
+# go mod download hg/hello@1234567890123456789012345678901234567890 should fail, still print origin info
# (40 hex digits is assumed to be a full hash and is a slightly different code path from @nonexist)
-! go mod download -x -json vcs-test.golang.org/git/hello.git@1234567890123456789012345678901234567890
+! go mod download -x -json vcs-test.golang.org/hg/hello.hg@1234567890123456789012345678901234567890
cp stdout hellononhash.json
stdout '"Version": "1234567890123456789012345678901234567890"'
stdout '"Error":.*unknown revision 1234567890123456789012345678901234567890'
-stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
! stdout '"(TagPrefix|TagSum|Ref|Hash)"'
-# go mod download vcstest/he...@v0.0.0-20220101120101-123456789abc should fail, still print origin info
+# go mod download hg/he...@v0.0.0-20220101120101-123456789abc should fail, still print origin info
# (non-existent pseudoversion)
-! go mod download -x -json vcs-test.golang.org/git/hell...@v0.0.0-20220101120101-123456789abc
+! go mod download -x -json vcs-test.golang.org/hg/hell...@v0.0.0-20220101120101-123456789abc
cp stdout hellononpseudo.json
stdout '"Version": "v0.0.0-20220101120101-123456789abc"'
stdout '"Error":.*unknown revision 123456789abc'
-stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
! stdout '"(TagPrefix|TagSum|Ref|Hash)"'
-# go mod download vcstest/tagtests should invoke git, print origin info
-go mod download -x -json vcs-test.golang.org/git/tagtests.git@latest
-stderr 'git( .*)* fetch'
+# go mod download hg/tagtests should invoke hg, print origin info
+go mod download -x -json vcs-test.golang.org/hg/tagtests.hg@latest
+stderr 'hg( .*)* pull'
cp stdout tagtests.json
stdout '"Version": "v0.2.2"'
stdout '"Query": "latest"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/tagtests"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/tagtests"'
! stdout '"TagPrefix"'
-stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
-stdout '"Ref": "refs/tags/v0.2.2"'
-stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
-! stdout '"RepoSum"'
+! stdout '"TagSum"'
+stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'
+stdout '"Hash": "1e531550e864b16f25013cfbbf2d8e7cf07a0374"'
-# go mod download vcstest/tagt...@v0.2.2 should print origin info, no TagSum needed
-go mod download -x -json vcs-test.golang.org/git/tagtes...@v0.2.2
+# go mod download hg/tagt...@v0.2.2 should print origin info,
+# needs a RepoSum because Mercurial tag info is strewn about the repo.
+go mod download -x -json vcs-test.golang.org/hg/tagte...@v0.2.2
cp stdout tagtestsv022.json
stdout '"Version": "v0.2.2"'
! stdout '"Query":'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/tagtests"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/tagtests"'
! stdout '"TagPrefix"'
! stdout '"TagSum"'
-stdout '"Ref": "refs/tags/v0.2.2"'
-stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
-! stdout '"RepoSum"'
+stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'
+stdout '"Hash": "1e531550e864b16f25013cfbbf2d8e7cf07a0374"'
-# go mod download vcstest/tagtests@master needs a TagSum again
-go mod download -x -json vcs-test.golang.org/git/tagtests.git@master
-cp stdout tagtestsmaster.json
-stdout '"Version": "v0.2.3-0.20190509225625-c7818c24fa2f"'
-stdout '"Query": "master"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/tagtests"'
+# go mod download hg/tagtests@default needs a RepoSum too
+go mod download -x -json vcs-test.golang.org/hg/tagtests.hg@default
+cp stdout tagtestsdefault.json
+stdout '"Version": "v0.0.0-20190509225625-8d0b18b816df"'
+stdout '"Query": "default"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/tagtests"'
! stdout '"TagPrefix"'
-stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
-stdout '"Ref": "refs/heads/master"'
-stdout '"Hash": "c7818c24fa2f3f714c67d0a6d3e411c85a518d1f"'
-! stdout '"RepoSum"'
+! stdout '"TagSum"'
+stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'
+stdout '"Hash": "8d0b18b816df5e9c564761b405b1d7949c24ee6b"'
-# go mod download vcstest/prefixtagtests should invoke git, print origin info
-go mod download -x -json vcs-test.golang.org/git/prefixtagtests.git/sub@latest
-stderr 'git( .*)* fetch'
+# go mod download hg/prefixtagtests should invoke hg, print origin info
+go mod download -x -json vcs-test.golang.org/hg/prefixtagtests.hg/sub@latest
+stderr 'hg( .*)* pull'
cp stdout prefixtagtests.json
stdout '"Version": "v0.0.10"'
stdout '"Query": "latest"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/prefixtagtests"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/prefixtagtests"'
stdout '"Subdir": "sub"'
-stdout '"TagPrefix": "sub/"'
-stdout '"TagSum": "t1:YGSbWkJ8dn9ORAr[+]BlKHFK/2ZhXLb9hVuYfTZ9D8C7g="'
-stdout '"Ref": "refs/tags/sub/v0.0.10"'
-stdout '"Hash": "2b7c4692e12c109263cab51b416fcc835ddd7eae"'
-! stdout '"RepoSum"'
+! stdout '"TagPrefix"'
+! stdout '"TagSum"'
+stdout '"RepoSum": "r1:YWOcei109p5Kohsr5xnSYlaQXmpT3iWZHZhRbfMoTkc="'
+stdout '"Hash": "1cc0dfcc254cb8901799e7f7ae182c04019b7a88"'
# go mod download of a bunch of these should fail (some are invalid) but write good JSON for later
-! go mod download -json vcs-test.golang.org/git/hello.git@latest vcs-test.golang.org/git/hello.git/v9@latest vcs-test.golang.org/git/hello.git/sub/v9@latest vcs-test.golang.org/git/tagtests.git@latest vcs-test.golang.org/git/tagtes...@v0.2.2 vcs-test.golang.org/git/tagtests.git@master
+! go mod download -json vcs-test.golang.org/hg/hello.hg@latest vcs-test.golang.org/hg/hello.hg/v9@latest vcs-test.golang.org/hg/hello.hg/sub/v9@latest vcs-test.golang.org/hg/tagtests.hg@latest vcs-test.golang.org/hg/tagte...@v0.2.2 vcs-test.golang.org/hg/tagtests.hg@default
cp stdout all.json
-# clean the module cache, make sure that makes go mod download re-run git fetch, clean again
+# clean the module cache, make sure that makes go mod download re-run hg pull, clean again
go clean -modcache
-go mod download -x -json vcs-test.golang.org/git/hello.git@latest
-stderr 'git( .*)* fetch'
+go mod download -x -json vcs-test.golang.org/hg/hello.hg@latest
+stderr 'hg( .*)* pull'
go clean -modcache
-# reuse go mod download vcstest/hello result
-go mod download -reuse=hello.json -x -json vcs-test.golang.org/git/hello.git@latest
-! stderr 'git( .*)* fetch'
+# reuse go mod download hg/hello result
+go mod download -reuse=hello.json -x -json vcs-test.golang.org/hg/hello.hg@latest
+! stderr 'hg( .*)* pull'
stdout '"Reuse": true'
-stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/hello"'
+stdout '"Version": "v0.0.0-20170922011414-e483a7d9f8c9"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/hello"'
! stdout '"TagPrefix"'
-stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
-stdout '"Ref": "HEAD"'
-stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
-! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
+stdout '"Hash": "e483a7d9f8c9b4bc57430bdd8f81f0a65e4011c0"'
+! stdout '"Dir"'
+! stdout '"Info"'
+! stdout '"GoMod"'
+! stdout '"Zip"'
-# reuse go mod download vcstest/hello pseudoversion result
-go mod download -reuse=hellopseudo.json -x -json vcs-test.golang.org/git/hell...@v0.0.0-20170922010558-fc3a09f3dc5c
-! stderr 'git( .*)* fetch'
+# reuse go mod download hg/hello pseudoversion result
+go mod download -reuse=hellopseudo.json -x -json vcs-test.golang.org/hg/hell...@v0.0.0-20170922011414-e483a7d9f8c9
+! stderr 'hg( .*)* (pull|clone)'
stdout '"Reuse": true'
-stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/hello"'
+stdout '"Version": "v0.0.0-20170922011414-e483a7d9f8c9"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/hello"'
! stdout '"(Query|TagPrefix|TagSum|Ref)"'
-stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
-! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
+stdout '"Hash": "e483a7d9f8c9b4bc57430bdd8f81f0a65e4011c0"'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
+! stdout '"(Dir|Info|GoMod|Zip)"'
-# reuse go mod download vcstest/hello@hash
-go mod download -reuse=hellohash.json -x -json vcs-test.golang.org/git/hello.git@fc3a09f3dc5c
-! stderr 'git( .*)* fetch'
+# reuse go mod download hg/hello@hash
+go mod download -reuse=hellohash.json -x -json vcs-test.golang.org/hg/hello.hg@e483a7d9f8c9
+! stderr 'hg( .*)* (pull|clone)'
stdout '"Reuse": true'
-stdout '"Query": "fc3a09f3dc5c"'
-stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/hello"'
+stdout '"Query": "e483a7d9f8c9"'
+stdout '"Version": "v0.0.0-20170922011414-e483a7d9f8c9"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/hello"'
! stdout '"(TagPrefix|Ref)"'
-stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
-stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
-! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
+stdout '"Hash": "e483a7d9f8c9b4bc57430bdd8f81f0a65e4011c0"'
+! stdout '"(Dir|Info|GoMod|Zip)"'
-# reuse go mod download vcstest/hello/v9 error result
-! go mod download -reuse=hellov9.json -x -json vcs-test.golang.org/git/hello.git/v9@latest
-! stderr 'git( .*)* fetch'
+# reuse go mod download hg/hello/v9 error result
+! go mod download -reuse=hellov9.json -x -json vcs-test.golang.org/hg/hello.hg/v9@latest
+! stderr 'hg( .*)* (pull|clone)'
stdout '"Reuse": true'
stdout '"Error":.*no matching versions'
! stdout '"TagPrefix"'
-stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
-stdout '"Ref": "HEAD"'
-stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
-! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
+stdout '"Hash": "e483a7d9f8c9b4bc57430bdd8f81f0a65e4011c0"'
+! stdout '"(Dir|Info|GoMod|Zip)"'
-# reuse go mod download vcstest/hello/sub/v9 error result
-! go mod download -reuse=hellosubv9.json -x -json vcs-test.golang.org/git/hello.git/sub/v9@latest
-! stderr 'git( .*)* fetch'
+# reuse go mod download hg/hello/sub/v9 error result
+! go mod download -reuse=hellosubv9.json -x -json vcs-test.golang.org/hg/hello.hg/sub/v9@latest
+! stderr 'hg( .*)* (pull|clone)'
stdout '"Reuse": true'
stdout '"Error":.*no matching versions'
-stdout '"TagPrefix": "sub/"'
-stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
-stdout '"Ref": "HEAD"'
-stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
-! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
+! stdout '"TagPrefix"'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
+stdout '"Hash": "e483a7d9f8c9b4bc57430bdd8f81f0a65e4011c0"'
+! stdout '"(Dir|Info|GoMod|Zip)"'
-# reuse go mod download vcstest/hello@nonexist
-! go mod download -reuse=hellononexist.json -x -json vcs-test.golang.org/git/hello.git@nonexist
-! stderr 'git( .*)* fetch'
+# reuse go mod download hg/hello@nonexist
+! go mod download -reuse=hellononexist.json -x -json vcs-test.golang.org/hg/hello.hg@nonexist
+! stderr 'hg( .*)* (pull|clone)'
stdout '"Reuse": true'
stdout '"Version": "nonexist"'
stdout '"Error":.*unknown revision nonexist'
-stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
! stdout '"(TagPrefix|TagSum|Ref|Hash)"'
! stdout '"(Dir|Info|GoMod|Zip)"'
-# reuse go mod download vcstest/hello@1234567890123456789012345678901234567890
-! go mod download -reuse=hellononhash.json -x -json vcs-test.golang.org/git/hello.git@1234567890123456789012345678901234567890
-! stderr 'git( .*)* fetch'
+# reuse go mod download hg/hello@1234567890123456789012345678901234567890
+! go mod download -reuse=hellononhash.json -x -json vcs-test.golang.org/hg/hello.hg@1234567890123456789012345678901234567890
+! stderr 'hg( .*)* (pull|clone)'
stdout '"Reuse": true'
stdout '"Version": "1234567890123456789012345678901234567890"'
stdout '"Error":.*unknown revision 1234567890123456789012345678901234567890'
-stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
! stdout '"(TagPrefix|TagSum|Ref|Hash)"'
! stdout '"(Dir|Info|GoMod|Zip)"'
-# reuse go mod download vcstest/he...@v0.0.0-20220101120101-123456789abc
-! go mod download -reuse=hellononpseudo.json -x -json vcs-test.golang.org/git/hell...@v0.0.0-20220101120101-123456789abc
-! stderr 'git( .*)* fetch'
+# reuse go mod download hg/he...@v0.0.0-20220101120101-123456789abc
+! go mod download -reuse=hellononpseudo.json -x -json vcs-test.golang.org/hg/hell...@v0.0.0-20220101120101-123456789abc
+! stderr 'hg( .*)* (pull|clone)'
stdout '"Reuse": true'
stdout '"Version": "v0.0.0-20220101120101-123456789abc"'
stdout '"Error":.*unknown revision 123456789abc'
-stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
! stdout '"(TagPrefix|TagSum|Ref|Hash)"'
! stdout '"(Dir|Info|GoMod|Zip)"'
-# reuse go mod download vcstest/tagtests result
-go mod download -reuse=tagtests.json -x -json vcs-test.golang.org/git/tagtests.git@latest
-! stderr 'git( .*)* fetch'
+# reuse go mod download hg/tagtests result
+go mod download -reuse=tagtests.json -x -json vcs-test.golang.org/hg/tagtests.hg@latest
+! stderr 'hg( .*)* (pull|clone)'
stdout '"Reuse": true'
stdout '"Version": "v0.2.2"'
stdout '"Query": "latest"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/tagtests"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/tagtests"'
! stdout '"TagPrefix"'
-stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
-stdout '"Ref": "refs/tags/v0.2.2"'
-stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
-! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
+stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'
+stdout '"Hash": "1e531550e864b16f25013cfbbf2d8e7cf07a0374"'
+! stdout '"(Dir|Info|GoMod|Zip)"'
-# reuse go mod download vcstest/tagt...@v0.2.2 result
-go mod download -reuse=tagtestsv022.json -x -json vcs-test.golang.org/git/tagtes...@v0.2.2
-! stderr 'git( .*)* fetch'
+# reuse go mod download hg/tagt...@v0.2.2 result
+go mod download -reuse=tagtestsv022.json -x -json vcs-test.golang.org/hg/tagte...@v0.2.2
+! stderr 'hg( .*)* (pull|clone)'
stdout '"Reuse": true'
stdout '"Version": "v0.2.2"'
! stdout '"Query":'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/tagtests"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/tagtests"'
! stdout '"TagPrefix"'
! stdout '"TagSum"'
-stdout '"Ref": "refs/tags/v0.2.2"'
-stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
-! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
+stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'
+stdout '"Hash": "1e531550e864b16f25013cfbbf2d8e7cf07a0374"'
+! stdout '"(Dir|Info|GoMod|Zip)"'
-# reuse go mod download vcstest/tagtests@master result
-go mod download -reuse=tagtestsmaster.json -x -json vcs-test.golang.org/git/tagtests.git@master
-! stderr 'git( .*)* fetch'
+# reuse go mod download hg/tagtests@default result
+go mod download -reuse=tagtestsdefault.json -x -json vcs-test.golang.org/hg/tagtests.hg@default
+! stderr 'hg( .*)* (pull|clone)'
stdout '"Reuse": true'
-stdout '"Version": "v0.2.3-0.20190509225625-c7818c24fa2f"'
-stdout '"Query": "master"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/tagtests"'
+stdout '"Version": "v0.0.0-20190509225625-8d0b18b816df"'
+stdout '"Query": "default"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/tagtests"'
! stdout '"TagPrefix"'
-stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
-stdout '"Ref": "refs/heads/master"'
-stdout '"Hash": "c7818c24fa2f3f714c67d0a6d3e411c85a518d1f"'
-! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
+stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'
+stdout '"Hash": "8d0b18b816df5e9c564761b405b1d7949c24ee6b"'
+! stdout '"(Dir|Info|GoMod|Zip)"'
-# reuse go mod download vcstest/tagtests@master result again with all.json
-go mod download -reuse=all.json -x -json vcs-test.golang.org/git/tagtests.git@master
-! stderr 'git( .*)* fetch'
+# reuse go mod download hg/tagtests@default result again with all.json
+go mod download -reuse=all.json -x -json vcs-test.golang.org/hg/tagtests.hg@default
+! stderr 'hg( .*)* (pull|clone)'
stdout '"Reuse": true'
-stdout '"Version": "v0.2.3-0.20190509225625-c7818c24fa2f"'
-stdout '"Query": "master"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/tagtests"'
+stdout '"Version": "v0.0.0-20190509225625-8d0b18b816df"'
+stdout '"Query": "default"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/tagtests"'
! stdout '"TagPrefix"'
-stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
-stdout '"Ref": "refs/heads/master"'
-stdout '"Hash": "c7818c24fa2f3f714c67d0a6d3e411c85a518d1f"'
-! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
+stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'
+stdout '"Hash": "8d0b18b816df5e9c564761b405b1d7949c24ee6b"'
+! stdout '"(Dir|Info|GoMod|Zip)"'
-# go mod download vcstest/prefixtagtests result with json
-go mod download -reuse=prefixtagtests.json -x -json vcs-test.golang.org/git/prefixtagtests.git/sub@latest
-! stderr 'git( .*)* fetch'
+# go mod download hg/prefixtagtests result with json
+go mod download -reuse=prefixtagtests.json -x -json vcs-test.golang.org/hg/prefixtagtests.hg/sub@latest
+! stderr 'hg( .*)* (pull|clone)'
stdout '"Version": "v0.0.10"'
stdout '"Query": "latest"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/prefixtagtests"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/prefixtagtests"'
stdout '"Subdir": "sub"'
-stdout '"TagPrefix": "sub/"'
-stdout '"TagSum": "t1:YGSbWkJ8dn9ORAr[+]BlKHFK/2ZhXLb9hVuYfTZ9D8C7g="'
-stdout '"Ref": "refs/tags/sub/v0.0.10"'
-stdout '"Hash": "2b7c4692e12c109263cab51b416fcc835ddd7eae"'
+stdout '"RepoSum": "r1:YWOcei109p5Kohsr5xnSYlaQXmpT3iWZHZhRbfMoTkc="'
+stdout '"Hash": "1cc0dfcc254cb8901799e7f7ae182c04019b7a88"'
! stdout '"(Dir|Info|GoMod|Zip)"'
# reuse the bulk results with all.json
-! go mod download -reuse=all.json -json vcs-test.golang.org/git/hello.git@latest vcs-test.golang.org/git/hello.git/v9@latest vcs-test.golang.org/git/hello.git/sub/v9@latest vcs-test.golang.org/git/tagtests.git@latest vcs-test.golang.org/git/tagtes...@v0.2.2 vcs-test.golang.org/git/tagtests.git@master
-! stderr 'git( .*)* fetch'
+! go mod download -reuse=all.json -json vcs-test.golang.org/hg/hello.hg@latest vcs-test.golang.org/hg/hello.hg/v9@latest vcs-test.golang.org/hg/hello.hg/sub/v9@latest vcs-test.golang.org/hg/tagtests.hg@latest vcs-test.golang.org/hg/tagte...@v0.2.2 vcs-test.golang.org/hg/tagtests.hg@default
+! stderr 'hg( .*)* (pull|clone)'
stdout '"Reuse": true'
! stdout '"(Dir|Info|GoMod|Zip)"'
-# reuse attempt with stale hash should reinvoke git, not report reuse
+# reuse attempt with stale hash should reuse, since we don't validate the hash.
cp tagtestsv022.json tagtestsv022badhash.json
-replace '57952' '56952XXX' tagtestsv022badhash.json
-go mod download -reuse=tagtestsv022badhash.json -x -json vcs-test.golang.org/git/tagtes...@v0.2.2
-stderr 'git( .*)* fetch'
-! stdout '"Reuse": true'
+replace '1e5315' '1e5315XXX' tagtestsv022badhash.json
+go mod download -reuse=tagtestsv022badhash.json -x -json vcs-test.golang.org/hg/tagte...@v0.2.2
+! stderr 'hg( .*)* pull'
+stdout '"Reuse": true'
stdout '"Version": "v0.2.2"'
! stdout '"Query"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/tagtests"'
-! stdout '"(TagPrefix|TagSum|RepoSum)"'
-stdout '"Ref": "refs/tags/v0.2.2"'
-stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
-stdout '"Dir"'
-stdout '"Info"'
-stdout '"GoMod"'
-stdout '"Zip"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/tagtests"'
+! stdout '"(TagPrefix|TagSum)"'
+stdout '"RepoSum"'
+stdout '"Hash": "1e5315XXX50e864b16f25013cfbbf2d8e7cf07a0374"'
+! stdout '"Dir"'
# reuse with stale repo URL
cp tagtestsv022.json tagtestsv022badurl.json
-replace 'git/tagtests\"' 'git/tagtestsXXX\"' tagtestsv022badurl.json
-go mod download -reuse=tagtestsv022badurl.json -x -json vcs-test.golang.org/git/tagtes...@v0.2.2
+replace 'hg/tagtests\"' 'hg/tagtestsXXX\"' tagtestsv022badurl.json
+go mod download -reuse=tagtestsv022badurl.json -x -json vcs-test.golang.org/hg/tagte...@v0.2.2
+stderr 'hg( .*)* pull'
! stdout '"Reuse": true'
-stdout '"URL": ".*/git/tagtests"'
+stdout '"URL": ".*/hg/tagtests"'
stdout '"Dir"'
stdout '"Info"'
stdout '"GoMod"'
@@ -362,102 +346,108 @@
# reuse with stale VCS
cp tagtestsv022.json tagtestsv022badvcs.json
-replace '\"git\"' '\"gitXXX\"' tagtestsv022badvcs.json
-go mod download -reuse=tagtestsv022badvcs.json -x -json vcs-test.golang.org/git/tagtes...@v0.2.2
+replace '\"hg\"' '\"hgXXX\"' tagtestsv022badvcs.json
+go mod download -reuse=tagtestsv022badvcs.json -x -json vcs-test.golang.org/hg/tagte...@v0.2.2
! stdout '"Reuse": true'
-stdout '"URL": ".*/git/tagtests"'
-! stdout '"RepoSum"'
+stdout '"URL": ".*/hg/tagtests"'
# reuse with stale Dir
cp tagtestsv022.json tagtestsv022baddir.json
-replace '\t\t\"Ref\":' '\t\t\"Subdir\": \"subdir\",\n\t\t\"Ref\":' tagtestsv022baddir.json
-go mod download -reuse=tagtestsv022baddir.json -x -json vcs-test.golang.org/git/tagtes...@v0.2.2
+replace '\"VCS\":' '\"Subdir\":\"subdir\", \"VCS\":' tagtestsv022baddir.json
+cat tagtestsv022baddir.json
+go mod download -reuse=tagtestsv022baddir.json -x -json vcs-test.golang.org/hg/tagte...@v0.2.2
! stdout '"Reuse": true'
-stdout '"URL": ".*/git/tagtests"'
-! stdout '"RepoSum"'
+stdout '"URL": ".*/hg/tagtests"'
-# reuse with stale TagSum
-cp tagtests.json tagtestsbadtagsum.json
-replace 'sMEOGo=' 'sMEoGo=XXX' tagtestsbadtagsum.json
-go mod download -reuse=tagtestsbadtagsum.json -x -json vcs-test.golang.org/git/tagtests.git@latest
+# reuse with stale RepoSum
+cp tagtests.json tagtestsbadreposum.json
+replace '8dnv90' '8dnv90XXX' tagtestsbadreposum.json
+go mod download -reuse=tagtestsbadreposum.json -x -json vcs-test.golang.org/hg/tagtests.hg@latest
! stdout '"Reuse": true'
-stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
-! stdout '"RepoSum"'
+stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'
+
+# reuse with go list
+go clean -modcache
+go list -x -json -m -retracted -json=Version,Versions,Error,Path,Query,Origin,Reuse -versions vcs-test.golang.org/hg/hello.hg@latest
+stderr 'hg( .*)* pull'
+cp stdout hello.json
+stdout '"Version": "v0.0.0-20170922011414-e483a7d9f8c9"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/hello"'
+stdout '"Query": "latest"'
+! stdout '"TagPrefix"'
+! stdout '"TagSum"'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
+stdout '"Hash": "e483a7d9f8c9b4bc57430bdd8f81f0a65e4011c0"'
# go list on repo with no tags
go clean -modcache
-go list -x -json -m -retracted -json=Version,Versions,Error,Path,Query,Origin,Reuse -versions vcs-test.golang.org/git/hello.git@latest
-stderr 'git( .*)* fetch'
+go list -x -json -m -retracted -versions vcs-test.golang.org/hg/hello.hg@latest
+stderr 'hg( .*)* pull'
cp stdout hellolist.json
! stdout '"Versions"'
-stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/hello"'
+stdout '"Version": "v0.0.0-20170922011414-e483a7d9f8c9"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/hello"'
stdout '"Query": "latest"'
-! stdout '"TagPrefix"'
-stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
-stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
-! stdout '"RepoSum"'
+stdout '"Hash": "e483a7d9f8c9b4bc57430bdd8f81f0a65e4011c0"'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
# reuse go list on repo with no tags
go clean -modcache
-go list -x -reuse=hellolist.json -json -m -retracted -versions vcs-test.golang.org/git/hello.git@latest
-! stderr 'git( .*)* fetch'
+go list -x -reuse=hellolist.json -json -m -retracted -versions vcs-test.golang.org/hg/hello.hg@latest
+! stderr 'hg( .*)* pull'
stdout '"Reuse": true'
! stdout '"Versions"'
-stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/hello"'
+stdout '"Version": "v0.0.0-20170922011414-e483a7d9f8c9"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/hello"'
stdout '"Query": "latest"'
-! stdout '"TagPrefix"'
-stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
-stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
-! stdout '"RepoSum"'
+stdout '"Hash": "e483a7d9f8c9b4bc57430bdd8f81f0a65e4011c0"'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
# reuse with stale list
cp hellolist.json hellolistbad.json
-replace '47DEQ' 'ZZZ' hellolistbad.json
+replace 'blLvkhBri' 'ZZZ' hellolistbad.json
go clean -modcache
-go list -x -reuse=hellolistbad.json -json -m -retracted -versions vcs-test.golang.org/git/hello.git@latest
-stderr 'git( .*)* fetch'
+go list -x -reuse=hellolistbad.json -json -m -retracted -versions vcs-test.golang.org/hg/hello.hg@latest
+stderr 'hg( .*)* pull'
! stdout '"Reuse": true'
-stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
+stdout '"RepoSum": "r1:blLvkhBriVMV[+]6Il4Ub43wlyWXIe1NpobTelF0peaG0="'
# go list on repo with tags
go clean -modcache
-go list -x -json -m -retracted -json=Version,Versions,Error,Path,Query,Origin,Reuse -versions vcs-test.golang.org/git/tagtests.git@latest
+go list -x -json -m -retracted -versions vcs-test.golang.org/hg/tagtests.hg@latest
cp stdout taglist.json
-stderr 'git( .*)* fetch'
+stderr 'hg( .*)* pull'
stdout '"Versions":'
stdout '"v0.2.1"'
stdout '"v0.2.2"'
stdout '"Version": "v0.2.2"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/tagtests"'
-stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
-stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
-stdout '"Ref": "refs/tags/v0.2.2"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/tagtests"'
+stdout '"Hash": "1e531550e864b16f25013cfbbf2d8e7cf07a0374"'
+stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'
# reuse go list on repo with tags
go clean -modcache
-go list -reuse=taglist.json -x -json -m -retracted -json=Version,Versions,Error,Path,Query,Origin,Reuse -versions vcs-test.golang.org/git/tagtests.git@latest
-! stderr 'git( .*)* fetch'
+go list -reuse=taglist.json -x -json -m -retracted -versions vcs-test.golang.org/hg/tagtests.hg@latest
+! stderr 'hg( .*)* pull'
stdout '"Reuse": true'
stdout '"Versions":'
stdout '"v0.2.1"'
stdout '"v0.2.2"'
stdout '"Version": "v0.2.2"'
-stdout '"VCS": "git"'
-stdout '"URL": ".*/git/tagtests"'
-stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
-stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
-stdout '"Ref": "refs/tags/v0.2.2"'
+stdout '"VCS": "hg"'
+stdout '"URL": ".*/hg/tagtests"'
+stdout '"Hash": "1e531550e864b16f25013cfbbf2d8e7cf07a0374"'
+stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'
# reuse with stale list
cp taglist.json taglistbad.json
-replace 'Dp7yRKDu' 'ZZZ' taglistbad.json
+replace '8dnv906' 'ZZZ' taglistbad.json
go clean -modcache
-go list -reuse=taglistbad.json -x -json -m -retracted -json=Version,Versions,Error,Path,Query,Origin,Reuse -versions vcs-test.golang.org/git/tagtests.git@latest
-stderr 'git( .*)* fetch'
+go list -reuse=taglistbad.json -x -json -m -retracted -versions vcs-test.golang.org/hg/tagtests.hg@latest
+stderr 'hg( .*)* pull'
! stdout '"Reuse": true'
-stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
+stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'
diff --git a/src/cmd/go/testdata/vcstest/hg/prefixtagtests.txt b/src/cmd/go/testdata/vcstest/hg/prefixtagtests.txt
index 6c89c85..c61c9ba 100644
--- a/src/cmd/go/testdata/vcstest/hg/prefixtagtests.txt
+++ b/src/cmd/go/testdata/vcstest/hg/prefixtagtests.txt
@@ -1,52 +1,51 @@
-handle git
+env date=2019-05-09T18:35:00-04:00
-env GIT_AUTHOR_NAME='Jay Conrod'
-env GIT_AUTHOR_EMAIL='jayc...@google.com'
-env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
-env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
+handle hg
-at 2019-05-09T18:35:00-04:00
+hg init
+hg add sub
+hg commit -u rsc -d $date -m 'create module sub'
-git init
-
-git add sub
-git commit -m 'create module sub'
-git branch -m master
-
-echo 'v0.1.0'
+echo v0.1.0
cp stdout status
-git add status
-git commit -a -m 'v0.1.0'
-git tag 'v0.1.0'
+hg add status
+hg commit -u rsc -d $date -m v0.1.0
+hg tag -u rsc -d $date v0.1.0
-echo 'sub/v0.0.9'
+echo sub/v0.0.9
cp stdout status
-git commit -a -m 'sub/v0.0.9'
-git tag 'sub/v0.0.9'
+hg add status
+hg commit -u rsc -d $date -m sub/v0.0.9
+hg tag -u rsc -d $date sub/v0.0.9
-echo 'sub/v0.0.10'
+echo sub/v0.0.10
cp stdout status
-git commit -a -m 'sub/v0.0.10'
-git tag 'sub/v0.0.10'
+hg commit -u rsc -d $date -m sub/v0.0.10 status
+hg tag -u rsc -d $date sub/v0.0.10
-echo 'v0.2.0'
+echo v0.2.0
cp stdout status
-git commit -a -m 'v0.2.0'
-git tag 'v0.2.0'
+hg commit -u rsc -d $date -m v0.2.0
+hg tag -u rsc -d $date v0.2.0
echo 'after last tag'
cp stdout status
-git commit -a -m 'after last tag'
+hg commit -u rsc -d $date -m 'after last tag'
-git show-ref --tags --heads
-cmp stdout .git-refs
+hg tags
+cmp stdout .hg-tags
--- .git-refs --
-c3ee5d0dfbb9bf3c4d8bb2bce24cd8d14d2d4238 refs/heads/master
-2b7c4692e12c109263cab51b416fcc835ddd7eae refs/tags/sub/v0.0.10
-883885166298d79a0561d571a3044ec5db2e7c28 refs/tags/sub/v0.0.9
-db89fc573cfb939faf0aa0660671eb4cf8b8b673 refs/tags/v0.1.0
-1abe41965749e50828dd41de8d12c6ebc8e4e131 refs/tags/v0.2.0
+hg branches
+cmp stdout .hg-branches
+
+-- .hg-tags --
+tip 9:840814f739c2
+v0.2.0 7:84e452ea2b0a
+sub/v0.0.10 5:1cc0dfcc254c
+sub/v0.0.9 3:c5f5e3168705
+v0.1.0 1:d6ba12969a9b
+-- .hg-branches --
+default 9:840814f739c2
-- sub/go.mod --
module vcs-test.golang.org/git/prefixtagtests.git/sub
-- sub/sub.go --
diff --git a/src/cmd/go/testdata/vcstest/hg/tagtests.txt b/src/cmd/go/testdata/vcstest/hg/tagtests.txt
index 92e79cd..38b3e97 100644
--- a/src/cmd/go/testdata/vcstest/hg/tagtests.txt
+++ b/src/cmd/go/testdata/vcstest/hg/tagtests.txt
@@ -1,39 +1,26 @@
-handle git
+env date=2019-05-09T18:56:25-04:00
-env GIT_AUTHOR_NAME='Jay Conrod'
-env GIT_AUTHOR_EMAIL='jayc...@google.com'
-env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
-env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
+handle hg
-at 2019-05-09T18:56:25-04:00
+hg init
+hg add go.mod tagtests.go
+hg commit --user 'rsc' --date $date -m 'create module tagtests'
+hg branch b
+hg add v0.2.1
+hg commit --user 'rsc' --date $date -m 'v0.2.1'
+hg tag --user 'rsc' --date $date v0.2.1
-git init
+hg update default
+hg add v0.2.2
+hg commit --user 'rsc' --date $date -m 'v0.2.2'
+hg tag --user 'rsc' --date $date v0.2.2
-git add go.mod tagtests.go
-git commit -m 'create module tagtests'
-git branch -m master
-git branch b
+hg tags
+cmp stdout .hg-tags
-git add v0.2.1
-git commit -m 'v0.2.1'
-git tag 'v0.2.1'
+hg branches
+cmp stdout .hg-branches
-git checkout b
-git add 'v0.2.2'
-git commit -m 'v0.2.2'
-git tag 'v0.2.2'
-
-git checkout master
-git merge b -m 'merge'
-
-git show-ref --tags --heads
-cmp stdout .git-refs
-
--- .git-refs --
-59356c8cd18c5fe9a598167d98a6843e52d57952 refs/heads/b
-c7818c24fa2f3f714c67d0a6d3e411c85a518d1f refs/heads/master
-101c49f5af1b2466332158058cf5f03c8cca6429 refs/tags/v0.2.1
-59356c8cd18c5fe9a598167d98a6843e52d57952 refs/tags/v0.2.2
-- go.mod --
module vcs-test.golang.org/git/tagtests.git
-- tagtests.go --
@@ -42,3 +29,10 @@
v0.2.1
-- v0.2.2 --
v0.2.2
+-- .hg-tags --
+tip 4:8d0b18b816df
+v0.2.2 3:1e531550e864
+v0.2.1 1:010a2d1a2ea7
+-- .hg-branches --
+default 4:8d0b18b816df
+b 2:ceae444ffda5