Skip to content

Commit 47a63a3

Browse files
rscgopherbot
authored andcommitted
cmd/go: rewrite hgrepo1 test repo to be deterministic
The use of git convert made it non-determinstic. Build it up by hand using hg commands instead. Change-Id: Iaa9c0925864a7003ea61e5bf2a9196ff3e0a662b Reviewed-on: https://go-review.googlesource.com/c/go/+/718520 Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org>
1 parent 7995751 commit 47a63a3

File tree

2 files changed

+65
-122
lines changed

2 files changed

+65
-122
lines changed

src/cmd/go/internal/modfetch/codehost/git_test.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,12 @@ func TestLatest(t *testing.T) {
383383
Origin: &Origin{
384384
VCS: "hg",
385385
URL: hgrepo1,
386-
Hash: "18518c07eb8ed5c80221e997e518cccaa8c0c287",
386+
Hash: "745aacc8b24decc44ac2b13870f5472b479f4d72",
387387
},
388-
Name: "18518c07eb8ed5c80221e997e518cccaa8c0c287",
389-
Short: "18518c07eb8e",
390-
Version: "18518c07eb8ed5c80221e997e518cccaa8c0c287",
391-
Time: time.Date(2018, 6, 27, 16, 16, 30, 0, time.UTC),
388+
Name: "745aacc8b24decc44ac2b13870f5472b479f4d72",
389+
Short: "745aacc8b24d",
390+
Version: "745aacc8b24decc44ac2b13870f5472b479f4d72",
391+
Time: time.Date(2018, 6, 27, 16, 16, 10, 0, time.UTC),
392392
},
393393
},
394394
} {
@@ -675,7 +675,6 @@ func TestReadZip(t *testing.T) {
675675
subdir: "",
676676
files: map[string]uint64{
677677
"prefix/.hg_archival.txt": ^uint64(0),
678-
"prefix/.hgtags": 405,
679678
"prefix/v3/sub/dir/file.txt": 16,
680679
"prefix/README": 0,
681680
},
@@ -788,11 +787,11 @@ func TestReadZip(t *testing.T) {
788787
}
789788

790789
var hgmap = map[string]string{
791-
"HEAD": "41964ddce1180313bdc01d0a39a2813344d6261d", // not tip due to bad hgrepo1 conversion
792-
"9d02800338b8a55be062c838d1f02e0c5780b9eb": "8f49ee7a6ddcdec6f0112d9dca48d4a2e4c3c09e",
793-
"76a00fb249b7f93091bc2c89a789dab1fc1bc26f": "88fde824ec8b41a76baa16b7e84212cee9f3edd0",
794-
"ede458df7cd0fdca520df19a33158086a8a68e81": "41964ddce1180313bdc01d0a39a2813344d6261d",
795-
"97f6aa59c81c623494825b43d39e445566e429a4": "c0cbbfb24c7c3c50c35c7b88e7db777da4ff625d",
790+
"HEAD": "c0186fb00e50985709b12266419f50bf11860166",
791+
"9d02800338b8a55be062c838d1f02e0c5780b9eb": "b1ed98abc2683d326f89b924875bf14bd584898e", // v2.0.2, v2
792+
"76a00fb249b7f93091bc2c89a789dab1fc1bc26f": "a546811101e11d6aff2ac72072d2d439b3a88f33", // v2.3, v2.0.1
793+
"ede458df7cd0fdca520df19a33158086a8a68e81": "c0186fb00e50985709b12266419f50bf11860166", // v1.2.3, v1.2.4-annotated
794+
"97f6aa59c81c623494825b43d39e445566e429a4": "c1638e3673b121d9c83e92166fce2a25dcadd6cb", // foo.txt commit on v2.3.4 branch
796795
}
797796

798797
func TestStat(t *testing.T) {
Lines changed: 55 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,97 @@
11
handle hg
22

3-
mkdir git
4-
cd git
5-
6-
env GIT_AUTHOR_NAME='Russ Cox'
7-
env GIT_AUTHOR_EMAIL='rsc@golang.org'
8-
env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
9-
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
10-
11-
git init
3+
hg init
124

13-
at 2018-04-17T15:43:22-04:00
5+
env date=2018-04-17T15:43:22-04:00
146
unquote ''
157
cp stdout README
16-
git add README
17-
git commit -a -m 'empty README'
18-
git branch -m master
19-
git tag v1.2.3
8+
hg add README
9+
hg commit --user=rsc --date=$date -m 'empty README'
10+
hg branch tagbranch
11+
hg tag --user=rsc --date=$date v1.2.3
12+
hg update default
2013

21-
at 2018-04-17T15:45:48-04:00
22-
git branch v2
23-
git checkout v2
14+
env date=2018-04-17T15:45:48-04:00
15+
hg branch v2
2416
echo 'v2'
2517
cp stdout v2
26-
git add v2
27-
git commit -a -m 'v2'
28-
git tag v2.3
29-
git tag v2.0.1
30-
git branch v2.3.4
31-
git tag branch-v2.3.4
18+
hg add v2
19+
hg commit --user=rsc --date=$date -m 'v2'
20+
hg update tagbranch
21+
hg tag --user=rsc --date=$date -r v2 v2.3
22+
hg tag --user=rsc --date=$date -r v2 v2.0.1
23+
hg update v2
24+
hg branch v2.3.4
3225

33-
at 2018-04-17T16:00:19-04:00
26+
env date=2018-04-17T16:00:19-04:00
3427
echo 'intermediate'
3528
cp stdout foo.txt
36-
git add foo.txt
37-
git commit -a -m 'intermediate'
29+
hg add foo.txt
30+
hg commit --user=rsc --date=$date -m 'intermediate'
3831

39-
at 2018-04-17T16:00:32-04:00
32+
env date=2018-04-17T16:00:32-04:00
4033
echo 'another'
4134
cp stdout another.txt
42-
git add another.txt
43-
git commit -a -m 'another'
44-
git tag v2.0.2
45-
git tag branch-v2
35+
hg add another.txt
36+
hg commit --user=rsc --date=$date -m 'another'
37+
hg update tagbranch
38+
hg tag --user=rsc --date=$date -r v2.3.4 v2.0.2
4639

47-
at 2018-04-17T16:16:52-04:00
48-
git checkout master
49-
git branch v3
50-
git checkout v3
40+
env date=2018-04-17T16:16:52-04:00
41+
hg update default
42+
hg branch v3
5143
mkdir v3/sub/dir
5244
echo 'v3/sub/dir/file'
5345
cp stdout v3/sub/dir/file.txt
54-
git add v3
55-
git commit -a -m 'add v3/sub/dir/file.txt'
56-
git tag branch-v3
57-
58-
at 2018-04-17T22:23:00-04:00
59-
git checkout master
60-
git tag -a v1.2.4-annotated -m 'v1.2.4-annotated'
46+
hg add v3
47+
hg commit --user=rsc --date=$date -m 'add v3/sub/dir/file.txt'
6148

62-
cd ..
49+
env date=2018-04-17T22:23:00-04:00
50+
hg update default
51+
hg tag --user=rsc --date=$date -r v1.2.3 v1.2.4-annotated
6352

64-
hg init
65-
hg convert --datesort ./git .
66-
rm ./git
67-
68-
hg update -C v2
69-
hg branch v2
53+
env date=2018-06-27T12:15:24-04:00
54+
hg update v2
7055
unquote ''
7156
cp stdout dummy
7257
hg add dummy
73-
hg commit --user 'Russ Cox <rsc@golang.org>' --date '2018-06-27T12:15:24-04:00' -m 'dummy'
74-
75-
# 'hg convert' blindly stamps a tag-update commit at the end of whatever branch
76-
# happened to contain the last converted commit — in this case, v3. However, the
77-
# original vcs-test.golang.org copy of this repo had this commit on the v3
78-
# branch as a descendent of 'add v3/sub/dir/file.txt', so that's where we put it
79-
# here. That leaves the convert-repo 'update tags' commit only reachable as the
80-
# head of the default branch.
81-
hg update -r 4
82-
83-
hg branch v3
84-
unquote ''
85-
cp stdout dummy
86-
hg add dummy
87-
hg commit --user 'Russ Cox <rsc@golang.org>' --date '2018-06-27T12:15:45-04:00' -m 'dummy'
58+
hg commit --user=rsc --date=$date -m 'dummy'
8859

60+
env date=2018-06-27T12:16:10-04:00
8961
hg update v2.3.4
9062
hg branch v2.3.4
9163
unquote ''
9264
cp stdout dummy
9365
hg add dummy
94-
hg commit --user 'Russ Cox <rsc@golang.org>' --date '2018-06-27T12:16:10-04:00' -m 'dummy'
95-
96-
hg tag --user 'Russ Cox <rsc@golang.org>' --date '2018-06-27T12:16:30-04:00' -m 'Removed tag branch-v2, branch-v3, branch-v2.3.4' --remove branch-v2 branch-v3 branch-v2.3.4
66+
hg commit --user=rsc --date=$date -m 'dummy'
9767

98-
# Adding commits to the above branches updates both the branch heads and the
99-
# corresponding bookmarks.
100-
# But apparently at some point it did not do so? The original copy of this repo
101-
# had bookmarks pointing to the base of each branch instead of the tip. 🤔
102-
# Either way, force the bookmarks we care about to match the original copy of
103-
# the repo.
104-
hg book v2 -r 3 --force
105-
hg book v2.3.4 -r 1 --force
106-
hg book v3 -r 5 --force
68+
hg book v2 -r v2.0.2 --force
69+
hg book v2.3.4 -r v2.0.1 --force
10770

10871
hg log -G --debug
10972

11073
hg tags
11174
cmp stdout .hg-tags
11275

113-
# 'hg convert' leaves an 'update tags' commit on the default branch, and that
114-
# commit always uses the current date (so is not reproducible). Fortunately,
115-
# that commit lands on the 'default' branch and is not tagged as 'tip', so it
116-
# seems to be mostly harmless. However, because it is nondeterministic we
117-
# should avoid listing it here.
118-
#
119-
# Unfortunately, some of our builders are still running Debian 9 “Stretch”,
120-
# which shipped with a version of 'hg' that does not support 'hg branch -r'
121-
# to list branches for specific versions. Although Stretch is past its
122-
# end-of-life date, we need to keep the builders happy until they can be
123-
# turned down (https://go.dev/issue/56414).
12476
hg branches
125-
? cmp stdout .hg-branches
126-
stdout 'v2\s+6:9a4f43d231ec'
127-
stdout 'v2.3.4\s+9:18518c07eb8e'
128-
stdout 'v3\s+7:a2cad8a2b1bb'
129-
stdout 'default\s+5:'
77+
cmp stdout .hg-branches
13078

131-
# Likewise, bookmark v3 ends up on the nondeterministic commit.
13279
hg bookmarks
133-
? cmp stdout .hg-bookmarks
134-
stdout 'master\s+0:41964ddce118'
135-
stdout 'v2\s+3:8f49ee7a6ddc'
136-
stdout 'v2.3.4\s+1:88fde824ec8b'
137-
stdout 'v3\s+5:.*'
80+
cmp stdout .hg-bookmarks
13881

139-
-- .hg-branches --
140-
v2.3.4 9:18518c07eb8e
141-
v3 7:a2cad8a2b1bb
142-
v2 6:9a4f43d231ec
14382
-- .hg-tags --
144-
tip 9:18518c07eb8e
145-
v2.0.2 3:8f49ee7a6ddc
146-
v2.3 1:88fde824ec8b
147-
v2.0.1 1:88fde824ec8b
148-
v1.2.4-annotated 0:41964ddce118
149-
v1.2.3 0:41964ddce118
83+
tip 11:745aacc8b24d
84+
v2.0.2 6:b1ed98abc268
85+
v2.3 2:a546811101e1
86+
v2.0.1 2:a546811101e1
87+
v1.2.4-annotated 0:c0186fb00e50
88+
v1.2.3 0:c0186fb00e50
89+
-- .hg-branches --
90+
v2.3.4 11:745aacc8b24d
91+
v2 10:2b5ca8689628
92+
default 9:a9a2a32d1392
93+
v3 8:442174d28f65
94+
tagbranch 7:1a3473c317b4
15095
-- .hg-bookmarks --
151-
master 0:41964ddce118
152-
v2 3:8f49ee7a6ddc
153-
v2.3.4 1:88fde824ec8b
96+
v2 6:b1ed98abc268
97+
v2.3.4 2:a546811101e1

0 commit comments

Comments
 (0)