Show More
@@ -1,318 +1,318 | |||
|
1 | 1 | Tests for the journal extension; records bookmark locations. |
|
2 | 2 | |
|
3 | 3 | $ cat >> testmocks.py << EOF |
|
4 | 4 | > # mock out procutil.getuser() and util.makedate() to supply testable values |
|
5 | 5 | > import os |
|
6 | 6 | > from mercurial import pycompat, util |
|
7 | 7 | > from mercurial.utils import dateutil, procutil |
|
8 | 8 | > def mockgetuser(): |
|
9 | 9 | > return b'foobar' |
|
10 | 10 | > |
|
11 | 11 | > def mockmakedate(): |
|
12 | 12 | > filename = os.path.join(os.environ['TESTTMP'], 'testtime') |
|
13 | 13 | > try: |
|
14 | 14 | > with open(filename, 'rb') as timef: |
|
15 | 15 | > time = float(timef.read()) + 1 |
|
16 | 16 | > except IOError: |
|
17 | 17 | > time = 0.0 |
|
18 | 18 | > with open(filename, 'wb') as timef: |
|
19 | 19 | > timef.write(pycompat.bytestr(time)) |
|
20 | 20 | > return (time, 0) |
|
21 | 21 | > |
|
22 | 22 | > procutil.getuser = mockgetuser |
|
23 | 23 | > dateutil.makedate = mockmakedate |
|
24 | 24 | > EOF |
|
25 | 25 | |
|
26 | 26 | $ cat >> $HGRCPATH << EOF |
|
27 | 27 | > [extensions] |
|
28 | 28 | > journal= |
|
29 | 29 | > testmocks=`pwd`/testmocks.py |
|
30 | 30 | > EOF |
|
31 | 31 | |
|
32 | 32 | Setup repo |
|
33 | 33 | |
|
34 | 34 | $ hg init repo |
|
35 | 35 | $ cd repo |
|
36 | 36 | |
|
37 | 37 | Test empty journal |
|
38 | 38 | |
|
39 | 39 | $ hg journal |
|
40 | 40 | previous locations of '.': |
|
41 | 41 | no recorded locations |
|
42 | 42 | $ hg journal foo |
|
43 | 43 | previous locations of 'foo': |
|
44 | 44 | no recorded locations |
|
45 | 45 | |
|
46 | 46 | Test that working copy changes are tracked |
|
47 | 47 | |
|
48 | 48 | $ echo a > a |
|
49 | 49 | $ hg commit -Aqm a |
|
50 | 50 | $ hg journal |
|
51 | 51 | previous locations of '.': |
|
52 | 52 | cb9a9f314b8b commit -Aqm a |
|
53 | 53 | $ echo b > a |
|
54 | 54 | $ hg commit -Aqm b |
|
55 | 55 | $ hg journal |
|
56 | 56 | previous locations of '.': |
|
57 | 57 | 1e6c11564562 commit -Aqm b |
|
58 | 58 | cb9a9f314b8b commit -Aqm a |
|
59 | 59 | $ hg up 0 |
|
60 | 60 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
61 | 61 | $ hg journal |
|
62 | 62 | previous locations of '.': |
|
63 | 63 | cb9a9f314b8b up 0 |
|
64 | 64 | 1e6c11564562 commit -Aqm b |
|
65 | 65 | cb9a9f314b8b commit -Aqm a |
|
66 | 66 | |
|
67 | 67 | Test that bookmarks are tracked |
|
68 | 68 | |
|
69 | 69 | $ hg book -r tip bar |
|
70 | 70 | $ hg journal bar |
|
71 | 71 | previous locations of 'bar': |
|
72 | 72 | 1e6c11564562 book -r tip bar |
|
73 | 73 | $ hg book -f bar |
|
74 | 74 | $ hg journal bar |
|
75 | 75 | previous locations of 'bar': |
|
76 | 76 | cb9a9f314b8b book -f bar |
|
77 | 77 | 1e6c11564562 book -r tip bar |
|
78 | 78 | $ hg up |
|
79 | 79 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
80 | 80 | updating bookmark bar |
|
81 | 81 | $ hg journal bar |
|
82 | 82 | previous locations of 'bar': |
|
83 | 83 | 1e6c11564562 up |
|
84 | 84 | cb9a9f314b8b book -f bar |
|
85 | 85 | 1e6c11564562 book -r tip bar |
|
86 | 86 | |
|
87 | 87 | Test that we tracks bookmark deletion |
|
88 | 88 | |
|
89 | 89 | $ hg book -r . babar |
|
90 | 90 | $ hg book -f -r .~1 babar |
|
91 | 91 | $ hg book -d babar |
|
92 | 92 | $ hg journal babar |
|
93 | 93 | previous locations of 'babar': |
|
94 | 94 | 000000000000 book -d babar |
|
95 |
cb9a9f314b8b book -f -r |
|
|
95 | cb9a9f314b8b book -f -r ?.~1? babar (glob) | |
|
96 | 96 | 1e6c11564562 book -r . babar |
|
97 | 97 | |
|
98 | 98 | Test that bookmarks and working copy tracking is not mixed |
|
99 | 99 | |
|
100 | 100 | $ hg journal |
|
101 | 101 | previous locations of '.': |
|
102 | 102 | 1e6c11564562 up |
|
103 | 103 | cb9a9f314b8b up 0 |
|
104 | 104 | 1e6c11564562 commit -Aqm b |
|
105 | 105 | cb9a9f314b8b commit -Aqm a |
|
106 | 106 | |
|
107 | 107 | Test that you can list all entries as well as limit the list or filter on them |
|
108 | 108 | |
|
109 | 109 | $ hg book -r tip baz |
|
110 | 110 | $ hg journal --all |
|
111 | 111 | previous locations of the working copy and bookmarks: |
|
112 | 112 | 1e6c11564562 baz book -r tip baz |
|
113 | 113 | 000000000000 babar book -d babar |
|
114 |
cb9a9f314b8b babar book -f -r |
|
|
114 | cb9a9f314b8b babar book -f -r ?.~1? babar (glob) | |
|
115 | 115 | 1e6c11564562 babar book -r . babar |
|
116 | 116 | 1e6c11564562 bar up |
|
117 | 117 | 1e6c11564562 . up |
|
118 | 118 | cb9a9f314b8b bar book -f bar |
|
119 | 119 | 1e6c11564562 bar book -r tip bar |
|
120 | 120 | cb9a9f314b8b . up 0 |
|
121 | 121 | 1e6c11564562 . commit -Aqm b |
|
122 | 122 | cb9a9f314b8b . commit -Aqm a |
|
123 | 123 | $ hg journal --limit 2 |
|
124 | 124 | previous locations of '.': |
|
125 | 125 | 1e6c11564562 up |
|
126 | 126 | cb9a9f314b8b up 0 |
|
127 | 127 | $ hg journal bar |
|
128 | 128 | previous locations of 'bar': |
|
129 | 129 | 1e6c11564562 up |
|
130 | 130 | cb9a9f314b8b book -f bar |
|
131 | 131 | 1e6c11564562 book -r tip bar |
|
132 | 132 | $ hg journal foo |
|
133 | 133 | previous locations of 'foo': |
|
134 | 134 | no recorded locations |
|
135 | 135 | $ hg journal . |
|
136 | 136 | previous locations of '.': |
|
137 | 137 | 1e6c11564562 up |
|
138 | 138 | cb9a9f314b8b up 0 |
|
139 | 139 | 1e6c11564562 commit -Aqm b |
|
140 | 140 | cb9a9f314b8b commit -Aqm a |
|
141 | 141 | $ hg journal "re:ba." |
|
142 | 142 | previous locations of 're:ba.': |
|
143 | 143 | 1e6c11564562 baz book -r tip baz |
|
144 | 144 | 000000000000 babar book -d babar |
|
145 |
cb9a9f314b8b babar book -f -r |
|
|
145 | cb9a9f314b8b babar book -f -r ?.~1? babar (glob) | |
|
146 | 146 | 1e6c11564562 babar book -r . babar |
|
147 | 147 | 1e6c11564562 bar up |
|
148 | 148 | cb9a9f314b8b bar book -f bar |
|
149 | 149 | 1e6c11564562 bar book -r tip bar |
|
150 | 150 | |
|
151 | 151 | Test that verbose, JSON, template and commit output work |
|
152 | 152 | |
|
153 | 153 | $ hg journal --verbose --all |
|
154 | 154 | previous locations of the working copy and bookmarks: |
|
155 | 155 | 000000000000 -> 1e6c11564562 foobar baz 1970-01-01 00:00 +0000 book -r tip baz |
|
156 | 156 | cb9a9f314b8b -> 000000000000 foobar babar 1970-01-01 00:00 +0000 book -d babar |
|
157 |
1e6c11564562 -> cb9a9f314b8b foobar babar 1970-01-01 00:00 +0000 book -f -r |
|
|
157 | 1e6c11564562 -> cb9a9f314b8b foobar babar 1970-01-01 00:00 +0000 book -f -r ?.~1? babar (glob) | |
|
158 | 158 | 000000000000 -> 1e6c11564562 foobar babar 1970-01-01 00:00 +0000 book -r . babar |
|
159 | 159 | cb9a9f314b8b -> 1e6c11564562 foobar bar 1970-01-01 00:00 +0000 up |
|
160 | 160 | cb9a9f314b8b -> 1e6c11564562 foobar . 1970-01-01 00:00 +0000 up |
|
161 | 161 | 1e6c11564562 -> cb9a9f314b8b foobar bar 1970-01-01 00:00 +0000 book -f bar |
|
162 | 162 | 000000000000 -> 1e6c11564562 foobar bar 1970-01-01 00:00 +0000 book -r tip bar |
|
163 | 163 | 1e6c11564562 -> cb9a9f314b8b foobar . 1970-01-01 00:00 +0000 up 0 |
|
164 | 164 | cb9a9f314b8b -> 1e6c11564562 foobar . 1970-01-01 00:00 +0000 commit -Aqm b |
|
165 | 165 | 000000000000 -> cb9a9f314b8b foobar . 1970-01-01 00:00 +0000 commit -Aqm a |
|
166 | 166 | $ hg journal --verbose -Tjson |
|
167 | 167 | [ |
|
168 | 168 | { |
|
169 | 169 | "command": "up", |
|
170 | 170 | "date": [5, 0], |
|
171 | 171 | "name": ".", |
|
172 | 172 | "newnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], |
|
173 | 173 | "oldnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
174 | 174 | "user": "foobar" |
|
175 | 175 | }, |
|
176 | 176 | { |
|
177 | 177 | "command": "up 0", |
|
178 | 178 | "date": [2, 0], |
|
179 | 179 | "name": ".", |
|
180 | 180 | "newnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
181 | 181 | "oldnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], |
|
182 | 182 | "user": "foobar" |
|
183 | 183 | }, |
|
184 | 184 | { |
|
185 | 185 | "command": "commit -Aqm b", |
|
186 | 186 | "date": [1, 0], |
|
187 | 187 | "name": ".", |
|
188 | 188 | "newnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], |
|
189 | 189 | "oldnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
190 | 190 | "user": "foobar" |
|
191 | 191 | }, |
|
192 | 192 | { |
|
193 | 193 | "command": "commit -Aqm a", |
|
194 | 194 | "date": [0, 0], |
|
195 | 195 | "name": ".", |
|
196 | 196 | "newnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
197 | 197 | "oldnodes": ["0000000000000000000000000000000000000000"], |
|
198 | 198 | "user": "foobar" |
|
199 | 199 | } |
|
200 | 200 | ] |
|
201 | 201 | |
|
202 | 202 | $ cat <<EOF >> $HGRCPATH |
|
203 | 203 | > [templates] |
|
204 | 204 | > j = "{oldnodes % '{node|upper}'} -> {newnodes % '{node|upper}'} |
|
205 | 205 | > - user: {user} |
|
206 | 206 | > - command: {command} |
|
207 | 207 | > - date: {date|rfc3339date} |
|
208 | 208 | > - newnodes: {newnodes} |
|
209 | 209 | > - oldnodes: {oldnodes} |
|
210 | 210 | > " |
|
211 | 211 | > EOF |
|
212 | 212 | $ hg journal -Tj -l1 |
|
213 | 213 | previous locations of '.': |
|
214 | 214 | CB9A9F314B8B07BA71012FCDBC544B5A4D82FF5B -> 1E6C11564562B4ED919BACA798BC4338BD299D6A |
|
215 | 215 | - user: foobar |
|
216 | 216 | - command: up |
|
217 | 217 | - date: 1970-01-01T00:00:05+00:00 |
|
218 | 218 | - newnodes: 1e6c11564562b4ed919baca798bc4338bd299d6a |
|
219 | 219 | - oldnodes: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b |
|
220 | 220 | |
|
221 | 221 | $ hg journal --commit |
|
222 | 222 | previous locations of '.': |
|
223 | 223 | 1e6c11564562 up |
|
224 | 224 | changeset: 1:1e6c11564562 |
|
225 | 225 | bookmark: bar |
|
226 | 226 | bookmark: baz |
|
227 | 227 | tag: tip |
|
228 | 228 | user: test |
|
229 | 229 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
230 | 230 | summary: b |
|
231 | 231 | |
|
232 | 232 | cb9a9f314b8b up 0 |
|
233 | 233 | changeset: 0:cb9a9f314b8b |
|
234 | 234 | user: test |
|
235 | 235 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
236 | 236 | summary: a |
|
237 | 237 | |
|
238 | 238 | 1e6c11564562 commit -Aqm b |
|
239 | 239 | changeset: 1:1e6c11564562 |
|
240 | 240 | bookmark: bar |
|
241 | 241 | bookmark: baz |
|
242 | 242 | tag: tip |
|
243 | 243 | user: test |
|
244 | 244 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
245 | 245 | summary: b |
|
246 | 246 | |
|
247 | 247 | cb9a9f314b8b commit -Aqm a |
|
248 | 248 | changeset: 0:cb9a9f314b8b |
|
249 | 249 | user: test |
|
250 | 250 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
251 | 251 | summary: a |
|
252 | 252 | |
|
253 | 253 | |
|
254 | 254 | $ hg journal --commit -Tjson |
|
255 | 255 | [ |
|
256 | 256 | { |
|
257 | 257 | "changesets": [{"bookmarks": ["bar", "baz"], "branch": "default", "date": [0, 0], "desc": "b", "node": "1e6c11564562b4ed919baca798bc4338bd299d6a", "parents": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "phase": "draft", "rev": 1, "tags": ["tip"], "user": "test"}], |
|
258 | 258 | "command": "up", |
|
259 | 259 | "date": [5, 0], |
|
260 | 260 | "name": ".", |
|
261 | 261 | "newnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], |
|
262 | 262 | "oldnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
263 | 263 | "user": "foobar" |
|
264 | 264 | }, |
|
265 | 265 | { |
|
266 | 266 | "changesets": [{"bookmarks": [], "branch": "default", "date": [0, 0], "desc": "a", "node": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b", "parents": ["0000000000000000000000000000000000000000"], "phase": "draft", "rev": 0, "tags": [], "user": "test"}], |
|
267 | 267 | "command": "up 0", |
|
268 | 268 | "date": [2, 0], |
|
269 | 269 | "name": ".", |
|
270 | 270 | "newnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
271 | 271 | "oldnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], |
|
272 | 272 | "user": "foobar" |
|
273 | 273 | }, |
|
274 | 274 | { |
|
275 | 275 | "changesets": [{"bookmarks": ["bar", "baz"], "branch": "default", "date": [0, 0], "desc": "b", "node": "1e6c11564562b4ed919baca798bc4338bd299d6a", "parents": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "phase": "draft", "rev": 1, "tags": ["tip"], "user": "test"}], |
|
276 | 276 | "command": "commit -Aqm b", |
|
277 | 277 | "date": [1, 0], |
|
278 | 278 | "name": ".", |
|
279 | 279 | "newnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], |
|
280 | 280 | "oldnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
281 | 281 | "user": "foobar" |
|
282 | 282 | }, |
|
283 | 283 | { |
|
284 | 284 | "changesets": [{"bookmarks": [], "branch": "default", "date": [0, 0], "desc": "a", "node": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b", "parents": ["0000000000000000000000000000000000000000"], "phase": "draft", "rev": 0, "tags": [], "user": "test"}], |
|
285 | 285 | "command": "commit -Aqm a", |
|
286 | 286 | "date": [0, 0], |
|
287 | 287 | "name": ".", |
|
288 | 288 | "newnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
289 | 289 | "oldnodes": ["0000000000000000000000000000000000000000"], |
|
290 | 290 | "user": "foobar" |
|
291 | 291 | } |
|
292 | 292 | ] |
|
293 | 293 | |
|
294 | 294 | $ hg journal --commit \ |
|
295 | 295 | > -T'command: {command}\n{changesets % " rev: {rev}\n children: {children}\n"}' |
|
296 | 296 | previous locations of '.': |
|
297 | 297 | command: up |
|
298 | 298 | rev: 1 |
|
299 | 299 | children: |
|
300 | 300 | command: up 0 |
|
301 | 301 | rev: 0 |
|
302 | 302 | children: 1:1e6c11564562 |
|
303 | 303 | command: commit -Aqm b |
|
304 | 304 | rev: 1 |
|
305 | 305 | children: |
|
306 | 306 | command: commit -Aqm a |
|
307 | 307 | rev: 0 |
|
308 | 308 | children: 1:1e6c11564562 |
|
309 | 309 | |
|
310 | 310 | Test for behaviour on unexpected storage version information |
|
311 | 311 | |
|
312 | 312 | $ printf '42\0' > .hg/namejournal |
|
313 | 313 | $ hg journal |
|
314 | 314 | previous locations of '.': |
|
315 | 315 | abort: unknown journal file version '42' |
|
316 | 316 | [255] |
|
317 | 317 | $ hg book -r tip doomed |
|
318 | 318 | unsupported journal file version '42' |
General Comments 0
You need to be logged in to leave comments.
Login now