Debian Codegraph @

tests/test-fastannotate-protocol.t

raw
1 $ cat >> $HGRCPATH << EOF
2 > [extensions]
3 > fastannotate=
4 > [fastannotate]
5 > mainbranch=@
6 > EOF
7
8 setup the server repo
9
10 $ hg init repo-server
11 $ cd repo-server
12 $ cat >> .hg/hgrc << EOF
13 > [fastannotate]
14 > server=1
15 > EOF
16 $ for i in 1 2 3 4; do
17 > echo $i >> a
18 > hg commit -A -m $i a
19 > done
20 $ [ -d .hg/fastannotate ]
21 [1]
22 $ hg bookmark @
23 $ cd ..
24
25 setup the local repo
26
27 $ hg clone 'ssh://user@dummy/repo-server' repo-local -q
28 $ cd repo-local
29 $ cat >> .hg/hgrc << EOF
30 > [fastannotate]
31 > client=1
32 > clientfetchthreshold=0
33 > EOF
34 $ [ -d .hg/fastannotate ]
35 [1]
36 $ hg fastannotate a --debug
37 running * (glob)
38 sending hello command
39 sending between command
40 remote: * (glob) (?)
41 remote: capabilities: * (glob)
42 remote: * (glob) (?)
43 sending protocaps command
44 fastannotate: requesting 1 files
45 sending getannotate command
46 fastannotate: writing 112 bytes to fastannotate/default/a.l
47 fastannotate: writing 94 bytes to fastannotate/default/a.m
48 fastannotate: a: using fast path (resolved fctx: True)
49 0: 1
50 1: 2
51 2: 3
52 3: 4
53
54 the cache could be reused and no download is necessary
55
56 $ hg fastannotate a --debug
57 fastannotate: a: using fast path (resolved fctx: True)
58 0: 1
59 1: 2
60 2: 3
61 3: 4
62
63 if the client agrees where the head of the master branch is, no re-download
64 happens even if the client has more commits
65
66 $ echo 5 >> a
67 $ hg commit -m 5
68 $ hg bookmark -r 3 @ -f
69 $ hg fastannotate a --debug
70 0: 1
71 1: 2
72 2: 3
73 3: 4
74 4: 5
75
76 if the client has a different "@" (head of the master branch) and "@" is ahead
77 of the server, the server can detect things are unchanged and does not return
78 full contents (not that there is no "writing ... to fastannotate"), but the
79 client can also build things up on its own (causing diverge)
80
81 $ hg bookmark -r 4 @ -f
82 $ hg fastannotate a --debug
83 running * (glob)
84 sending hello command
85 sending between command
86 remote: * (glob) (?)
87 remote: capabilities: * (glob)
88 remote: * (glob) (?)
89 sending protocaps command
90 fastannotate: requesting 1 files
91 sending getannotate command
92 fastannotate: a: 1 new changesets in the main branch
93 0: 1
94 1: 2
95 2: 3
96 3: 4
97 4: 5
98
99 if the client has a different "@" which is behind the server. no download is
100 necessary
101
102 $ hg fastannotate a --debug --config fastannotate.mainbranch=2
103 fastannotate: a: using fast path (resolved fctx: True)
104 0: 1
105 1: 2
106 2: 3
107 3: 4
108 4: 5
109
110 define fastannotate on-disk paths
111
112 $ p1=.hg/fastannotate/default
113 $ p2=../repo-server/.hg/fastannotate/default
114
115 revert bookmark change so the client is behind the server
116
117 $ hg bookmark -r 2 @ -f
118
119 in the "fctx" mode with the "annotate" command, the client also downloads the
120 cache. but not in the (default) "fastannotate" mode.
121
122 $ rm $p1/a.l $p1/a.m
123 $ hg annotate a --debug | grep 'fastannotate: writing'
124 [1]
125 $ hg annotate a --config fastannotate.modes=fctx --debug | grep 'fastannotate: writing' | sort
126 fastannotate: writing 112 bytes to fastannotate/default/a.l
127 fastannotate: writing 94 bytes to fastannotate/default/a.m
128
129 the fastannotate cache (built server-side, downloaded client-side) in two repos
130 have the same content (because the client downloads from the server)
131
132 $ diff $p1/a.l $p2/a.l
133 $ diff $p1/a.m $p2/a.m
134
135 in the "fctx" mode, the client could also build the cache locally
136
137 $ hg annotate a --config fastannotate.modes=fctx --debug --config fastannotate.mainbranch=4 | grep fastannotate
138 fastannotate: requesting 1 files
139 fastannotate: a: 1 new changesets in the main branch
140
141 the server would rebuild broken cache automatically
142
143 $ cp $p2/a.m $p2/a.m.bak
144 $ echo BROKEN1 > $p1/a.m
145 $ echo BROKEN2 > $p2/a.m
146 $ hg fastannotate a --debug | grep 'fastannotate: writing' | sort
147 fastannotate: writing 112 bytes to fastannotate/default/a.l
148 fastannotate: writing 94 bytes to fastannotate/default/a.m
149 $ diff $p1/a.m $p2/a.m
150 $ diff $p2/a.m $p2/a.m.bak
151
152 use the "debugbuildannotatecache" command to build annotate cache
153
154 $ rm -rf $p1 $p2
155 $ hg --cwd ../repo-server debugbuildannotatecache a --debug
156 fastannotate: a: 4 new changesets in the main branch
157 $ hg --cwd ../repo-local debugbuildannotatecache a --debug
158 running * (glob)
159 sending hello command
160 sending between command
161 remote: * (glob) (?)
162 remote: capabilities: * (glob)
163 remote: * (glob) (?)
164 sending protocaps command
165 fastannotate: requesting 1 files
166 sending getannotate command
167 fastannotate: writing * (glob)
168 fastannotate: writing * (glob)
169 $ diff $p1/a.l $p2/a.l
170 $ diff $p1/a.m $p2/a.m
171
172 with the clientfetchthreshold config option, the client can build up the cache
173 without downloading from the server
174
175 $ rm -rf $p1
176 $ hg fastannotate a --debug --config fastannotate.clientfetchthreshold=10
177 fastannotate: a: 3 new changesets in the main branch
178 0: 1
179 1: 2
180 2: 3
181 3: 4
182 4: 5
183
184 if the fastannotate directory is not writable, the fctx mode still works
185
186 $ rm -rf $p1
187 $ touch $p1
188 $ hg annotate a --debug --traceback --config fastannotate.modes=fctx
189 fastannotate: a: cache broken and deleted
190 fastannotate: prefetch failed: * (glob)
191 fastannotate: a: cache broken and deleted
192 fastannotate: falling back to the vanilla annotate: * (glob)
193 0: 1
194 1: 2
195 2: 3
196 3: 4
197 4: 5
198
199 with serverbuildondemand=False, the server will not build anything
200
201 $ cat >> ../repo-server/.hg/hgrc <<EOF
202 > [fastannotate]
203 > serverbuildondemand=False
204 > EOF
205 $ rm -rf $p1 $p2
206 $ hg fastannotate a --debug | grep 'fastannotate: writing'
207 [1]