Show More
@@ -1,298 +1,314 b'' | |||
|
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 | Test that we tracks bookmark deletion | |
|
88 | ||
|
89 | $ hg book -r . babar | |
|
90 | $ hg book -f -r .~1 babar | |
|
91 | $ hg book -d babar | |
|
92 | $ hg journal babar | |
|
93 | previous locations of 'babar': | |
|
94 | cb9a9f314b8b book -f -r '.~1' babar | |
|
95 | 1e6c11564562 book -r . babar | |
|
96 | ||
|
87 | 97 | Test that bookmarks and working copy tracking is not mixed |
|
88 | 98 | |
|
89 | 99 | $ hg journal |
|
90 | 100 | previous locations of '.': |
|
91 | 101 | 1e6c11564562 up |
|
92 | 102 | cb9a9f314b8b up 0 |
|
93 | 103 | 1e6c11564562 commit -Aqm b |
|
94 | 104 | cb9a9f314b8b commit -Aqm a |
|
95 | 105 | |
|
96 | 106 | Test that you can list all entries as well as limit the list or filter on them |
|
97 | 107 | |
|
98 | 108 | $ hg book -r tip baz |
|
99 | 109 | $ hg journal --all |
|
100 | 110 | previous locations of the working copy and bookmarks: |
|
101 | 111 | 1e6c11564562 baz book -r tip baz |
|
112 | cb9a9f314b8b babar book -f -r '.~1' babar | |
|
113 | 1e6c11564562 babar book -r . babar | |
|
102 | 114 | 1e6c11564562 bar up |
|
103 | 115 | 1e6c11564562 . up |
|
104 | 116 | cb9a9f314b8b bar book -f bar |
|
105 | 117 | 1e6c11564562 bar book -r tip bar |
|
106 | 118 | cb9a9f314b8b . up 0 |
|
107 | 119 | 1e6c11564562 . commit -Aqm b |
|
108 | 120 | cb9a9f314b8b . commit -Aqm a |
|
109 | 121 | $ hg journal --limit 2 |
|
110 | 122 | previous locations of '.': |
|
111 | 123 | 1e6c11564562 up |
|
112 | 124 | cb9a9f314b8b up 0 |
|
113 | 125 | $ hg journal bar |
|
114 | 126 | previous locations of 'bar': |
|
115 | 127 | 1e6c11564562 up |
|
116 | 128 | cb9a9f314b8b book -f bar |
|
117 | 129 | 1e6c11564562 book -r tip bar |
|
118 | 130 | $ hg journal foo |
|
119 | 131 | previous locations of 'foo': |
|
120 | 132 | no recorded locations |
|
121 | 133 | $ hg journal . |
|
122 | 134 | previous locations of '.': |
|
123 | 135 | 1e6c11564562 up |
|
124 | 136 | cb9a9f314b8b up 0 |
|
125 | 137 | 1e6c11564562 commit -Aqm b |
|
126 | 138 | cb9a9f314b8b commit -Aqm a |
|
127 | 139 | $ hg journal "re:ba." |
|
128 | 140 | previous locations of 're:ba.': |
|
129 | 141 | 1e6c11564562 baz book -r tip baz |
|
142 | cb9a9f314b8b babar book -f -r '.~1' babar | |
|
143 | 1e6c11564562 babar book -r . babar | |
|
130 | 144 | 1e6c11564562 bar up |
|
131 | 145 | cb9a9f314b8b bar book -f bar |
|
132 | 146 | 1e6c11564562 bar book -r tip bar |
|
133 | 147 | |
|
134 | 148 | Test that verbose, JSON, template and commit output work |
|
135 | 149 | |
|
136 | 150 | $ hg journal --verbose --all |
|
137 | 151 | previous locations of the working copy and bookmarks: |
|
138 | 152 | 000000000000 -> 1e6c11564562 foobar baz 1970-01-01 00:00 +0000 book -r tip baz |
|
153 | 1e6c11564562 -> cb9a9f314b8b foobar babar 1970-01-01 00:00 +0000 book -f -r '.~1' babar | |
|
154 | 000000000000 -> 1e6c11564562 foobar babar 1970-01-01 00:00 +0000 book -r . babar | |
|
139 | 155 | cb9a9f314b8b -> 1e6c11564562 foobar bar 1970-01-01 00:00 +0000 up |
|
140 | 156 | cb9a9f314b8b -> 1e6c11564562 foobar . 1970-01-01 00:00 +0000 up |
|
141 | 157 | 1e6c11564562 -> cb9a9f314b8b foobar bar 1970-01-01 00:00 +0000 book -f bar |
|
142 | 158 | 000000000000 -> 1e6c11564562 foobar bar 1970-01-01 00:00 +0000 book -r tip bar |
|
143 | 159 | 1e6c11564562 -> cb9a9f314b8b foobar . 1970-01-01 00:00 +0000 up 0 |
|
144 | 160 | cb9a9f314b8b -> 1e6c11564562 foobar . 1970-01-01 00:00 +0000 commit -Aqm b |
|
145 | 161 | 000000000000 -> cb9a9f314b8b foobar . 1970-01-01 00:00 +0000 commit -Aqm a |
|
146 | 162 | $ hg journal --verbose -Tjson |
|
147 | 163 | [ |
|
148 | 164 | { |
|
149 | 165 | "command": "up", |
|
150 | 166 | "date": [5, 0], |
|
151 | 167 | "name": ".", |
|
152 | 168 | "newnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], |
|
153 | 169 | "oldnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
154 | 170 | "user": "foobar" |
|
155 | 171 | }, |
|
156 | 172 | { |
|
157 | 173 | "command": "up 0", |
|
158 | 174 | "date": [2, 0], |
|
159 | 175 | "name": ".", |
|
160 | 176 | "newnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
161 | 177 | "oldnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], |
|
162 | 178 | "user": "foobar" |
|
163 | 179 | }, |
|
164 | 180 | { |
|
165 | 181 | "command": "commit -Aqm b", |
|
166 | 182 | "date": [1, 0], |
|
167 | 183 | "name": ".", |
|
168 | 184 | "newnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], |
|
169 | 185 | "oldnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
170 | 186 | "user": "foobar" |
|
171 | 187 | }, |
|
172 | 188 | { |
|
173 | 189 | "command": "commit -Aqm a", |
|
174 | 190 | "date": [0, 0], |
|
175 | 191 | "name": ".", |
|
176 | 192 | "newnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
177 | 193 | "oldnodes": ["0000000000000000000000000000000000000000"], |
|
178 | 194 | "user": "foobar" |
|
179 | 195 | } |
|
180 | 196 | ] |
|
181 | 197 | |
|
182 | 198 | $ cat <<EOF >> $HGRCPATH |
|
183 | 199 | > [templates] |
|
184 | 200 | > j = "{oldnodes % '{node|upper}'} -> {newnodes % '{node|upper}'} |
|
185 | 201 | > - user: {user} |
|
186 | 202 | > - command: {command} |
|
187 | 203 | > - date: {date|rfc3339date} |
|
188 | 204 | > - newnodes: {newnodes} |
|
189 | 205 | > - oldnodes: {oldnodes} |
|
190 | 206 | > " |
|
191 | 207 | > EOF |
|
192 | 208 | $ hg journal -Tj -l1 |
|
193 | 209 | previous locations of '.': |
|
194 | 210 | CB9A9F314B8B07BA71012FCDBC544B5A4D82FF5B -> 1E6C11564562B4ED919BACA798BC4338BD299D6A |
|
195 | 211 | - user: foobar |
|
196 | 212 | - command: up |
|
197 | 213 | - date: 1970-01-01T00:00:05+00:00 |
|
198 | 214 | - newnodes: 1e6c11564562b4ed919baca798bc4338bd299d6a |
|
199 | 215 | - oldnodes: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b |
|
200 | 216 | |
|
201 | 217 | $ hg journal --commit |
|
202 | 218 | previous locations of '.': |
|
203 | 219 | 1e6c11564562 up |
|
204 | 220 | changeset: 1:1e6c11564562 |
|
205 | 221 | bookmark: bar |
|
206 | 222 | bookmark: baz |
|
207 | 223 | tag: tip |
|
208 | 224 | user: test |
|
209 | 225 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
210 | 226 | summary: b |
|
211 | 227 | |
|
212 | 228 | cb9a9f314b8b up 0 |
|
213 | 229 | changeset: 0:cb9a9f314b8b |
|
214 | 230 | user: test |
|
215 | 231 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
216 | 232 | summary: a |
|
217 | 233 | |
|
218 | 234 | 1e6c11564562 commit -Aqm b |
|
219 | 235 | changeset: 1:1e6c11564562 |
|
220 | 236 | bookmark: bar |
|
221 | 237 | bookmark: baz |
|
222 | 238 | tag: tip |
|
223 | 239 | user: test |
|
224 | 240 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
225 | 241 | summary: b |
|
226 | 242 | |
|
227 | 243 | cb9a9f314b8b commit -Aqm a |
|
228 | 244 | changeset: 0:cb9a9f314b8b |
|
229 | 245 | user: test |
|
230 | 246 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
231 | 247 | summary: a |
|
232 | 248 | |
|
233 | 249 | |
|
234 | 250 | $ hg journal --commit -Tjson |
|
235 | 251 | [ |
|
236 | 252 | { |
|
237 | 253 | "changesets": [{"bookmarks": ["bar", "baz"], "branch": "default", "date": [0, 0], "desc": "b", "node": "1e6c11564562b4ed919baca798bc4338bd299d6a", "parents": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "phase": "draft", "rev": 1, "tags": ["tip"], "user": "test"}], |
|
238 | 254 | "command": "up", |
|
239 | 255 | "date": [5, 0], |
|
240 | 256 | "name": ".", |
|
241 | 257 | "newnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], |
|
242 | 258 | "oldnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
243 | 259 | "user": "foobar" |
|
244 | 260 | }, |
|
245 | 261 | { |
|
246 | 262 | "changesets": [{"bookmarks": [], "branch": "default", "date": [0, 0], "desc": "a", "node": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b", "parents": ["0000000000000000000000000000000000000000"], "phase": "draft", "rev": 0, "tags": [], "user": "test"}], |
|
247 | 263 | "command": "up 0", |
|
248 | 264 | "date": [2, 0], |
|
249 | 265 | "name": ".", |
|
250 | 266 | "newnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
251 | 267 | "oldnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], |
|
252 | 268 | "user": "foobar" |
|
253 | 269 | }, |
|
254 | 270 | { |
|
255 | 271 | "changesets": [{"bookmarks": ["bar", "baz"], "branch": "default", "date": [0, 0], "desc": "b", "node": "1e6c11564562b4ed919baca798bc4338bd299d6a", "parents": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], "phase": "draft", "rev": 1, "tags": ["tip"], "user": "test"}], |
|
256 | 272 | "command": "commit -Aqm b", |
|
257 | 273 | "date": [1, 0], |
|
258 | 274 | "name": ".", |
|
259 | 275 | "newnodes": ["1e6c11564562b4ed919baca798bc4338bd299d6a"], |
|
260 | 276 | "oldnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
261 | 277 | "user": "foobar" |
|
262 | 278 | }, |
|
263 | 279 | { |
|
264 | 280 | "changesets": [{"bookmarks": [], "branch": "default", "date": [0, 0], "desc": "a", "node": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b", "parents": ["0000000000000000000000000000000000000000"], "phase": "draft", "rev": 0, "tags": [], "user": "test"}], |
|
265 | 281 | "command": "commit -Aqm a", |
|
266 | 282 | "date": [0, 0], |
|
267 | 283 | "name": ".", |
|
268 | 284 | "newnodes": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"], |
|
269 | 285 | "oldnodes": ["0000000000000000000000000000000000000000"], |
|
270 | 286 | "user": "foobar" |
|
271 | 287 | } |
|
272 | 288 | ] |
|
273 | 289 | |
|
274 | 290 | $ hg journal --commit \ |
|
275 | 291 | > -T'command: {command}\n{changesets % " rev: {rev}\n children: {children}\n"}' |
|
276 | 292 | previous locations of '.': |
|
277 | 293 | command: up |
|
278 | 294 | rev: 1 |
|
279 | 295 | children: |
|
280 | 296 | command: up 0 |
|
281 | 297 | rev: 0 |
|
282 | 298 | children: 1:1e6c11564562 |
|
283 | 299 | command: commit -Aqm b |
|
284 | 300 | rev: 1 |
|
285 | 301 | children: |
|
286 | 302 | command: commit -Aqm a |
|
287 | 303 | rev: 0 |
|
288 | 304 | children: 1:1e6c11564562 |
|
289 | 305 | |
|
290 | 306 | Test for behaviour on unexpected storage version information |
|
291 | 307 | |
|
292 | 308 | $ printf '42\0' > .hg/namejournal |
|
293 | 309 | $ hg journal |
|
294 | 310 | previous locations of '.': |
|
295 | 311 | abort: unknown journal file version '42' |
|
296 | 312 | [255] |
|
297 | 313 | $ hg book -r tip doomed |
|
298 | 314 | unsupported journal file version '42' |
General Comments 0
You need to be logged in to leave comments.
Login now