##// END OF EJS Templates
visibility: improve the message when accessing filtered obsolete rev...
Boris Feld -
r35612:265cd9e1 default
parent child Browse files
Show More
This diff has been collapsed as it changes many lines, (551 lines changed) Show them Hide them
@@ -0,0 +1,551 b''
1 This test file test the various messages when accessing obsolete
2 revisions.
3
4 Global setup
5 ============
6
7 $ . $TESTDIR/testlib/obsmarker-common.sh
8 $ cat >> $HGRCPATH <<EOF
9 > [ui]
10 > interactive = true
11 > [phases]
12 > publish=False
13 > [experimental]
14 > evolution.createmarkers = yes
15 > evolution.effect-flags = yes
16 > EOF
17
18 Test output on amended commit
19 =============================
20
21 Test setup
22 ----------
23
24 $ hg init $TESTTMP/local-amend
25 $ cd $TESTTMP/local-amend
26 $ mkcommit ROOT
27 $ mkcommit A0
28 $ echo 42 >> A0
29 $ hg commit --amend -m "A1
30 >
31 > Better commit message"
32 $ hg log --hidden -G
33 @ changeset: 2:4ae3a4151de9
34 | tag: tip
35 | parent: 0:ea207398892e
36 | user: test
37 | date: Thu Jan 01 00:00:00 1970 +0000
38 | summary: A1
39 |
40 | x changeset: 1:471f378eab4c
41 |/ user: test
42 | date: Thu Jan 01 00:00:00 1970 +0000
43 | obsolete: rewritten using amend as 2:4ae3a4151de9
44 | summary: A0
45 |
46 o changeset: 0:ea207398892e
47 user: test
48 date: Thu Jan 01 00:00:00 1970 +0000
49 summary: ROOT
50
51 Actual test
52 -----------
53 $ hg update 471f378eab4c
54 abort: hidden revision '471f378eab4c' was rewritten as: 4ae3a4151de9!
55 (use --hidden to access hidden revisions)
56 [255]
57 $ hg update --hidden "desc(A0)"
58 updating to a hidden changeset 471f378eab4c
59 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
60
61 Test output with pruned commit
62 ==============================
63
64 Test setup
65 ----------
66
67 $ hg init $TESTTMP/local-prune
68 $ cd $TESTTMP/local-prune
69 $ mkcommit ROOT
70 $ mkcommit A0 # 0
71 $ mkcommit B0 # 1
72 $ hg log --hidden -G
73 @ changeset: 2:0dec01379d3b
74 | tag: tip
75 | user: test
76 | date: Thu Jan 01 00:00:00 1970 +0000
77 | summary: B0
78 |
79 o changeset: 1:471f378eab4c
80 | user: test
81 | date: Thu Jan 01 00:00:00 1970 +0000
82 | summary: A0
83 |
84 o changeset: 0:ea207398892e
85 user: test
86 date: Thu Jan 01 00:00:00 1970 +0000
87 summary: ROOT
88
89 $ hg debugobsolete --record-parents `getid 'desc(B0)'`
90 obsoleted 1 changesets
91
92 $ hg log --hidden -G
93 @ changeset: 2:0dec01379d3b
94 | tag: tip
95 | user: test
96 | date: Thu Jan 01 00:00:00 1970 +0000
97 | obsolete: pruned
98 | summary: B0
99 |
100 o changeset: 1:471f378eab4c
101 | user: test
102 | date: Thu Jan 01 00:00:00 1970 +0000
103 | summary: A0
104 |
105 o changeset: 0:ea207398892e
106 user: test
107 date: Thu Jan 01 00:00:00 1970 +0000
108 summary: ROOT
109
110
111 Actual test
112 -----------
113 $ hg up 1
114 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
115 $ hg up 0dec01379d3b
116 abort: hidden revision '0dec01379d3b' is pruned!
117 (use --hidden to access hidden revisions)
118 [255]
119 $ hg up --hidden -r 'desc(B0)'
120 updating to a hidden changeset 0dec01379d3b
121 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
122
123 Test output with splitted commit
124 ================================
125
126 Test setup
127 ----------
128
129 $ hg init $TESTTMP/local-split
130 $ cd $TESTTMP/local-split
131 $ mkcommit ROOT
132 $ echo 42 >> a
133 $ echo 43 >> b
134 $ hg commit -A -m "A0"
135 adding a
136 adding b
137 $ hg log --hidden -G
138 @ changeset: 1:471597cad322
139 | tag: tip
140 | user: test
141 | date: Thu Jan 01 00:00:00 1970 +0000
142 | summary: A0
143 |
144 o changeset: 0:ea207398892e
145 user: test
146 date: Thu Jan 01 00:00:00 1970 +0000
147 summary: ROOT
148
149 # Simulate a split
150 $ hg up 0
151 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
152
153 $ echo 42 >> a
154 $ hg commit -A -m "A0"
155 adding a
156 created new head
157
158 $ echo 43 >> b
159 $ hg commit -A -m "A0"
160 adding b
161
162 $ hg debugobsolete `getid '1'` `getid '2'` `getid '3'`
163 obsoleted 1 changesets
164
165 $ hg log --hidden -G
166 @ changeset: 3:f257fde29c7a
167 | tag: tip
168 | user: test
169 | date: Thu Jan 01 00:00:00 1970 +0000
170 | summary: A0
171 |
172 o changeset: 2:337fec4d2edc
173 | parent: 0:ea207398892e
174 | user: test
175 | date: Thu Jan 01 00:00:00 1970 +0000
176 | summary: A0
177 |
178 | x changeset: 1:471597cad322
179 |/ user: test
180 | date: Thu Jan 01 00:00:00 1970 +0000
181 | obsolete: split as 2:337fec4d2edc, 3:f257fde29c7a
182 | summary: A0
183 |
184 o changeset: 0:ea207398892e
185 user: test
186 date: Thu Jan 01 00:00:00 1970 +0000
187 summary: ROOT
188
189 Actual test
190 -----------
191 $ hg update 471597cad322
192 abort: hidden revision '471597cad322' was split as: 337fec4d2edc, f257fde29c7a!
193 (use --hidden to access hidden revisions)
194 [255]
195 $ hg update --hidden 'min(desc(A0))'
196 updating to a hidden changeset 471597cad322
197 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
198
199 Test output with lots of splitted commit
200 ========================================
201
202 Test setup
203 ----------
204
205 $ hg init $TESTTMP/local-lots-split
206 $ cd $TESTTMP/local-lots-split
207 $ mkcommit ROOT
208 $ echo 42 >> a
209 $ echo 43 >> b
210 $ echo 44 >> c
211 $ echo 45 >> d
212 $ hg commit -A -m "A0"
213 adding a
214 adding b
215 adding c
216 adding d
217 $ hg log --hidden -G
218 @ changeset: 1:de7290d8b885
219 | tag: tip
220 | user: test
221 | date: Thu Jan 01 00:00:00 1970 +0000
222 | summary: A0
223 |
224 o changeset: 0:ea207398892e
225 user: test
226 date: Thu Jan 01 00:00:00 1970 +0000
227 summary: ROOT
228
229 # Simulate a split
230 $ hg up 0
231 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
232
233 $ echo 42 >> a
234 $ hg commit -A -m "A0"
235 adding a
236 created new head
237
238 $ echo 43 >> b
239 $ hg commit -A -m "A0"
240 adding b
241
242 $ echo 44 >> c
243 $ hg commit -A -m "A0"
244 adding c
245
246 $ echo 45 >> d
247 $ hg commit -A -m "A0"
248 adding d
249
250 $ hg debugobsolete `getid '1'` `getid '2'` `getid '3'` `getid '4'` `getid '5'`
251 obsoleted 1 changesets
252
253 $ hg log --hidden -G
254 @ changeset: 5:c7f044602e9b
255 | tag: tip
256 | user: test
257 | date: Thu Jan 01 00:00:00 1970 +0000
258 | summary: A0
259 |
260 o changeset: 4:1ae8bc733a14
261 | user: test
262 | date: Thu Jan 01 00:00:00 1970 +0000
263 | summary: A0
264 |
265 o changeset: 3:f257fde29c7a
266 | user: test
267 | date: Thu Jan 01 00:00:00 1970 +0000
268 | summary: A0
269 |
270 o changeset: 2:337fec4d2edc
271 | parent: 0:ea207398892e
272 | user: test
273 | date: Thu Jan 01 00:00:00 1970 +0000
274 | summary: A0
275 |
276 | x changeset: 1:de7290d8b885
277 |/ user: test
278 | date: Thu Jan 01 00:00:00 1970 +0000
279 | obsolete: split as 2:337fec4d2edc, 3:f257fde29c7a, 4:1ae8bc733a14, 5:c7f044602e9b
280 | summary: A0
281 |
282 o changeset: 0:ea207398892e
283 user: test
284 date: Thu Jan 01 00:00:00 1970 +0000
285 summary: ROOT
286
287 Actual test
288 -----------
289 $ hg update de7290d8b885
290 abort: hidden revision 'de7290d8b885' was split as: 337fec4d2edc, f257fde29c7a and 2 more!
291 (use --hidden to access hidden revisions)
292 [255]
293 $ hg update --hidden 'min(desc(A0))'
294 updating to a hidden changeset de7290d8b885
295 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
296
297 Test output with folded commit
298 ==============================
299
300 Test setup
301 ----------
302
303 $ hg init $TESTTMP/local-fold
304 $ cd $TESTTMP/local-fold
305 $ mkcommit ROOT
306 $ mkcommit A0
307 $ mkcommit B0
308 $ hg log --hidden -G
309 @ changeset: 2:0dec01379d3b
310 | tag: tip
311 | user: test
312 | date: Thu Jan 01 00:00:00 1970 +0000
313 | summary: B0
314 |
315 o changeset: 1:471f378eab4c
316 | user: test
317 | date: Thu Jan 01 00:00:00 1970 +0000
318 | summary: A0
319 |
320 o changeset: 0:ea207398892e
321 user: test
322 date: Thu Jan 01 00:00:00 1970 +0000
323 summary: ROOT
324
325 # Simulate a fold
326 $ hg up 0
327 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
328 $ echo "A0" > A0
329 $ echo "B0" > B0
330 $ hg add A0 B0
331 $ hg commit -m "C0"
332 created new head
333
334 $ hg debugobsolete `getid 'desc(A0)'` `getid 'desc(C0)'`
335 obsoleted 1 changesets
336 $ hg debugobsolete `getid 'desc(B0)'` `getid 'desc(C0)'`
337 obsoleted 1 changesets
338
339 $ hg log --hidden -G
340 @ changeset: 3:eb5a0daa2192
341 | tag: tip
342 | parent: 0:ea207398892e
343 | user: test
344 | date: Thu Jan 01 00:00:00 1970 +0000
345 | summary: C0
346 |
347 | x changeset: 2:0dec01379d3b
348 | | user: test
349 | | date: Thu Jan 01 00:00:00 1970 +0000
350 | | obsolete: rewritten as 3:eb5a0daa2192
351 | | summary: B0
352 | |
353 | x changeset: 1:471f378eab4c
354 |/ user: test
355 | date: Thu Jan 01 00:00:00 1970 +0000
356 | obsolete: rewritten as 3:eb5a0daa2192
357 | summary: A0
358 |
359 o changeset: 0:ea207398892e
360 user: test
361 date: Thu Jan 01 00:00:00 1970 +0000
362 summary: ROOT
363
364 Actual test
365 -----------
366 $ hg update 471f378eab4c
367 abort: hidden revision '471f378eab4c' was rewritten as: eb5a0daa2192!
368 (use --hidden to access hidden revisions)
369 [255]
370 $ hg update --hidden 'desc(A0)'
371 updating to a hidden changeset 471f378eab4c
372 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
373 $ hg update 0dec01379d3b
374 abort: hidden revision '0dec01379d3b' was rewritten as: eb5a0daa2192!
375 (use --hidden to access hidden revisions)
376 [255]
377 $ hg update --hidden 'desc(B0)'
378 updating to a hidden changeset 0dec01379d3b
379 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
380
381 Test output with divergence
382 ===========================
383
384 Test setup
385 ----------
386
387 $ hg init $TESTTMP/local-divergence
388 $ cd $TESTTMP/local-divergence
389 $ mkcommit ROOT
390 $ mkcommit A0
391 $ hg commit --amend -m "A1"
392 $ hg log --hidden -G
393 @ changeset: 2:fdf9bde5129a
394 | tag: tip
395 | parent: 0:ea207398892e
396 | user: test
397 | date: Thu Jan 01 00:00:00 1970 +0000
398 | summary: A1
399 |
400 | x changeset: 1:471f378eab4c
401 |/ user: test
402 | date: Thu Jan 01 00:00:00 1970 +0000
403 | obsolete: rewritten using amend as 2:fdf9bde5129a
404 | summary: A0
405 |
406 o changeset: 0:ea207398892e
407 user: test
408 date: Thu Jan 01 00:00:00 1970 +0000
409 summary: ROOT
410
411 $ hg update --hidden 'desc(A0)'
412 updating to a hidden changeset 471f378eab4c
413 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
414 $ hg commit --amend -m "A2"
415 $ hg log --hidden -G
416 @ changeset: 3:65b757b745b9
417 | tag: tip
418 | parent: 0:ea207398892e
419 | user: test
420 | date: Thu Jan 01 00:00:00 1970 +0000
421 | instability: content-divergent
422 | summary: A2
423 |
424 | * changeset: 2:fdf9bde5129a
425 |/ parent: 0:ea207398892e
426 | user: test
427 | date: Thu Jan 01 00:00:00 1970 +0000
428 | instability: content-divergent
429 | summary: A1
430 |
431 | x changeset: 1:471f378eab4c
432 |/ user: test
433 | date: Thu Jan 01 00:00:00 1970 +0000
434 | obsolete: rewritten using amend as 2:fdf9bde5129a
435 | obsolete: rewritten using amend as 3:65b757b745b9
436 | summary: A0
437 |
438 o changeset: 0:ea207398892e
439 user: test
440 date: Thu Jan 01 00:00:00 1970 +0000
441 summary: ROOT
442
443 Actual test
444 -----------
445 $ hg update 471f378eab4c
446 abort: hidden revision '471f378eab4c' has diverged!
447 (use --hidden to access hidden revisions)
448 [255]
449 $ hg update --hidden 'desc(A0)'
450 updating to a hidden changeset 471f378eab4c
451 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
452
453 Test output with amended + folded commit
454 ========================================
455
456 Test setup
457 ----------
458
459 $ hg init $TESTTMP/local-amend-fold
460 $ cd $TESTTMP/local-amend-fold
461 $ mkcommit ROOT
462 $ mkcommit A0
463 $ mkcommit B0
464 $ hg commit --amend -m "B1"
465 $ hg log --hidden -G
466 @ changeset: 3:b7ea6d14e664
467 | tag: tip
468 | parent: 1:471f378eab4c
469 | user: test
470 | date: Thu Jan 01 00:00:00 1970 +0000
471 | summary: B1
472 |
473 | x changeset: 2:0dec01379d3b
474 |/ user: test
475 | date: Thu Jan 01 00:00:00 1970 +0000
476 | obsolete: rewritten using amend as 3:b7ea6d14e664
477 | summary: B0
478 |
479 o changeset: 1:471f378eab4c
480 | user: test
481 | date: Thu Jan 01 00:00:00 1970 +0000
482 | summary: A0
483 |
484 o changeset: 0:ea207398892e
485 user: test
486 date: Thu Jan 01 00:00:00 1970 +0000
487 summary: ROOT
488
489
490 # Simulate a fold
491 $ hg up 0
492 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
493 $ echo "A0" > A0
494 $ echo "B0" > B0
495 $ hg add A0 B0
496 $ hg commit -m "C0"
497 created new head
498
499 $ hg debugobsolete `getid 'desc(A0)'` `getid 'desc(C0)'`
500 obsoleted 1 changesets
501 $ hg debugobsolete `getid 'desc(B1)'` `getid 'desc(C0)'`
502 obsoleted 1 changesets
503
504 $ hg log --hidden -G
505 @ changeset: 4:eb5a0daa2192
506 | tag: tip
507 | parent: 0:ea207398892e
508 | user: test
509 | date: Thu Jan 01 00:00:00 1970 +0000
510 | summary: C0
511 |
512 | x changeset: 3:b7ea6d14e664
513 | | parent: 1:471f378eab4c
514 | | user: test
515 | | date: Thu Jan 01 00:00:00 1970 +0000
516 | | obsolete: rewritten as 4:eb5a0daa2192
517 | | summary: B1
518 | |
519 | | x changeset: 2:0dec01379d3b
520 | |/ user: test
521 | | date: Thu Jan 01 00:00:00 1970 +0000
522 | | obsolete: rewritten using amend as 3:b7ea6d14e664
523 | | summary: B0
524 | |
525 | x changeset: 1:471f378eab4c
526 |/ user: test
527 | date: Thu Jan 01 00:00:00 1970 +0000
528 | obsolete: rewritten as 4:eb5a0daa2192
529 | summary: A0
530 |
531 o changeset: 0:ea207398892e
532 user: test
533 date: Thu Jan 01 00:00:00 1970 +0000
534 summary: ROOT
535
536 Actual test
537 -----------
538 $ hg update 471f378eab4c
539 abort: hidden revision '471f378eab4c' was rewritten as: eb5a0daa2192!
540 (use --hidden to access hidden revisions)
541 [255]
542 $ hg update --hidden 'desc(A0)'
543 updating to a hidden changeset 471f378eab4c
544 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
545 $ hg update --hidden 0dec01379d3b
546 updating to a hidden changeset 0dec01379d3b
547 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
548 $ hg update 0dec01379d3b
549 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
550 $ hg update --hidden 'desc(B0)'
551 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -1,2776 +1,2790 b''
1 1 # context.py - changeset and file context objects for mercurial
2 2 #
3 3 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 import errno
11 11 import filecmp
12 12 import os
13 13 import re
14 14 import stat
15 15
16 16 from .i18n import _
17 17 from .node import (
18 18 addednodeid,
19 19 bin,
20 20 hex,
21 21 modifiednodeid,
22 22 nullid,
23 23 nullrev,
24 24 short,
25 25 wdirid,
26 26 wdirnodes,
27 27 wdirrev,
28 28 )
29 29 from .thirdparty import (
30 30 attr,
31 31 )
32 32 from . import (
33 33 encoding,
34 34 error,
35 35 fileset,
36 36 match as matchmod,
37 37 mdiff,
38 38 obsolete as obsmod,
39 obsutil,
39 40 patch,
40 41 pathutil,
41 42 phases,
42 43 pycompat,
43 44 repoview,
44 45 revlog,
45 46 scmutil,
46 47 sparse,
47 48 subrepo,
48 49 util,
49 50 )
50 51
51 52 propertycache = util.propertycache
52 53
53 54 nonascii = re.compile(r'[^\x21-\x7f]').search
54 55
55 56 class basectx(object):
56 57 """A basectx object represents the common logic for its children:
57 58 changectx: read-only context that is already present in the repo,
58 59 workingctx: a context that represents the working directory and can
59 60 be committed,
60 61 memctx: a context that represents changes in-memory and can also
61 62 be committed."""
62 63 def __new__(cls, repo, changeid='', *args, **kwargs):
63 64 if isinstance(changeid, basectx):
64 65 return changeid
65 66
66 67 o = super(basectx, cls).__new__(cls)
67 68
68 69 o._repo = repo
69 70 o._rev = nullrev
70 71 o._node = nullid
71 72
72 73 return o
73 74
74 75 def __bytes__(self):
75 76 return short(self.node())
76 77
77 78 __str__ = encoding.strmethod(__bytes__)
78 79
79 80 def __int__(self):
80 81 return self.rev()
81 82
82 83 def __repr__(self):
83 84 return r"<%s %s>" % (type(self).__name__, str(self))
84 85
85 86 def __eq__(self, other):
86 87 try:
87 88 return type(self) == type(other) and self._rev == other._rev
88 89 except AttributeError:
89 90 return False
90 91
91 92 def __ne__(self, other):
92 93 return not (self == other)
93 94
94 95 def __contains__(self, key):
95 96 return key in self._manifest
96 97
97 98 def __getitem__(self, key):
98 99 return self.filectx(key)
99 100
100 101 def __iter__(self):
101 102 return iter(self._manifest)
102 103
103 104 def _buildstatusmanifest(self, status):
104 105 """Builds a manifest that includes the given status results, if this is
105 106 a working copy context. For non-working copy contexts, it just returns
106 107 the normal manifest."""
107 108 return self.manifest()
108 109
109 110 def _matchstatus(self, other, match):
110 111 """This internal method provides a way for child objects to override the
111 112 match operator.
112 113 """
113 114 return match
114 115
115 116 def _buildstatus(self, other, s, match, listignored, listclean,
116 117 listunknown):
117 118 """build a status with respect to another context"""
118 119 # Load earliest manifest first for caching reasons. More specifically,
119 120 # if you have revisions 1000 and 1001, 1001 is probably stored as a
120 121 # delta against 1000. Thus, if you read 1000 first, we'll reconstruct
121 122 # 1000 and cache it so that when you read 1001, we just need to apply a
122 123 # delta to what's in the cache. So that's one full reconstruction + one
123 124 # delta application.
124 125 mf2 = None
125 126 if self.rev() is not None and self.rev() < other.rev():
126 127 mf2 = self._buildstatusmanifest(s)
127 128 mf1 = other._buildstatusmanifest(s)
128 129 if mf2 is None:
129 130 mf2 = self._buildstatusmanifest(s)
130 131
131 132 modified, added = [], []
132 133 removed = []
133 134 clean = []
134 135 deleted, unknown, ignored = s.deleted, s.unknown, s.ignored
135 136 deletedset = set(deleted)
136 137 d = mf1.diff(mf2, match=match, clean=listclean)
137 138 for fn, value in d.iteritems():
138 139 if fn in deletedset:
139 140 continue
140 141 if value is None:
141 142 clean.append(fn)
142 143 continue
143 144 (node1, flag1), (node2, flag2) = value
144 145 if node1 is None:
145 146 added.append(fn)
146 147 elif node2 is None:
147 148 removed.append(fn)
148 149 elif flag1 != flag2:
149 150 modified.append(fn)
150 151 elif node2 not in wdirnodes:
151 152 # When comparing files between two commits, we save time by
152 153 # not comparing the file contents when the nodeids differ.
153 154 # Note that this means we incorrectly report a reverted change
154 155 # to a file as a modification.
155 156 modified.append(fn)
156 157 elif self[fn].cmp(other[fn]):
157 158 modified.append(fn)
158 159 else:
159 160 clean.append(fn)
160 161
161 162 if removed:
162 163 # need to filter files if they are already reported as removed
163 164 unknown = [fn for fn in unknown if fn not in mf1 and
164 165 (not match or match(fn))]
165 166 ignored = [fn for fn in ignored if fn not in mf1 and
166 167 (not match or match(fn))]
167 168 # if they're deleted, don't report them as removed
168 169 removed = [fn for fn in removed if fn not in deletedset]
169 170
170 171 return scmutil.status(modified, added, removed, deleted, unknown,
171 172 ignored, clean)
172 173
173 174 @propertycache
174 175 def substate(self):
175 176 return subrepo.state(self, self._repo.ui)
176 177
177 178 def subrev(self, subpath):
178 179 return self.substate[subpath][1]
179 180
180 181 def rev(self):
181 182 return self._rev
182 183 def node(self):
183 184 return self._node
184 185 def hex(self):
185 186 return hex(self.node())
186 187 def manifest(self):
187 188 return self._manifest
188 189 def manifestctx(self):
189 190 return self._manifestctx
190 191 def repo(self):
191 192 return self._repo
192 193 def phasestr(self):
193 194 return phases.phasenames[self.phase()]
194 195 def mutable(self):
195 196 return self.phase() > phases.public
196 197
197 198 def getfileset(self, expr):
198 199 return fileset.getfileset(self, expr)
199 200
200 201 def obsolete(self):
201 202 """True if the changeset is obsolete"""
202 203 return self.rev() in obsmod.getrevs(self._repo, 'obsolete')
203 204
204 205 def extinct(self):
205 206 """True if the changeset is extinct"""
206 207 return self.rev() in obsmod.getrevs(self._repo, 'extinct')
207 208
208 209 def unstable(self):
209 210 msg = ("'context.unstable' is deprecated, "
210 211 "use 'context.orphan'")
211 212 self._repo.ui.deprecwarn(msg, '4.4')
212 213 return self.orphan()
213 214
214 215 def orphan(self):
215 216 """True if the changeset is not obsolete but it's ancestor are"""
216 217 return self.rev() in obsmod.getrevs(self._repo, 'orphan')
217 218
218 219 def bumped(self):
219 220 msg = ("'context.bumped' is deprecated, "
220 221 "use 'context.phasedivergent'")
221 222 self._repo.ui.deprecwarn(msg, '4.4')
222 223 return self.phasedivergent()
223 224
224 225 def phasedivergent(self):
225 226 """True if the changeset try to be a successor of a public changeset
226 227
227 228 Only non-public and non-obsolete changesets may be bumped.
228 229 """
229 230 return self.rev() in obsmod.getrevs(self._repo, 'phasedivergent')
230 231
231 232 def divergent(self):
232 233 msg = ("'context.divergent' is deprecated, "
233 234 "use 'context.contentdivergent'")
234 235 self._repo.ui.deprecwarn(msg, '4.4')
235 236 return self.contentdivergent()
236 237
237 238 def contentdivergent(self):
238 239 """Is a successors of a changeset with multiple possible successors set
239 240
240 241 Only non-public and non-obsolete changesets may be divergent.
241 242 """
242 243 return self.rev() in obsmod.getrevs(self._repo, 'contentdivergent')
243 244
244 245 def troubled(self):
245 246 msg = ("'context.troubled' is deprecated, "
246 247 "use 'context.isunstable'")
247 248 self._repo.ui.deprecwarn(msg, '4.4')
248 249 return self.isunstable()
249 250
250 251 def isunstable(self):
251 252 """True if the changeset is either unstable, bumped or divergent"""
252 253 return self.orphan() or self.phasedivergent() or self.contentdivergent()
253 254
254 255 def troubles(self):
255 256 """Keep the old version around in order to avoid breaking extensions
256 257 about different return values.
257 258 """
258 259 msg = ("'context.troubles' is deprecated, "
259 260 "use 'context.instabilities'")
260 261 self._repo.ui.deprecwarn(msg, '4.4')
261 262
262 263 troubles = []
263 264 if self.orphan():
264 265 troubles.append('orphan')
265 266 if self.phasedivergent():
266 267 troubles.append('bumped')
267 268 if self.contentdivergent():
268 269 troubles.append('divergent')
269 270 return troubles
270 271
271 272 def instabilities(self):
272 273 """return the list of instabilities affecting this changeset.
273 274
274 275 Instabilities are returned as strings. possible values are:
275 276 - orphan,
276 277 - phase-divergent,
277 278 - content-divergent.
278 279 """
279 280 instabilities = []
280 281 if self.orphan():
281 282 instabilities.append('orphan')
282 283 if self.phasedivergent():
283 284 instabilities.append('phase-divergent')
284 285 if self.contentdivergent():
285 286 instabilities.append('content-divergent')
286 287 return instabilities
287 288
288 289 def parents(self):
289 290 """return contexts for each parent changeset"""
290 291 return self._parents
291 292
292 293 def p1(self):
293 294 return self._parents[0]
294 295
295 296 def p2(self):
296 297 parents = self._parents
297 298 if len(parents) == 2:
298 299 return parents[1]
299 300 return changectx(self._repo, nullrev)
300 301
301 302 def _fileinfo(self, path):
302 303 if r'_manifest' in self.__dict__:
303 304 try:
304 305 return self._manifest[path], self._manifest.flags(path)
305 306 except KeyError:
306 307 raise error.ManifestLookupError(self._node, path,
307 308 _('not found in manifest'))
308 309 if r'_manifestdelta' in self.__dict__ or path in self.files():
309 310 if path in self._manifestdelta:
310 311 return (self._manifestdelta[path],
311 312 self._manifestdelta.flags(path))
312 313 mfl = self._repo.manifestlog
313 314 try:
314 315 node, flag = mfl[self._changeset.manifest].find(path)
315 316 except KeyError:
316 317 raise error.ManifestLookupError(self._node, path,
317 318 _('not found in manifest'))
318 319
319 320 return node, flag
320 321
321 322 def filenode(self, path):
322 323 return self._fileinfo(path)[0]
323 324
324 325 def flags(self, path):
325 326 try:
326 327 return self._fileinfo(path)[1]
327 328 except error.LookupError:
328 329 return ''
329 330
330 331 def sub(self, path, allowcreate=True):
331 332 '''return a subrepo for the stored revision of path, never wdir()'''
332 333 return subrepo.subrepo(self, path, allowcreate=allowcreate)
333 334
334 335 def nullsub(self, path, pctx):
335 336 return subrepo.nullsubrepo(self, path, pctx)
336 337
337 338 def workingsub(self, path):
338 339 '''return a subrepo for the stored revision, or wdir if this is a wdir
339 340 context.
340 341 '''
341 342 return subrepo.subrepo(self, path, allowwdir=True)
342 343
343 344 def match(self, pats=None, include=None, exclude=None, default='glob',
344 345 listsubrepos=False, badfn=None):
345 346 r = self._repo
346 347 return matchmod.match(r.root, r.getcwd(), pats,
347 348 include, exclude, default,
348 349 auditor=r.nofsauditor, ctx=self,
349 350 listsubrepos=listsubrepos, badfn=badfn)
350 351
351 352 def diff(self, ctx2=None, match=None, **opts):
352 353 """Returns a diff generator for the given contexts and matcher"""
353 354 if ctx2 is None:
354 355 ctx2 = self.p1()
355 356 if ctx2 is not None:
356 357 ctx2 = self._repo[ctx2]
357 358 diffopts = patch.diffopts(self._repo.ui, pycompat.byteskwargs(opts))
358 359 return patch.diff(self._repo, ctx2, self, match=match, opts=diffopts)
359 360
360 361 def dirs(self):
361 362 return self._manifest.dirs()
362 363
363 364 def hasdir(self, dir):
364 365 return self._manifest.hasdir(dir)
365 366
366 367 def status(self, other=None, match=None, listignored=False,
367 368 listclean=False, listunknown=False, listsubrepos=False):
368 369 """return status of files between two nodes or node and working
369 370 directory.
370 371
371 372 If other is None, compare this node with working directory.
372 373
373 374 returns (modified, added, removed, deleted, unknown, ignored, clean)
374 375 """
375 376
376 377 ctx1 = self
377 378 ctx2 = self._repo[other]
378 379
379 380 # This next code block is, admittedly, fragile logic that tests for
380 381 # reversing the contexts and wouldn't need to exist if it weren't for
381 382 # the fast (and common) code path of comparing the working directory
382 383 # with its first parent.
383 384 #
384 385 # What we're aiming for here is the ability to call:
385 386 #
386 387 # workingctx.status(parentctx)
387 388 #
388 389 # If we always built the manifest for each context and compared those,
389 390 # then we'd be done. But the special case of the above call means we
390 391 # just copy the manifest of the parent.
391 392 reversed = False
392 393 if (not isinstance(ctx1, changectx)
393 394 and isinstance(ctx2, changectx)):
394 395 reversed = True
395 396 ctx1, ctx2 = ctx2, ctx1
396 397
397 398 match = match or matchmod.always(self._repo.root, self._repo.getcwd())
398 399 match = ctx2._matchstatus(ctx1, match)
399 400 r = scmutil.status([], [], [], [], [], [], [])
400 401 r = ctx2._buildstatus(ctx1, r, match, listignored, listclean,
401 402 listunknown)
402 403
403 404 if reversed:
404 405 # Reverse added and removed. Clear deleted, unknown and ignored as
405 406 # these make no sense to reverse.
406 407 r = scmutil.status(r.modified, r.removed, r.added, [], [], [],
407 408 r.clean)
408 409
409 410 if listsubrepos:
410 411 for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
411 412 try:
412 413 rev2 = ctx2.subrev(subpath)
413 414 except KeyError:
414 415 # A subrepo that existed in node1 was deleted between
415 416 # node1 and node2 (inclusive). Thus, ctx2's substate
416 417 # won't contain that subpath. The best we can do ignore it.
417 418 rev2 = None
418 419 submatch = matchmod.subdirmatcher(subpath, match)
419 420 s = sub.status(rev2, match=submatch, ignored=listignored,
420 421 clean=listclean, unknown=listunknown,
421 422 listsubrepos=True)
422 423 for rfiles, sfiles in zip(r, s):
423 424 rfiles.extend("%s/%s" % (subpath, f) for f in sfiles)
424 425
425 426 for l in r:
426 427 l.sort()
427 428
428 429 return r
429 430
430 431 def _filterederror(repo, changeid):
431 432 """build an exception to be raised about a filtered changeid
432 433
433 434 This is extracted in a function to help extensions (eg: evolve) to
434 435 experiment with various message variants."""
435 436 if repo.filtername.startswith('visible'):
437
438 # Check if the changeset is obsolete
439 unfilteredrepo = repo.unfiltered()
440 ctx = unfilteredrepo[changeid]
441
442 # If the changeset is obsolete, enrich the hint with the reason that
443 # made this changeset not visible
444 if ctx.obsolete():
445 reason = obsutil._getfilteredreason(unfilteredrepo, ctx)
446 msg = _("hidden revision '%s' %s") % (changeid, reason)
447 else:
436 448 msg = _("hidden revision '%s'") % changeid
449
437 450 hint = _('use --hidden to access hidden revisions')
451
438 452 return error.FilteredRepoLookupError(msg, hint=hint)
439 453 msg = _("filtered revision '%s' (not in '%s' subset)")
440 454 msg %= (changeid, repo.filtername)
441 455 return error.FilteredRepoLookupError(msg)
442 456
443 457 class changectx(basectx):
444 458 """A changecontext object makes access to data related to a particular
445 459 changeset convenient. It represents a read-only context already present in
446 460 the repo."""
447 461 def __init__(self, repo, changeid=''):
448 462 """changeid is a revision number, node, or tag"""
449 463
450 464 # since basectx.__new__ already took care of copying the object, we
451 465 # don't need to do anything in __init__, so we just exit here
452 466 if isinstance(changeid, basectx):
453 467 return
454 468
455 469 if changeid == '':
456 470 changeid = '.'
457 471 self._repo = repo
458 472
459 473 try:
460 474 if isinstance(changeid, int):
461 475 self._node = repo.changelog.node(changeid)
462 476 self._rev = changeid
463 477 return
464 478 if not pycompat.ispy3 and isinstance(changeid, long):
465 479 changeid = str(changeid)
466 480 if changeid == 'null':
467 481 self._node = nullid
468 482 self._rev = nullrev
469 483 return
470 484 if changeid == 'tip':
471 485 self._node = repo.changelog.tip()
472 486 self._rev = repo.changelog.rev(self._node)
473 487 return
474 488 if (changeid == '.'
475 489 or repo.local() and changeid == repo.dirstate.p1()):
476 490 # this is a hack to delay/avoid loading obsmarkers
477 491 # when we know that '.' won't be hidden
478 492 self._node = repo.dirstate.p1()
479 493 self._rev = repo.unfiltered().changelog.rev(self._node)
480 494 return
481 495 if len(changeid) == 20:
482 496 try:
483 497 self._node = changeid
484 498 self._rev = repo.changelog.rev(changeid)
485 499 return
486 500 except error.FilteredRepoLookupError:
487 501 raise
488 502 except LookupError:
489 503 pass
490 504
491 505 try:
492 506 r = int(changeid)
493 507 if '%d' % r != changeid:
494 508 raise ValueError
495 509 l = len(repo.changelog)
496 510 if r < 0:
497 511 r += l
498 512 if r < 0 or r >= l and r != wdirrev:
499 513 raise ValueError
500 514 self._rev = r
501 515 self._node = repo.changelog.node(r)
502 516 return
503 517 except error.FilteredIndexError:
504 518 raise
505 519 except (ValueError, OverflowError, IndexError):
506 520 pass
507 521
508 522 if len(changeid) == 40:
509 523 try:
510 524 self._node = bin(changeid)
511 525 self._rev = repo.changelog.rev(self._node)
512 526 return
513 527 except error.FilteredLookupError:
514 528 raise
515 529 except (TypeError, LookupError):
516 530 pass
517 531
518 532 # lookup bookmarks through the name interface
519 533 try:
520 534 self._node = repo.names.singlenode(repo, changeid)
521 535 self._rev = repo.changelog.rev(self._node)
522 536 return
523 537 except KeyError:
524 538 pass
525 539 except error.FilteredRepoLookupError:
526 540 raise
527 541 except error.RepoLookupError:
528 542 pass
529 543
530 544 self._node = repo.unfiltered().changelog._partialmatch(changeid)
531 545 if self._node is not None:
532 546 self._rev = repo.changelog.rev(self._node)
533 547 return
534 548
535 549 # lookup failed
536 550 # check if it might have come from damaged dirstate
537 551 #
538 552 # XXX we could avoid the unfiltered if we had a recognizable
539 553 # exception for filtered changeset access
540 554 if (repo.local()
541 555 and changeid in repo.unfiltered().dirstate.parents()):
542 556 msg = _("working directory has unknown parent '%s'!")
543 557 raise error.Abort(msg % short(changeid))
544 558 try:
545 559 if len(changeid) == 20 and nonascii(changeid):
546 560 changeid = hex(changeid)
547 561 except TypeError:
548 562 pass
549 563 except (error.FilteredIndexError, error.FilteredLookupError,
550 564 error.FilteredRepoLookupError):
551 565 raise _filterederror(repo, changeid)
552 566 except IndexError:
553 567 pass
554 568 raise error.RepoLookupError(
555 569 _("unknown revision '%s'") % changeid)
556 570
557 571 def __hash__(self):
558 572 try:
559 573 return hash(self._rev)
560 574 except AttributeError:
561 575 return id(self)
562 576
563 577 def __nonzero__(self):
564 578 return self._rev != nullrev
565 579
566 580 __bool__ = __nonzero__
567 581
568 582 @propertycache
569 583 def _changeset(self):
570 584 return self._repo.changelog.changelogrevision(self.rev())
571 585
572 586 @propertycache
573 587 def _manifest(self):
574 588 return self._manifestctx.read()
575 589
576 590 @property
577 591 def _manifestctx(self):
578 592 return self._repo.manifestlog[self._changeset.manifest]
579 593
580 594 @propertycache
581 595 def _manifestdelta(self):
582 596 return self._manifestctx.readdelta()
583 597
584 598 @propertycache
585 599 def _parents(self):
586 600 repo = self._repo
587 601 p1, p2 = repo.changelog.parentrevs(self._rev)
588 602 if p2 == nullrev:
589 603 return [changectx(repo, p1)]
590 604 return [changectx(repo, p1), changectx(repo, p2)]
591 605
592 606 def changeset(self):
593 607 c = self._changeset
594 608 return (
595 609 c.manifest,
596 610 c.user,
597 611 c.date,
598 612 c.files,
599 613 c.description,
600 614 c.extra,
601 615 )
602 616 def manifestnode(self):
603 617 return self._changeset.manifest
604 618
605 619 def user(self):
606 620 return self._changeset.user
607 621 def date(self):
608 622 return self._changeset.date
609 623 def files(self):
610 624 return self._changeset.files
611 625 def description(self):
612 626 return self._changeset.description
613 627 def branch(self):
614 628 return encoding.tolocal(self._changeset.extra.get("branch"))
615 629 def closesbranch(self):
616 630 return 'close' in self._changeset.extra
617 631 def extra(self):
618 632 """Return a dict of extra information."""
619 633 return self._changeset.extra
620 634 def tags(self):
621 635 """Return a list of byte tag names"""
622 636 return self._repo.nodetags(self._node)
623 637 def bookmarks(self):
624 638 """Return a list of byte bookmark names."""
625 639 return self._repo.nodebookmarks(self._node)
626 640 def phase(self):
627 641 return self._repo._phasecache.phase(self._repo, self._rev)
628 642 def hidden(self):
629 643 return self._rev in repoview.filterrevs(self._repo, 'visible')
630 644
631 645 def isinmemory(self):
632 646 return False
633 647
634 648 def children(self):
635 649 """return list of changectx contexts for each child changeset.
636 650
637 651 This returns only the immediate child changesets. Use descendants() to
638 652 recursively walk children.
639 653 """
640 654 c = self._repo.changelog.children(self._node)
641 655 return [changectx(self._repo, x) for x in c]
642 656
643 657 def ancestors(self):
644 658 for a in self._repo.changelog.ancestors([self._rev]):
645 659 yield changectx(self._repo, a)
646 660
647 661 def descendants(self):
648 662 """Recursively yield all children of the changeset.
649 663
650 664 For just the immediate children, use children()
651 665 """
652 666 for d in self._repo.changelog.descendants([self._rev]):
653 667 yield changectx(self._repo, d)
654 668
655 669 def filectx(self, path, fileid=None, filelog=None):
656 670 """get a file context from this changeset"""
657 671 if fileid is None:
658 672 fileid = self.filenode(path)
659 673 return filectx(self._repo, path, fileid=fileid,
660 674 changectx=self, filelog=filelog)
661 675
662 676 def ancestor(self, c2, warn=False):
663 677 """return the "best" ancestor context of self and c2
664 678
665 679 If there are multiple candidates, it will show a message and check
666 680 merge.preferancestor configuration before falling back to the
667 681 revlog ancestor."""
668 682 # deal with workingctxs
669 683 n2 = c2._node
670 684 if n2 is None:
671 685 n2 = c2._parents[0]._node
672 686 cahs = self._repo.changelog.commonancestorsheads(self._node, n2)
673 687 if not cahs:
674 688 anc = nullid
675 689 elif len(cahs) == 1:
676 690 anc = cahs[0]
677 691 else:
678 692 # experimental config: merge.preferancestor
679 693 for r in self._repo.ui.configlist('merge', 'preferancestor'):
680 694 try:
681 695 ctx = changectx(self._repo, r)
682 696 except error.RepoLookupError:
683 697 continue
684 698 anc = ctx.node()
685 699 if anc in cahs:
686 700 break
687 701 else:
688 702 anc = self._repo.changelog.ancestor(self._node, n2)
689 703 if warn:
690 704 self._repo.ui.status(
691 705 (_("note: using %s as ancestor of %s and %s\n") %
692 706 (short(anc), short(self._node), short(n2))) +
693 707 ''.join(_(" alternatively, use --config "
694 708 "merge.preferancestor=%s\n") %
695 709 short(n) for n in sorted(cahs) if n != anc))
696 710 return changectx(self._repo, anc)
697 711
698 712 def descendant(self, other):
699 713 """True if other is descendant of this changeset"""
700 714 return self._repo.changelog.descendant(self._rev, other._rev)
701 715
702 716 def walk(self, match):
703 717 '''Generates matching file names.'''
704 718
705 719 # Wrap match.bad method to have message with nodeid
706 720 def bad(fn, msg):
707 721 # The manifest doesn't know about subrepos, so don't complain about
708 722 # paths into valid subrepos.
709 723 if any(fn == s or fn.startswith(s + '/')
710 724 for s in self.substate):
711 725 return
712 726 match.bad(fn, _('no such file in rev %s') % self)
713 727
714 728 m = matchmod.badmatch(match, bad)
715 729 return self._manifest.walk(m)
716 730
717 731 def matches(self, match):
718 732 return self.walk(match)
719 733
720 734 class basefilectx(object):
721 735 """A filecontext object represents the common logic for its children:
722 736 filectx: read-only access to a filerevision that is already present
723 737 in the repo,
724 738 workingfilectx: a filecontext that represents files from the working
725 739 directory,
726 740 memfilectx: a filecontext that represents files in-memory,
727 741 overlayfilectx: duplicate another filecontext with some fields overridden.
728 742 """
729 743 @propertycache
730 744 def _filelog(self):
731 745 return self._repo.file(self._path)
732 746
733 747 @propertycache
734 748 def _changeid(self):
735 749 if r'_changeid' in self.__dict__:
736 750 return self._changeid
737 751 elif r'_changectx' in self.__dict__:
738 752 return self._changectx.rev()
739 753 elif r'_descendantrev' in self.__dict__:
740 754 # this file context was created from a revision with a known
741 755 # descendant, we can (lazily) correct for linkrev aliases
742 756 return self._adjustlinkrev(self._descendantrev)
743 757 else:
744 758 return self._filelog.linkrev(self._filerev)
745 759
746 760 @propertycache
747 761 def _filenode(self):
748 762 if r'_fileid' in self.__dict__:
749 763 return self._filelog.lookup(self._fileid)
750 764 else:
751 765 return self._changectx.filenode(self._path)
752 766
753 767 @propertycache
754 768 def _filerev(self):
755 769 return self._filelog.rev(self._filenode)
756 770
757 771 @propertycache
758 772 def _repopath(self):
759 773 return self._path
760 774
761 775 def __nonzero__(self):
762 776 try:
763 777 self._filenode
764 778 return True
765 779 except error.LookupError:
766 780 # file is missing
767 781 return False
768 782
769 783 __bool__ = __nonzero__
770 784
771 785 def __bytes__(self):
772 786 try:
773 787 return "%s@%s" % (self.path(), self._changectx)
774 788 except error.LookupError:
775 789 return "%s@???" % self.path()
776 790
777 791 __str__ = encoding.strmethod(__bytes__)
778 792
779 793 def __repr__(self):
780 794 return "<%s %s>" % (type(self).__name__, str(self))
781 795
782 796 def __hash__(self):
783 797 try:
784 798 return hash((self._path, self._filenode))
785 799 except AttributeError:
786 800 return id(self)
787 801
788 802 def __eq__(self, other):
789 803 try:
790 804 return (type(self) == type(other) and self._path == other._path
791 805 and self._filenode == other._filenode)
792 806 except AttributeError:
793 807 return False
794 808
795 809 def __ne__(self, other):
796 810 return not (self == other)
797 811
798 812 def filerev(self):
799 813 return self._filerev
800 814 def filenode(self):
801 815 return self._filenode
802 816 @propertycache
803 817 def _flags(self):
804 818 return self._changectx.flags(self._path)
805 819 def flags(self):
806 820 return self._flags
807 821 def filelog(self):
808 822 return self._filelog
809 823 def rev(self):
810 824 return self._changeid
811 825 def linkrev(self):
812 826 return self._filelog.linkrev(self._filerev)
813 827 def node(self):
814 828 return self._changectx.node()
815 829 def hex(self):
816 830 return self._changectx.hex()
817 831 def user(self):
818 832 return self._changectx.user()
819 833 def date(self):
820 834 return self._changectx.date()
821 835 def files(self):
822 836 return self._changectx.files()
823 837 def description(self):
824 838 return self._changectx.description()
825 839 def branch(self):
826 840 return self._changectx.branch()
827 841 def extra(self):
828 842 return self._changectx.extra()
829 843 def phase(self):
830 844 return self._changectx.phase()
831 845 def phasestr(self):
832 846 return self._changectx.phasestr()
833 847 def obsolete(self):
834 848 return self._changectx.obsolete()
835 849 def instabilities(self):
836 850 return self._changectx.instabilities()
837 851 def manifest(self):
838 852 return self._changectx.manifest()
839 853 def changectx(self):
840 854 return self._changectx
841 855 def renamed(self):
842 856 return self._copied
843 857 def repo(self):
844 858 return self._repo
845 859 def size(self):
846 860 return len(self.data())
847 861
848 862 def path(self):
849 863 return self._path
850 864
851 865 def isbinary(self):
852 866 try:
853 867 return util.binary(self.data())
854 868 except IOError:
855 869 return False
856 870 def isexec(self):
857 871 return 'x' in self.flags()
858 872 def islink(self):
859 873 return 'l' in self.flags()
860 874
861 875 def isabsent(self):
862 876 """whether this filectx represents a file not in self._changectx
863 877
864 878 This is mainly for merge code to detect change/delete conflicts. This is
865 879 expected to be True for all subclasses of basectx."""
866 880 return False
867 881
868 882 _customcmp = False
869 883 def cmp(self, fctx):
870 884 """compare with other file context
871 885
872 886 returns True if different than fctx.
873 887 """
874 888 if fctx._customcmp:
875 889 return fctx.cmp(self)
876 890
877 891 if (fctx._filenode is None
878 892 and (self._repo._encodefilterpats
879 893 # if file data starts with '\1\n', empty metadata block is
880 894 # prepended, which adds 4 bytes to filelog.size().
881 895 or self.size() - 4 == fctx.size())
882 896 or self.size() == fctx.size()):
883 897 return self._filelog.cmp(self._filenode, fctx.data())
884 898
885 899 return True
886 900
887 901 def _adjustlinkrev(self, srcrev, inclusive=False):
888 902 """return the first ancestor of <srcrev> introducing <fnode>
889 903
890 904 If the linkrev of the file revision does not point to an ancestor of
891 905 srcrev, we'll walk down the ancestors until we find one introducing
892 906 this file revision.
893 907
894 908 :srcrev: the changeset revision we search ancestors from
895 909 :inclusive: if true, the src revision will also be checked
896 910 """
897 911 repo = self._repo
898 912 cl = repo.unfiltered().changelog
899 913 mfl = repo.manifestlog
900 914 # fetch the linkrev
901 915 lkr = self.linkrev()
902 916 # hack to reuse ancestor computation when searching for renames
903 917 memberanc = getattr(self, '_ancestrycontext', None)
904 918 iteranc = None
905 919 if srcrev is None:
906 920 # wctx case, used by workingfilectx during mergecopy
907 921 revs = [p.rev() for p in self._repo[None].parents()]
908 922 inclusive = True # we skipped the real (revless) source
909 923 else:
910 924 revs = [srcrev]
911 925 if memberanc is None:
912 926 memberanc = iteranc = cl.ancestors(revs, lkr,
913 927 inclusive=inclusive)
914 928 # check if this linkrev is an ancestor of srcrev
915 929 if lkr not in memberanc:
916 930 if iteranc is None:
917 931 iteranc = cl.ancestors(revs, lkr, inclusive=inclusive)
918 932 fnode = self._filenode
919 933 path = self._path
920 934 for a in iteranc:
921 935 ac = cl.read(a) # get changeset data (we avoid object creation)
922 936 if path in ac[3]: # checking the 'files' field.
923 937 # The file has been touched, check if the content is
924 938 # similar to the one we search for.
925 939 if fnode == mfl[ac[0]].readfast().get(path):
926 940 return a
927 941 # In theory, we should never get out of that loop without a result.
928 942 # But if manifest uses a buggy file revision (not children of the
929 943 # one it replaces) we could. Such a buggy situation will likely
930 944 # result is crash somewhere else at to some point.
931 945 return lkr
932 946
933 947 def introrev(self):
934 948 """return the rev of the changeset which introduced this file revision
935 949
936 950 This method is different from linkrev because it take into account the
937 951 changeset the filectx was created from. It ensures the returned
938 952 revision is one of its ancestors. This prevents bugs from
939 953 'linkrev-shadowing' when a file revision is used by multiple
940 954 changesets.
941 955 """
942 956 lkr = self.linkrev()
943 957 attrs = vars(self)
944 958 noctx = not ('_changeid' in attrs or '_changectx' in attrs)
945 959 if noctx or self.rev() == lkr:
946 960 return self.linkrev()
947 961 return self._adjustlinkrev(self.rev(), inclusive=True)
948 962
949 963 def introfilectx(self):
950 964 """Return filectx having identical contents, but pointing to the
951 965 changeset revision where this filectx was introduced"""
952 966 introrev = self.introrev()
953 967 if self.rev() == introrev:
954 968 return self
955 969 return self.filectx(self.filenode(), changeid=introrev)
956 970
957 971 def _parentfilectx(self, path, fileid, filelog):
958 972 """create parent filectx keeping ancestry info for _adjustlinkrev()"""
959 973 fctx = filectx(self._repo, path, fileid=fileid, filelog=filelog)
960 974 if '_changeid' in vars(self) or '_changectx' in vars(self):
961 975 # If self is associated with a changeset (probably explicitly
962 976 # fed), ensure the created filectx is associated with a
963 977 # changeset that is an ancestor of self.changectx.
964 978 # This lets us later use _adjustlinkrev to get a correct link.
965 979 fctx._descendantrev = self.rev()
966 980 fctx._ancestrycontext = getattr(self, '_ancestrycontext', None)
967 981 elif '_descendantrev' in vars(self):
968 982 # Otherwise propagate _descendantrev if we have one associated.
969 983 fctx._descendantrev = self._descendantrev
970 984 fctx._ancestrycontext = getattr(self, '_ancestrycontext', None)
971 985 return fctx
972 986
973 987 def parents(self):
974 988 _path = self._path
975 989 fl = self._filelog
976 990 parents = self._filelog.parents(self._filenode)
977 991 pl = [(_path, node, fl) for node in parents if node != nullid]
978 992
979 993 r = fl.renamed(self._filenode)
980 994 if r:
981 995 # - In the simple rename case, both parent are nullid, pl is empty.
982 996 # - In case of merge, only one of the parent is null id and should
983 997 # be replaced with the rename information. This parent is -always-
984 998 # the first one.
985 999 #
986 1000 # As null id have always been filtered out in the previous list
987 1001 # comprehension, inserting to 0 will always result in "replacing
988 1002 # first nullid parent with rename information.
989 1003 pl.insert(0, (r[0], r[1], self._repo.file(r[0])))
990 1004
991 1005 return [self._parentfilectx(path, fnode, l) for path, fnode, l in pl]
992 1006
993 1007 def p1(self):
994 1008 return self.parents()[0]
995 1009
996 1010 def p2(self):
997 1011 p = self.parents()
998 1012 if len(p) == 2:
999 1013 return p[1]
1000 1014 return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog)
1001 1015
1002 1016 def annotate(self, follow=False, linenumber=False, skiprevs=None,
1003 1017 diffopts=None):
1004 1018 '''returns a list of tuples of ((ctx, number), line) for each line
1005 1019 in the file, where ctx is the filectx of the node where
1006 1020 that line was last changed; if linenumber parameter is true, number is
1007 1021 the line number at the first appearance in the managed file, otherwise,
1008 1022 number has a fixed value of False.
1009 1023 '''
1010 1024
1011 1025 def lines(text):
1012 1026 if text.endswith("\n"):
1013 1027 return text.count("\n")
1014 1028 return text.count("\n") + int(bool(text))
1015 1029
1016 1030 if linenumber:
1017 1031 def decorate(text, rev):
1018 1032 return ([annotateline(fctx=rev, lineno=i)
1019 1033 for i in xrange(1, lines(text) + 1)], text)
1020 1034 else:
1021 1035 def decorate(text, rev):
1022 1036 return ([annotateline(fctx=rev)] * lines(text), text)
1023 1037
1024 1038 getlog = util.lrucachefunc(lambda x: self._repo.file(x))
1025 1039
1026 1040 def parents(f):
1027 1041 # Cut _descendantrev here to mitigate the penalty of lazy linkrev
1028 1042 # adjustment. Otherwise, p._adjustlinkrev() would walk changelog
1029 1043 # from the topmost introrev (= srcrev) down to p.linkrev() if it
1030 1044 # isn't an ancestor of the srcrev.
1031 1045 f._changeid
1032 1046 pl = f.parents()
1033 1047
1034 1048 # Don't return renamed parents if we aren't following.
1035 1049 if not follow:
1036 1050 pl = [p for p in pl if p.path() == f.path()]
1037 1051
1038 1052 # renamed filectx won't have a filelog yet, so set it
1039 1053 # from the cache to save time
1040 1054 for p in pl:
1041 1055 if not '_filelog' in p.__dict__:
1042 1056 p._filelog = getlog(p.path())
1043 1057
1044 1058 return pl
1045 1059
1046 1060 # use linkrev to find the first changeset where self appeared
1047 1061 base = self.introfilectx()
1048 1062 if getattr(base, '_ancestrycontext', None) is None:
1049 1063 cl = self._repo.changelog
1050 1064 if base.rev() is None:
1051 1065 # wctx is not inclusive, but works because _ancestrycontext
1052 1066 # is used to test filelog revisions
1053 1067 ac = cl.ancestors([p.rev() for p in base.parents()],
1054 1068 inclusive=True)
1055 1069 else:
1056 1070 ac = cl.ancestors([base.rev()], inclusive=True)
1057 1071 base._ancestrycontext = ac
1058 1072
1059 1073 # This algorithm would prefer to be recursive, but Python is a
1060 1074 # bit recursion-hostile. Instead we do an iterative
1061 1075 # depth-first search.
1062 1076
1063 1077 # 1st DFS pre-calculates pcache and needed
1064 1078 visit = [base]
1065 1079 pcache = {}
1066 1080 needed = {base: 1}
1067 1081 while visit:
1068 1082 f = visit.pop()
1069 1083 if f in pcache:
1070 1084 continue
1071 1085 pl = parents(f)
1072 1086 pcache[f] = pl
1073 1087 for p in pl:
1074 1088 needed[p] = needed.get(p, 0) + 1
1075 1089 if p not in pcache:
1076 1090 visit.append(p)
1077 1091
1078 1092 # 2nd DFS does the actual annotate
1079 1093 visit[:] = [base]
1080 1094 hist = {}
1081 1095 while visit:
1082 1096 f = visit[-1]
1083 1097 if f in hist:
1084 1098 visit.pop()
1085 1099 continue
1086 1100
1087 1101 ready = True
1088 1102 pl = pcache[f]
1089 1103 for p in pl:
1090 1104 if p not in hist:
1091 1105 ready = False
1092 1106 visit.append(p)
1093 1107 if ready:
1094 1108 visit.pop()
1095 1109 curr = decorate(f.data(), f)
1096 1110 skipchild = False
1097 1111 if skiprevs is not None:
1098 1112 skipchild = f._changeid in skiprevs
1099 1113 curr = _annotatepair([hist[p] for p in pl], f, curr, skipchild,
1100 1114 diffopts)
1101 1115 for p in pl:
1102 1116 if needed[p] == 1:
1103 1117 del hist[p]
1104 1118 del needed[p]
1105 1119 else:
1106 1120 needed[p] -= 1
1107 1121
1108 1122 hist[f] = curr
1109 1123 del pcache[f]
1110 1124
1111 1125 return zip(hist[base][0], hist[base][1].splitlines(True))
1112 1126
1113 1127 def ancestors(self, followfirst=False):
1114 1128 visit = {}
1115 1129 c = self
1116 1130 if followfirst:
1117 1131 cut = 1
1118 1132 else:
1119 1133 cut = None
1120 1134
1121 1135 while True:
1122 1136 for parent in c.parents()[:cut]:
1123 1137 visit[(parent.linkrev(), parent.filenode())] = parent
1124 1138 if not visit:
1125 1139 break
1126 1140 c = visit.pop(max(visit))
1127 1141 yield c
1128 1142
1129 1143 def decodeddata(self):
1130 1144 """Returns `data()` after running repository decoding filters.
1131 1145
1132 1146 This is often equivalent to how the data would be expressed on disk.
1133 1147 """
1134 1148 return self._repo.wwritedata(self.path(), self.data())
1135 1149
1136 1150 @attr.s(slots=True, frozen=True)
1137 1151 class annotateline(object):
1138 1152 fctx = attr.ib()
1139 1153 lineno = attr.ib(default=False)
1140 1154 # Whether this annotation was the result of a skip-annotate.
1141 1155 skip = attr.ib(default=False)
1142 1156
1143 1157 def _annotatepair(parents, childfctx, child, skipchild, diffopts):
1144 1158 r'''
1145 1159 Given parent and child fctxes and annotate data for parents, for all lines
1146 1160 in either parent that match the child, annotate the child with the parent's
1147 1161 data.
1148 1162
1149 1163 Additionally, if `skipchild` is True, replace all other lines with parent
1150 1164 annotate data as well such that child is never blamed for any lines.
1151 1165
1152 1166 See test-annotate.py for unit tests.
1153 1167 '''
1154 1168 pblocks = [(parent, mdiff.allblocks(parent[1], child[1], opts=diffopts))
1155 1169 for parent in parents]
1156 1170
1157 1171 if skipchild:
1158 1172 # Need to iterate over the blocks twice -- make it a list
1159 1173 pblocks = [(p, list(blocks)) for (p, blocks) in pblocks]
1160 1174 # Mercurial currently prefers p2 over p1 for annotate.
1161 1175 # TODO: change this?
1162 1176 for parent, blocks in pblocks:
1163 1177 for (a1, a2, b1, b2), t in blocks:
1164 1178 # Changed blocks ('!') or blocks made only of blank lines ('~')
1165 1179 # belong to the child.
1166 1180 if t == '=':
1167 1181 child[0][b1:b2] = parent[0][a1:a2]
1168 1182
1169 1183 if skipchild:
1170 1184 # Now try and match up anything that couldn't be matched,
1171 1185 # Reversing pblocks maintains bias towards p2, matching above
1172 1186 # behavior.
1173 1187 pblocks.reverse()
1174 1188
1175 1189 # The heuristics are:
1176 1190 # * Work on blocks of changed lines (effectively diff hunks with -U0).
1177 1191 # This could potentially be smarter but works well enough.
1178 1192 # * For a non-matching section, do a best-effort fit. Match lines in
1179 1193 # diff hunks 1:1, dropping lines as necessary.
1180 1194 # * Repeat the last line as a last resort.
1181 1195
1182 1196 # First, replace as much as possible without repeating the last line.
1183 1197 remaining = [(parent, []) for parent, _blocks in pblocks]
1184 1198 for idx, (parent, blocks) in enumerate(pblocks):
1185 1199 for (a1, a2, b1, b2), _t in blocks:
1186 1200 if a2 - a1 >= b2 - b1:
1187 1201 for bk in xrange(b1, b2):
1188 1202 if child[0][bk].fctx == childfctx:
1189 1203 ak = min(a1 + (bk - b1), a2 - 1)
1190 1204 child[0][bk] = attr.evolve(parent[0][ak], skip=True)
1191 1205 else:
1192 1206 remaining[idx][1].append((a1, a2, b1, b2))
1193 1207
1194 1208 # Then, look at anything left, which might involve repeating the last
1195 1209 # line.
1196 1210 for parent, blocks in remaining:
1197 1211 for a1, a2, b1, b2 in blocks:
1198 1212 for bk in xrange(b1, b2):
1199 1213 if child[0][bk].fctx == childfctx:
1200 1214 ak = min(a1 + (bk - b1), a2 - 1)
1201 1215 child[0][bk] = attr.evolve(parent[0][ak], skip=True)
1202 1216 return child
1203 1217
1204 1218 class filectx(basefilectx):
1205 1219 """A filecontext object makes access to data related to a particular
1206 1220 filerevision convenient."""
1207 1221 def __init__(self, repo, path, changeid=None, fileid=None,
1208 1222 filelog=None, changectx=None):
1209 1223 """changeid can be a changeset revision, node, or tag.
1210 1224 fileid can be a file revision or node."""
1211 1225 self._repo = repo
1212 1226 self._path = path
1213 1227
1214 1228 assert (changeid is not None
1215 1229 or fileid is not None
1216 1230 or changectx is not None), \
1217 1231 ("bad args: changeid=%r, fileid=%r, changectx=%r"
1218 1232 % (changeid, fileid, changectx))
1219 1233
1220 1234 if filelog is not None:
1221 1235 self._filelog = filelog
1222 1236
1223 1237 if changeid is not None:
1224 1238 self._changeid = changeid
1225 1239 if changectx is not None:
1226 1240 self._changectx = changectx
1227 1241 if fileid is not None:
1228 1242 self._fileid = fileid
1229 1243
1230 1244 @propertycache
1231 1245 def _changectx(self):
1232 1246 try:
1233 1247 return changectx(self._repo, self._changeid)
1234 1248 except error.FilteredRepoLookupError:
1235 1249 # Linkrev may point to any revision in the repository. When the
1236 1250 # repository is filtered this may lead to `filectx` trying to build
1237 1251 # `changectx` for filtered revision. In such case we fallback to
1238 1252 # creating `changectx` on the unfiltered version of the reposition.
1239 1253 # This fallback should not be an issue because `changectx` from
1240 1254 # `filectx` are not used in complex operations that care about
1241 1255 # filtering.
1242 1256 #
1243 1257 # This fallback is a cheap and dirty fix that prevent several
1244 1258 # crashes. It does not ensure the behavior is correct. However the
1245 1259 # behavior was not correct before filtering either and "incorrect
1246 1260 # behavior" is seen as better as "crash"
1247 1261 #
1248 1262 # Linkrevs have several serious troubles with filtering that are
1249 1263 # complicated to solve. Proper handling of the issue here should be
1250 1264 # considered when solving linkrev issue are on the table.
1251 1265 return changectx(self._repo.unfiltered(), self._changeid)
1252 1266
1253 1267 def filectx(self, fileid, changeid=None):
1254 1268 '''opens an arbitrary revision of the file without
1255 1269 opening a new filelog'''
1256 1270 return filectx(self._repo, self._path, fileid=fileid,
1257 1271 filelog=self._filelog, changeid=changeid)
1258 1272
1259 1273 def rawdata(self):
1260 1274 return self._filelog.revision(self._filenode, raw=True)
1261 1275
1262 1276 def rawflags(self):
1263 1277 """low-level revlog flags"""
1264 1278 return self._filelog.flags(self._filerev)
1265 1279
1266 1280 def data(self):
1267 1281 try:
1268 1282 return self._filelog.read(self._filenode)
1269 1283 except error.CensoredNodeError:
1270 1284 if self._repo.ui.config("censor", "policy") == "ignore":
1271 1285 return ""
1272 1286 raise error.Abort(_("censored node: %s") % short(self._filenode),
1273 1287 hint=_("set censor.policy to ignore errors"))
1274 1288
1275 1289 def size(self):
1276 1290 return self._filelog.size(self._filerev)
1277 1291
1278 1292 @propertycache
1279 1293 def _copied(self):
1280 1294 """check if file was actually renamed in this changeset revision
1281 1295
1282 1296 If rename logged in file revision, we report copy for changeset only
1283 1297 if file revisions linkrev points back to the changeset in question
1284 1298 or both changeset parents contain different file revisions.
1285 1299 """
1286 1300
1287 1301 renamed = self._filelog.renamed(self._filenode)
1288 1302 if not renamed:
1289 1303 return renamed
1290 1304
1291 1305 if self.rev() == self.linkrev():
1292 1306 return renamed
1293 1307
1294 1308 name = self.path()
1295 1309 fnode = self._filenode
1296 1310 for p in self._changectx.parents():
1297 1311 try:
1298 1312 if fnode == p.filenode(name):
1299 1313 return None
1300 1314 except error.LookupError:
1301 1315 pass
1302 1316 return renamed
1303 1317
1304 1318 def children(self):
1305 1319 # hard for renames
1306 1320 c = self._filelog.children(self._filenode)
1307 1321 return [filectx(self._repo, self._path, fileid=x,
1308 1322 filelog=self._filelog) for x in c]
1309 1323
1310 1324 class committablectx(basectx):
1311 1325 """A committablectx object provides common functionality for a context that
1312 1326 wants the ability to commit, e.g. workingctx or memctx."""
1313 1327 def __init__(self, repo, text="", user=None, date=None, extra=None,
1314 1328 changes=None):
1315 1329 self._repo = repo
1316 1330 self._rev = None
1317 1331 self._node = None
1318 1332 self._text = text
1319 1333 if date:
1320 1334 self._date = util.parsedate(date)
1321 1335 if user:
1322 1336 self._user = user
1323 1337 if changes:
1324 1338 self._status = changes
1325 1339
1326 1340 self._extra = {}
1327 1341 if extra:
1328 1342 self._extra = extra.copy()
1329 1343 if 'branch' not in self._extra:
1330 1344 try:
1331 1345 branch = encoding.fromlocal(self._repo.dirstate.branch())
1332 1346 except UnicodeDecodeError:
1333 1347 raise error.Abort(_('branch name not in UTF-8!'))
1334 1348 self._extra['branch'] = branch
1335 1349 if self._extra['branch'] == '':
1336 1350 self._extra['branch'] = 'default'
1337 1351
1338 1352 def __bytes__(self):
1339 1353 return bytes(self._parents[0]) + "+"
1340 1354
1341 1355 __str__ = encoding.strmethod(__bytes__)
1342 1356
1343 1357 def __nonzero__(self):
1344 1358 return True
1345 1359
1346 1360 __bool__ = __nonzero__
1347 1361
1348 1362 def _buildflagfunc(self):
1349 1363 # Create a fallback function for getting file flags when the
1350 1364 # filesystem doesn't support them
1351 1365
1352 1366 copiesget = self._repo.dirstate.copies().get
1353 1367 parents = self.parents()
1354 1368 if len(parents) < 2:
1355 1369 # when we have one parent, it's easy: copy from parent
1356 1370 man = parents[0].manifest()
1357 1371 def func(f):
1358 1372 f = copiesget(f, f)
1359 1373 return man.flags(f)
1360 1374 else:
1361 1375 # merges are tricky: we try to reconstruct the unstored
1362 1376 # result from the merge (issue1802)
1363 1377 p1, p2 = parents
1364 1378 pa = p1.ancestor(p2)
1365 1379 m1, m2, ma = p1.manifest(), p2.manifest(), pa.manifest()
1366 1380
1367 1381 def func(f):
1368 1382 f = copiesget(f, f) # may be wrong for merges with copies
1369 1383 fl1, fl2, fla = m1.flags(f), m2.flags(f), ma.flags(f)
1370 1384 if fl1 == fl2:
1371 1385 return fl1
1372 1386 if fl1 == fla:
1373 1387 return fl2
1374 1388 if fl2 == fla:
1375 1389 return fl1
1376 1390 return '' # punt for conflicts
1377 1391
1378 1392 return func
1379 1393
1380 1394 @propertycache
1381 1395 def _flagfunc(self):
1382 1396 return self._repo.dirstate.flagfunc(self._buildflagfunc)
1383 1397
1384 1398 @propertycache
1385 1399 def _status(self):
1386 1400 return self._repo.status()
1387 1401
1388 1402 @propertycache
1389 1403 def _user(self):
1390 1404 return self._repo.ui.username()
1391 1405
1392 1406 @propertycache
1393 1407 def _date(self):
1394 1408 ui = self._repo.ui
1395 1409 date = ui.configdate('devel', 'default-date')
1396 1410 if date is None:
1397 1411 date = util.makedate()
1398 1412 return date
1399 1413
1400 1414 def subrev(self, subpath):
1401 1415 return None
1402 1416
1403 1417 def manifestnode(self):
1404 1418 return None
1405 1419 def user(self):
1406 1420 return self._user or self._repo.ui.username()
1407 1421 def date(self):
1408 1422 return self._date
1409 1423 def description(self):
1410 1424 return self._text
1411 1425 def files(self):
1412 1426 return sorted(self._status.modified + self._status.added +
1413 1427 self._status.removed)
1414 1428
1415 1429 def modified(self):
1416 1430 return self._status.modified
1417 1431 def added(self):
1418 1432 return self._status.added
1419 1433 def removed(self):
1420 1434 return self._status.removed
1421 1435 def deleted(self):
1422 1436 return self._status.deleted
1423 1437 def branch(self):
1424 1438 return encoding.tolocal(self._extra['branch'])
1425 1439 def closesbranch(self):
1426 1440 return 'close' in self._extra
1427 1441 def extra(self):
1428 1442 return self._extra
1429 1443
1430 1444 def isinmemory(self):
1431 1445 return False
1432 1446
1433 1447 def tags(self):
1434 1448 return []
1435 1449
1436 1450 def bookmarks(self):
1437 1451 b = []
1438 1452 for p in self.parents():
1439 1453 b.extend(p.bookmarks())
1440 1454 return b
1441 1455
1442 1456 def phase(self):
1443 1457 phase = phases.draft # default phase to draft
1444 1458 for p in self.parents():
1445 1459 phase = max(phase, p.phase())
1446 1460 return phase
1447 1461
1448 1462 def hidden(self):
1449 1463 return False
1450 1464
1451 1465 def children(self):
1452 1466 return []
1453 1467
1454 1468 def flags(self, path):
1455 1469 if r'_manifest' in self.__dict__:
1456 1470 try:
1457 1471 return self._manifest.flags(path)
1458 1472 except KeyError:
1459 1473 return ''
1460 1474
1461 1475 try:
1462 1476 return self._flagfunc(path)
1463 1477 except OSError:
1464 1478 return ''
1465 1479
1466 1480 def ancestor(self, c2):
1467 1481 """return the "best" ancestor context of self and c2"""
1468 1482 return self._parents[0].ancestor(c2) # punt on two parents for now
1469 1483
1470 1484 def walk(self, match):
1471 1485 '''Generates matching file names.'''
1472 1486 return sorted(self._repo.dirstate.walk(match,
1473 1487 subrepos=sorted(self.substate),
1474 1488 unknown=True, ignored=False))
1475 1489
1476 1490 def matches(self, match):
1477 1491 return sorted(self._repo.dirstate.matches(match))
1478 1492
1479 1493 def ancestors(self):
1480 1494 for p in self._parents:
1481 1495 yield p
1482 1496 for a in self._repo.changelog.ancestors(
1483 1497 [p.rev() for p in self._parents]):
1484 1498 yield changectx(self._repo, a)
1485 1499
1486 1500 def markcommitted(self, node):
1487 1501 """Perform post-commit cleanup necessary after committing this ctx
1488 1502
1489 1503 Specifically, this updates backing stores this working context
1490 1504 wraps to reflect the fact that the changes reflected by this
1491 1505 workingctx have been committed. For example, it marks
1492 1506 modified and added files as normal in the dirstate.
1493 1507
1494 1508 """
1495 1509
1496 1510 with self._repo.dirstate.parentchange():
1497 1511 for f in self.modified() + self.added():
1498 1512 self._repo.dirstate.normal(f)
1499 1513 for f in self.removed():
1500 1514 self._repo.dirstate.drop(f)
1501 1515 self._repo.dirstate.setparents(node)
1502 1516
1503 1517 # write changes out explicitly, because nesting wlock at
1504 1518 # runtime may prevent 'wlock.release()' in 'repo.commit()'
1505 1519 # from immediately doing so for subsequent changing files
1506 1520 self._repo.dirstate.write(self._repo.currenttransaction())
1507 1521
1508 1522 def dirty(self, missing=False, merge=True, branch=True):
1509 1523 return False
1510 1524
1511 1525 class workingctx(committablectx):
1512 1526 """A workingctx object makes access to data related to
1513 1527 the current working directory convenient.
1514 1528 date - any valid date string or (unixtime, offset), or None.
1515 1529 user - username string, or None.
1516 1530 extra - a dictionary of extra values, or None.
1517 1531 changes - a list of file lists as returned by localrepo.status()
1518 1532 or None to use the repository status.
1519 1533 """
1520 1534 def __init__(self, repo, text="", user=None, date=None, extra=None,
1521 1535 changes=None):
1522 1536 super(workingctx, self).__init__(repo, text, user, date, extra, changes)
1523 1537
1524 1538 def __iter__(self):
1525 1539 d = self._repo.dirstate
1526 1540 for f in d:
1527 1541 if d[f] != 'r':
1528 1542 yield f
1529 1543
1530 1544 def __contains__(self, key):
1531 1545 return self._repo.dirstate[key] not in "?r"
1532 1546
1533 1547 def hex(self):
1534 1548 return hex(wdirid)
1535 1549
1536 1550 @propertycache
1537 1551 def _parents(self):
1538 1552 p = self._repo.dirstate.parents()
1539 1553 if p[1] == nullid:
1540 1554 p = p[:-1]
1541 1555 return [changectx(self._repo, x) for x in p]
1542 1556
1543 1557 def filectx(self, path, filelog=None):
1544 1558 """get a file context from the working directory"""
1545 1559 return workingfilectx(self._repo, path, workingctx=self,
1546 1560 filelog=filelog)
1547 1561
1548 1562 def dirty(self, missing=False, merge=True, branch=True):
1549 1563 "check whether a working directory is modified"
1550 1564 # check subrepos first
1551 1565 for s in sorted(self.substate):
1552 1566 if self.sub(s).dirty(missing=missing):
1553 1567 return True
1554 1568 # check current working dir
1555 1569 return ((merge and self.p2()) or
1556 1570 (branch and self.branch() != self.p1().branch()) or
1557 1571 self.modified() or self.added() or self.removed() or
1558 1572 (missing and self.deleted()))
1559 1573
1560 1574 def add(self, list, prefix=""):
1561 1575 with self._repo.wlock():
1562 1576 ui, ds = self._repo.ui, self._repo.dirstate
1563 1577 uipath = lambda f: ds.pathto(pathutil.join(prefix, f))
1564 1578 rejected = []
1565 1579 lstat = self._repo.wvfs.lstat
1566 1580 for f in list:
1567 1581 # ds.pathto() returns an absolute file when this is invoked from
1568 1582 # the keyword extension. That gets flagged as non-portable on
1569 1583 # Windows, since it contains the drive letter and colon.
1570 1584 scmutil.checkportable(ui, os.path.join(prefix, f))
1571 1585 try:
1572 1586 st = lstat(f)
1573 1587 except OSError:
1574 1588 ui.warn(_("%s does not exist!\n") % uipath(f))
1575 1589 rejected.append(f)
1576 1590 continue
1577 1591 if st.st_size > 10000000:
1578 1592 ui.warn(_("%s: up to %d MB of RAM may be required "
1579 1593 "to manage this file\n"
1580 1594 "(use 'hg revert %s' to cancel the "
1581 1595 "pending addition)\n")
1582 1596 % (f, 3 * st.st_size // 1000000, uipath(f)))
1583 1597 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
1584 1598 ui.warn(_("%s not added: only files and symlinks "
1585 1599 "supported currently\n") % uipath(f))
1586 1600 rejected.append(f)
1587 1601 elif ds[f] in 'amn':
1588 1602 ui.warn(_("%s already tracked!\n") % uipath(f))
1589 1603 elif ds[f] == 'r':
1590 1604 ds.normallookup(f)
1591 1605 else:
1592 1606 ds.add(f)
1593 1607 return rejected
1594 1608
1595 1609 def forget(self, files, prefix=""):
1596 1610 with self._repo.wlock():
1597 1611 ds = self._repo.dirstate
1598 1612 uipath = lambda f: ds.pathto(pathutil.join(prefix, f))
1599 1613 rejected = []
1600 1614 for f in files:
1601 1615 if f not in self._repo.dirstate:
1602 1616 self._repo.ui.warn(_("%s not tracked!\n") % uipath(f))
1603 1617 rejected.append(f)
1604 1618 elif self._repo.dirstate[f] != 'a':
1605 1619 self._repo.dirstate.remove(f)
1606 1620 else:
1607 1621 self._repo.dirstate.drop(f)
1608 1622 return rejected
1609 1623
1610 1624 def undelete(self, list):
1611 1625 pctxs = self.parents()
1612 1626 with self._repo.wlock():
1613 1627 ds = self._repo.dirstate
1614 1628 for f in list:
1615 1629 if self._repo.dirstate[f] != 'r':
1616 1630 self._repo.ui.warn(_("%s not removed!\n") % ds.pathto(f))
1617 1631 else:
1618 1632 fctx = f in pctxs[0] and pctxs[0][f] or pctxs[1][f]
1619 1633 t = fctx.data()
1620 1634 self._repo.wwrite(f, t, fctx.flags())
1621 1635 self._repo.dirstate.normal(f)
1622 1636
1623 1637 def copy(self, source, dest):
1624 1638 try:
1625 1639 st = self._repo.wvfs.lstat(dest)
1626 1640 except OSError as err:
1627 1641 if err.errno != errno.ENOENT:
1628 1642 raise
1629 1643 self._repo.ui.warn(_("%s does not exist!\n")
1630 1644 % self._repo.dirstate.pathto(dest))
1631 1645 return
1632 1646 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
1633 1647 self._repo.ui.warn(_("copy failed: %s is not a file or a "
1634 1648 "symbolic link\n")
1635 1649 % self._repo.dirstate.pathto(dest))
1636 1650 else:
1637 1651 with self._repo.wlock():
1638 1652 if self._repo.dirstate[dest] in '?':
1639 1653 self._repo.dirstate.add(dest)
1640 1654 elif self._repo.dirstate[dest] in 'r':
1641 1655 self._repo.dirstate.normallookup(dest)
1642 1656 self._repo.dirstate.copy(source, dest)
1643 1657
1644 1658 def match(self, pats=None, include=None, exclude=None, default='glob',
1645 1659 listsubrepos=False, badfn=None):
1646 1660 r = self._repo
1647 1661
1648 1662 # Only a case insensitive filesystem needs magic to translate user input
1649 1663 # to actual case in the filesystem.
1650 1664 icasefs = not util.fscasesensitive(r.root)
1651 1665 return matchmod.match(r.root, r.getcwd(), pats, include, exclude,
1652 1666 default, auditor=r.auditor, ctx=self,
1653 1667 listsubrepos=listsubrepos, badfn=badfn,
1654 1668 icasefs=icasefs)
1655 1669
1656 1670 def _filtersuspectsymlink(self, files):
1657 1671 if not files or self._repo.dirstate._checklink:
1658 1672 return files
1659 1673
1660 1674 # Symlink placeholders may get non-symlink-like contents
1661 1675 # via user error or dereferencing by NFS or Samba servers,
1662 1676 # so we filter out any placeholders that don't look like a
1663 1677 # symlink
1664 1678 sane = []
1665 1679 for f in files:
1666 1680 if self.flags(f) == 'l':
1667 1681 d = self[f].data()
1668 1682 if d == '' or len(d) >= 1024 or '\n' in d or util.binary(d):
1669 1683 self._repo.ui.debug('ignoring suspect symlink placeholder'
1670 1684 ' "%s"\n' % f)
1671 1685 continue
1672 1686 sane.append(f)
1673 1687 return sane
1674 1688
1675 1689 def _checklookup(self, files):
1676 1690 # check for any possibly clean files
1677 1691 if not files:
1678 1692 return [], [], []
1679 1693
1680 1694 modified = []
1681 1695 deleted = []
1682 1696 fixup = []
1683 1697 pctx = self._parents[0]
1684 1698 # do a full compare of any files that might have changed
1685 1699 for f in sorted(files):
1686 1700 try:
1687 1701 # This will return True for a file that got replaced by a
1688 1702 # directory in the interim, but fixing that is pretty hard.
1689 1703 if (f not in pctx or self.flags(f) != pctx.flags(f)
1690 1704 or pctx[f].cmp(self[f])):
1691 1705 modified.append(f)
1692 1706 else:
1693 1707 fixup.append(f)
1694 1708 except (IOError, OSError):
1695 1709 # A file become inaccessible in between? Mark it as deleted,
1696 1710 # matching dirstate behavior (issue5584).
1697 1711 # The dirstate has more complex behavior around whether a
1698 1712 # missing file matches a directory, etc, but we don't need to
1699 1713 # bother with that: if f has made it to this point, we're sure
1700 1714 # it's in the dirstate.
1701 1715 deleted.append(f)
1702 1716
1703 1717 return modified, deleted, fixup
1704 1718
1705 1719 def _poststatusfixup(self, status, fixup):
1706 1720 """update dirstate for files that are actually clean"""
1707 1721 poststatus = self._repo.postdsstatus()
1708 1722 if fixup or poststatus:
1709 1723 try:
1710 1724 oldid = self._repo.dirstate.identity()
1711 1725
1712 1726 # updating the dirstate is optional
1713 1727 # so we don't wait on the lock
1714 1728 # wlock can invalidate the dirstate, so cache normal _after_
1715 1729 # taking the lock
1716 1730 with self._repo.wlock(False):
1717 1731 if self._repo.dirstate.identity() == oldid:
1718 1732 if fixup:
1719 1733 normal = self._repo.dirstate.normal
1720 1734 for f in fixup:
1721 1735 normal(f)
1722 1736 # write changes out explicitly, because nesting
1723 1737 # wlock at runtime may prevent 'wlock.release()'
1724 1738 # after this block from doing so for subsequent
1725 1739 # changing files
1726 1740 tr = self._repo.currenttransaction()
1727 1741 self._repo.dirstate.write(tr)
1728 1742
1729 1743 if poststatus:
1730 1744 for ps in poststatus:
1731 1745 ps(self, status)
1732 1746 else:
1733 1747 # in this case, writing changes out breaks
1734 1748 # consistency, because .hg/dirstate was
1735 1749 # already changed simultaneously after last
1736 1750 # caching (see also issue5584 for detail)
1737 1751 self._repo.ui.debug('skip updating dirstate: '
1738 1752 'identity mismatch\n')
1739 1753 except error.LockError:
1740 1754 pass
1741 1755 finally:
1742 1756 # Even if the wlock couldn't be grabbed, clear out the list.
1743 1757 self._repo.clearpostdsstatus()
1744 1758
1745 1759 def _dirstatestatus(self, match, ignored=False, clean=False, unknown=False):
1746 1760 '''Gets the status from the dirstate -- internal use only.'''
1747 1761 subrepos = []
1748 1762 if '.hgsub' in self:
1749 1763 subrepos = sorted(self.substate)
1750 1764 cmp, s = self._repo.dirstate.status(match, subrepos, ignored=ignored,
1751 1765 clean=clean, unknown=unknown)
1752 1766
1753 1767 # check for any possibly clean files
1754 1768 fixup = []
1755 1769 if cmp:
1756 1770 modified2, deleted2, fixup = self._checklookup(cmp)
1757 1771 s.modified.extend(modified2)
1758 1772 s.deleted.extend(deleted2)
1759 1773
1760 1774 if fixup and clean:
1761 1775 s.clean.extend(fixup)
1762 1776
1763 1777 self._poststatusfixup(s, fixup)
1764 1778
1765 1779 if match.always():
1766 1780 # cache for performance
1767 1781 if s.unknown or s.ignored or s.clean:
1768 1782 # "_status" is cached with list*=False in the normal route
1769 1783 self._status = scmutil.status(s.modified, s.added, s.removed,
1770 1784 s.deleted, [], [], [])
1771 1785 else:
1772 1786 self._status = s
1773 1787
1774 1788 return s
1775 1789
1776 1790 @propertycache
1777 1791 def _manifest(self):
1778 1792 """generate a manifest corresponding to the values in self._status
1779 1793
1780 1794 This reuse the file nodeid from parent, but we use special node
1781 1795 identifiers for added and modified files. This is used by manifests
1782 1796 merge to see that files are different and by update logic to avoid
1783 1797 deleting newly added files.
1784 1798 """
1785 1799 return self._buildstatusmanifest(self._status)
1786 1800
1787 1801 def _buildstatusmanifest(self, status):
1788 1802 """Builds a manifest that includes the given status results."""
1789 1803 parents = self.parents()
1790 1804
1791 1805 man = parents[0].manifest().copy()
1792 1806
1793 1807 ff = self._flagfunc
1794 1808 for i, l in ((addednodeid, status.added),
1795 1809 (modifiednodeid, status.modified)):
1796 1810 for f in l:
1797 1811 man[f] = i
1798 1812 try:
1799 1813 man.setflag(f, ff(f))
1800 1814 except OSError:
1801 1815 pass
1802 1816
1803 1817 for f in status.deleted + status.removed:
1804 1818 if f in man:
1805 1819 del man[f]
1806 1820
1807 1821 return man
1808 1822
1809 1823 def _buildstatus(self, other, s, match, listignored, listclean,
1810 1824 listunknown):
1811 1825 """build a status with respect to another context
1812 1826
1813 1827 This includes logic for maintaining the fast path of status when
1814 1828 comparing the working directory against its parent, which is to skip
1815 1829 building a new manifest if self (working directory) is not comparing
1816 1830 against its parent (repo['.']).
1817 1831 """
1818 1832 s = self._dirstatestatus(match, listignored, listclean, listunknown)
1819 1833 # Filter out symlinks that, in the case of FAT32 and NTFS filesystems,
1820 1834 # might have accidentally ended up with the entire contents of the file
1821 1835 # they are supposed to be linking to.
1822 1836 s.modified[:] = self._filtersuspectsymlink(s.modified)
1823 1837 if other != self._repo['.']:
1824 1838 s = super(workingctx, self)._buildstatus(other, s, match,
1825 1839 listignored, listclean,
1826 1840 listunknown)
1827 1841 return s
1828 1842
1829 1843 def _matchstatus(self, other, match):
1830 1844 """override the match method with a filter for directory patterns
1831 1845
1832 1846 We use inheritance to customize the match.bad method only in cases of
1833 1847 workingctx since it belongs only to the working directory when
1834 1848 comparing against the parent changeset.
1835 1849
1836 1850 If we aren't comparing against the working directory's parent, then we
1837 1851 just use the default match object sent to us.
1838 1852 """
1839 1853 if other != self._repo['.']:
1840 1854 def bad(f, msg):
1841 1855 # 'f' may be a directory pattern from 'match.files()',
1842 1856 # so 'f not in ctx1' is not enough
1843 1857 if f not in other and not other.hasdir(f):
1844 1858 self._repo.ui.warn('%s: %s\n' %
1845 1859 (self._repo.dirstate.pathto(f), msg))
1846 1860 match.bad = bad
1847 1861 return match
1848 1862
1849 1863 def markcommitted(self, node):
1850 1864 super(workingctx, self).markcommitted(node)
1851 1865
1852 1866 sparse.aftercommit(self._repo, node)
1853 1867
1854 1868 class committablefilectx(basefilectx):
1855 1869 """A committablefilectx provides common functionality for a file context
1856 1870 that wants the ability to commit, e.g. workingfilectx or memfilectx."""
1857 1871 def __init__(self, repo, path, filelog=None, ctx=None):
1858 1872 self._repo = repo
1859 1873 self._path = path
1860 1874 self._changeid = None
1861 1875 self._filerev = self._filenode = None
1862 1876
1863 1877 if filelog is not None:
1864 1878 self._filelog = filelog
1865 1879 if ctx:
1866 1880 self._changectx = ctx
1867 1881
1868 1882 def __nonzero__(self):
1869 1883 return True
1870 1884
1871 1885 __bool__ = __nonzero__
1872 1886
1873 1887 def linkrev(self):
1874 1888 # linked to self._changectx no matter if file is modified or not
1875 1889 return self.rev()
1876 1890
1877 1891 def parents(self):
1878 1892 '''return parent filectxs, following copies if necessary'''
1879 1893 def filenode(ctx, path):
1880 1894 return ctx._manifest.get(path, nullid)
1881 1895
1882 1896 path = self._path
1883 1897 fl = self._filelog
1884 1898 pcl = self._changectx._parents
1885 1899 renamed = self.renamed()
1886 1900
1887 1901 if renamed:
1888 1902 pl = [renamed + (None,)]
1889 1903 else:
1890 1904 pl = [(path, filenode(pcl[0], path), fl)]
1891 1905
1892 1906 for pc in pcl[1:]:
1893 1907 pl.append((path, filenode(pc, path), fl))
1894 1908
1895 1909 return [self._parentfilectx(p, fileid=n, filelog=l)
1896 1910 for p, n, l in pl if n != nullid]
1897 1911
1898 1912 def children(self):
1899 1913 return []
1900 1914
1901 1915 class workingfilectx(committablefilectx):
1902 1916 """A workingfilectx object makes access to data related to a particular
1903 1917 file in the working directory convenient."""
1904 1918 def __init__(self, repo, path, filelog=None, workingctx=None):
1905 1919 super(workingfilectx, self).__init__(repo, path, filelog, workingctx)
1906 1920
1907 1921 @propertycache
1908 1922 def _changectx(self):
1909 1923 return workingctx(self._repo)
1910 1924
1911 1925 def data(self):
1912 1926 return self._repo.wread(self._path)
1913 1927 def renamed(self):
1914 1928 rp = self._repo.dirstate.copied(self._path)
1915 1929 if not rp:
1916 1930 return None
1917 1931 return rp, self._changectx._parents[0]._manifest.get(rp, nullid)
1918 1932
1919 1933 def size(self):
1920 1934 return self._repo.wvfs.lstat(self._path).st_size
1921 1935 def date(self):
1922 1936 t, tz = self._changectx.date()
1923 1937 try:
1924 1938 return (self._repo.wvfs.lstat(self._path).st_mtime, tz)
1925 1939 except OSError as err:
1926 1940 if err.errno != errno.ENOENT:
1927 1941 raise
1928 1942 return (t, tz)
1929 1943
1930 1944 def exists(self):
1931 1945 return self._repo.wvfs.exists(self._path)
1932 1946
1933 1947 def lexists(self):
1934 1948 return self._repo.wvfs.lexists(self._path)
1935 1949
1936 1950 def audit(self):
1937 1951 return self._repo.wvfs.audit(self._path)
1938 1952
1939 1953 def cmp(self, fctx):
1940 1954 """compare with other file context
1941 1955
1942 1956 returns True if different than fctx.
1943 1957 """
1944 1958 # fctx should be a filectx (not a workingfilectx)
1945 1959 # invert comparison to reuse the same code path
1946 1960 return fctx.cmp(self)
1947 1961
1948 1962 def remove(self, ignoremissing=False):
1949 1963 """wraps unlink for a repo's working directory"""
1950 1964 self._repo.wvfs.unlinkpath(self._path, ignoremissing=ignoremissing)
1951 1965
1952 1966 def write(self, data, flags, backgroundclose=False):
1953 1967 """wraps repo.wwrite"""
1954 1968 self._repo.wwrite(self._path, data, flags,
1955 1969 backgroundclose=backgroundclose)
1956 1970
1957 1971 def markcopied(self, src):
1958 1972 """marks this file a copy of `src`"""
1959 1973 if self._repo.dirstate[self._path] in "nma":
1960 1974 self._repo.dirstate.copy(src, self._path)
1961 1975
1962 1976 def clearunknown(self):
1963 1977 """Removes conflicting items in the working directory so that
1964 1978 ``write()`` can be called successfully.
1965 1979 """
1966 1980 wvfs = self._repo.wvfs
1967 1981 f = self._path
1968 1982 wvfs.audit(f)
1969 1983 if wvfs.isdir(f) and not wvfs.islink(f):
1970 1984 wvfs.rmtree(f, forcibly=True)
1971 1985 for p in reversed(list(util.finddirs(f))):
1972 1986 if wvfs.isfileorlink(p):
1973 1987 wvfs.unlink(p)
1974 1988 break
1975 1989
1976 1990 def setflags(self, l, x):
1977 1991 self._repo.wvfs.setflags(self._path, l, x)
1978 1992
1979 1993 class overlayworkingctx(committablectx):
1980 1994 """Wraps another mutable context with a write-back cache that can be
1981 1995 converted into a commit context.
1982 1996
1983 1997 self._cache[path] maps to a dict with keys: {
1984 1998 'exists': bool?
1985 1999 'date': date?
1986 2000 'data': str?
1987 2001 'flags': str?
1988 2002 'copied': str? (path or None)
1989 2003 }
1990 2004 If `exists` is True, `flags` must be non-None and 'date' is non-None. If it
1991 2005 is `False`, the file was deleted.
1992 2006 """
1993 2007
1994 2008 def __init__(self, repo):
1995 2009 super(overlayworkingctx, self).__init__(repo)
1996 2010 self._repo = repo
1997 2011 self.clean()
1998 2012
1999 2013 def setbase(self, wrappedctx):
2000 2014 self._wrappedctx = wrappedctx
2001 2015 self._parents = [wrappedctx]
2002 2016 # Drop old manifest cache as it is now out of date.
2003 2017 # This is necessary when, e.g., rebasing several nodes with one
2004 2018 # ``overlayworkingctx`` (e.g. with --collapse).
2005 2019 util.clearcachedproperty(self, '_manifest')
2006 2020
2007 2021 def data(self, path):
2008 2022 if self.isdirty(path):
2009 2023 if self._cache[path]['exists']:
2010 2024 if self._cache[path]['data']:
2011 2025 return self._cache[path]['data']
2012 2026 else:
2013 2027 # Must fallback here, too, because we only set flags.
2014 2028 return self._wrappedctx[path].data()
2015 2029 else:
2016 2030 raise error.ProgrammingError("No such file or directory: %s" %
2017 2031 path)
2018 2032 else:
2019 2033 return self._wrappedctx[path].data()
2020 2034
2021 2035 @propertycache
2022 2036 def _manifest(self):
2023 2037 parents = self.parents()
2024 2038 man = parents[0].manifest().copy()
2025 2039
2026 2040 flag = self._flagfunc
2027 2041 for path in self.added():
2028 2042 man[path] = addednodeid
2029 2043 man.setflag(path, flag(path))
2030 2044 for path in self.modified():
2031 2045 man[path] = modifiednodeid
2032 2046 man.setflag(path, flag(path))
2033 2047 for path in self.removed():
2034 2048 del man[path]
2035 2049 return man
2036 2050
2037 2051 @propertycache
2038 2052 def _flagfunc(self):
2039 2053 def f(path):
2040 2054 return self._cache[path]['flags']
2041 2055 return f
2042 2056
2043 2057 def files(self):
2044 2058 return sorted(self.added() + self.modified() + self.removed())
2045 2059
2046 2060 def modified(self):
2047 2061 return [f for f in self._cache.keys() if self._cache[f]['exists'] and
2048 2062 self._existsinparent(f)]
2049 2063
2050 2064 def added(self):
2051 2065 return [f for f in self._cache.keys() if self._cache[f]['exists'] and
2052 2066 not self._existsinparent(f)]
2053 2067
2054 2068 def removed(self):
2055 2069 return [f for f in self._cache.keys() if
2056 2070 not self._cache[f]['exists'] and self._existsinparent(f)]
2057 2071
2058 2072 def isinmemory(self):
2059 2073 return True
2060 2074
2061 2075 def filedate(self, path):
2062 2076 if self.isdirty(path):
2063 2077 return self._cache[path]['date']
2064 2078 else:
2065 2079 return self._wrappedctx[path].date()
2066 2080
2067 2081 def markcopied(self, path, origin):
2068 2082 if self.isdirty(path):
2069 2083 self._cache[path]['copied'] = origin
2070 2084 else:
2071 2085 raise error.ProgrammingError('markcopied() called on clean context')
2072 2086
2073 2087 def copydata(self, path):
2074 2088 if self.isdirty(path):
2075 2089 return self._cache[path]['copied']
2076 2090 else:
2077 2091 raise error.ProgrammingError('copydata() called on clean context')
2078 2092
2079 2093 def flags(self, path):
2080 2094 if self.isdirty(path):
2081 2095 if self._cache[path]['exists']:
2082 2096 return self._cache[path]['flags']
2083 2097 else:
2084 2098 raise error.ProgrammingError("No such file or directory: %s" %
2085 2099 self._path)
2086 2100 else:
2087 2101 return self._wrappedctx[path].flags()
2088 2102
2089 2103 def _existsinparent(self, path):
2090 2104 try:
2091 2105 # ``commitctx` raises a ``ManifestLookupError`` if a path does not
2092 2106 # exist, unlike ``workingctx``, which returns a ``workingfilectx``
2093 2107 # with an ``exists()`` function.
2094 2108 self._wrappedctx[path]
2095 2109 return True
2096 2110 except error.ManifestLookupError:
2097 2111 return False
2098 2112
2099 2113 def _auditconflicts(self, path):
2100 2114 """Replicates conflict checks done by wvfs.write().
2101 2115
2102 2116 Since we never write to the filesystem and never call `applyupdates` in
2103 2117 IMM, we'll never check that a path is actually writable -- e.g., because
2104 2118 it adds `a/foo`, but `a` is actually a file in the other commit.
2105 2119 """
2106 2120 def fail(path, component):
2107 2121 # p1() is the base and we're receiving "writes" for p2()'s
2108 2122 # files.
2109 2123 if 'l' in self.p1()[component].flags():
2110 2124 raise error.Abort("error: %s conflicts with symlink %s "
2111 2125 "in %s." % (path, component,
2112 2126 self.p1().rev()))
2113 2127 else:
2114 2128 raise error.Abort("error: '%s' conflicts with file '%s' in "
2115 2129 "%s." % (path, component,
2116 2130 self.p1().rev()))
2117 2131
2118 2132 # Test that each new directory to be created to write this path from p2
2119 2133 # is not a file in p1.
2120 2134 components = path.split('/')
2121 2135 for i in xrange(len(components)):
2122 2136 component = "/".join(components[0:i])
2123 2137 if component in self.p1():
2124 2138 fail(path, component)
2125 2139
2126 2140 # Test the other direction -- that this path from p2 isn't a directory
2127 2141 # in p1 (test that p1 doesn't any paths matching `path/*`).
2128 2142 match = matchmod.match('/', '', [path + '/'], default=b'relpath')
2129 2143 matches = self.p1().manifest().matches(match)
2130 2144 if len(matches) > 0:
2131 2145 if len(matches) == 1 and matches.keys()[0] == path:
2132 2146 return
2133 2147 raise error.Abort("error: file '%s' cannot be written because "
2134 2148 " '%s/' is a folder in %s (containing %d "
2135 2149 "entries: %s)"
2136 2150 % (path, path, self.p1(), len(matches),
2137 2151 ', '.join(matches.keys())))
2138 2152
2139 2153 def write(self, path, data, flags=''):
2140 2154 if data is None:
2141 2155 raise error.ProgrammingError("data must be non-None")
2142 2156 self._auditconflicts(path)
2143 2157 self._markdirty(path, exists=True, data=data, date=util.makedate(),
2144 2158 flags=flags)
2145 2159
2146 2160 def setflags(self, path, l, x):
2147 2161 self._markdirty(path, exists=True, date=util.makedate(),
2148 2162 flags=(l and 'l' or '') + (x and 'x' or ''))
2149 2163
2150 2164 def remove(self, path):
2151 2165 self._markdirty(path, exists=False)
2152 2166
2153 2167 def exists(self, path):
2154 2168 """exists behaves like `lexists`, but needs to follow symlinks and
2155 2169 return False if they are broken.
2156 2170 """
2157 2171 if self.isdirty(path):
2158 2172 # If this path exists and is a symlink, "follow" it by calling
2159 2173 # exists on the destination path.
2160 2174 if (self._cache[path]['exists'] and
2161 2175 'l' in self._cache[path]['flags']):
2162 2176 return self.exists(self._cache[path]['data'].strip())
2163 2177 else:
2164 2178 return self._cache[path]['exists']
2165 2179
2166 2180 return self._existsinparent(path)
2167 2181
2168 2182 def lexists(self, path):
2169 2183 """lexists returns True if the path exists"""
2170 2184 if self.isdirty(path):
2171 2185 return self._cache[path]['exists']
2172 2186
2173 2187 return self._existsinparent(path)
2174 2188
2175 2189 def size(self, path):
2176 2190 if self.isdirty(path):
2177 2191 if self._cache[path]['exists']:
2178 2192 return len(self._cache[path]['data'])
2179 2193 else:
2180 2194 raise error.ProgrammingError("No such file or directory: %s" %
2181 2195 self._path)
2182 2196 return self._wrappedctx[path].size()
2183 2197
2184 2198 def tomemctx(self, text, branch=None, extra=None, date=None, parents=None,
2185 2199 user=None, editor=None):
2186 2200 """Converts this ``overlayworkingctx`` into a ``memctx`` ready to be
2187 2201 committed.
2188 2202
2189 2203 ``text`` is the commit message.
2190 2204 ``parents`` (optional) are rev numbers.
2191 2205 """
2192 2206 # Default parents to the wrapped contexts' if not passed.
2193 2207 if parents is None:
2194 2208 parents = self._wrappedctx.parents()
2195 2209 if len(parents) == 1:
2196 2210 parents = (parents[0], None)
2197 2211
2198 2212 # ``parents`` is passed as rev numbers; convert to ``commitctxs``.
2199 2213 if parents[1] is None:
2200 2214 parents = (self._repo[parents[0]], None)
2201 2215 else:
2202 2216 parents = (self._repo[parents[0]], self._repo[parents[1]])
2203 2217
2204 2218 files = self._cache.keys()
2205 2219 def getfile(repo, memctx, path):
2206 2220 if self._cache[path]['exists']:
2207 2221 return memfilectx(repo, memctx, path,
2208 2222 self._cache[path]['data'],
2209 2223 'l' in self._cache[path]['flags'],
2210 2224 'x' in self._cache[path]['flags'],
2211 2225 self._cache[path]['copied'])
2212 2226 else:
2213 2227 # Returning None, but including the path in `files`, is
2214 2228 # necessary for memctx to register a deletion.
2215 2229 return None
2216 2230 return memctx(self._repo, parents, text, files, getfile, date=date,
2217 2231 extra=extra, user=user, branch=branch, editor=editor)
2218 2232
2219 2233 def isdirty(self, path):
2220 2234 return path in self._cache
2221 2235
2222 2236 def isempty(self):
2223 2237 # We need to discard any keys that are actually clean before the empty
2224 2238 # commit check.
2225 2239 self._compact()
2226 2240 return len(self._cache) == 0
2227 2241
2228 2242 def clean(self):
2229 2243 self._cache = {}
2230 2244
2231 2245 def _compact(self):
2232 2246 """Removes keys from the cache that are actually clean, by comparing
2233 2247 them with the underlying context.
2234 2248
2235 2249 This can occur during the merge process, e.g. by passing --tool :local
2236 2250 to resolve a conflict.
2237 2251 """
2238 2252 keys = []
2239 2253 for path in self._cache.keys():
2240 2254 cache = self._cache[path]
2241 2255 try:
2242 2256 underlying = self._wrappedctx[path]
2243 2257 if (underlying.data() == cache['data'] and
2244 2258 underlying.flags() == cache['flags']):
2245 2259 keys.append(path)
2246 2260 except error.ManifestLookupError:
2247 2261 # Path not in the underlying manifest (created).
2248 2262 continue
2249 2263
2250 2264 for path in keys:
2251 2265 del self._cache[path]
2252 2266 return keys
2253 2267
2254 2268 def _markdirty(self, path, exists, data=None, date=None, flags=''):
2255 2269 self._cache[path] = {
2256 2270 'exists': exists,
2257 2271 'data': data,
2258 2272 'date': date,
2259 2273 'flags': flags,
2260 2274 'copied': None,
2261 2275 }
2262 2276
2263 2277 def filectx(self, path, filelog=None):
2264 2278 return overlayworkingfilectx(self._repo, path, parent=self,
2265 2279 filelog=filelog)
2266 2280
2267 2281 class overlayworkingfilectx(committablefilectx):
2268 2282 """Wrap a ``workingfilectx`` but intercepts all writes into an in-memory
2269 2283 cache, which can be flushed through later by calling ``flush()``."""
2270 2284
2271 2285 def __init__(self, repo, path, filelog=None, parent=None):
2272 2286 super(overlayworkingfilectx, self).__init__(repo, path, filelog,
2273 2287 parent)
2274 2288 self._repo = repo
2275 2289 self._parent = parent
2276 2290 self._path = path
2277 2291
2278 2292 def cmp(self, fctx):
2279 2293 return self.data() != fctx.data()
2280 2294
2281 2295 def changectx(self):
2282 2296 return self._parent
2283 2297
2284 2298 def data(self):
2285 2299 return self._parent.data(self._path)
2286 2300
2287 2301 def date(self):
2288 2302 return self._parent.filedate(self._path)
2289 2303
2290 2304 def exists(self):
2291 2305 return self.lexists()
2292 2306
2293 2307 def lexists(self):
2294 2308 return self._parent.exists(self._path)
2295 2309
2296 2310 def renamed(self):
2297 2311 path = self._parent.copydata(self._path)
2298 2312 if not path:
2299 2313 return None
2300 2314 return path, self._changectx._parents[0]._manifest.get(path, nullid)
2301 2315
2302 2316 def size(self):
2303 2317 return self._parent.size(self._path)
2304 2318
2305 2319 def markcopied(self, origin):
2306 2320 self._parent.markcopied(self._path, origin)
2307 2321
2308 2322 def audit(self):
2309 2323 pass
2310 2324
2311 2325 def flags(self):
2312 2326 return self._parent.flags(self._path)
2313 2327
2314 2328 def setflags(self, islink, isexec):
2315 2329 return self._parent.setflags(self._path, islink, isexec)
2316 2330
2317 2331 def write(self, data, flags, backgroundclose=False):
2318 2332 return self._parent.write(self._path, data, flags)
2319 2333
2320 2334 def remove(self, ignoremissing=False):
2321 2335 return self._parent.remove(self._path)
2322 2336
2323 2337 def clearunknown(self):
2324 2338 pass
2325 2339
2326 2340 class workingcommitctx(workingctx):
2327 2341 """A workingcommitctx object makes access to data related to
2328 2342 the revision being committed convenient.
2329 2343
2330 2344 This hides changes in the working directory, if they aren't
2331 2345 committed in this context.
2332 2346 """
2333 2347 def __init__(self, repo, changes,
2334 2348 text="", user=None, date=None, extra=None):
2335 2349 super(workingctx, self).__init__(repo, text, user, date, extra,
2336 2350 changes)
2337 2351
2338 2352 def _dirstatestatus(self, match, ignored=False, clean=False, unknown=False):
2339 2353 """Return matched files only in ``self._status``
2340 2354
2341 2355 Uncommitted files appear "clean" via this context, even if
2342 2356 they aren't actually so in the working directory.
2343 2357 """
2344 2358 if clean:
2345 2359 clean = [f for f in self._manifest if f not in self._changedset]
2346 2360 else:
2347 2361 clean = []
2348 2362 return scmutil.status([f for f in self._status.modified if match(f)],
2349 2363 [f for f in self._status.added if match(f)],
2350 2364 [f for f in self._status.removed if match(f)],
2351 2365 [], [], [], clean)
2352 2366
2353 2367 @propertycache
2354 2368 def _changedset(self):
2355 2369 """Return the set of files changed in this context
2356 2370 """
2357 2371 changed = set(self._status.modified)
2358 2372 changed.update(self._status.added)
2359 2373 changed.update(self._status.removed)
2360 2374 return changed
2361 2375
2362 2376 def makecachingfilectxfn(func):
2363 2377 """Create a filectxfn that caches based on the path.
2364 2378
2365 2379 We can't use util.cachefunc because it uses all arguments as the cache
2366 2380 key and this creates a cycle since the arguments include the repo and
2367 2381 memctx.
2368 2382 """
2369 2383 cache = {}
2370 2384
2371 2385 def getfilectx(repo, memctx, path):
2372 2386 if path not in cache:
2373 2387 cache[path] = func(repo, memctx, path)
2374 2388 return cache[path]
2375 2389
2376 2390 return getfilectx
2377 2391
2378 2392 def memfilefromctx(ctx):
2379 2393 """Given a context return a memfilectx for ctx[path]
2380 2394
2381 2395 This is a convenience method for building a memctx based on another
2382 2396 context.
2383 2397 """
2384 2398 def getfilectx(repo, memctx, path):
2385 2399 fctx = ctx[path]
2386 2400 # this is weird but apparently we only keep track of one parent
2387 2401 # (why not only store that instead of a tuple?)
2388 2402 copied = fctx.renamed()
2389 2403 if copied:
2390 2404 copied = copied[0]
2391 2405 return memfilectx(repo, memctx, path, fctx.data(),
2392 2406 islink=fctx.islink(), isexec=fctx.isexec(),
2393 2407 copied=copied)
2394 2408
2395 2409 return getfilectx
2396 2410
2397 2411 def memfilefrompatch(patchstore):
2398 2412 """Given a patch (e.g. patchstore object) return a memfilectx
2399 2413
2400 2414 This is a convenience method for building a memctx based on a patchstore.
2401 2415 """
2402 2416 def getfilectx(repo, memctx, path):
2403 2417 data, mode, copied = patchstore.getfile(path)
2404 2418 if data is None:
2405 2419 return None
2406 2420 islink, isexec = mode
2407 2421 return memfilectx(repo, memctx, path, data, islink=islink,
2408 2422 isexec=isexec, copied=copied)
2409 2423
2410 2424 return getfilectx
2411 2425
2412 2426 class memctx(committablectx):
2413 2427 """Use memctx to perform in-memory commits via localrepo.commitctx().
2414 2428
2415 2429 Revision information is supplied at initialization time while
2416 2430 related files data and is made available through a callback
2417 2431 mechanism. 'repo' is the current localrepo, 'parents' is a
2418 2432 sequence of two parent revisions identifiers (pass None for every
2419 2433 missing parent), 'text' is the commit message and 'files' lists
2420 2434 names of files touched by the revision (normalized and relative to
2421 2435 repository root).
2422 2436
2423 2437 filectxfn(repo, memctx, path) is a callable receiving the
2424 2438 repository, the current memctx object and the normalized path of
2425 2439 requested file, relative to repository root. It is fired by the
2426 2440 commit function for every file in 'files', but calls order is
2427 2441 undefined. If the file is available in the revision being
2428 2442 committed (updated or added), filectxfn returns a memfilectx
2429 2443 object. If the file was removed, filectxfn return None for recent
2430 2444 Mercurial. Moved files are represented by marking the source file
2431 2445 removed and the new file added with copy information (see
2432 2446 memfilectx).
2433 2447
2434 2448 user receives the committer name and defaults to current
2435 2449 repository username, date is the commit date in any format
2436 2450 supported by util.parsedate() and defaults to current date, extra
2437 2451 is a dictionary of metadata or is left empty.
2438 2452 """
2439 2453
2440 2454 # Mercurial <= 3.1 expects the filectxfn to raise IOError for missing files.
2441 2455 # Extensions that need to retain compatibility across Mercurial 3.1 can use
2442 2456 # this field to determine what to do in filectxfn.
2443 2457 _returnnoneformissingfiles = True
2444 2458
2445 2459 def __init__(self, repo, parents, text, files, filectxfn, user=None,
2446 2460 date=None, extra=None, branch=None, editor=False):
2447 2461 super(memctx, self).__init__(repo, text, user, date, extra)
2448 2462 self._rev = None
2449 2463 self._node = None
2450 2464 parents = [(p or nullid) for p in parents]
2451 2465 p1, p2 = parents
2452 2466 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
2453 2467 files = sorted(set(files))
2454 2468 self._files = files
2455 2469 if branch is not None:
2456 2470 self._extra['branch'] = encoding.fromlocal(branch)
2457 2471 self.substate = {}
2458 2472
2459 2473 if isinstance(filectxfn, patch.filestore):
2460 2474 filectxfn = memfilefrompatch(filectxfn)
2461 2475 elif not callable(filectxfn):
2462 2476 # if store is not callable, wrap it in a function
2463 2477 filectxfn = memfilefromctx(filectxfn)
2464 2478
2465 2479 # memoizing increases performance for e.g. vcs convert scenarios.
2466 2480 self._filectxfn = makecachingfilectxfn(filectxfn)
2467 2481
2468 2482 if editor:
2469 2483 self._text = editor(self._repo, self, [])
2470 2484 self._repo.savecommitmessage(self._text)
2471 2485
2472 2486 def filectx(self, path, filelog=None):
2473 2487 """get a file context from the working directory
2474 2488
2475 2489 Returns None if file doesn't exist and should be removed."""
2476 2490 return self._filectxfn(self._repo, self, path)
2477 2491
2478 2492 def commit(self):
2479 2493 """commit context to the repo"""
2480 2494 return self._repo.commitctx(self)
2481 2495
2482 2496 @propertycache
2483 2497 def _manifest(self):
2484 2498 """generate a manifest based on the return values of filectxfn"""
2485 2499
2486 2500 # keep this simple for now; just worry about p1
2487 2501 pctx = self._parents[0]
2488 2502 man = pctx.manifest().copy()
2489 2503
2490 2504 for f in self._status.modified:
2491 2505 p1node = nullid
2492 2506 p2node = nullid
2493 2507 p = pctx[f].parents() # if file isn't in pctx, check p2?
2494 2508 if len(p) > 0:
2495 2509 p1node = p[0].filenode()
2496 2510 if len(p) > 1:
2497 2511 p2node = p[1].filenode()
2498 2512 man[f] = revlog.hash(self[f].data(), p1node, p2node)
2499 2513
2500 2514 for f in self._status.added:
2501 2515 man[f] = revlog.hash(self[f].data(), nullid, nullid)
2502 2516
2503 2517 for f in self._status.removed:
2504 2518 if f in man:
2505 2519 del man[f]
2506 2520
2507 2521 return man
2508 2522
2509 2523 @propertycache
2510 2524 def _status(self):
2511 2525 """Calculate exact status from ``files`` specified at construction
2512 2526 """
2513 2527 man1 = self.p1().manifest()
2514 2528 p2 = self._parents[1]
2515 2529 # "1 < len(self._parents)" can't be used for checking
2516 2530 # existence of the 2nd parent, because "memctx._parents" is
2517 2531 # explicitly initialized by the list, of which length is 2.
2518 2532 if p2.node() != nullid:
2519 2533 man2 = p2.manifest()
2520 2534 managing = lambda f: f in man1 or f in man2
2521 2535 else:
2522 2536 managing = lambda f: f in man1
2523 2537
2524 2538 modified, added, removed = [], [], []
2525 2539 for f in self._files:
2526 2540 if not managing(f):
2527 2541 added.append(f)
2528 2542 elif self[f]:
2529 2543 modified.append(f)
2530 2544 else:
2531 2545 removed.append(f)
2532 2546
2533 2547 return scmutil.status(modified, added, removed, [], [], [], [])
2534 2548
2535 2549 class memfilectx(committablefilectx):
2536 2550 """memfilectx represents an in-memory file to commit.
2537 2551
2538 2552 See memctx and committablefilectx for more details.
2539 2553 """
2540 2554 def __init__(self, repo, changectx, path, data, islink=False,
2541 2555 isexec=False, copied=None):
2542 2556 """
2543 2557 path is the normalized file path relative to repository root.
2544 2558 data is the file content as a string.
2545 2559 islink is True if the file is a symbolic link.
2546 2560 isexec is True if the file is executable.
2547 2561 copied is the source file path if current file was copied in the
2548 2562 revision being committed, or None."""
2549 2563 super(memfilectx, self).__init__(repo, path, None, changectx)
2550 2564 self._data = data
2551 2565 self._flags = (islink and 'l' or '') + (isexec and 'x' or '')
2552 2566 self._copied = None
2553 2567 if copied:
2554 2568 self._copied = (copied, nullid)
2555 2569
2556 2570 def data(self):
2557 2571 return self._data
2558 2572
2559 2573 def remove(self, ignoremissing=False):
2560 2574 """wraps unlink for a repo's working directory"""
2561 2575 # need to figure out what to do here
2562 2576 del self._changectx[self._path]
2563 2577
2564 2578 def write(self, data, flags):
2565 2579 """wraps repo.wwrite"""
2566 2580 self._data = data
2567 2581
2568 2582 class overlayfilectx(committablefilectx):
2569 2583 """Like memfilectx but take an original filectx and optional parameters to
2570 2584 override parts of it. This is useful when fctx.data() is expensive (i.e.
2571 2585 flag processor is expensive) and raw data, flags, and filenode could be
2572 2586 reused (ex. rebase or mode-only amend a REVIDX_EXTSTORED file).
2573 2587 """
2574 2588
2575 2589 def __init__(self, originalfctx, datafunc=None, path=None, flags=None,
2576 2590 copied=None, ctx=None):
2577 2591 """originalfctx: filecontext to duplicate
2578 2592
2579 2593 datafunc: None or a function to override data (file content). It is a
2580 2594 function to be lazy. path, flags, copied, ctx: None or overridden value
2581 2595
2582 2596 copied could be (path, rev), or False. copied could also be just path,
2583 2597 and will be converted to (path, nullid). This simplifies some callers.
2584 2598 """
2585 2599
2586 2600 if path is None:
2587 2601 path = originalfctx.path()
2588 2602 if ctx is None:
2589 2603 ctx = originalfctx.changectx()
2590 2604 ctxmatch = lambda: True
2591 2605 else:
2592 2606 ctxmatch = lambda: ctx == originalfctx.changectx()
2593 2607
2594 2608 repo = originalfctx.repo()
2595 2609 flog = originalfctx.filelog()
2596 2610 super(overlayfilectx, self).__init__(repo, path, flog, ctx)
2597 2611
2598 2612 if copied is None:
2599 2613 copied = originalfctx.renamed()
2600 2614 copiedmatch = lambda: True
2601 2615 else:
2602 2616 if copied and not isinstance(copied, tuple):
2603 2617 # repo._filecommit will recalculate copyrev so nullid is okay
2604 2618 copied = (copied, nullid)
2605 2619 copiedmatch = lambda: copied == originalfctx.renamed()
2606 2620
2607 2621 # When data, copied (could affect data), ctx (could affect filelog
2608 2622 # parents) are not overridden, rawdata, rawflags, and filenode may be
2609 2623 # reused (repo._filecommit should double check filelog parents).
2610 2624 #
2611 2625 # path, flags are not hashed in filelog (but in manifestlog) so they do
2612 2626 # not affect reusable here.
2613 2627 #
2614 2628 # If ctx or copied is overridden to a same value with originalfctx,
2615 2629 # still consider it's reusable. originalfctx.renamed() may be a bit
2616 2630 # expensive so it's not called unless necessary. Assuming datafunc is
2617 2631 # always expensive, do not call it for this "reusable" test.
2618 2632 reusable = datafunc is None and ctxmatch() and copiedmatch()
2619 2633
2620 2634 if datafunc is None:
2621 2635 datafunc = originalfctx.data
2622 2636 if flags is None:
2623 2637 flags = originalfctx.flags()
2624 2638
2625 2639 self._datafunc = datafunc
2626 2640 self._flags = flags
2627 2641 self._copied = copied
2628 2642
2629 2643 if reusable:
2630 2644 # copy extra fields from originalfctx
2631 2645 attrs = ['rawdata', 'rawflags', '_filenode', '_filerev']
2632 2646 for attr_ in attrs:
2633 2647 if util.safehasattr(originalfctx, attr_):
2634 2648 setattr(self, attr_, getattr(originalfctx, attr_))
2635 2649
2636 2650 def data(self):
2637 2651 return self._datafunc()
2638 2652
2639 2653 class metadataonlyctx(committablectx):
2640 2654 """Like memctx but it's reusing the manifest of different commit.
2641 2655 Intended to be used by lightweight operations that are creating
2642 2656 metadata-only changes.
2643 2657
2644 2658 Revision information is supplied at initialization time. 'repo' is the
2645 2659 current localrepo, 'ctx' is original revision which manifest we're reuisng
2646 2660 'parents' is a sequence of two parent revisions identifiers (pass None for
2647 2661 every missing parent), 'text' is the commit.
2648 2662
2649 2663 user receives the committer name and defaults to current repository
2650 2664 username, date is the commit date in any format supported by
2651 2665 util.parsedate() and defaults to current date, extra is a dictionary of
2652 2666 metadata or is left empty.
2653 2667 """
2654 2668 def __new__(cls, repo, originalctx, *args, **kwargs):
2655 2669 return super(metadataonlyctx, cls).__new__(cls, repo)
2656 2670
2657 2671 def __init__(self, repo, originalctx, parents=None, text=None, user=None,
2658 2672 date=None, extra=None, editor=False):
2659 2673 if text is None:
2660 2674 text = originalctx.description()
2661 2675 super(metadataonlyctx, self).__init__(repo, text, user, date, extra)
2662 2676 self._rev = None
2663 2677 self._node = None
2664 2678 self._originalctx = originalctx
2665 2679 self._manifestnode = originalctx.manifestnode()
2666 2680 if parents is None:
2667 2681 parents = originalctx.parents()
2668 2682 else:
2669 2683 parents = [repo[p] for p in parents if p is not None]
2670 2684 parents = parents[:]
2671 2685 while len(parents) < 2:
2672 2686 parents.append(repo[nullid])
2673 2687 p1, p2 = self._parents = parents
2674 2688
2675 2689 # sanity check to ensure that the reused manifest parents are
2676 2690 # manifests of our commit parents
2677 2691 mp1, mp2 = self.manifestctx().parents
2678 2692 if p1 != nullid and p1.manifestnode() != mp1:
2679 2693 raise RuntimeError('can\'t reuse the manifest: '
2680 2694 'its p1 doesn\'t match the new ctx p1')
2681 2695 if p2 != nullid and p2.manifestnode() != mp2:
2682 2696 raise RuntimeError('can\'t reuse the manifest: '
2683 2697 'its p2 doesn\'t match the new ctx p2')
2684 2698
2685 2699 self._files = originalctx.files()
2686 2700 self.substate = {}
2687 2701
2688 2702 if editor:
2689 2703 self._text = editor(self._repo, self, [])
2690 2704 self._repo.savecommitmessage(self._text)
2691 2705
2692 2706 def manifestnode(self):
2693 2707 return self._manifestnode
2694 2708
2695 2709 @property
2696 2710 def _manifestctx(self):
2697 2711 return self._repo.manifestlog[self._manifestnode]
2698 2712
2699 2713 def filectx(self, path, filelog=None):
2700 2714 return self._originalctx.filectx(path, filelog=filelog)
2701 2715
2702 2716 def commit(self):
2703 2717 """commit context to the repo"""
2704 2718 return self._repo.commitctx(self)
2705 2719
2706 2720 @property
2707 2721 def _manifest(self):
2708 2722 return self._originalctx.manifest()
2709 2723
2710 2724 @propertycache
2711 2725 def _status(self):
2712 2726 """Calculate exact status from ``files`` specified in the ``origctx``
2713 2727 and parents manifests.
2714 2728 """
2715 2729 man1 = self.p1().manifest()
2716 2730 p2 = self._parents[1]
2717 2731 # "1 < len(self._parents)" can't be used for checking
2718 2732 # existence of the 2nd parent, because "metadataonlyctx._parents" is
2719 2733 # explicitly initialized by the list, of which length is 2.
2720 2734 if p2.node() != nullid:
2721 2735 man2 = p2.manifest()
2722 2736 managing = lambda f: f in man1 or f in man2
2723 2737 else:
2724 2738 managing = lambda f: f in man1
2725 2739
2726 2740 modified, added, removed = [], [], []
2727 2741 for f in self._files:
2728 2742 if not managing(f):
2729 2743 added.append(f)
2730 2744 elif f in self:
2731 2745 modified.append(f)
2732 2746 else:
2733 2747 removed.append(f)
2734 2748
2735 2749 return scmutil.status(modified, added, removed, [], [], [], [])
2736 2750
2737 2751 class arbitraryfilectx(object):
2738 2752 """Allows you to use filectx-like functions on a file in an arbitrary
2739 2753 location on disk, possibly not in the working directory.
2740 2754 """
2741 2755 def __init__(self, path, repo=None):
2742 2756 # Repo is optional because contrib/simplemerge uses this class.
2743 2757 self._repo = repo
2744 2758 self._path = path
2745 2759
2746 2760 def cmp(self, fctx):
2747 2761 # filecmp follows symlinks whereas `cmp` should not, so skip the fast
2748 2762 # path if either side is a symlink.
2749 2763 symlinks = ('l' in self.flags() or 'l' in fctx.flags())
2750 2764 if not symlinks and isinstance(fctx, workingfilectx) and self._repo:
2751 2765 # Add a fast-path for merge if both sides are disk-backed.
2752 2766 # Note that filecmp uses the opposite return values (True if same)
2753 2767 # from our cmp functions (True if different).
2754 2768 return not filecmp.cmp(self.path(), self._repo.wjoin(fctx.path()))
2755 2769 return self.data() != fctx.data()
2756 2770
2757 2771 def path(self):
2758 2772 return self._path
2759 2773
2760 2774 def flags(self):
2761 2775 return ''
2762 2776
2763 2777 def data(self):
2764 2778 return util.readfile(self._path)
2765 2779
2766 2780 def decodeddata(self):
2767 2781 with open(self._path, "rb") as f:
2768 2782 return f.read()
2769 2783
2770 2784 def remove(self):
2771 2785 util.unlink(self._path)
2772 2786
2773 2787 def write(self, data, flags):
2774 2788 assert not flags
2775 2789 with open(self._path, "w") as f:
2776 2790 f.write(data)
@@ -1,838 +1,897 b''
1 1 # obsutil.py - utility functions for obsolescence
2 2 #
3 3 # Copyright 2017 Boris Feld <boris.feld@octobus.net>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 import re
11 11
12 from .i18n import _
12 13 from . import (
14 node as nodemod,
13 15 phases,
14 util
16 util,
15 17 )
16 18
17 19 class marker(object):
18 20 """Wrap obsolete marker raw data"""
19 21
20 22 def __init__(self, repo, data):
21 23 # the repo argument will be used to create changectx in later version
22 24 self._repo = repo
23 25 self._data = data
24 26 self._decodedmeta = None
25 27
26 28 def __hash__(self):
27 29 return hash(self._data)
28 30
29 31 def __eq__(self, other):
30 32 if type(other) != type(self):
31 33 return False
32 34 return self._data == other._data
33 35
34 36 def precnode(self):
35 37 msg = ("'marker.precnode' is deprecated, "
36 38 "use 'marker.prednode'")
37 39 util.nouideprecwarn(msg, '4.4')
38 40 return self.prednode()
39 41
40 42 def prednode(self):
41 43 """Predecessor changeset node identifier"""
42 44 return self._data[0]
43 45
44 46 def succnodes(self):
45 47 """List of successor changesets node identifiers"""
46 48 return self._data[1]
47 49
48 50 def parentnodes(self):
49 51 """Parents of the predecessors (None if not recorded)"""
50 52 return self._data[5]
51 53
52 54 def metadata(self):
53 55 """Decoded metadata dictionary"""
54 56 return dict(self._data[3])
55 57
56 58 def date(self):
57 59 """Creation date as (unixtime, offset)"""
58 60 return self._data[4]
59 61
60 62 def flags(self):
61 63 """The flags field of the marker"""
62 64 return self._data[2]
63 65
64 66 def getmarkers(repo, nodes=None, exclusive=False):
65 67 """returns markers known in a repository
66 68
67 69 If <nodes> is specified, only markers "relevant" to those nodes are are
68 70 returned"""
69 71 if nodes is None:
70 72 rawmarkers = repo.obsstore
71 73 elif exclusive:
72 74 rawmarkers = exclusivemarkers(repo, nodes)
73 75 else:
74 76 rawmarkers = repo.obsstore.relevantmarkers(nodes)
75 77
76 78 for markerdata in rawmarkers:
77 79 yield marker(repo, markerdata)
78 80
79 81 def closestpredecessors(repo, nodeid):
80 82 """yield the list of next predecessors pointing on visible changectx nodes
81 83
82 84 This function respect the repoview filtering, filtered revision will be
83 85 considered missing.
84 86 """
85 87
86 88 precursors = repo.obsstore.predecessors
87 89 stack = [nodeid]
88 90 seen = set(stack)
89 91
90 92 while stack:
91 93 current = stack.pop()
92 94 currentpreccs = precursors.get(current, ())
93 95
94 96 for prec in currentpreccs:
95 97 precnodeid = prec[0]
96 98
97 99 # Basic cycle protection
98 100 if precnodeid in seen:
99 101 continue
100 102 seen.add(precnodeid)
101 103
102 104 if precnodeid in repo:
103 105 yield precnodeid
104 106 else:
105 107 stack.append(precnodeid)
106 108
107 109 def allprecursors(*args, **kwargs):
108 110 """ (DEPRECATED)
109 111 """
110 112 msg = ("'obsutil.allprecursors' is deprecated, "
111 113 "use 'obsutil.allpredecessors'")
112 114 util.nouideprecwarn(msg, '4.4')
113 115
114 116 return allpredecessors(*args, **kwargs)
115 117
116 118 def allpredecessors(obsstore, nodes, ignoreflags=0):
117 119 """Yield node for every precursors of <nodes>.
118 120
119 121 Some precursors may be unknown locally.
120 122
121 123 This is a linear yield unsuited to detecting folded changesets. It includes
122 124 initial nodes too."""
123 125
124 126 remaining = set(nodes)
125 127 seen = set(remaining)
126 128 while remaining:
127 129 current = remaining.pop()
128 130 yield current
129 131 for mark in obsstore.predecessors.get(current, ()):
130 132 # ignore marker flagged with specified flag
131 133 if mark[2] & ignoreflags:
132 134 continue
133 135 suc = mark[0]
134 136 if suc not in seen:
135 137 seen.add(suc)
136 138 remaining.add(suc)
137 139
138 140 def allsuccessors(obsstore, nodes, ignoreflags=0):
139 141 """Yield node for every successor of <nodes>.
140 142
141 143 Some successors may be unknown locally.
142 144
143 145 This is a linear yield unsuited to detecting split changesets. It includes
144 146 initial nodes too."""
145 147 remaining = set(nodes)
146 148 seen = set(remaining)
147 149 while remaining:
148 150 current = remaining.pop()
149 151 yield current
150 152 for mark in obsstore.successors.get(current, ()):
151 153 # ignore marker flagged with specified flag
152 154 if mark[2] & ignoreflags:
153 155 continue
154 156 for suc in mark[1]:
155 157 if suc not in seen:
156 158 seen.add(suc)
157 159 remaining.add(suc)
158 160
159 161 def _filterprunes(markers):
160 162 """return a set with no prune markers"""
161 163 return set(m for m in markers if m[1])
162 164
163 165 def exclusivemarkers(repo, nodes):
164 166 """set of markers relevant to "nodes" but no other locally-known nodes
165 167
166 168 This function compute the set of markers "exclusive" to a locally-known
167 169 node. This means we walk the markers starting from <nodes> until we reach a
168 170 locally-known precursors outside of <nodes>. Element of <nodes> with
169 171 locally-known successors outside of <nodes> are ignored (since their
170 172 precursors markers are also relevant to these successors).
171 173
172 174 For example:
173 175
174 176 # (A0 rewritten as A1)
175 177 #
176 178 # A0 <-1- A1 # Marker "1" is exclusive to A1
177 179
178 180 or
179 181
180 182 # (A0 rewritten as AX; AX rewritten as A1; AX is unkown locally)
181 183 #
182 184 # <-1- A0 <-2- AX <-3- A1 # Marker "2,3" are exclusive to A1
183 185
184 186 or
185 187
186 188 # (A0 has unknown precursors, A0 rewritten as A1 and A2 (divergence))
187 189 #
188 190 # <-2- A1 # Marker "2" is exclusive to A0,A1
189 191 # /
190 192 # <-1- A0
191 193 # \
192 194 # <-3- A2 # Marker "3" is exclusive to A0,A2
193 195 #
194 196 # in addition:
195 197 #
196 198 # Markers "2,3" are exclusive to A1,A2
197 199 # Markers "1,2,3" are exclusive to A0,A1,A2
198 200
199 201 See test/test-obsolete-bundle-strip.t for more examples.
200 202
201 203 An example usage is strip. When stripping a changeset, we also want to
202 204 strip the markers exclusive to this changeset. Otherwise we would have
203 205 "dangling"" obsolescence markers from its precursors: Obsolescence markers
204 206 marking a node as obsolete without any successors available locally.
205 207
206 208 As for relevant markers, the prune markers for children will be followed.
207 209 Of course, they will only be followed if the pruned children is
208 210 locally-known. Since the prune markers are relevant to the pruned node.
209 211 However, while prune markers are considered relevant to the parent of the
210 212 pruned changesets, prune markers for locally-known changeset (with no
211 213 successors) are considered exclusive to the pruned nodes. This allows
212 214 to strip the prune markers (with the rest of the exclusive chain) alongside
213 215 the pruned changesets.
214 216 """
215 217 # running on a filtered repository would be dangerous as markers could be
216 218 # reported as exclusive when they are relevant for other filtered nodes.
217 219 unfi = repo.unfiltered()
218 220
219 221 # shortcut to various useful item
220 222 nm = unfi.changelog.nodemap
221 223 precursorsmarkers = unfi.obsstore.predecessors
222 224 successormarkers = unfi.obsstore.successors
223 225 childrenmarkers = unfi.obsstore.children
224 226
225 227 # exclusive markers (return of the function)
226 228 exclmarkers = set()
227 229 # we need fast membership testing
228 230 nodes = set(nodes)
229 231 # looking for head in the obshistory
230 232 #
231 233 # XXX we are ignoring all issues in regard with cycle for now.
232 234 stack = [n for n in nodes if not _filterprunes(successormarkers.get(n, ()))]
233 235 stack.sort()
234 236 # nodes already stacked
235 237 seennodes = set(stack)
236 238 while stack:
237 239 current = stack.pop()
238 240 # fetch precursors markers
239 241 markers = list(precursorsmarkers.get(current, ()))
240 242 # extend the list with prune markers
241 243 for mark in successormarkers.get(current, ()):
242 244 if not mark[1]:
243 245 markers.append(mark)
244 246 # and markers from children (looking for prune)
245 247 for mark in childrenmarkers.get(current, ()):
246 248 if not mark[1]:
247 249 markers.append(mark)
248 250 # traverse the markers
249 251 for mark in markers:
250 252 if mark in exclmarkers:
251 253 # markers already selected
252 254 continue
253 255
254 256 # If the markers is about the current node, select it
255 257 #
256 258 # (this delay the addition of markers from children)
257 259 if mark[1] or mark[0] == current:
258 260 exclmarkers.add(mark)
259 261
260 262 # should we keep traversing through the precursors?
261 263 prec = mark[0]
262 264
263 265 # nodes in the stack or already processed
264 266 if prec in seennodes:
265 267 continue
266 268
267 269 # is this a locally known node ?
268 270 known = prec in nm
269 271 # if locally-known and not in the <nodes> set the traversal
270 272 # stop here.
271 273 if known and prec not in nodes:
272 274 continue
273 275
274 276 # do not keep going if there are unselected markers pointing to this
275 277 # nodes. If we end up traversing these unselected markers later the
276 278 # node will be taken care of at that point.
277 279 precmarkers = _filterprunes(successormarkers.get(prec))
278 280 if precmarkers.issubset(exclmarkers):
279 281 seennodes.add(prec)
280 282 stack.append(prec)
281 283
282 284 return exclmarkers
283 285
284 286 def foreground(repo, nodes):
285 287 """return all nodes in the "foreground" of other node
286 288
287 289 The foreground of a revision is anything reachable using parent -> children
288 290 or precursor -> successor relation. It is very similar to "descendant" but
289 291 augmented with obsolescence information.
290 292
291 293 Beware that possible obsolescence cycle may result if complex situation.
292 294 """
293 295 repo = repo.unfiltered()
294 296 foreground = set(repo.set('%ln::', nodes))
295 297 if repo.obsstore:
296 298 # We only need this complicated logic if there is obsolescence
297 299 # XXX will probably deserve an optimised revset.
298 300 nm = repo.changelog.nodemap
299 301 plen = -1
300 302 # compute the whole set of successors or descendants
301 303 while len(foreground) != plen:
302 304 plen = len(foreground)
303 305 succs = set(c.node() for c in foreground)
304 306 mutable = [c.node() for c in foreground if c.mutable()]
305 307 succs.update(allsuccessors(repo.obsstore, mutable))
306 308 known = (n for n in succs if n in nm)
307 309 foreground = set(repo.set('%ln::', known))
308 310 return set(c.node() for c in foreground)
309 311
310 312 # effectflag field
311 313 #
312 314 # Effect-flag is a 1-byte bit field used to store what changed between a
313 315 # changeset and its successor(s).
314 316 #
315 317 # The effect flag is stored in obs-markers metadata while we iterate on the
316 318 # information design. That's why we have the EFFECTFLAGFIELD. If we come up
317 319 # with an incompatible design for effect flag, we can store a new design under
318 320 # another field name so we don't break readers. We plan to extend the existing
319 321 # obsmarkers bit-field when the effect flag design will be stabilized.
320 322 #
321 323 # The effect-flag is placed behind an experimental flag
322 324 # `effect-flags` set to off by default.
323 325 #
324 326
325 327 EFFECTFLAGFIELD = "ef1"
326 328
327 329 DESCCHANGED = 1 << 0 # action changed the description
328 330 METACHANGED = 1 << 1 # action change the meta
329 331 DIFFCHANGED = 1 << 3 # action change diff introduced by the changeset
330 332 PARENTCHANGED = 1 << 2 # action change the parent
331 333 USERCHANGED = 1 << 4 # the user changed
332 334 DATECHANGED = 1 << 5 # the date changed
333 335 BRANCHCHANGED = 1 << 6 # the branch changed
334 336
335 337 METABLACKLIST = [
336 338 re.compile('^branch$'),
337 339 re.compile('^.*-source$'),
338 340 re.compile('^.*_source$'),
339 341 re.compile('^source$'),
340 342 ]
341 343
342 344 def metanotblacklisted(metaitem):
343 345 """ Check that the key of a meta item (extrakey, extravalue) does not
344 346 match at least one of the blacklist pattern
345 347 """
346 348 metakey = metaitem[0]
347 349
348 350 return not any(pattern.match(metakey) for pattern in METABLACKLIST)
349 351
350 352 def _prepare_hunk(hunk):
351 353 """Drop all information but the username and patch"""
352 354 cleanhunk = []
353 355 for line in hunk.splitlines():
354 356 if line.startswith(b'# User') or not line.startswith(b'#'):
355 357 if line.startswith(b'@@'):
356 358 line = b'@@\n'
357 359 cleanhunk.append(line)
358 360 return cleanhunk
359 361
360 362 def _getdifflines(iterdiff):
361 363 """return a cleaned up lines"""
362 364 lines = next(iterdiff, None)
363 365
364 366 if lines is None:
365 367 return lines
366 368
367 369 return _prepare_hunk(lines)
368 370
369 371 def _cmpdiff(leftctx, rightctx):
370 372 """return True if both ctx introduce the "same diff"
371 373
372 374 This is a first and basic implementation, with many shortcoming.
373 375 """
374 376
375 377 # Leftctx or right ctx might be filtered, so we need to use the contexts
376 378 # with an unfiltered repository to safely compute the diff
377 379 leftunfi = leftctx._repo.unfiltered()[leftctx.rev()]
378 380 leftdiff = leftunfi.diff(git=1)
379 381 rightunfi = rightctx._repo.unfiltered()[rightctx.rev()]
380 382 rightdiff = rightunfi.diff(git=1)
381 383
382 384 left, right = (0, 0)
383 385 while None not in (left, right):
384 386 left = _getdifflines(leftdiff)
385 387 right = _getdifflines(rightdiff)
386 388
387 389 if left != right:
388 390 return False
389 391 return True
390 392
391 393 def geteffectflag(relation):
392 394 """ From an obs-marker relation, compute what changed between the
393 395 predecessor and the successor.
394 396 """
395 397 effects = 0
396 398
397 399 source = relation[0]
398 400
399 401 for changectx in relation[1]:
400 402 # Check if description has changed
401 403 if changectx.description() != source.description():
402 404 effects |= DESCCHANGED
403 405
404 406 # Check if user has changed
405 407 if changectx.user() != source.user():
406 408 effects |= USERCHANGED
407 409
408 410 # Check if date has changed
409 411 if changectx.date() != source.date():
410 412 effects |= DATECHANGED
411 413
412 414 # Check if branch has changed
413 415 if changectx.branch() != source.branch():
414 416 effects |= BRANCHCHANGED
415 417
416 418 # Check if at least one of the parent has changed
417 419 if changectx.parents() != source.parents():
418 420 effects |= PARENTCHANGED
419 421
420 422 # Check if other meta has changed
421 423 changeextra = changectx.extra().items()
422 424 ctxmeta = filter(metanotblacklisted, changeextra)
423 425
424 426 sourceextra = source.extra().items()
425 427 srcmeta = filter(metanotblacklisted, sourceextra)
426 428
427 429 if ctxmeta != srcmeta:
428 430 effects |= METACHANGED
429 431
430 432 # Check if the diff has changed
431 433 if not _cmpdiff(source, changectx):
432 434 effects |= DIFFCHANGED
433 435
434 436 return effects
435 437
436 438 def getobsoleted(repo, tr):
437 439 """return the set of pre-existing revisions obsoleted by a transaction"""
438 440 torev = repo.unfiltered().changelog.nodemap.get
439 441 phase = repo._phasecache.phase
440 442 succsmarkers = repo.obsstore.successors.get
441 443 public = phases.public
442 444 addedmarkers = tr.changes.get('obsmarkers')
443 445 addedrevs = tr.changes.get('revs')
444 446 seenrevs = set()
445 447 obsoleted = set()
446 448 for mark in addedmarkers:
447 449 node = mark[0]
448 450 rev = torev(node)
449 451 if rev is None or rev in seenrevs or rev in addedrevs:
450 452 continue
451 453 seenrevs.add(rev)
452 454 if phase(repo, rev) == public:
453 455 continue
454 456 if set(succsmarkers(node) or []).issubset(addedmarkers):
455 457 obsoleted.add(rev)
456 458 return obsoleted
457 459
458 460 class _succs(list):
459 461 """small class to represent a successors with some metadata about it"""
460 462
461 463 def __init__(self, *args, **kwargs):
462 464 super(_succs, self).__init__(*args, **kwargs)
463 465 self.markers = set()
464 466
465 467 def copy(self):
466 468 new = _succs(self)
467 469 new.markers = self.markers.copy()
468 470 return new
469 471
470 472 @util.propertycache
471 473 def _set(self):
472 474 # immutable
473 475 return set(self)
474 476
475 477 def canmerge(self, other):
476 478 return self._set.issubset(other._set)
477 479
478 480 def successorssets(repo, initialnode, closest=False, cache=None):
479 481 """Return set of all latest successors of initial nodes
480 482
481 483 The successors set of a changeset A are the group of revisions that succeed
482 484 A. It succeeds A as a consistent whole, each revision being only a partial
483 485 replacement. By default, the successors set contains non-obsolete
484 486 changesets only, walking the obsolescence graph until reaching a leaf. If
485 487 'closest' is set to True, closest successors-sets are return (the
486 488 obsolescence walk stops on known changesets).
487 489
488 490 This function returns the full list of successor sets which is why it
489 491 returns a list of tuples and not just a single tuple. Each tuple is a valid
490 492 successors set. Note that (A,) may be a valid successors set for changeset A
491 493 (see below).
492 494
493 495 In most cases, a changeset A will have a single element (e.g. the changeset
494 496 A is replaced by A') in its successors set. Though, it is also common for a
495 497 changeset A to have no elements in its successor set (e.g. the changeset
496 498 has been pruned). Therefore, the returned list of successors sets will be
497 499 [(A',)] or [], respectively.
498 500
499 501 When a changeset A is split into A' and B', however, it will result in a
500 502 successors set containing more than a single element, i.e. [(A',B')].
501 503 Divergent changesets will result in multiple successors sets, i.e. [(A',),
502 504 (A'')].
503 505
504 506 If a changeset A is not obsolete, then it will conceptually have no
505 507 successors set. To distinguish this from a pruned changeset, the successor
506 508 set will contain itself only, i.e. [(A,)].
507 509
508 510 Finally, final successors unknown locally are considered to be pruned
509 511 (pruned: obsoleted without any successors). (Final: successors not affected
510 512 by markers).
511 513
512 514 The 'closest' mode respect the repoview filtering. For example, without
513 515 filter it will stop at the first locally known changeset, with 'visible'
514 516 filter it will stop on visible changesets).
515 517
516 518 The optional `cache` parameter is a dictionary that may contains
517 519 precomputed successors sets. It is meant to reuse the computation of a
518 520 previous call to `successorssets` when multiple calls are made at the same
519 521 time. The cache dictionary is updated in place. The caller is responsible
520 522 for its life span. Code that makes multiple calls to `successorssets`
521 523 *should* use this cache mechanism or risk a performance hit.
522 524
523 525 Since results are different depending of the 'closest' most, the same cache
524 526 cannot be reused for both mode.
525 527 """
526 528
527 529 succmarkers = repo.obsstore.successors
528 530
529 531 # Stack of nodes we search successors sets for
530 532 toproceed = [initialnode]
531 533 # set version of above list for fast loop detection
532 534 # element added to "toproceed" must be added here
533 535 stackedset = set(toproceed)
534 536 if cache is None:
535 537 cache = {}
536 538
537 539 # This while loop is the flattened version of a recursive search for
538 540 # successors sets
539 541 #
540 542 # def successorssets(x):
541 543 # successors = directsuccessors(x)
542 544 # ss = [[]]
543 545 # for succ in directsuccessors(x):
544 546 # # product as in itertools cartesian product
545 547 # ss = product(ss, successorssets(succ))
546 548 # return ss
547 549 #
548 550 # But we can not use plain recursive calls here:
549 551 # - that would blow the python call stack
550 552 # - obsolescence markers may have cycles, we need to handle them.
551 553 #
552 554 # The `toproceed` list act as our call stack. Every node we search
553 555 # successors set for are stacked there.
554 556 #
555 557 # The `stackedset` is set version of this stack used to check if a node is
556 558 # already stacked. This check is used to detect cycles and prevent infinite
557 559 # loop.
558 560 #
559 561 # successors set of all nodes are stored in the `cache` dictionary.
560 562 #
561 563 # After this while loop ends we use the cache to return the successors sets
562 564 # for the node requested by the caller.
563 565 while toproceed:
564 566 # Every iteration tries to compute the successors sets of the topmost
565 567 # node of the stack: CURRENT.
566 568 #
567 569 # There are four possible outcomes:
568 570 #
569 571 # 1) We already know the successors sets of CURRENT:
570 572 # -> mission accomplished, pop it from the stack.
571 573 # 2) Stop the walk:
572 574 # default case: Node is not obsolete
573 575 # closest case: Node is known at this repo filter level
574 576 # -> the node is its own successors sets. Add it to the cache.
575 577 # 3) We do not know successors set of direct successors of CURRENT:
576 578 # -> We add those successors to the stack.
577 579 # 4) We know successors sets of all direct successors of CURRENT:
578 580 # -> We can compute CURRENT successors set and add it to the
579 581 # cache.
580 582 #
581 583 current = toproceed[-1]
582 584
583 585 # case 2 condition is a bit hairy because of closest,
584 586 # we compute it on its own
585 587 case2condition = ((current not in succmarkers)
586 588 or (closest and current != initialnode
587 589 and current in repo))
588 590
589 591 if current in cache:
590 592 # case (1): We already know the successors sets
591 593 stackedset.remove(toproceed.pop())
592 594 elif case2condition:
593 595 # case (2): end of walk.
594 596 if current in repo:
595 597 # We have a valid successors.
596 598 cache[current] = [_succs((current,))]
597 599 else:
598 600 # Final obsolete version is unknown locally.
599 601 # Do not count that as a valid successors
600 602 cache[current] = []
601 603 else:
602 604 # cases (3) and (4)
603 605 #
604 606 # We proceed in two phases. Phase 1 aims to distinguish case (3)
605 607 # from case (4):
606 608 #
607 609 # For each direct successors of CURRENT, we check whether its
608 610 # successors sets are known. If they are not, we stack the
609 611 # unknown node and proceed to the next iteration of the while
610 612 # loop. (case 3)
611 613 #
612 614 # During this step, we may detect obsolescence cycles: a node
613 615 # with unknown successors sets but already in the call stack.
614 616 # In such a situation, we arbitrary set the successors sets of
615 617 # the node to nothing (node pruned) to break the cycle.
616 618 #
617 619 # If no break was encountered we proceed to phase 2.
618 620 #
619 621 # Phase 2 computes successors sets of CURRENT (case 4); see details
620 622 # in phase 2 itself.
621 623 #
622 624 # Note the two levels of iteration in each phase.
623 625 # - The first one handles obsolescence markers using CURRENT as
624 626 # precursor (successors markers of CURRENT).
625 627 #
626 628 # Having multiple entry here means divergence.
627 629 #
628 630 # - The second one handles successors defined in each marker.
629 631 #
630 632 # Having none means pruned node, multiple successors means split,
631 633 # single successors are standard replacement.
632 634 #
633 635 for mark in sorted(succmarkers[current]):
634 636 for suc in mark[1]:
635 637 if suc not in cache:
636 638 if suc in stackedset:
637 639 # cycle breaking
638 640 cache[suc] = []
639 641 else:
640 642 # case (3) If we have not computed successors sets
641 643 # of one of those successors we add it to the
642 644 # `toproceed` stack and stop all work for this
643 645 # iteration.
644 646 toproceed.append(suc)
645 647 stackedset.add(suc)
646 648 break
647 649 else:
648 650 continue
649 651 break
650 652 else:
651 653 # case (4): we know all successors sets of all direct
652 654 # successors
653 655 #
654 656 # Successors set contributed by each marker depends on the
655 657 # successors sets of all its "successors" node.
656 658 #
657 659 # Each different marker is a divergence in the obsolescence
658 660 # history. It contributes successors sets distinct from other
659 661 # markers.
660 662 #
661 663 # Within a marker, a successor may have divergent successors
662 664 # sets. In such a case, the marker will contribute multiple
663 665 # divergent successors sets. If multiple successors have
664 666 # divergent successors sets, a Cartesian product is used.
665 667 #
666 668 # At the end we post-process successors sets to remove
667 669 # duplicated entry and successors set that are strict subset of
668 670 # another one.
669 671 succssets = []
670 672 for mark in sorted(succmarkers[current]):
671 673 # successors sets contributed by this marker
672 674 base = _succs()
673 675 base.markers.add(mark)
674 676 markss = [base]
675 677 for suc in mark[1]:
676 678 # cardinal product with previous successors
677 679 productresult = []
678 680 for prefix in markss:
679 681 for suffix in cache[suc]:
680 682 newss = prefix.copy()
681 683 newss.markers.update(suffix.markers)
682 684 for part in suffix:
683 685 # do not duplicated entry in successors set
684 686 # first entry wins.
685 687 if part not in newss:
686 688 newss.append(part)
687 689 productresult.append(newss)
688 690 markss = productresult
689 691 succssets.extend(markss)
690 692 # remove duplicated and subset
691 693 seen = []
692 694 final = []
693 695 candidates = sorted((s for s in succssets if s),
694 696 key=len, reverse=True)
695 697 for cand in candidates:
696 698 for seensuccs in seen:
697 699 if cand.canmerge(seensuccs):
698 700 seensuccs.markers.update(cand.markers)
699 701 break
700 702 else:
701 703 final.append(cand)
702 704 seen.append(cand)
703 705 final.reverse() # put small successors set first
704 706 cache[current] = final
705 707 return cache[initialnode]
706 708
707 709 def successorsandmarkers(repo, ctx):
708 710 """compute the raw data needed for computing obsfate
709 711 Returns a list of dict, one dict per successors set
710 712 """
711 713 if not ctx.obsolete():
712 714 return None
713 715
714 716 ssets = successorssets(repo, ctx.node(), closest=True)
715 717
716 718 # closestsuccessors returns an empty list for pruned revisions, remap it
717 719 # into a list containing an empty list for future processing
718 720 if ssets == []:
719 721 ssets = [[]]
720 722
721 723 # Try to recover pruned markers
722 724 succsmap = repo.obsstore.successors
723 725 fullsuccessorsets = [] # successor set + markers
724 726 for sset in ssets:
725 727 if sset:
726 728 fullsuccessorsets.append(sset)
727 729 else:
728 730 # successorsset return an empty set() when ctx or one of its
729 731 # successors is pruned.
730 732 # In this case, walk the obs-markers tree again starting with ctx
731 733 # and find the relevant pruning obs-makers, the ones without
732 734 # successors.
733 735 # Having these markers allow us to compute some information about
734 736 # its fate, like who pruned this changeset and when.
735 737
736 738 # XXX we do not catch all prune markers (eg rewritten then pruned)
737 739 # (fix me later)
738 740 foundany = False
739 741 for mark in succsmap.get(ctx.node(), ()):
740 742 if not mark[1]:
741 743 foundany = True
742 744 sset = _succs()
743 745 sset.markers.add(mark)
744 746 fullsuccessorsets.append(sset)
745 747 if not foundany:
746 748 fullsuccessorsets.append(_succs())
747 749
748 750 values = []
749 751 for sset in fullsuccessorsets:
750 752 values.append({'successors': sset, 'markers': sset.markers})
751 753
752 754 return values
753 755
756 def _getobsfate(successorssets):
757 """ Compute a changeset obsolescence fate based on its successorssets.
758 Successors can be the tipmost ones or the immediate ones. This function
759 return values are not meant to be shown directly to users, it is meant to
760 be used by internal functions only.
761 Returns one fate from the following values:
762 - pruned
763 - diverged
764 - superseded
765 - superseded_split
766 """
767
768 if len(successorssets) == 0:
769 # The commit has been pruned
770 return 'pruned'
771 elif len(successorssets) > 1:
772 return 'diverged'
773 else:
774 # No divergence, only one set of successors
775 successors = successorssets[0]
776
777 if len(successors) == 1:
778 return 'superseded'
779 else:
780 return 'superseded_split'
781
754 782 def obsfateverb(successorset, markers):
755 783 """ Return the verb summarizing the successorset and potentially using
756 784 information from the markers
757 785 """
758 786 if not successorset:
759 787 verb = 'pruned'
760 788 elif len(successorset) == 1:
761 789 verb = 'rewritten'
762 790 else:
763 791 verb = 'split'
764 792 return verb
765 793
766 794 def markersdates(markers):
767 795 """returns the list of dates for a list of markers
768 796 """
769 797 return [m[4] for m in markers]
770 798
771 799 def markersusers(markers):
772 800 """ Returns a sorted list of markers users without duplicates
773 801 """
774 802 markersmeta = [dict(m[3]) for m in markers]
775 803 users = set(meta.get('user') for meta in markersmeta if meta.get('user'))
776 804
777 805 return sorted(users)
778 806
779 807 def markersoperations(markers):
780 808 """ Returns a sorted list of markers operations without duplicates
781 809 """
782 810 markersmeta = [dict(m[3]) for m in markers]
783 811 operations = set(meta.get('operation') for meta in markersmeta
784 812 if meta.get('operation'))
785 813
786 814 return sorted(operations)
787 815
788 816 def obsfateprinter(successors, markers, ui):
789 817 """ Build a obsfate string for a single successorset using all obsfate
790 818 related function defined in obsutil
791 819 """
792 820 quiet = ui.quiet
793 821 verbose = ui.verbose
794 822 normal = not verbose and not quiet
795 823
796 824 line = []
797 825
798 826 # Verb
799 827 line.append(obsfateverb(successors, markers))
800 828
801 829 # Operations
802 830 operations = markersoperations(markers)
803 831 if operations:
804 832 line.append(" using %s" % ", ".join(operations))
805 833
806 834 # Successors
807 835 if successors:
808 836 fmtsuccessors = [successors.joinfmt(succ) for succ in successors]
809 837 line.append(" as %s" % ", ".join(fmtsuccessors))
810 838
811 839 # Users
812 840 users = markersusers(markers)
813 841 # Filter out current user in not verbose mode to reduce amount of
814 842 # information
815 843 if not verbose:
816 844 currentuser = ui.username(acceptempty=True)
817 845 if len(users) == 1 and currentuser in users:
818 846 users = None
819 847
820 848 if (verbose or normal) and users:
821 849 line.append(" by %s" % ", ".join(users))
822 850
823 851 # Date
824 852 dates = markersdates(markers)
825 853
826 854 if dates and verbose:
827 855 min_date = min(dates)
828 856 max_date = max(dates)
829 857
830 858 if min_date == max_date:
831 859 fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
832 860 line.append(" (at %s)" % fmtmin_date)
833 861 else:
834 862 fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
835 863 fmtmax_date = util.datestr(max_date, '%Y-%m-%d %H:%M %1%2')
836 864 line.append(" (between %s and %s)" % (fmtmin_date, fmtmax_date))
837 865
838 866 return "".join(line)
867
868 def _getfilteredreason(unfilteredrepo, ctx):
869 """return a human-friendly string on why a obsolete changeset is hidden
870 """
871 successors = successorssets(unfilteredrepo, ctx.node())
872 fate = _getobsfate(successors)
873
874 # Be more precise in case the revision is superseded
875 if fate == 'pruned':
876 reason = _('is pruned')
877 elif fate == 'diverged':
878 reason = _('has diverged')
879 elif fate == 'superseded':
880 reason = _("was rewritten as: %s") % nodemod.short(successors[0][0])
881 elif fate == 'superseded_split':
882
883 succs = []
884 for node_id in successors[0]:
885 succs.append(nodemod.short(node_id))
886
887 if len(succs) <= 2:
888 reason = _("was split as: %s") % ", ".join(succs)
889 else:
890 firstsuccessors = ", ".join(succs[:2])
891 remainingnumber = len(succs) - 2
892
893 args = (firstsuccessors, remainingnumber)
894 successorsmsg = _("%s and %d more") % args
895 reason = _("was split as: %s") % successorsmsg
896
897 return reason
@@ -1,188 +1,188 b''
1 1 Tests for access level on hidden commits by various commands on based of their
2 2 type.
3 3
4 4 Setting the required config to start this
5 5
6 6 $ cat >> $HGRCPATH <<EOF
7 7 > [experimental]
8 8 > evolution=createmarkers, allowunstable
9 9 > directaccess=True
10 10 > directaccess.revnums=True
11 11 > [extensions]
12 12 > amend =
13 13 > EOF
14 14
15 15 $ hg init repo
16 16 $ cd repo
17 17 $ for ch in a b c; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done
18 18
19 19 $ hg log -G -T '{rev}:{node} {desc}' --hidden
20 20 @ 2:28ad74487de9599d00d81085be739c61fc340652 Added c
21 21 |
22 22 o 1:29becc82797a4bc11ec8880b58eaecd2ab3e7760 Added b
23 23 |
24 24 o 0:18d04c59bb5d2d4090ad9a5b59bd6274adb63add Added a
25 25
26 26 $ echo "bar" >> c
27 27 $ hg amend
28 28
29 29 $ hg log -G -T '{rev}:{node} {desc}' --hidden
30 30 @ 3:2443a0e664694756d8b435d06b6ad84f941b6fc0 Added c
31 31 |
32 32 | x 2:28ad74487de9599d00d81085be739c61fc340652 Added c
33 33 |/
34 34 o 1:29becc82797a4bc11ec8880b58eaecd2ab3e7760 Added b
35 35 |
36 36 o 0:18d04c59bb5d2d4090ad9a5b59bd6274adb63add Added a
37 37
38 38 Testing read only commands on the hidden revision
39 39
40 40 Testing with rev number
41 41
42 42 $ hg exp 2 --config experimental.directaccess.revnums=False
43 abort: hidden revision '2'!
43 abort: hidden revision '2' was rewritten as: 2443a0e66469!
44 44 (use --hidden to access hidden revisions)
45 45 [255]
46 46
47 47 $ hg exp 2
48 48 # HG changeset patch
49 49 # User test
50 50 # Date 0 0
51 51 # Thu Jan 01 00:00:00 1970 +0000
52 52 # Node ID 28ad74487de9599d00d81085be739c61fc340652
53 53 # Parent 29becc82797a4bc11ec8880b58eaecd2ab3e7760
54 54 Added c
55 55
56 56 diff -r 29becc82797a -r 28ad74487de9 c
57 57 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
58 58 +++ b/c Thu Jan 01 00:00:00 1970 +0000
59 59 @@ -0,0 +1,1 @@
60 60 +foo
61 61
62 62 $ hg log -r 2
63 63 changeset: 2:28ad74487de9
64 64 user: test
65 65 date: Thu Jan 01 00:00:00 1970 +0000
66 66 obsolete: rewritten using amend as 3:2443a0e66469
67 67 summary: Added c
68 68
69 69 $ hg identify -r 2
70 70 28ad74487de9
71 71
72 72 $ hg status --change 2
73 73 A c
74 74
75 75 $ hg status --change 2 --config experimental.directaccess.revnums=False
76 abort: hidden revision '2'!
76 abort: hidden revision '2' was rewritten as: 2443a0e66469!
77 77 (use --hidden to access hidden revisions)
78 78 [255]
79 79
80 80 $ hg diff -c 2
81 81 diff -r 29becc82797a -r 28ad74487de9 c
82 82 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
83 83 +++ b/c Thu Jan 01 00:00:00 1970 +0000
84 84 @@ -0,0 +1,1 @@
85 85 +foo
86 86
87 87 Testing with hash
88 88
89 89 `hg export`
90 90
91 91 $ hg exp 28ad74
92 92 # HG changeset patch
93 93 # User test
94 94 # Date 0 0
95 95 # Thu Jan 01 00:00:00 1970 +0000
96 96 # Node ID 28ad74487de9599d00d81085be739c61fc340652
97 97 # Parent 29becc82797a4bc11ec8880b58eaecd2ab3e7760
98 98 Added c
99 99
100 100 diff -r 29becc82797a -r 28ad74487de9 c
101 101 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
102 102 +++ b/c Thu Jan 01 00:00:00 1970 +0000
103 103 @@ -0,0 +1,1 @@
104 104 +foo
105 105
106 106 `hg log`
107 107
108 108 $ hg log -r 28ad74
109 109 changeset: 2:28ad74487de9
110 110 user: test
111 111 date: Thu Jan 01 00:00:00 1970 +0000
112 112 obsolete: rewritten using amend as 3:2443a0e66469
113 113 summary: Added c
114 114
115 115 `hg cat`
116 116
117 117 $ hg cat -r 28ad74 c
118 118 foo
119 119
120 120 `hg diff`
121 121
122 122 $ hg diff -c 28ad74
123 123 diff -r 29becc82797a -r 28ad74487de9 c
124 124 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
125 125 +++ b/c Thu Jan 01 00:00:00 1970 +0000
126 126 @@ -0,0 +1,1 @@
127 127 +foo
128 128
129 129 `hg files`
130 130
131 131 $ hg files -r 28ad74
132 132 a
133 133 b
134 134 c
135 135
136 136 `hg identify`
137 137
138 138 $ hg identify -r 28ad74
139 139 28ad74487de9
140 140
141 141 `hg annotate`
142 142
143 143 $ hg annotate -r 28ad74 a
144 144 0: foo
145 145
146 146 `hg status`
147 147
148 148 $ hg status --change 28ad74
149 149 A c
150 150
151 151 `hg archive`
152 152
153 153 This should not throw error
154 154 $ hg archive -r 28ad74 foo
155 155
156 156 `hg update`
157 157
158 158 $ hg up 28ad74
159 159 updating to a hidden changeset 28ad74487de9
160 160 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
161 161
162 162 $ hg up 3
163 163 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
164 164
165 165 `hg revert`
166 166
167 167 $ hg revert -r 28ad74 --all
168 168 reverting c
169 169
170 170 $ hg diff
171 171 diff -r 2443a0e66469 c
172 172 --- a/c Thu Jan 01 00:00:00 1970 +0000
173 173 +++ b/c Thu Jan 01 00:00:00 1970 +0000
174 174 @@ -1,2 +1,1 @@
175 175 foo
176 176 -bar
177 177
178 178 Commands with undefined cmdtype should not work right now
179 179
180 180 $ hg phase -r 28ad74
181 abort: hidden revision '28ad74'!
181 abort: hidden revision '28ad74' was rewritten as: 2443a0e66469!
182 182 (use --hidden to access hidden revisions)
183 183 [255]
184 184
185 185 $ hg phase -r 2
186 abort: hidden revision '2'!
186 abort: hidden revision '2' was rewritten as: 2443a0e66469!
187 187 (use --hidden to access hidden revisions)
188 188 [255]
@@ -1,2506 +1,2506 b''
1 1 Log on empty repository: checking consistency
2 2
3 3 $ hg init empty
4 4 $ cd empty
5 5 $ hg log
6 6 $ hg log -r 1
7 7 abort: unknown revision '1'!
8 8 [255]
9 9 $ hg log -r -1:0
10 10 abort: unknown revision '-1'!
11 11 [255]
12 12 $ hg log -r 'branch(name)'
13 13 abort: unknown revision 'name'!
14 14 [255]
15 15 $ hg log -r null -q
16 16 -1:000000000000
17 17
18 18 $ cd ..
19 19
20 20 The g is crafted to have 2 filelog topological heads in a linear
21 21 changeset graph
22 22
23 23 $ hg init a
24 24 $ cd a
25 25 $ echo a > a
26 26 $ echo f > f
27 27 $ hg ci -Ama -d '1 0'
28 28 adding a
29 29 adding f
30 30
31 31 $ hg cp a b
32 32 $ hg cp f g
33 33 $ hg ci -mb -d '2 0'
34 34
35 35 $ mkdir dir
36 36 $ hg mv b dir
37 37 $ echo g >> g
38 38 $ echo f >> f
39 39 $ hg ci -mc -d '3 0'
40 40
41 41 $ hg mv a b
42 42 $ hg cp -f f g
43 43 $ echo a > d
44 44 $ hg add d
45 45 $ hg ci -md -d '4 0'
46 46
47 47 $ hg mv dir/b e
48 48 $ hg ci -me -d '5 0'
49 49
50 50 Make sure largefiles doesn't interfere with logging a regular file
51 51 $ hg --debug log a -T '{rev}: {desc}\n' --config extensions.largefiles=
52 52 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
53 53 updated patterns: .hglf/a, a
54 54 0: a
55 55 $ hg log a
56 56 changeset: 0:9161b9aeaf16
57 57 user: test
58 58 date: Thu Jan 01 00:00:01 1970 +0000
59 59 summary: a
60 60
61 61 $ hg log glob:a*
62 62 changeset: 3:2ca5ba701980
63 63 user: test
64 64 date: Thu Jan 01 00:00:04 1970 +0000
65 65 summary: d
66 66
67 67 changeset: 0:9161b9aeaf16
68 68 user: test
69 69 date: Thu Jan 01 00:00:01 1970 +0000
70 70 summary: a
71 71
72 72 $ hg --debug log glob:a* -T '{rev}: {desc}\n' --config extensions.largefiles=
73 73 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
74 74 updated patterns: glob:.hglf/a*, glob:a*
75 75 3: d
76 76 0: a
77 77
78 78 log on directory
79 79
80 80 $ hg log dir
81 81 changeset: 4:7e4639b4691b
82 82 tag: tip
83 83 user: test
84 84 date: Thu Jan 01 00:00:05 1970 +0000
85 85 summary: e
86 86
87 87 changeset: 2:f8954cd4dc1f
88 88 user: test
89 89 date: Thu Jan 01 00:00:03 1970 +0000
90 90 summary: c
91 91
92 92 $ hg log somethingthatdoesntexist dir
93 93 changeset: 4:7e4639b4691b
94 94 tag: tip
95 95 user: test
96 96 date: Thu Jan 01 00:00:05 1970 +0000
97 97 summary: e
98 98
99 99 changeset: 2:f8954cd4dc1f
100 100 user: test
101 101 date: Thu Jan 01 00:00:03 1970 +0000
102 102 summary: c
103 103
104 104
105 105 -f, non-existent directory
106 106
107 107 $ hg log -f dir
108 108 abort: cannot follow file not in parent revision: "dir"
109 109 [255]
110 110
111 111 -f, directory
112 112
113 113 $ hg up -q 3
114 114 $ hg log -f dir
115 115 changeset: 2:f8954cd4dc1f
116 116 user: test
117 117 date: Thu Jan 01 00:00:03 1970 +0000
118 118 summary: c
119 119
120 120 -f, directory with --patch
121 121
122 122 $ hg log -f dir -p
123 123 changeset: 2:f8954cd4dc1f
124 124 user: test
125 125 date: Thu Jan 01 00:00:03 1970 +0000
126 126 summary: c
127 127
128 128 diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
129 129 --- /dev/null* (glob)
130 130 +++ b/dir/b* (glob)
131 131 @@ -0,0 +1,1 @@
132 132 +a
133 133
134 134
135 135 -f, pattern
136 136
137 137 $ hg log -f -I 'dir**' -p
138 138 changeset: 2:f8954cd4dc1f
139 139 user: test
140 140 date: Thu Jan 01 00:00:03 1970 +0000
141 141 summary: c
142 142
143 143 diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
144 144 --- /dev/null* (glob)
145 145 +++ b/dir/b* (glob)
146 146 @@ -0,0 +1,1 @@
147 147 +a
148 148
149 149 $ hg up -q 4
150 150
151 151 -f, a wrong style
152 152
153 153 $ hg log -f -l1 --style something
154 154 abort: style 'something' not found
155 155 (available styles: bisect, changelog, compact, default, phases, show, status, xml)
156 156 [255]
157 157
158 158 -f, phases style
159 159
160 160
161 161 $ hg log -f -l1 --style phases
162 162 changeset: 4:7e4639b4691b
163 163 tag: tip
164 164 phase: draft
165 165 user: test
166 166 date: Thu Jan 01 00:00:05 1970 +0000
167 167 summary: e
168 168
169 169
170 170 $ hg log -f -l1 --style phases -q
171 171 4:7e4639b4691b
172 172
173 173 -f, but no args
174 174
175 175 $ hg log -f
176 176 changeset: 4:7e4639b4691b
177 177 tag: tip
178 178 user: test
179 179 date: Thu Jan 01 00:00:05 1970 +0000
180 180 summary: e
181 181
182 182 changeset: 3:2ca5ba701980
183 183 user: test
184 184 date: Thu Jan 01 00:00:04 1970 +0000
185 185 summary: d
186 186
187 187 changeset: 2:f8954cd4dc1f
188 188 user: test
189 189 date: Thu Jan 01 00:00:03 1970 +0000
190 190 summary: c
191 191
192 192 changeset: 1:d89b0a12d229
193 193 user: test
194 194 date: Thu Jan 01 00:00:02 1970 +0000
195 195 summary: b
196 196
197 197 changeset: 0:9161b9aeaf16
198 198 user: test
199 199 date: Thu Jan 01 00:00:01 1970 +0000
200 200 summary: a
201 201
202 202
203 203 one rename
204 204
205 205 $ hg up -q 2
206 206 $ hg log -vf a
207 207 changeset: 0:9161b9aeaf16
208 208 user: test
209 209 date: Thu Jan 01 00:00:01 1970 +0000
210 210 files: a f
211 211 description:
212 212 a
213 213
214 214
215 215
216 216 many renames
217 217
218 218 $ hg up -q tip
219 219 $ hg log -vf e
220 220 changeset: 4:7e4639b4691b
221 221 tag: tip
222 222 user: test
223 223 date: Thu Jan 01 00:00:05 1970 +0000
224 224 files: dir/b e
225 225 description:
226 226 e
227 227
228 228
229 229 changeset: 2:f8954cd4dc1f
230 230 user: test
231 231 date: Thu Jan 01 00:00:03 1970 +0000
232 232 files: b dir/b f g
233 233 description:
234 234 c
235 235
236 236
237 237 changeset: 1:d89b0a12d229
238 238 user: test
239 239 date: Thu Jan 01 00:00:02 1970 +0000
240 240 files: b g
241 241 description:
242 242 b
243 243
244 244
245 245 changeset: 0:9161b9aeaf16
246 246 user: test
247 247 date: Thu Jan 01 00:00:01 1970 +0000
248 248 files: a f
249 249 description:
250 250 a
251 251
252 252
253 253
254 254
255 255 log -pf dir/b
256 256
257 257 $ hg up -q 3
258 258 $ hg log -pf dir/b
259 259 changeset: 2:f8954cd4dc1f
260 260 user: test
261 261 date: Thu Jan 01 00:00:03 1970 +0000
262 262 summary: c
263 263
264 264 diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
265 265 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
266 266 +++ b/dir/b Thu Jan 01 00:00:03 1970 +0000
267 267 @@ -0,0 +1,1 @@
268 268 +a
269 269
270 270 changeset: 1:d89b0a12d229
271 271 user: test
272 272 date: Thu Jan 01 00:00:02 1970 +0000
273 273 summary: b
274 274
275 275 diff -r 9161b9aeaf16 -r d89b0a12d229 b
276 276 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
277 277 +++ b/b Thu Jan 01 00:00:02 1970 +0000
278 278 @@ -0,0 +1,1 @@
279 279 +a
280 280
281 281 changeset: 0:9161b9aeaf16
282 282 user: test
283 283 date: Thu Jan 01 00:00:01 1970 +0000
284 284 summary: a
285 285
286 286 diff -r 000000000000 -r 9161b9aeaf16 a
287 287 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
288 288 +++ b/a Thu Jan 01 00:00:01 1970 +0000
289 289 @@ -0,0 +1,1 @@
290 290 +a
291 291
292 292
293 293 log -pf b inside dir
294 294
295 295 $ hg --cwd=dir log -pf b
296 296 changeset: 2:f8954cd4dc1f
297 297 user: test
298 298 date: Thu Jan 01 00:00:03 1970 +0000
299 299 summary: c
300 300
301 301 diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
302 302 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
303 303 +++ b/dir/b Thu Jan 01 00:00:03 1970 +0000
304 304 @@ -0,0 +1,1 @@
305 305 +a
306 306
307 307 changeset: 1:d89b0a12d229
308 308 user: test
309 309 date: Thu Jan 01 00:00:02 1970 +0000
310 310 summary: b
311 311
312 312 diff -r 9161b9aeaf16 -r d89b0a12d229 b
313 313 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
314 314 +++ b/b Thu Jan 01 00:00:02 1970 +0000
315 315 @@ -0,0 +1,1 @@
316 316 +a
317 317
318 318 changeset: 0:9161b9aeaf16
319 319 user: test
320 320 date: Thu Jan 01 00:00:01 1970 +0000
321 321 summary: a
322 322
323 323 diff -r 000000000000 -r 9161b9aeaf16 a
324 324 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
325 325 +++ b/a Thu Jan 01 00:00:01 1970 +0000
326 326 @@ -0,0 +1,1 @@
327 327 +a
328 328
329 329
330 330 log -pf, but no args
331 331
332 332 $ hg log -pf
333 333 changeset: 3:2ca5ba701980
334 334 user: test
335 335 date: Thu Jan 01 00:00:04 1970 +0000
336 336 summary: d
337 337
338 338 diff -r f8954cd4dc1f -r 2ca5ba701980 a
339 339 --- a/a Thu Jan 01 00:00:03 1970 +0000
340 340 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
341 341 @@ -1,1 +0,0 @@
342 342 -a
343 343 diff -r f8954cd4dc1f -r 2ca5ba701980 b
344 344 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
345 345 +++ b/b Thu Jan 01 00:00:04 1970 +0000
346 346 @@ -0,0 +1,1 @@
347 347 +a
348 348 diff -r f8954cd4dc1f -r 2ca5ba701980 d
349 349 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
350 350 +++ b/d Thu Jan 01 00:00:04 1970 +0000
351 351 @@ -0,0 +1,1 @@
352 352 +a
353 353 diff -r f8954cd4dc1f -r 2ca5ba701980 g
354 354 --- a/g Thu Jan 01 00:00:03 1970 +0000
355 355 +++ b/g Thu Jan 01 00:00:04 1970 +0000
356 356 @@ -1,2 +1,2 @@
357 357 f
358 358 -g
359 359 +f
360 360
361 361 changeset: 2:f8954cd4dc1f
362 362 user: test
363 363 date: Thu Jan 01 00:00:03 1970 +0000
364 364 summary: c
365 365
366 366 diff -r d89b0a12d229 -r f8954cd4dc1f b
367 367 --- a/b Thu Jan 01 00:00:02 1970 +0000
368 368 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
369 369 @@ -1,1 +0,0 @@
370 370 -a
371 371 diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
372 372 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
373 373 +++ b/dir/b Thu Jan 01 00:00:03 1970 +0000
374 374 @@ -0,0 +1,1 @@
375 375 +a
376 376 diff -r d89b0a12d229 -r f8954cd4dc1f f
377 377 --- a/f Thu Jan 01 00:00:02 1970 +0000
378 378 +++ b/f Thu Jan 01 00:00:03 1970 +0000
379 379 @@ -1,1 +1,2 @@
380 380 f
381 381 +f
382 382 diff -r d89b0a12d229 -r f8954cd4dc1f g
383 383 --- a/g Thu Jan 01 00:00:02 1970 +0000
384 384 +++ b/g Thu Jan 01 00:00:03 1970 +0000
385 385 @@ -1,1 +1,2 @@
386 386 f
387 387 +g
388 388
389 389 changeset: 1:d89b0a12d229
390 390 user: test
391 391 date: Thu Jan 01 00:00:02 1970 +0000
392 392 summary: b
393 393
394 394 diff -r 9161b9aeaf16 -r d89b0a12d229 b
395 395 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
396 396 +++ b/b Thu Jan 01 00:00:02 1970 +0000
397 397 @@ -0,0 +1,1 @@
398 398 +a
399 399 diff -r 9161b9aeaf16 -r d89b0a12d229 g
400 400 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
401 401 +++ b/g Thu Jan 01 00:00:02 1970 +0000
402 402 @@ -0,0 +1,1 @@
403 403 +f
404 404
405 405 changeset: 0:9161b9aeaf16
406 406 user: test
407 407 date: Thu Jan 01 00:00:01 1970 +0000
408 408 summary: a
409 409
410 410 diff -r 000000000000 -r 9161b9aeaf16 a
411 411 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
412 412 +++ b/a Thu Jan 01 00:00:01 1970 +0000
413 413 @@ -0,0 +1,1 @@
414 414 +a
415 415 diff -r 000000000000 -r 9161b9aeaf16 f
416 416 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
417 417 +++ b/f Thu Jan 01 00:00:01 1970 +0000
418 418 @@ -0,0 +1,1 @@
419 419 +f
420 420
421 421
422 422 log -vf dir/b
423 423
424 424 $ hg log -vf dir/b
425 425 changeset: 2:f8954cd4dc1f
426 426 user: test
427 427 date: Thu Jan 01 00:00:03 1970 +0000
428 428 files: b dir/b f g
429 429 description:
430 430 c
431 431
432 432
433 433 changeset: 1:d89b0a12d229
434 434 user: test
435 435 date: Thu Jan 01 00:00:02 1970 +0000
436 436 files: b g
437 437 description:
438 438 b
439 439
440 440
441 441 changeset: 0:9161b9aeaf16
442 442 user: test
443 443 date: Thu Jan 01 00:00:01 1970 +0000
444 444 files: a f
445 445 description:
446 446 a
447 447
448 448
449 449
450 450
451 451 -f and multiple filelog heads
452 452
453 453 $ hg up -q 2
454 454 $ hg log -f g --template '{rev}\n'
455 455 2
456 456 1
457 457 0
458 458 $ hg up -q tip
459 459 $ hg log -f g --template '{rev}\n'
460 460 3
461 461 2
462 462 0
463 463
464 464
465 465 log copies with --copies
466 466
467 467 $ hg log -vC --template '{rev} {file_copies}\n'
468 468 4 e (dir/b)
469 469 3 b (a)g (f)
470 470 2 dir/b (b)
471 471 1 b (a)g (f)
472 472 0
473 473
474 474 log copies switch without --copies, with old filecopy template
475 475
476 476 $ hg log -v --template '{rev} {file_copies_switch%filecopy}\n'
477 477 4
478 478 3
479 479 2
480 480 1
481 481 0
482 482
483 483 log copies switch with --copies
484 484
485 485 $ hg log -vC --template '{rev} {file_copies_switch}\n'
486 486 4 e (dir/b)
487 487 3 b (a)g (f)
488 488 2 dir/b (b)
489 489 1 b (a)g (f)
490 490 0
491 491
492 492
493 493 log copies with hardcoded style and with --style=default
494 494
495 495 $ hg log -vC -r4
496 496 changeset: 4:7e4639b4691b
497 497 tag: tip
498 498 user: test
499 499 date: Thu Jan 01 00:00:05 1970 +0000
500 500 files: dir/b e
501 501 copies: e (dir/b)
502 502 description:
503 503 e
504 504
505 505
506 506 $ hg log -vC -r4 --style=default
507 507 changeset: 4:7e4639b4691b
508 508 tag: tip
509 509 user: test
510 510 date: Thu Jan 01 00:00:05 1970 +0000
511 511 files: dir/b e
512 512 copies: e (dir/b)
513 513 description:
514 514 e
515 515
516 516
517 517 $ hg log -vC -r4 -Tjson
518 518 [
519 519 {
520 520 "rev": 4,
521 521 "node": "7e4639b4691b9f84b81036a8d4fb218ce3c5e3a3",
522 522 "branch": "default",
523 523 "phase": "draft",
524 524 "user": "test",
525 525 "date": [5, 0],
526 526 "desc": "e",
527 527 "bookmarks": [],
528 528 "tags": ["tip"],
529 529 "parents": ["2ca5ba7019804f1f597249caddf22a64d34df0ba"],
530 530 "files": ["dir/b", "e"],
531 531 "copies": {"e": "dir/b"}
532 532 }
533 533 ]
534 534
535 535 log copies, non-linear manifest
536 536
537 537 $ hg up -C 3
538 538 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
539 539 $ hg mv dir/b e
540 540 $ echo foo > foo
541 541 $ hg ci -Ame2 -d '6 0'
542 542 adding foo
543 543 created new head
544 544 $ hg log -v --template '{rev} {file_copies}\n' -r 5
545 545 5 e (dir/b)
546 546
547 547
548 548 log copies, execute bit set
549 549
550 550 #if execbit
551 551 $ chmod +x e
552 552 $ hg ci -me3 -d '7 0'
553 553 $ hg log -v --template '{rev} {file_copies}\n' -r 6
554 554 6
555 555 #endif
556 556
557 557
558 558 log -p d
559 559
560 560 $ hg log -pv d
561 561 changeset: 3:2ca5ba701980
562 562 user: test
563 563 date: Thu Jan 01 00:00:04 1970 +0000
564 564 files: a b d g
565 565 description:
566 566 d
567 567
568 568
569 569 diff -r f8954cd4dc1f -r 2ca5ba701980 d
570 570 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
571 571 +++ b/d Thu Jan 01 00:00:04 1970 +0000
572 572 @@ -0,0 +1,1 @@
573 573 +a
574 574
575 575
576 576
577 577 log --removed file
578 578
579 579 $ hg log --removed -v a
580 580 changeset: 3:2ca5ba701980
581 581 user: test
582 582 date: Thu Jan 01 00:00:04 1970 +0000
583 583 files: a b d g
584 584 description:
585 585 d
586 586
587 587
588 588 changeset: 0:9161b9aeaf16
589 589 user: test
590 590 date: Thu Jan 01 00:00:01 1970 +0000
591 591 files: a f
592 592 description:
593 593 a
594 594
595 595
596 596
597 597 log --removed revrange file
598 598
599 599 $ hg log --removed -v -r0:2 a
600 600 changeset: 0:9161b9aeaf16
601 601 user: test
602 602 date: Thu Jan 01 00:00:01 1970 +0000
603 603 files: a f
604 604 description:
605 605 a
606 606
607 607
608 608 $ cd ..
609 609
610 610 log --follow tests
611 611
612 612 $ hg init follow
613 613 $ cd follow
614 614
615 615 $ echo base > base
616 616 $ hg ci -Ambase -d '1 0'
617 617 adding base
618 618
619 619 $ echo r1 >> base
620 620 $ hg ci -Amr1 -d '1 0'
621 621 $ echo r2 >> base
622 622 $ hg ci -Amr2 -d '1 0'
623 623
624 624 $ hg up -C 1
625 625 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
626 626 $ echo b1 > b1
627 627
628 628 log -r "follow('set:clean()')"
629 629
630 630 $ hg log -r "follow('set:clean()')"
631 631 changeset: 0:67e992f2c4f3
632 632 user: test
633 633 date: Thu Jan 01 00:00:01 1970 +0000
634 634 summary: base
635 635
636 636 changeset: 1:3d5bf5654eda
637 637 user: test
638 638 date: Thu Jan 01 00:00:01 1970 +0000
639 639 summary: r1
640 640
641 641
642 642 $ hg ci -Amb1 -d '1 0'
643 643 adding b1
644 644 created new head
645 645
646 646
647 647 log -f
648 648
649 649 $ hg log -f
650 650 changeset: 3:e62f78d544b4
651 651 tag: tip
652 652 parent: 1:3d5bf5654eda
653 653 user: test
654 654 date: Thu Jan 01 00:00:01 1970 +0000
655 655 summary: b1
656 656
657 657 changeset: 1:3d5bf5654eda
658 658 user: test
659 659 date: Thu Jan 01 00:00:01 1970 +0000
660 660 summary: r1
661 661
662 662 changeset: 0:67e992f2c4f3
663 663 user: test
664 664 date: Thu Jan 01 00:00:01 1970 +0000
665 665 summary: base
666 666
667 667
668 668 log -r follow('glob:b*')
669 669
670 670 $ hg log -r "follow('glob:b*')"
671 671 changeset: 0:67e992f2c4f3
672 672 user: test
673 673 date: Thu Jan 01 00:00:01 1970 +0000
674 674 summary: base
675 675
676 676 changeset: 1:3d5bf5654eda
677 677 user: test
678 678 date: Thu Jan 01 00:00:01 1970 +0000
679 679 summary: r1
680 680
681 681 changeset: 3:e62f78d544b4
682 682 tag: tip
683 683 parent: 1:3d5bf5654eda
684 684 user: test
685 685 date: Thu Jan 01 00:00:01 1970 +0000
686 686 summary: b1
687 687
688 688 log -f -r '1 + 4'
689 689
690 690 $ hg up -C 0
691 691 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
692 692 $ echo b2 > b2
693 693 $ hg ci -Amb2 -d '1 0'
694 694 adding b2
695 695 created new head
696 696 $ hg log -f -r '1 + 4'
697 697 changeset: 4:ddb82e70d1a1
698 698 tag: tip
699 699 parent: 0:67e992f2c4f3
700 700 user: test
701 701 date: Thu Jan 01 00:00:01 1970 +0000
702 702 summary: b2
703 703
704 704 changeset: 1:3d5bf5654eda
705 705 user: test
706 706 date: Thu Jan 01 00:00:01 1970 +0000
707 707 summary: r1
708 708
709 709 changeset: 0:67e992f2c4f3
710 710 user: test
711 711 date: Thu Jan 01 00:00:01 1970 +0000
712 712 summary: base
713 713
714 714 log -r "follow('set:grep(b2)')"
715 715
716 716 $ hg log -r "follow('set:grep(b2)')"
717 717 changeset: 4:ddb82e70d1a1
718 718 tag: tip
719 719 parent: 0:67e992f2c4f3
720 720 user: test
721 721 date: Thu Jan 01 00:00:01 1970 +0000
722 722 summary: b2
723 723
724 724 log -r "follow('set:grep(b2)', 4)"
725 725
726 726 $ hg up -qC 0
727 727 $ hg log -r "follow('set:grep(b2)', 4)"
728 728 changeset: 4:ddb82e70d1a1
729 729 tag: tip
730 730 parent: 0:67e992f2c4f3
731 731 user: test
732 732 date: Thu Jan 01 00:00:01 1970 +0000
733 733 summary: b2
734 734
735 735
736 736 follow files starting from multiple revisions:
737 737
738 738 $ hg log -T '{rev}: {files}\n' -r "follow('glob:b?', startrev=2+3+4)"
739 739 3: b1
740 740 4: b2
741 741
742 742 follow files starting from empty revision:
743 743
744 744 $ hg log -T '{rev}: {files}\n' -r "follow('glob:*', startrev=.-.)"
745 745
746 746 follow starting from revisions:
747 747
748 748 $ hg log -Gq -r "follow(startrev=2+4)"
749 749 o 4:ddb82e70d1a1
750 750 |
751 751 | o 2:60c670bf5b30
752 752 | |
753 753 | o 1:3d5bf5654eda
754 754 |/
755 755 @ 0:67e992f2c4f3
756 756
757 757
758 758 follow the current revision:
759 759
760 760 $ hg log -Gq -r "follow()"
761 761 @ 0:67e992f2c4f3
762 762
763 763
764 764 $ hg up -qC 4
765 765
766 766 log -f -r null
767 767
768 768 $ hg log -f -r null
769 769 changeset: -1:000000000000
770 770 user:
771 771 date: Thu Jan 01 00:00:00 1970 +0000
772 772
773 773 $ hg log -f -r null -G
774 774 o changeset: -1:000000000000
775 775 user:
776 776 date: Thu Jan 01 00:00:00 1970 +0000
777 777
778 778
779 779
780 780 log -f with null parent
781 781
782 782 $ hg up -C null
783 783 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
784 784 $ hg log -f
785 785
786 786
787 787 log -r . with two parents
788 788
789 789 $ hg up -C 3
790 790 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
791 791 $ hg merge tip
792 792 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
793 793 (branch merge, don't forget to commit)
794 794 $ hg log -r .
795 795 changeset: 3:e62f78d544b4
796 796 parent: 1:3d5bf5654eda
797 797 user: test
798 798 date: Thu Jan 01 00:00:01 1970 +0000
799 799 summary: b1
800 800
801 801
802 802
803 803 log -r . with one parent
804 804
805 805 $ hg ci -mm12 -d '1 0'
806 806 $ hg log -r .
807 807 changeset: 5:302e9dd6890d
808 808 tag: tip
809 809 parent: 3:e62f78d544b4
810 810 parent: 4:ddb82e70d1a1
811 811 user: test
812 812 date: Thu Jan 01 00:00:01 1970 +0000
813 813 summary: m12
814 814
815 815
816 816 $ echo postm >> b1
817 817 $ hg ci -Amb1.1 -d'1 0'
818 818
819 819
820 820 log --follow-first
821 821
822 822 $ hg log --follow-first
823 823 changeset: 6:2404bbcab562
824 824 tag: tip
825 825 user: test
826 826 date: Thu Jan 01 00:00:01 1970 +0000
827 827 summary: b1.1
828 828
829 829 changeset: 5:302e9dd6890d
830 830 parent: 3:e62f78d544b4
831 831 parent: 4:ddb82e70d1a1
832 832 user: test
833 833 date: Thu Jan 01 00:00:01 1970 +0000
834 834 summary: m12
835 835
836 836 changeset: 3:e62f78d544b4
837 837 parent: 1:3d5bf5654eda
838 838 user: test
839 839 date: Thu Jan 01 00:00:01 1970 +0000
840 840 summary: b1
841 841
842 842 changeset: 1:3d5bf5654eda
843 843 user: test
844 844 date: Thu Jan 01 00:00:01 1970 +0000
845 845 summary: r1
846 846
847 847 changeset: 0:67e992f2c4f3
848 848 user: test
849 849 date: Thu Jan 01 00:00:01 1970 +0000
850 850 summary: base
851 851
852 852
853 853
854 854 log -P 2
855 855
856 856 $ hg log -P 2
857 857 changeset: 6:2404bbcab562
858 858 tag: tip
859 859 user: test
860 860 date: Thu Jan 01 00:00:01 1970 +0000
861 861 summary: b1.1
862 862
863 863 changeset: 5:302e9dd6890d
864 864 parent: 3:e62f78d544b4
865 865 parent: 4:ddb82e70d1a1
866 866 user: test
867 867 date: Thu Jan 01 00:00:01 1970 +0000
868 868 summary: m12
869 869
870 870 changeset: 4:ddb82e70d1a1
871 871 parent: 0:67e992f2c4f3
872 872 user: test
873 873 date: Thu Jan 01 00:00:01 1970 +0000
874 874 summary: b2
875 875
876 876 changeset: 3:e62f78d544b4
877 877 parent: 1:3d5bf5654eda
878 878 user: test
879 879 date: Thu Jan 01 00:00:01 1970 +0000
880 880 summary: b1
881 881
882 882
883 883
884 884 log -r tip -p --git
885 885
886 886 $ hg log -r tip -p --git
887 887 changeset: 6:2404bbcab562
888 888 tag: tip
889 889 user: test
890 890 date: Thu Jan 01 00:00:01 1970 +0000
891 891 summary: b1.1
892 892
893 893 diff --git a/b1 b/b1
894 894 --- a/b1
895 895 +++ b/b1
896 896 @@ -1,1 +1,2 @@
897 897 b1
898 898 +postm
899 899
900 900
901 901
902 902 log -r ""
903 903
904 904 $ hg log -r ''
905 905 hg: parse error: empty query
906 906 [255]
907 907
908 908 log -r <some unknown node id>
909 909
910 910 $ hg log -r 1000000000000000000000000000000000000000
911 911 abort: unknown revision '1000000000000000000000000000000000000000'!
912 912 [255]
913 913
914 914 log -k r1
915 915
916 916 $ hg log -k r1
917 917 changeset: 1:3d5bf5654eda
918 918 user: test
919 919 date: Thu Jan 01 00:00:01 1970 +0000
920 920 summary: r1
921 921
922 922 log -p -l2 --color=always
923 923
924 924 $ hg --config extensions.color= --config color.mode=ansi \
925 925 > log -p -l2 --color=always
926 926 \x1b[0;33mchangeset: 6:2404bbcab562\x1b[0m (esc)
927 927 tag: tip
928 928 user: test
929 929 date: Thu Jan 01 00:00:01 1970 +0000
930 930 summary: b1.1
931 931
932 932 \x1b[0;1mdiff -r 302e9dd6890d -r 2404bbcab562 b1\x1b[0m (esc)
933 933 \x1b[0;31;1m--- a/b1 Thu Jan 01 00:00:01 1970 +0000\x1b[0m (esc)
934 934 \x1b[0;32;1m+++ b/b1 Thu Jan 01 00:00:01 1970 +0000\x1b[0m (esc)
935 935 \x1b[0;35m@@ -1,1 +1,2 @@\x1b[0m (esc)
936 936 b1
937 937 \x1b[0;32m+postm\x1b[0m (esc)
938 938
939 939 \x1b[0;33mchangeset: 5:302e9dd6890d\x1b[0m (esc)
940 940 parent: 3:e62f78d544b4
941 941 parent: 4:ddb82e70d1a1
942 942 user: test
943 943 date: Thu Jan 01 00:00:01 1970 +0000
944 944 summary: m12
945 945
946 946 \x1b[0;1mdiff -r e62f78d544b4 -r 302e9dd6890d b2\x1b[0m (esc)
947 947 \x1b[0;31;1m--- /dev/null Thu Jan 01 00:00:00 1970 +0000\x1b[0m (esc)
948 948 \x1b[0;32;1m+++ b/b2 Thu Jan 01 00:00:01 1970 +0000\x1b[0m (esc)
949 949 \x1b[0;35m@@ -0,0 +1,1 @@\x1b[0m (esc)
950 950 \x1b[0;32m+b2\x1b[0m (esc)
951 951
952 952
953 953
954 954 log -r tip --stat
955 955
956 956 $ hg log -r tip --stat
957 957 changeset: 6:2404bbcab562
958 958 tag: tip
959 959 user: test
960 960 date: Thu Jan 01 00:00:01 1970 +0000
961 961 summary: b1.1
962 962
963 963 b1 | 1 +
964 964 1 files changed, 1 insertions(+), 0 deletions(-)
965 965
966 966
967 967 $ cd ..
968 968
969 969 log --follow --patch FILE in repository where linkrev isn't trustworthy
970 970 (issue5376)
971 971
972 972 $ hg init follow-dup
973 973 $ cd follow-dup
974 974 $ cat <<EOF >> .hg/hgrc
975 975 > [ui]
976 976 > logtemplate = '=== {rev}: {desc}\n'
977 977 > [diff]
978 978 > nodates = True
979 979 > EOF
980 980 $ echo 0 >> a
981 981 $ hg ci -qAm 'a0'
982 982 $ echo 1 >> a
983 983 $ hg ci -m 'a1'
984 984 $ hg up -q 0
985 985 $ echo 1 >> a
986 986 $ touch b
987 987 $ hg ci -qAm 'a1 with b'
988 988 $ echo 3 >> a
989 989 $ hg ci -m 'a3'
990 990
991 991 fctx.rev() == 2, but fctx.linkrev() == 1
992 992
993 993 $ hg log -pf a
994 994 === 3: a3
995 995 diff -r 4ea02ba94d66 -r e7a6331a34f0 a
996 996 --- a/a
997 997 +++ b/a
998 998 @@ -1,2 +1,3 @@
999 999 0
1000 1000 1
1001 1001 +3
1002 1002
1003 1003 === 2: a1 with b
1004 1004 diff -r 49b5e81287e2 -r 4ea02ba94d66 a
1005 1005 --- a/a
1006 1006 +++ b/a
1007 1007 @@ -1,1 +1,2 @@
1008 1008 0
1009 1009 +1
1010 1010
1011 1011 === 0: a0
1012 1012 diff -r 000000000000 -r 49b5e81287e2 a
1013 1013 --- /dev/null
1014 1014 +++ b/a
1015 1015 @@ -0,0 +1,1 @@
1016 1016 +0
1017 1017
1018 1018
1019 1019 fctx.introrev() == 2, but fctx.linkrev() == 1
1020 1020
1021 1021 $ hg up -q 2
1022 1022 $ hg log -pf a
1023 1023 === 2: a1 with b
1024 1024 diff -r 49b5e81287e2 -r 4ea02ba94d66 a
1025 1025 --- a/a
1026 1026 +++ b/a
1027 1027 @@ -1,1 +1,2 @@
1028 1028 0
1029 1029 +1
1030 1030
1031 1031 === 0: a0
1032 1032 diff -r 000000000000 -r 49b5e81287e2 a
1033 1033 --- /dev/null
1034 1034 +++ b/a
1035 1035 @@ -0,0 +1,1 @@
1036 1036 +0
1037 1037
1038 1038
1039 1039 $ cd ..
1040 1040
1041 1041 Multiple copy sources of a file:
1042 1042
1043 1043 $ hg init follow-multi
1044 1044 $ cd follow-multi
1045 1045 $ echo 0 >> a
1046 1046 $ hg ci -qAm 'a'
1047 1047 $ hg cp a b
1048 1048 $ hg ci -m 'a->b'
1049 1049 $ echo 2 >> a
1050 1050 $ hg ci -m 'a'
1051 1051 $ echo 3 >> b
1052 1052 $ hg ci -m 'b'
1053 1053 $ echo 4 >> a
1054 1054 $ echo 4 >> b
1055 1055 $ hg ci -m 'a,b'
1056 1056 $ echo 5 >> a
1057 1057 $ hg ci -m 'a0'
1058 1058 $ echo 6 >> b
1059 1059 $ hg ci -m 'b0'
1060 1060 $ hg up -q 4
1061 1061 $ echo 7 >> b
1062 1062 $ hg ci -m 'b1'
1063 1063 created new head
1064 1064 $ echo 8 >> a
1065 1065 $ hg ci -m 'a1'
1066 1066 $ hg rm a
1067 1067 $ hg mv b a
1068 1068 $ hg ci -m 'b1->a1'
1069 1069 $ hg merge -qt :local
1070 1070 $ hg ci -m '(a0,b1->a1)->a'
1071 1071
1072 1072 $ hg log -GT '{rev}: {desc}\n'
1073 1073 @ 10: (a0,b1->a1)->a
1074 1074 |\
1075 1075 | o 9: b1->a1
1076 1076 | |
1077 1077 | o 8: a1
1078 1078 | |
1079 1079 | o 7: b1
1080 1080 | |
1081 1081 o | 6: b0
1082 1082 | |
1083 1083 o | 5: a0
1084 1084 |/
1085 1085 o 4: a,b
1086 1086 |
1087 1087 o 3: b
1088 1088 |
1089 1089 o 2: a
1090 1090 |
1091 1091 o 1: a->b
1092 1092 |
1093 1093 o 0: a
1094 1094
1095 1095
1096 1096 since file 'a' has multiple copy sources at the revision 4, ancestors can't
1097 1097 be indexed solely by fctx.linkrev().
1098 1098
1099 1099 $ hg log -T '{rev}: {desc}\n' -f a
1100 1100 10: (a0,b1->a1)->a
1101 1101 9: b1->a1
1102 1102 7: b1
1103 1103 5: a0
1104 1104 4: a,b
1105 1105 3: b
1106 1106 2: a
1107 1107 1: a->b
1108 1108 0: a
1109 1109
1110 1110 $ cd ..
1111 1111
1112 1112 Test that log should respect the order of -rREV even if multiple OR conditions
1113 1113 are specified (issue5100):
1114 1114
1115 1115 $ hg init revorder
1116 1116 $ cd revorder
1117 1117
1118 1118 $ hg branch -q b0
1119 1119 $ echo 0 >> f0
1120 1120 $ hg ci -qAm k0 -u u0
1121 1121 $ hg branch -q b1
1122 1122 $ echo 1 >> f1
1123 1123 $ hg ci -qAm k1 -u u1
1124 1124 $ hg branch -q b2
1125 1125 $ echo 2 >> f2
1126 1126 $ hg ci -qAm k2 -u u2
1127 1127
1128 1128 $ hg update -q b2
1129 1129 $ echo 3 >> f2
1130 1130 $ hg ci -qAm k2 -u u2
1131 1131 $ hg update -q b1
1132 1132 $ echo 4 >> f1
1133 1133 $ hg ci -qAm k1 -u u1
1134 1134 $ hg update -q b0
1135 1135 $ echo 5 >> f0
1136 1136 $ hg ci -qAm k0 -u u0
1137 1137
1138 1138 summary of revisions:
1139 1139
1140 1140 $ hg log -G -T '{rev} {branch} {author} {desc} {files}\n'
1141 1141 @ 5 b0 u0 k0 f0
1142 1142 |
1143 1143 | o 4 b1 u1 k1 f1
1144 1144 | |
1145 1145 | | o 3 b2 u2 k2 f2
1146 1146 | | |
1147 1147 | | o 2 b2 u2 k2 f2
1148 1148 | |/
1149 1149 | o 1 b1 u1 k1 f1
1150 1150 |/
1151 1151 o 0 b0 u0 k0 f0
1152 1152
1153 1153
1154 1154 log -b BRANCH in ascending order:
1155 1155
1156 1156 $ hg log -r0:tip -T '{rev} {branch}\n' -b b0 -b b1
1157 1157 0 b0
1158 1158 1 b1
1159 1159 4 b1
1160 1160 5 b0
1161 1161 $ hg log -r0:tip -T '{rev} {branch}\n' -b b1 -b b0
1162 1162 0 b0
1163 1163 1 b1
1164 1164 4 b1
1165 1165 5 b0
1166 1166
1167 1167 log --only-branch BRANCH in descending order:
1168 1168
1169 1169 $ hg log -rtip:0 -T '{rev} {branch}\n' --only-branch b1 --only-branch b2
1170 1170 4 b1
1171 1171 3 b2
1172 1172 2 b2
1173 1173 1 b1
1174 1174 $ hg log -rtip:0 -T '{rev} {branch}\n' --only-branch b2 --only-branch b1
1175 1175 4 b1
1176 1176 3 b2
1177 1177 2 b2
1178 1178 1 b1
1179 1179
1180 1180 log -u USER in ascending order, against compound set:
1181 1181
1182 1182 $ hg log -r'::head()' -T '{rev} {author}\n' -u u0 -u u2
1183 1183 0 u0
1184 1184 2 u2
1185 1185 3 u2
1186 1186 5 u0
1187 1187 $ hg log -r'::head()' -T '{rev} {author}\n' -u u2 -u u0
1188 1188 0 u0
1189 1189 2 u2
1190 1190 3 u2
1191 1191 5 u0
1192 1192
1193 1193 log -k TEXT in descending order, against compound set:
1194 1194
1195 1195 $ hg log -r'5 + reverse(::3)' -T '{rev} {desc}\n' -k k0 -k k1 -k k2
1196 1196 5 k0
1197 1197 3 k2
1198 1198 2 k2
1199 1199 1 k1
1200 1200 0 k0
1201 1201 $ hg log -r'5 + reverse(::3)' -T '{rev} {desc}\n' -k k2 -k k1 -k k0
1202 1202 5 k0
1203 1203 3 k2
1204 1204 2 k2
1205 1205 1 k1
1206 1206 0 k0
1207 1207
1208 1208 log FILE in ascending order, against dagrange:
1209 1209
1210 1210 $ hg log -r1:: -T '{rev} {files}\n' f1 f2
1211 1211 1 f1
1212 1212 2 f2
1213 1213 3 f2
1214 1214 4 f1
1215 1215 $ hg log -r1:: -T '{rev} {files}\n' f2 f1
1216 1216 1 f1
1217 1217 2 f2
1218 1218 3 f2
1219 1219 4 f1
1220 1220
1221 1221 $ cd ..
1222 1222
1223 1223 User
1224 1224
1225 1225 $ hg init usertest
1226 1226 $ cd usertest
1227 1227
1228 1228 $ echo a > a
1229 1229 $ hg ci -A -m "a" -u "User One <user1@example.org>"
1230 1230 adding a
1231 1231 $ echo b > b
1232 1232 $ hg ci -A -m "b" -u "User Two <user2@example.org>"
1233 1233 adding b
1234 1234
1235 1235 $ hg log -u "User One <user1@example.org>"
1236 1236 changeset: 0:29a4c94f1924
1237 1237 user: User One <user1@example.org>
1238 1238 date: Thu Jan 01 00:00:00 1970 +0000
1239 1239 summary: a
1240 1240
1241 1241 $ hg log -u "user1" -u "user2"
1242 1242 changeset: 1:e834b5e69c0e
1243 1243 tag: tip
1244 1244 user: User Two <user2@example.org>
1245 1245 date: Thu Jan 01 00:00:00 1970 +0000
1246 1246 summary: b
1247 1247
1248 1248 changeset: 0:29a4c94f1924
1249 1249 user: User One <user1@example.org>
1250 1250 date: Thu Jan 01 00:00:00 1970 +0000
1251 1251 summary: a
1252 1252
1253 1253 $ hg log -u "user3"
1254 1254
1255 1255 "-u USER" shouldn't be overridden by "user(USER)" alias
1256 1256
1257 1257 $ hg log --config 'revsetalias.user(x)=branch(x)' -u default
1258 1258 $ hg log --config 'revsetalias.user(x)=branch(x)' -u user1
1259 1259 changeset: 0:29a4c94f1924
1260 1260 user: User One <user1@example.org>
1261 1261 date: Thu Jan 01 00:00:00 1970 +0000
1262 1262 summary: a
1263 1263
1264 1264
1265 1265 $ cd ..
1266 1266
1267 1267 $ hg init branches
1268 1268 $ cd branches
1269 1269
1270 1270 $ echo a > a
1271 1271 $ hg ci -A -m "commit on default"
1272 1272 adding a
1273 1273 $ hg branch test
1274 1274 marked working directory as branch test
1275 1275 (branches are permanent and global, did you want a bookmark?)
1276 1276 $ echo b > b
1277 1277 $ hg ci -A -m "commit on test"
1278 1278 adding b
1279 1279
1280 1280 $ hg up default
1281 1281 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1282 1282 $ echo c > c
1283 1283 $ hg ci -A -m "commit on default"
1284 1284 adding c
1285 1285 $ hg up test
1286 1286 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1287 1287 $ echo c > c
1288 1288 $ hg ci -A -m "commit on test"
1289 1289 adding c
1290 1290
1291 1291
1292 1292 log -b default
1293 1293
1294 1294 $ hg log -b default
1295 1295 changeset: 2:c3a4f03cc9a7
1296 1296 parent: 0:24427303d56f
1297 1297 user: test
1298 1298 date: Thu Jan 01 00:00:00 1970 +0000
1299 1299 summary: commit on default
1300 1300
1301 1301 changeset: 0:24427303d56f
1302 1302 user: test
1303 1303 date: Thu Jan 01 00:00:00 1970 +0000
1304 1304 summary: commit on default
1305 1305
1306 1306
1307 1307
1308 1308 log -b test
1309 1309
1310 1310 $ hg log -b test
1311 1311 changeset: 3:f5d8de11c2e2
1312 1312 branch: test
1313 1313 tag: tip
1314 1314 parent: 1:d32277701ccb
1315 1315 user: test
1316 1316 date: Thu Jan 01 00:00:00 1970 +0000
1317 1317 summary: commit on test
1318 1318
1319 1319 changeset: 1:d32277701ccb
1320 1320 branch: test
1321 1321 user: test
1322 1322 date: Thu Jan 01 00:00:00 1970 +0000
1323 1323 summary: commit on test
1324 1324
1325 1325
1326 1326
1327 1327 log -b dummy
1328 1328
1329 1329 $ hg log -b dummy
1330 1330 abort: unknown revision 'dummy'!
1331 1331 [255]
1332 1332
1333 1333
1334 1334 log -b .
1335 1335
1336 1336 $ hg log -b .
1337 1337 changeset: 3:f5d8de11c2e2
1338 1338 branch: test
1339 1339 tag: tip
1340 1340 parent: 1:d32277701ccb
1341 1341 user: test
1342 1342 date: Thu Jan 01 00:00:00 1970 +0000
1343 1343 summary: commit on test
1344 1344
1345 1345 changeset: 1:d32277701ccb
1346 1346 branch: test
1347 1347 user: test
1348 1348 date: Thu Jan 01 00:00:00 1970 +0000
1349 1349 summary: commit on test
1350 1350
1351 1351
1352 1352
1353 1353 log -b default -b test
1354 1354
1355 1355 $ hg log -b default -b test
1356 1356 changeset: 3:f5d8de11c2e2
1357 1357 branch: test
1358 1358 tag: tip
1359 1359 parent: 1:d32277701ccb
1360 1360 user: test
1361 1361 date: Thu Jan 01 00:00:00 1970 +0000
1362 1362 summary: commit on test
1363 1363
1364 1364 changeset: 2:c3a4f03cc9a7
1365 1365 parent: 0:24427303d56f
1366 1366 user: test
1367 1367 date: Thu Jan 01 00:00:00 1970 +0000
1368 1368 summary: commit on default
1369 1369
1370 1370 changeset: 1:d32277701ccb
1371 1371 branch: test
1372 1372 user: test
1373 1373 date: Thu Jan 01 00:00:00 1970 +0000
1374 1374 summary: commit on test
1375 1375
1376 1376 changeset: 0:24427303d56f
1377 1377 user: test
1378 1378 date: Thu Jan 01 00:00:00 1970 +0000
1379 1379 summary: commit on default
1380 1380
1381 1381
1382 1382
1383 1383 log -b default -b .
1384 1384
1385 1385 $ hg log -b default -b .
1386 1386 changeset: 3:f5d8de11c2e2
1387 1387 branch: test
1388 1388 tag: tip
1389 1389 parent: 1:d32277701ccb
1390 1390 user: test
1391 1391 date: Thu Jan 01 00:00:00 1970 +0000
1392 1392 summary: commit on test
1393 1393
1394 1394 changeset: 2:c3a4f03cc9a7
1395 1395 parent: 0:24427303d56f
1396 1396 user: test
1397 1397 date: Thu Jan 01 00:00:00 1970 +0000
1398 1398 summary: commit on default
1399 1399
1400 1400 changeset: 1:d32277701ccb
1401 1401 branch: test
1402 1402 user: test
1403 1403 date: Thu Jan 01 00:00:00 1970 +0000
1404 1404 summary: commit on test
1405 1405
1406 1406 changeset: 0:24427303d56f
1407 1407 user: test
1408 1408 date: Thu Jan 01 00:00:00 1970 +0000
1409 1409 summary: commit on default
1410 1410
1411 1411
1412 1412
1413 1413 log -b . -b test
1414 1414
1415 1415 $ hg log -b . -b test
1416 1416 changeset: 3:f5d8de11c2e2
1417 1417 branch: test
1418 1418 tag: tip
1419 1419 parent: 1:d32277701ccb
1420 1420 user: test
1421 1421 date: Thu Jan 01 00:00:00 1970 +0000
1422 1422 summary: commit on test
1423 1423
1424 1424 changeset: 1:d32277701ccb
1425 1425 branch: test
1426 1426 user: test
1427 1427 date: Thu Jan 01 00:00:00 1970 +0000
1428 1428 summary: commit on test
1429 1429
1430 1430
1431 1431
1432 1432 log -b 2
1433 1433
1434 1434 $ hg log -b 2
1435 1435 changeset: 2:c3a4f03cc9a7
1436 1436 parent: 0:24427303d56f
1437 1437 user: test
1438 1438 date: Thu Jan 01 00:00:00 1970 +0000
1439 1439 summary: commit on default
1440 1440
1441 1441 changeset: 0:24427303d56f
1442 1442 user: test
1443 1443 date: Thu Jan 01 00:00:00 1970 +0000
1444 1444 summary: commit on default
1445 1445
1446 1446 #if gettext
1447 1447
1448 1448 Test that all log names are translated (e.g. branches, bookmarks, tags):
1449 1449
1450 1450 $ hg bookmark babar -r tip
1451 1451
1452 1452 $ HGENCODING=UTF-8 LANGUAGE=de hg log -r tip
1453 1453 \xc3\x84nderung: 3:f5d8de11c2e2 (esc)
1454 1454 Zweig: test
1455 1455 Lesezeichen: babar
1456 1456 Marke: tip
1457 1457 Vorg\xc3\xa4nger: 1:d32277701ccb (esc)
1458 1458 Nutzer: test
1459 1459 Datum: Thu Jan 01 00:00:00 1970 +0000
1460 1460 Zusammenfassung: commit on test
1461 1461
1462 1462 $ hg bookmark -d babar
1463 1463
1464 1464 #endif
1465 1465
1466 1466 log -p --cwd dir (in subdir)
1467 1467
1468 1468 $ mkdir dir
1469 1469 $ hg log -p --cwd dir
1470 1470 changeset: 3:f5d8de11c2e2
1471 1471 branch: test
1472 1472 tag: tip
1473 1473 parent: 1:d32277701ccb
1474 1474 user: test
1475 1475 date: Thu Jan 01 00:00:00 1970 +0000
1476 1476 summary: commit on test
1477 1477
1478 1478 diff -r d32277701ccb -r f5d8de11c2e2 c
1479 1479 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1480 1480 +++ b/c Thu Jan 01 00:00:00 1970 +0000
1481 1481 @@ -0,0 +1,1 @@
1482 1482 +c
1483 1483
1484 1484 changeset: 2:c3a4f03cc9a7
1485 1485 parent: 0:24427303d56f
1486 1486 user: test
1487 1487 date: Thu Jan 01 00:00:00 1970 +0000
1488 1488 summary: commit on default
1489 1489
1490 1490 diff -r 24427303d56f -r c3a4f03cc9a7 c
1491 1491 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1492 1492 +++ b/c Thu Jan 01 00:00:00 1970 +0000
1493 1493 @@ -0,0 +1,1 @@
1494 1494 +c
1495 1495
1496 1496 changeset: 1:d32277701ccb
1497 1497 branch: test
1498 1498 user: test
1499 1499 date: Thu Jan 01 00:00:00 1970 +0000
1500 1500 summary: commit on test
1501 1501
1502 1502 diff -r 24427303d56f -r d32277701ccb b
1503 1503 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1504 1504 +++ b/b Thu Jan 01 00:00:00 1970 +0000
1505 1505 @@ -0,0 +1,1 @@
1506 1506 +b
1507 1507
1508 1508 changeset: 0:24427303d56f
1509 1509 user: test
1510 1510 date: Thu Jan 01 00:00:00 1970 +0000
1511 1511 summary: commit on default
1512 1512
1513 1513 diff -r 000000000000 -r 24427303d56f a
1514 1514 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1515 1515 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1516 1516 @@ -0,0 +1,1 @@
1517 1517 +a
1518 1518
1519 1519
1520 1520
1521 1521 log -p -R repo
1522 1522
1523 1523 $ cd dir
1524 1524 $ hg log -p -R .. ../a
1525 1525 changeset: 0:24427303d56f
1526 1526 user: test
1527 1527 date: Thu Jan 01 00:00:00 1970 +0000
1528 1528 summary: commit on default
1529 1529
1530 1530 diff -r 000000000000 -r 24427303d56f a
1531 1531 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1532 1532 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1533 1533 @@ -0,0 +1,1 @@
1534 1534 +a
1535 1535
1536 1536
1537 1537 $ cd ../..
1538 1538
1539 1539 $ hg init follow2
1540 1540 $ cd follow2
1541 1541
1542 1542 # Build the following history:
1543 1543 # tip - o - x - o - x - x
1544 1544 # \ /
1545 1545 # o - o - o - x
1546 1546 # \ /
1547 1547 # o
1548 1548 #
1549 1549 # Where "o" is a revision containing "foo" and
1550 1550 # "x" is a revision without "foo"
1551 1551
1552 1552 $ touch init
1553 1553 $ hg ci -A -m "init, unrelated"
1554 1554 adding init
1555 1555 $ echo 'foo' > init
1556 1556 $ hg ci -m "change, unrelated"
1557 1557 $ echo 'foo' > foo
1558 1558 $ hg ci -A -m "add unrelated old foo"
1559 1559 adding foo
1560 1560 $ hg rm foo
1561 1561 $ hg ci -m "delete foo, unrelated"
1562 1562 $ echo 'related' > foo
1563 1563 $ hg ci -A -m "add foo, related"
1564 1564 adding foo
1565 1565
1566 1566 $ hg up 0
1567 1567 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1568 1568 $ touch branch
1569 1569 $ hg ci -A -m "first branch, unrelated"
1570 1570 adding branch
1571 1571 created new head
1572 1572 $ touch foo
1573 1573 $ hg ci -A -m "create foo, related"
1574 1574 adding foo
1575 1575 $ echo 'change' > foo
1576 1576 $ hg ci -m "change foo, related"
1577 1577
1578 1578 $ hg up 6
1579 1579 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1580 1580 $ echo 'change foo in branch' > foo
1581 1581 $ hg ci -m "change foo in branch, related"
1582 1582 created new head
1583 1583 $ hg merge 7
1584 1584 merging foo
1585 1585 warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
1586 1586 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1587 1587 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
1588 1588 [1]
1589 1589 $ echo 'merge 1' > foo
1590 1590 $ hg resolve -m foo
1591 1591 (no more unresolved files)
1592 1592 $ hg ci -m "First merge, related"
1593 1593
1594 1594 $ hg merge 4
1595 1595 merging foo
1596 1596 warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
1597 1597 1 files updated, 0 files merged, 0 files removed, 1 files unresolved
1598 1598 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
1599 1599 [1]
1600 1600 $ echo 'merge 2' > foo
1601 1601 $ hg resolve -m foo
1602 1602 (no more unresolved files)
1603 1603 $ hg ci -m "Last merge, related"
1604 1604
1605 1605 $ hg log --graph
1606 1606 @ changeset: 10:4dae8563d2c5
1607 1607 |\ tag: tip
1608 1608 | | parent: 9:7b35701b003e
1609 1609 | | parent: 4:88176d361b69
1610 1610 | | user: test
1611 1611 | | date: Thu Jan 01 00:00:00 1970 +0000
1612 1612 | | summary: Last merge, related
1613 1613 | |
1614 1614 | o changeset: 9:7b35701b003e
1615 1615 | |\ parent: 8:e5416ad8a855
1616 1616 | | | parent: 7:87fe3144dcfa
1617 1617 | | | user: test
1618 1618 | | | date: Thu Jan 01 00:00:00 1970 +0000
1619 1619 | | | summary: First merge, related
1620 1620 | | |
1621 1621 | | o changeset: 8:e5416ad8a855
1622 1622 | | | parent: 6:dc6c325fe5ee
1623 1623 | | | user: test
1624 1624 | | | date: Thu Jan 01 00:00:00 1970 +0000
1625 1625 | | | summary: change foo in branch, related
1626 1626 | | |
1627 1627 | o | changeset: 7:87fe3144dcfa
1628 1628 | |/ user: test
1629 1629 | | date: Thu Jan 01 00:00:00 1970 +0000
1630 1630 | | summary: change foo, related
1631 1631 | |
1632 1632 | o changeset: 6:dc6c325fe5ee
1633 1633 | | user: test
1634 1634 | | date: Thu Jan 01 00:00:00 1970 +0000
1635 1635 | | summary: create foo, related
1636 1636 | |
1637 1637 | o changeset: 5:73db34516eb9
1638 1638 | | parent: 0:e87515fd044a
1639 1639 | | user: test
1640 1640 | | date: Thu Jan 01 00:00:00 1970 +0000
1641 1641 | | summary: first branch, unrelated
1642 1642 | |
1643 1643 o | changeset: 4:88176d361b69
1644 1644 | | user: test
1645 1645 | | date: Thu Jan 01 00:00:00 1970 +0000
1646 1646 | | summary: add foo, related
1647 1647 | |
1648 1648 o | changeset: 3:dd78ae4afb56
1649 1649 | | user: test
1650 1650 | | date: Thu Jan 01 00:00:00 1970 +0000
1651 1651 | | summary: delete foo, unrelated
1652 1652 | |
1653 1653 o | changeset: 2:c4c64aedf0f7
1654 1654 | | user: test
1655 1655 | | date: Thu Jan 01 00:00:00 1970 +0000
1656 1656 | | summary: add unrelated old foo
1657 1657 | |
1658 1658 o | changeset: 1:e5faa7440653
1659 1659 |/ user: test
1660 1660 | date: Thu Jan 01 00:00:00 1970 +0000
1661 1661 | summary: change, unrelated
1662 1662 |
1663 1663 o changeset: 0:e87515fd044a
1664 1664 user: test
1665 1665 date: Thu Jan 01 00:00:00 1970 +0000
1666 1666 summary: init, unrelated
1667 1667
1668 1668
1669 1669 $ hg --traceback log -f foo
1670 1670 changeset: 10:4dae8563d2c5
1671 1671 tag: tip
1672 1672 parent: 9:7b35701b003e
1673 1673 parent: 4:88176d361b69
1674 1674 user: test
1675 1675 date: Thu Jan 01 00:00:00 1970 +0000
1676 1676 summary: Last merge, related
1677 1677
1678 1678 changeset: 9:7b35701b003e
1679 1679 parent: 8:e5416ad8a855
1680 1680 parent: 7:87fe3144dcfa
1681 1681 user: test
1682 1682 date: Thu Jan 01 00:00:00 1970 +0000
1683 1683 summary: First merge, related
1684 1684
1685 1685 changeset: 8:e5416ad8a855
1686 1686 parent: 6:dc6c325fe5ee
1687 1687 user: test
1688 1688 date: Thu Jan 01 00:00:00 1970 +0000
1689 1689 summary: change foo in branch, related
1690 1690
1691 1691 changeset: 7:87fe3144dcfa
1692 1692 user: test
1693 1693 date: Thu Jan 01 00:00:00 1970 +0000
1694 1694 summary: change foo, related
1695 1695
1696 1696 changeset: 6:dc6c325fe5ee
1697 1697 user: test
1698 1698 date: Thu Jan 01 00:00:00 1970 +0000
1699 1699 summary: create foo, related
1700 1700
1701 1701 changeset: 4:88176d361b69
1702 1702 user: test
1703 1703 date: Thu Jan 01 00:00:00 1970 +0000
1704 1704 summary: add foo, related
1705 1705
1706 1706
1707 1707 Also check when maxrev < lastrevfilelog
1708 1708
1709 1709 $ hg --traceback log -f -r4 foo
1710 1710 changeset: 4:88176d361b69
1711 1711 user: test
1712 1712 date: Thu Jan 01 00:00:00 1970 +0000
1713 1713 summary: add foo, related
1714 1714
1715 1715 changeset: 2:c4c64aedf0f7
1716 1716 user: test
1717 1717 date: Thu Jan 01 00:00:00 1970 +0000
1718 1718 summary: add unrelated old foo
1719 1719
1720 1720 $ cd ..
1721 1721
1722 1722 Issue2383: hg log showing _less_ differences than hg diff
1723 1723
1724 1724 $ hg init issue2383
1725 1725 $ cd issue2383
1726 1726
1727 1727 Create a test repo:
1728 1728
1729 1729 $ echo a > a
1730 1730 $ hg ci -Am0
1731 1731 adding a
1732 1732 $ echo b > b
1733 1733 $ hg ci -Am1
1734 1734 adding b
1735 1735 $ hg co 0
1736 1736 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1737 1737 $ echo b > a
1738 1738 $ hg ci -m2
1739 1739 created new head
1740 1740
1741 1741 Merge:
1742 1742
1743 1743 $ hg merge
1744 1744 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1745 1745 (branch merge, don't forget to commit)
1746 1746
1747 1747 Make sure there's a file listed in the merge to trigger the bug:
1748 1748
1749 1749 $ echo c > a
1750 1750 $ hg ci -m3
1751 1751
1752 1752 Two files shown here in diff:
1753 1753
1754 1754 $ hg diff --rev 2:3
1755 1755 diff -r b09be438c43a -r 8e07aafe1edc a
1756 1756 --- a/a Thu Jan 01 00:00:00 1970 +0000
1757 1757 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1758 1758 @@ -1,1 +1,1 @@
1759 1759 -b
1760 1760 +c
1761 1761 diff -r b09be438c43a -r 8e07aafe1edc b
1762 1762 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1763 1763 +++ b/b Thu Jan 01 00:00:00 1970 +0000
1764 1764 @@ -0,0 +1,1 @@
1765 1765 +b
1766 1766
1767 1767 Diff here should be the same:
1768 1768
1769 1769 $ hg log -vpr 3
1770 1770 changeset: 3:8e07aafe1edc
1771 1771 tag: tip
1772 1772 parent: 2:b09be438c43a
1773 1773 parent: 1:925d80f479bb
1774 1774 user: test
1775 1775 date: Thu Jan 01 00:00:00 1970 +0000
1776 1776 files: a
1777 1777 description:
1778 1778 3
1779 1779
1780 1780
1781 1781 diff -r b09be438c43a -r 8e07aafe1edc a
1782 1782 --- a/a Thu Jan 01 00:00:00 1970 +0000
1783 1783 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1784 1784 @@ -1,1 +1,1 @@
1785 1785 -b
1786 1786 +c
1787 1787 diff -r b09be438c43a -r 8e07aafe1edc b
1788 1788 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1789 1789 +++ b/b Thu Jan 01 00:00:00 1970 +0000
1790 1790 @@ -0,0 +1,1 @@
1791 1791 +b
1792 1792
1793 1793 $ cd ..
1794 1794
1795 1795 'hg log -r rev fn' when last(filelog(fn)) != rev
1796 1796
1797 1797 $ hg init simplelog
1798 1798 $ cd simplelog
1799 1799 $ echo f > a
1800 1800 $ hg ci -Am'a' -d '0 0'
1801 1801 adding a
1802 1802 $ echo f >> a
1803 1803 $ hg ci -Am'a bis' -d '1 0'
1804 1804
1805 1805 $ hg log -r0 a
1806 1806 changeset: 0:9f758d63dcde
1807 1807 user: test
1808 1808 date: Thu Jan 01 00:00:00 1970 +0000
1809 1809 summary: a
1810 1810
1811 1811 enable obsolete to test hidden feature
1812 1812
1813 1813 $ cat >> $HGRCPATH << EOF
1814 1814 > [experimental]
1815 1815 > evolution.createmarkers=True
1816 1816 > EOF
1817 1817
1818 1818 $ hg log --template='{rev}:{node}\n'
1819 1819 1:a765632148dc55d38c35c4f247c618701886cb2f
1820 1820 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1821 1821 $ hg debugobsolete a765632148dc55d38c35c4f247c618701886cb2f
1822 1822 obsoleted 1 changesets
1823 1823 $ hg up null -q
1824 1824 $ hg log --template='{rev}:{node}\n'
1825 1825 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1826 1826 $ hg log --template='{rev}:{node}\n' --hidden
1827 1827 1:a765632148dc55d38c35c4f247c618701886cb2f
1828 1828 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1829 1829 $ hg log -r a
1830 abort: hidden revision 'a'!
1830 abort: hidden revision 'a' is pruned!
1831 1831 (use --hidden to access hidden revisions)
1832 1832 [255]
1833 1833
1834 1834 test that parent prevent a changeset to be hidden
1835 1835
1836 1836 $ hg up 1 -q --hidden
1837 1837 updating to a hidden changeset a765632148dc
1838 1838 $ hg log --template='{rev}:{node}\n'
1839 1839 1:a765632148dc55d38c35c4f247c618701886cb2f
1840 1840 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1841 1841
1842 1842 test that second parent prevent a changeset to be hidden too
1843 1843
1844 1844 $ hg debugsetparents 0 1 # nothing suitable to merge here
1845 1845 $ hg log --template='{rev}:{node}\n'
1846 1846 1:a765632148dc55d38c35c4f247c618701886cb2f
1847 1847 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1848 1848 $ hg debugsetparents 1
1849 1849 $ hg up -q null
1850 1850
1851 1851 bookmarks prevent a changeset being hidden
1852 1852
1853 1853 $ hg bookmark --hidden -r 1 X
1854 1854 $ hg log --template '{rev}:{node}\n'
1855 1855 1:a765632148dc55d38c35c4f247c618701886cb2f
1856 1856 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1857 1857 $ hg bookmark -d X
1858 1858
1859 1859 divergent bookmarks are not hidden
1860 1860
1861 1861 $ hg bookmark --hidden -r 1 X@foo
1862 1862 $ hg log --template '{rev}:{node}\n'
1863 1863 1:a765632148dc55d38c35c4f247c618701886cb2f
1864 1864 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1865 1865
1866 1866 test hidden revision 0 (issue5385)
1867 1867
1868 1868 $ hg bookmark -d X@foo
1869 1869 $ hg up null -q
1870 1870 $ hg debugobsolete 9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1871 1871 obsoleted 1 changesets
1872 1872 $ echo f > b
1873 1873 $ hg ci -Am'b' -d '2 0'
1874 1874 adding b
1875 1875 $ echo f >> b
1876 1876 $ hg ci -m'b bis' -d '3 0'
1877 1877 $ hg log -T'{rev}:{node}\n'
1878 1878 3:d7d28b288a6b83d5d2cf49f10c5974deed3a1d2e
1879 1879 2:94375ec45bddd2a824535fc04855bd058c926ec0
1880 1880
1881 1881 $ hg log -T'{rev}:{node}\n' -r:
1882 1882 2:94375ec45bddd2a824535fc04855bd058c926ec0
1883 1883 3:d7d28b288a6b83d5d2cf49f10c5974deed3a1d2e
1884 1884 $ hg log -T'{rev}:{node}\n' -r:tip
1885 1885 2:94375ec45bddd2a824535fc04855bd058c926ec0
1886 1886 3:d7d28b288a6b83d5d2cf49f10c5974deed3a1d2e
1887 1887 $ hg log -T'{rev}:{node}\n' -r:0
1888 abort: hidden revision '0'!
1888 abort: hidden revision '0' is pruned!
1889 1889 (use --hidden to access hidden revisions)
1890 1890 [255]
1891 1891 $ hg log -T'{rev}:{node}\n' -f
1892 1892 3:d7d28b288a6b83d5d2cf49f10c5974deed3a1d2e
1893 1893 2:94375ec45bddd2a824535fc04855bd058c926ec0
1894 1894
1895 1895 clear extensions configuration
1896 1896 $ echo '[extensions]' >> $HGRCPATH
1897 1897 $ echo "obs=!" >> $HGRCPATH
1898 1898 $ cd ..
1899 1899
1900 1900 test -u/-k for problematic encoding
1901 1901 # unicode: cp932:
1902 1902 # u30A2 0x83 0x41(= 'A')
1903 1903 # u30C2 0x83 0x61(= 'a')
1904 1904
1905 1905 $ hg init problematicencoding
1906 1906 $ cd problematicencoding
1907 1907
1908 1908 $ $PYTHON > setup.sh <<EOF
1909 1909 > print(u'''
1910 1910 > echo a > text
1911 1911 > hg add text
1912 1912 > hg --encoding utf-8 commit -u '\u30A2' -m none
1913 1913 > echo b > text
1914 1914 > hg --encoding utf-8 commit -u '\u30C2' -m none
1915 1915 > echo c > text
1916 1916 > hg --encoding utf-8 commit -u none -m '\u30A2'
1917 1917 > echo d > text
1918 1918 > hg --encoding utf-8 commit -u none -m '\u30C2'
1919 1919 > '''.encode('utf-8'))
1920 1920 > EOF
1921 1921 $ sh < setup.sh
1922 1922
1923 1923 test in problematic encoding
1924 1924 $ $PYTHON > test.sh <<EOF
1925 1925 > print(u'''
1926 1926 > hg --encoding cp932 log --template '{rev}\\n' -u '\u30A2'
1927 1927 > echo ====
1928 1928 > hg --encoding cp932 log --template '{rev}\\n' -u '\u30C2'
1929 1929 > echo ====
1930 1930 > hg --encoding cp932 log --template '{rev}\\n' -k '\u30A2'
1931 1931 > echo ====
1932 1932 > hg --encoding cp932 log --template '{rev}\\n' -k '\u30C2'
1933 1933 > '''.encode('cp932'))
1934 1934 > EOF
1935 1935 $ sh < test.sh
1936 1936 0
1937 1937 ====
1938 1938 1
1939 1939 ====
1940 1940 2
1941 1941 0
1942 1942 ====
1943 1943 3
1944 1944 1
1945 1945
1946 1946 $ cd ..
1947 1947
1948 1948 test hg log on non-existent files and on directories
1949 1949 $ hg init issue1340
1950 1950 $ cd issue1340
1951 1951 $ mkdir d1; mkdir D2; mkdir D3.i; mkdir d4.hg; mkdir d5.d; mkdir .d6
1952 1952 $ echo 1 > d1/f1
1953 1953 $ echo 1 > D2/f1
1954 1954 $ echo 1 > D3.i/f1
1955 1955 $ echo 1 > d4.hg/f1
1956 1956 $ echo 1 > d5.d/f1
1957 1957 $ echo 1 > .d6/f1
1958 1958 $ hg -q add .
1959 1959 $ hg commit -m "a bunch of weird directories"
1960 1960 $ hg log -l1 d1/f1 | grep changeset
1961 1961 changeset: 0:65624cd9070a
1962 1962 $ hg log -l1 f1
1963 1963 $ hg log -l1 . | grep changeset
1964 1964 changeset: 0:65624cd9070a
1965 1965 $ hg log -l1 ./ | grep changeset
1966 1966 changeset: 0:65624cd9070a
1967 1967 $ hg log -l1 d1 | grep changeset
1968 1968 changeset: 0:65624cd9070a
1969 1969 $ hg log -l1 D2 | grep changeset
1970 1970 changeset: 0:65624cd9070a
1971 1971 $ hg log -l1 D2/f1 | grep changeset
1972 1972 changeset: 0:65624cd9070a
1973 1973 $ hg log -l1 D3.i | grep changeset
1974 1974 changeset: 0:65624cd9070a
1975 1975 $ hg log -l1 D3.i/f1 | grep changeset
1976 1976 changeset: 0:65624cd9070a
1977 1977 $ hg log -l1 d4.hg | grep changeset
1978 1978 changeset: 0:65624cd9070a
1979 1979 $ hg log -l1 d4.hg/f1 | grep changeset
1980 1980 changeset: 0:65624cd9070a
1981 1981 $ hg log -l1 d5.d | grep changeset
1982 1982 changeset: 0:65624cd9070a
1983 1983 $ hg log -l1 d5.d/f1 | grep changeset
1984 1984 changeset: 0:65624cd9070a
1985 1985 $ hg log -l1 .d6 | grep changeset
1986 1986 changeset: 0:65624cd9070a
1987 1987 $ hg log -l1 .d6/f1 | grep changeset
1988 1988 changeset: 0:65624cd9070a
1989 1989
1990 1990 issue3772: hg log -r :null showing revision 0 as well
1991 1991
1992 1992 $ hg log -r :null
1993 1993 changeset: 0:65624cd9070a
1994 1994 tag: tip
1995 1995 user: test
1996 1996 date: Thu Jan 01 00:00:00 1970 +0000
1997 1997 summary: a bunch of weird directories
1998 1998
1999 1999 changeset: -1:000000000000
2000 2000 user:
2001 2001 date: Thu Jan 01 00:00:00 1970 +0000
2002 2002
2003 2003 $ hg log -r null:null
2004 2004 changeset: -1:000000000000
2005 2005 user:
2006 2006 date: Thu Jan 01 00:00:00 1970 +0000
2007 2007
2008 2008 working-directory revision requires special treatment
2009 2009
2010 2010 clean:
2011 2011
2012 2012 $ hg log -r 'wdir()' --debug
2013 2013 changeset: 2147483647:ffffffffffffffffffffffffffffffffffffffff
2014 2014 phase: draft
2015 2015 parent: 0:65624cd9070a035fa7191a54f2b8af39f16b0c08
2016 2016 parent: -1:0000000000000000000000000000000000000000
2017 2017 user: test
2018 2018 date: [A-Za-z0-9:+ ]+ (re)
2019 2019 extra: branch=default
2020 2020
2021 2021 $ hg log -r 'wdir()' -p --stat
2022 2022 changeset: 2147483647:ffffffffffff
2023 2023 parent: 0:65624cd9070a
2024 2024 user: test
2025 2025 date: [A-Za-z0-9:+ ]+ (re)
2026 2026
2027 2027
2028 2028
2029 2029
2030 2030 dirty:
2031 2031
2032 2032 $ echo 2 >> d1/f1
2033 2033 $ echo 2 > d1/f2
2034 2034 $ hg add d1/f2
2035 2035 $ hg remove .d6/f1
2036 2036 $ hg status
2037 2037 M d1/f1
2038 2038 A d1/f2
2039 2039 R .d6/f1
2040 2040
2041 2041 $ hg log -r 'wdir()'
2042 2042 changeset: 2147483647:ffffffffffff
2043 2043 parent: 0:65624cd9070a
2044 2044 user: test
2045 2045 date: [A-Za-z0-9:+ ]+ (re)
2046 2046
2047 2047 $ hg log -r 'wdir()' -q
2048 2048 2147483647:ffffffffffff
2049 2049
2050 2050 $ hg log -r 'wdir()' --debug
2051 2051 changeset: 2147483647:ffffffffffffffffffffffffffffffffffffffff
2052 2052 phase: draft
2053 2053 parent: 0:65624cd9070a035fa7191a54f2b8af39f16b0c08
2054 2054 parent: -1:0000000000000000000000000000000000000000
2055 2055 user: test
2056 2056 date: [A-Za-z0-9:+ ]+ (re)
2057 2057 files: d1/f1
2058 2058 files+: d1/f2
2059 2059 files-: .d6/f1
2060 2060 extra: branch=default
2061 2061
2062 2062 $ hg log -r 'wdir()' -p --stat --git
2063 2063 changeset: 2147483647:ffffffffffff
2064 2064 parent: 0:65624cd9070a
2065 2065 user: test
2066 2066 date: [A-Za-z0-9:+ ]+ (re)
2067 2067
2068 2068 .d6/f1 | 1 -
2069 2069 d1/f1 | 1 +
2070 2070 d1/f2 | 1 +
2071 2071 3 files changed, 2 insertions(+), 1 deletions(-)
2072 2072
2073 2073 diff --git a/.d6/f1 b/.d6/f1
2074 2074 deleted file mode 100644
2075 2075 --- a/.d6/f1
2076 2076 +++ /dev/null
2077 2077 @@ -1,1 +0,0 @@
2078 2078 -1
2079 2079 diff --git a/d1/f1 b/d1/f1
2080 2080 --- a/d1/f1
2081 2081 +++ b/d1/f1
2082 2082 @@ -1,1 +1,2 @@
2083 2083 1
2084 2084 +2
2085 2085 diff --git a/d1/f2 b/d1/f2
2086 2086 new file mode 100644
2087 2087 --- /dev/null
2088 2088 +++ b/d1/f2
2089 2089 @@ -0,0 +1,1 @@
2090 2090 +2
2091 2091
2092 2092 $ hg log -r 'wdir()' -Tjson
2093 2093 [
2094 2094 {
2095 2095 "rev": null,
2096 2096 "node": null,
2097 2097 "branch": "default",
2098 2098 "phase": "draft",
2099 2099 "user": "test",
2100 2100 "date": [*, 0], (glob)
2101 2101 "desc": "",
2102 2102 "bookmarks": [],
2103 2103 "tags": [],
2104 2104 "parents": ["65624cd9070a035fa7191a54f2b8af39f16b0c08"]
2105 2105 }
2106 2106 ]
2107 2107
2108 2108 $ hg log -r 'wdir()' -Tjson -q
2109 2109 [
2110 2110 {
2111 2111 "rev": null,
2112 2112 "node": null
2113 2113 }
2114 2114 ]
2115 2115
2116 2116 $ hg log -r 'wdir()' -Tjson --debug
2117 2117 [
2118 2118 {
2119 2119 "rev": null,
2120 2120 "node": null,
2121 2121 "branch": "default",
2122 2122 "phase": "draft",
2123 2123 "user": "test",
2124 2124 "date": [*, 0], (glob)
2125 2125 "desc": "",
2126 2126 "bookmarks": [],
2127 2127 "tags": [],
2128 2128 "parents": ["65624cd9070a035fa7191a54f2b8af39f16b0c08"],
2129 2129 "manifest": null,
2130 2130 "extra": {"branch": "default"},
2131 2131 "modified": ["d1/f1"],
2132 2132 "added": ["d1/f2"],
2133 2133 "removed": [".d6/f1"]
2134 2134 }
2135 2135 ]
2136 2136
2137 2137 $ hg revert -aqC
2138 2138
2139 2139 Check that adding an arbitrary name shows up in log automatically
2140 2140
2141 2141 $ cat > ../names.py <<EOF
2142 2142 > """A small extension to test adding arbitrary names to a repo"""
2143 2143 > from __future__ import absolute_import
2144 2144 > from mercurial import namespaces
2145 2145 >
2146 2146 > def reposetup(ui, repo):
2147 2147 > foo = {'foo': repo[0].node()}
2148 2148 > names = lambda r: foo.keys()
2149 2149 > namemap = lambda r, name: foo.get(name)
2150 2150 > nodemap = lambda r, node: [name for name, n in foo.iteritems()
2151 2151 > if n == node]
2152 2152 > ns = namespaces.namespace(
2153 2153 > "bars", templatename="bar", logname="barlog",
2154 2154 > colorname="barcolor", listnames=names, namemap=namemap,
2155 2155 > nodemap=nodemap)
2156 2156 >
2157 2157 > repo.names.addnamespace(ns)
2158 2158 > EOF
2159 2159
2160 2160 $ hg --config extensions.names=../names.py log -r 0
2161 2161 changeset: 0:65624cd9070a
2162 2162 tag: tip
2163 2163 barlog: foo
2164 2164 user: test
2165 2165 date: Thu Jan 01 00:00:00 1970 +0000
2166 2166 summary: a bunch of weird directories
2167 2167
2168 2168 $ hg --config extensions.names=../names.py \
2169 2169 > --config extensions.color= --config color.log.barcolor=red \
2170 2170 > --color=always log -r 0
2171 2171 \x1b[0;33mchangeset: 0:65624cd9070a\x1b[0m (esc)
2172 2172 tag: tip
2173 2173 \x1b[0;31mbarlog: foo\x1b[0m (esc)
2174 2174 user: test
2175 2175 date: Thu Jan 01 00:00:00 1970 +0000
2176 2176 summary: a bunch of weird directories
2177 2177
2178 2178 $ hg --config extensions.names=../names.py log -r 0 --template '{bars}\n'
2179 2179 foo
2180 2180
2181 2181 $ cd ..
2182 2182
2183 2183 hg log -f dir across branches
2184 2184
2185 2185 $ hg init acrossbranches
2186 2186 $ cd acrossbranches
2187 2187 $ mkdir d
2188 2188 $ echo a > d/a && hg ci -Aqm a
2189 2189 $ echo b > d/a && hg ci -Aqm b
2190 2190 $ hg up -q 0
2191 2191 $ echo b > d/a && hg ci -Aqm c
2192 2192 $ hg log -f d -T '{desc}' -G
2193 2193 @ c
2194 2194 |
2195 2195 o a
2196 2196
2197 2197 Ensure that largefiles doesn't interfere with following a normal file
2198 2198 $ hg --config extensions.largefiles= log -f d -T '{desc}' -G
2199 2199 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
2200 2200 @ c
2201 2201 |
2202 2202 o a
2203 2203
2204 2204 $ hg log -f d/a -T '{desc}' -G
2205 2205 @ c
2206 2206 |
2207 2207 o a
2208 2208
2209 2209 $ cd ..
2210 2210
2211 2211 hg log -f with linkrev pointing to another branch
2212 2212 -------------------------------------------------
2213 2213
2214 2214 create history with a filerev whose linkrev points to another branch
2215 2215
2216 2216 $ hg init branchedlinkrev
2217 2217 $ cd branchedlinkrev
2218 2218 $ echo 1 > a
2219 2219 $ hg commit -Am 'content1'
2220 2220 adding a
2221 2221 $ echo 2 > a
2222 2222 $ hg commit -m 'content2'
2223 2223 $ hg up --rev 'desc(content1)'
2224 2224 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
2225 2225 $ echo unrelated > unrelated
2226 2226 $ hg commit -Am 'unrelated'
2227 2227 adding unrelated
2228 2228 created new head
2229 2229 $ hg graft -r 'desc(content2)'
2230 2230 grafting 1:2294ae80ad84 "content2"
2231 2231 $ echo 3 > a
2232 2232 $ hg commit -m 'content3'
2233 2233 $ hg log -G
2234 2234 @ changeset: 4:50b9b36e9c5d
2235 2235 | tag: tip
2236 2236 | user: test
2237 2237 | date: Thu Jan 01 00:00:00 1970 +0000
2238 2238 | summary: content3
2239 2239 |
2240 2240 o changeset: 3:15b2327059e5
2241 2241 | user: test
2242 2242 | date: Thu Jan 01 00:00:00 1970 +0000
2243 2243 | summary: content2
2244 2244 |
2245 2245 o changeset: 2:2029acd1168c
2246 2246 | parent: 0:ae0a3c9f9e95
2247 2247 | user: test
2248 2248 | date: Thu Jan 01 00:00:00 1970 +0000
2249 2249 | summary: unrelated
2250 2250 |
2251 2251 | o changeset: 1:2294ae80ad84
2252 2252 |/ user: test
2253 2253 | date: Thu Jan 01 00:00:00 1970 +0000
2254 2254 | summary: content2
2255 2255 |
2256 2256 o changeset: 0:ae0a3c9f9e95
2257 2257 user: test
2258 2258 date: Thu Jan 01 00:00:00 1970 +0000
2259 2259 summary: content1
2260 2260
2261 2261
2262 2262 log -f on the file should list the graft result.
2263 2263
2264 2264 $ hg log -Gf a
2265 2265 @ changeset: 4:50b9b36e9c5d
2266 2266 | tag: tip
2267 2267 | user: test
2268 2268 | date: Thu Jan 01 00:00:00 1970 +0000
2269 2269 | summary: content3
2270 2270 |
2271 2271 o changeset: 3:15b2327059e5
2272 2272 : user: test
2273 2273 : date: Thu Jan 01 00:00:00 1970 +0000
2274 2274 : summary: content2
2275 2275 :
2276 2276 o changeset: 0:ae0a3c9f9e95
2277 2277 user: test
2278 2278 date: Thu Jan 01 00:00:00 1970 +0000
2279 2279 summary: content1
2280 2280
2281 2281
2282 2282 plain log lists the original version
2283 2283 (XXX we should probably list both)
2284 2284
2285 2285 $ hg log -G a
2286 2286 @ changeset: 4:50b9b36e9c5d
2287 2287 : tag: tip
2288 2288 : user: test
2289 2289 : date: Thu Jan 01 00:00:00 1970 +0000
2290 2290 : summary: content3
2291 2291 :
2292 2292 : o changeset: 1:2294ae80ad84
2293 2293 :/ user: test
2294 2294 : date: Thu Jan 01 00:00:00 1970 +0000
2295 2295 : summary: content2
2296 2296 :
2297 2297 o changeset: 0:ae0a3c9f9e95
2298 2298 user: test
2299 2299 date: Thu Jan 01 00:00:00 1970 +0000
2300 2300 summary: content1
2301 2301
2302 2302
2303 2303 hg log -f from the grafted changeset
2304 2304 (The bootstrap should properly take the topology in account)
2305 2305
2306 2306 $ hg up 'desc(content3)^'
2307 2307 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
2308 2308 $ hg log -Gf a
2309 2309 @ changeset: 3:15b2327059e5
2310 2310 : user: test
2311 2311 : date: Thu Jan 01 00:00:00 1970 +0000
2312 2312 : summary: content2
2313 2313 :
2314 2314 o changeset: 0:ae0a3c9f9e95
2315 2315 user: test
2316 2316 date: Thu Jan 01 00:00:00 1970 +0000
2317 2317 summary: content1
2318 2318
2319 2319
2320 2320 Test that we use the first non-hidden changeset in that case.
2321 2321
2322 2322 (hide the changeset)
2323 2323
2324 2324 $ hg log -T '{node}\n' -r 1
2325 2325 2294ae80ad8447bc78383182eeac50cb049df623
2326 2326 $ hg debugobsolete 2294ae80ad8447bc78383182eeac50cb049df623
2327 2327 obsoleted 1 changesets
2328 2328 $ hg log -G
2329 2329 o changeset: 4:50b9b36e9c5d
2330 2330 | tag: tip
2331 2331 | user: test
2332 2332 | date: Thu Jan 01 00:00:00 1970 +0000
2333 2333 | summary: content3
2334 2334 |
2335 2335 @ changeset: 3:15b2327059e5
2336 2336 | user: test
2337 2337 | date: Thu Jan 01 00:00:00 1970 +0000
2338 2338 | summary: content2
2339 2339 |
2340 2340 o changeset: 2:2029acd1168c
2341 2341 | parent: 0:ae0a3c9f9e95
2342 2342 | user: test
2343 2343 | date: Thu Jan 01 00:00:00 1970 +0000
2344 2344 | summary: unrelated
2345 2345 |
2346 2346 o changeset: 0:ae0a3c9f9e95
2347 2347 user: test
2348 2348 date: Thu Jan 01 00:00:00 1970 +0000
2349 2349 summary: content1
2350 2350
2351 2351
2352 2352 Check that log on the file does not drop the file revision.
2353 2353
2354 2354 $ hg log -G a
2355 2355 o changeset: 4:50b9b36e9c5d
2356 2356 | tag: tip
2357 2357 | user: test
2358 2358 | date: Thu Jan 01 00:00:00 1970 +0000
2359 2359 | summary: content3
2360 2360 |
2361 2361 @ changeset: 3:15b2327059e5
2362 2362 : user: test
2363 2363 : date: Thu Jan 01 00:00:00 1970 +0000
2364 2364 : summary: content2
2365 2365 :
2366 2366 o changeset: 0:ae0a3c9f9e95
2367 2367 user: test
2368 2368 date: Thu Jan 01 00:00:00 1970 +0000
2369 2369 summary: content1
2370 2370
2371 2371
2372 2372 Even when a head revision is linkrev-shadowed.
2373 2373
2374 2374 $ hg log -T '{node}\n' -r 4
2375 2375 50b9b36e9c5df2c6fc6dcefa8ad0da929e84aed2
2376 2376 $ hg debugobsolete 50b9b36e9c5df2c6fc6dcefa8ad0da929e84aed2
2377 2377 obsoleted 1 changesets
2378 2378 $ hg log -G a
2379 2379 @ changeset: 3:15b2327059e5
2380 2380 : tag: tip
2381 2381 : user: test
2382 2382 : date: Thu Jan 01 00:00:00 1970 +0000
2383 2383 : summary: content2
2384 2384 :
2385 2385 o changeset: 0:ae0a3c9f9e95
2386 2386 user: test
2387 2387 date: Thu Jan 01 00:00:00 1970 +0000
2388 2388 summary: content1
2389 2389
2390 2390
2391 2391 $ cd ..
2392 2392
2393 2393 Even when the file revision is missing from some head:
2394 2394
2395 2395 $ hg init issue4490
2396 2396 $ cd issue4490
2397 2397 $ echo '[experimental]' >> .hg/hgrc
2398 2398 $ echo 'evolution.createmarkers=True' >> .hg/hgrc
2399 2399 $ echo a > a
2400 2400 $ hg ci -Am0
2401 2401 adding a
2402 2402 $ echo b > b
2403 2403 $ hg ci -Am1
2404 2404 adding b
2405 2405 $ echo B > b
2406 2406 $ hg ci --amend -m 1
2407 2407 $ hg up 0
2408 2408 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
2409 2409 $ echo c > c
2410 2410 $ hg ci -Am2
2411 2411 adding c
2412 2412 created new head
2413 2413 $ hg up 'head() and not .'
2414 2414 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
2415 2415 $ hg log -G
2416 2416 o changeset: 3:db815d6d32e6
2417 2417 | tag: tip
2418 2418 | parent: 0:f7b1eb17ad24
2419 2419 | user: test
2420 2420 | date: Thu Jan 01 00:00:00 1970 +0000
2421 2421 | summary: 2
2422 2422 |
2423 2423 | @ changeset: 2:9bc8ce7f9356
2424 2424 |/ parent: 0:f7b1eb17ad24
2425 2425 | user: test
2426 2426 | date: Thu Jan 01 00:00:00 1970 +0000
2427 2427 | summary: 1
2428 2428 |
2429 2429 o changeset: 0:f7b1eb17ad24
2430 2430 user: test
2431 2431 date: Thu Jan 01 00:00:00 1970 +0000
2432 2432 summary: 0
2433 2433
2434 2434 $ hg log -f -G b
2435 2435 @ changeset: 2:9bc8ce7f9356
2436 2436 | parent: 0:f7b1eb17ad24
2437 2437 ~ user: test
2438 2438 date: Thu Jan 01 00:00:00 1970 +0000
2439 2439 summary: 1
2440 2440
2441 2441 $ hg log -G b
2442 2442 @ changeset: 2:9bc8ce7f9356
2443 2443 | parent: 0:f7b1eb17ad24
2444 2444 ~ user: test
2445 2445 date: Thu Jan 01 00:00:00 1970 +0000
2446 2446 summary: 1
2447 2447
2448 2448 $ cd ..
2449 2449
2450 2450 Check proper report when the manifest changes but not the file issue4499
2451 2451 ------------------------------------------------------------------------
2452 2452
2453 2453 $ hg init issue4499
2454 2454 $ cd issue4499
2455 2455 $ for f in A B C D F E G H I J K L M N O P Q R S T U; do
2456 2456 > echo 1 > $f;
2457 2457 > hg add $f;
2458 2458 > done
2459 2459 $ hg commit -m 'A1B1C1'
2460 2460 $ echo 2 > A
2461 2461 $ echo 2 > B
2462 2462 $ echo 2 > C
2463 2463 $ hg commit -m 'A2B2C2'
2464 2464 $ hg up 0
2465 2465 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
2466 2466 $ echo 3 > A
2467 2467 $ echo 2 > B
2468 2468 $ echo 2 > C
2469 2469 $ hg commit -m 'A3B2C2'
2470 2470 created new head
2471 2471
2472 2472 $ hg log -G
2473 2473 @ changeset: 2:fe5fc3d0eb17
2474 2474 | tag: tip
2475 2475 | parent: 0:abf4f0e38563
2476 2476 | user: test
2477 2477 | date: Thu Jan 01 00:00:00 1970 +0000
2478 2478 | summary: A3B2C2
2479 2479 |
2480 2480 | o changeset: 1:07dcc6b312c0
2481 2481 |/ user: test
2482 2482 | date: Thu Jan 01 00:00:00 1970 +0000
2483 2483 | summary: A2B2C2
2484 2484 |
2485 2485 o changeset: 0:abf4f0e38563
2486 2486 user: test
2487 2487 date: Thu Jan 01 00:00:00 1970 +0000
2488 2488 summary: A1B1C1
2489 2489
2490 2490
2491 2491 Log -f on B should reports current changesets
2492 2492
2493 2493 $ hg log -fG B
2494 2494 @ changeset: 2:fe5fc3d0eb17
2495 2495 | tag: tip
2496 2496 | parent: 0:abf4f0e38563
2497 2497 | user: test
2498 2498 | date: Thu Jan 01 00:00:00 1970 +0000
2499 2499 | summary: A3B2C2
2500 2500 |
2501 2501 o changeset: 0:abf4f0e38563
2502 2502 user: test
2503 2503 date: Thu Jan 01 00:00:00 1970 +0000
2504 2504 summary: A1B1C1
2505 2505
2506 2506 $ cd ..
@@ -1,1563 +1,1563 b''
1 1 $ cat >> $HGRCPATH << EOF
2 2 > [phases]
3 3 > # public changeset are not obsolete
4 4 > publish=false
5 5 > [ui]
6 6 > logtemplate="{rev}:{node|short} ({phase}{if(obsolete, ' *{obsolete}*')}{if(instabilities, ' {instabilities}')}) [{tags} {bookmarks}] {desc|firstline}{if(obsfate, " [{join(obsfate, "; ")}]")}\n"
7 7 > EOF
8 8 $ mkcommit() {
9 9 > echo "$1" > "$1"
10 10 > hg add "$1"
11 11 > hg ci -m "add $1"
12 12 > }
13 13 $ getid() {
14 14 > hg log -T "{node}\n" --hidden -r "desc('$1')"
15 15 > }
16 16
17 17 $ cat > debugkeys.py <<EOF
18 18 > def reposetup(ui, repo):
19 19 > class debugkeysrepo(repo.__class__):
20 20 > def listkeys(self, namespace):
21 21 > ui.write('listkeys %s\n' % (namespace,))
22 22 > return super(debugkeysrepo, self).listkeys(namespace)
23 23 >
24 24 > if repo.local():
25 25 > repo.__class__ = debugkeysrepo
26 26 > EOF
27 27
28 28 $ hg init tmpa
29 29 $ cd tmpa
30 30 $ mkcommit kill_me
31 31
32 32 Checking that the feature is properly disabled
33 33
34 34 $ hg debugobsolete -d '0 0' `getid kill_me` -u babar
35 35 abort: creating obsolete markers is not enabled on this repo
36 36 [255]
37 37
38 38 Enabling it
39 39
40 40 $ cat >> $HGRCPATH << EOF
41 41 > [experimental]
42 42 > evolution=exchange
43 43 > evolution.createmarkers=True
44 44 > EOF
45 45
46 46 Killing a single changeset without replacement
47 47
48 48 $ hg debugobsolete 0
49 49 abort: changeset references must be full hexadecimal node identifiers
50 50 [255]
51 51 $ hg debugobsolete '00'
52 52 abort: changeset references must be full hexadecimal node identifiers
53 53 [255]
54 54 $ hg debugobsolete -d '0 0' `getid kill_me` -u babar
55 55 obsoleted 1 changesets
56 56 $ hg debugobsolete
57 57 97b7c2d76b1845ed3eb988cd612611e72406cef0 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'babar'}
58 58
59 59 (test that mercurial is not confused)
60 60
61 61 $ hg up null --quiet # having 0 as parent prevents it to be hidden
62 62 $ hg tip
63 63 -1:000000000000 (public) [tip ]
64 64 $ hg up --hidden tip --quiet
65 65 updating to a hidden changeset 97b7c2d76b18
66 66
67 67 Killing a single changeset with itself should fail
68 68 (simple local safeguard)
69 69
70 70 $ hg debugobsolete `getid kill_me` `getid kill_me`
71 71 abort: bad obsmarker input: in-marker cycle with 97b7c2d76b1845ed3eb988cd612611e72406cef0
72 72 [255]
73 73
74 74 $ cd ..
75 75
76 76 Killing a single changeset with replacement
77 77 (and testing the format option)
78 78
79 79 $ hg init tmpb
80 80 $ cd tmpb
81 81 $ mkcommit a
82 82 $ mkcommit b
83 83 $ mkcommit original_c
84 84 $ hg up "desc('b')"
85 85 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
86 86 $ mkcommit new_c
87 87 created new head
88 88 $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden
89 89 $ hg debugobsolete --config format.obsstore-version=0 --flag 12 `getid original_c` `getid new_c` -d '121 120'
90 90 obsoleted 1 changesets
91 91 $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden
92 92 2:245bde4270cd add original_c
93 93 $ hg debugrevlog -cd
94 94 # rev p1rev p2rev start end deltastart base p1 p2 rawsize totalsize compression heads chainlen
95 95 0 -1 -1 0 59 0 0 0 0 58 58 0 1 0
96 96 1 0 -1 59 118 59 59 0 0 58 116 0 1 0
97 97 2 1 -1 118 193 118 118 59 0 76 192 0 1 0
98 98 3 1 -1 193 260 193 193 59 0 66 258 0 2 0
99 99 $ hg debugobsolete
100 100 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
101 101
102 102 (check for version number of the obsstore)
103 103
104 104 $ dd bs=1 count=1 if=.hg/store/obsstore 2>/dev/null
105 105 \x00 (no-eol) (esc)
106 106
107 107 do it again (it read the obsstore before adding new changeset)
108 108
109 109 $ hg up '.^'
110 110 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
111 111 $ mkcommit new_2_c
112 112 created new head
113 113 $ hg debugobsolete -d '1337 0' `getid new_c` `getid new_2_c`
114 114 obsoleted 1 changesets
115 115 $ hg debugobsolete
116 116 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
117 117 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
118 118
119 119 Register two markers with a missing node
120 120
121 121 $ hg up '.^'
122 122 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
123 123 $ mkcommit new_3_c
124 124 created new head
125 125 $ hg debugobsolete -d '1338 0' `getid new_2_c` 1337133713371337133713371337133713371337
126 126 obsoleted 1 changesets
127 127 $ hg debugobsolete -d '1339 0' 1337133713371337133713371337133713371337 `getid new_3_c`
128 128 $ hg debugobsolete
129 129 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
130 130 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
131 131 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
132 132 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
133 133
134 134 Test the --index option of debugobsolete command
135 135 $ hg debugobsolete --index
136 136 0 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
137 137 1 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
138 138 2 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
139 139 3 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
140 140
141 141 Refuse pathological nullid successors
142 142 $ hg debugobsolete -d '9001 0' 1337133713371337133713371337133713371337 0000000000000000000000000000000000000000
143 143 transaction abort!
144 144 rollback completed
145 145 abort: bad obsolescence marker detected: invalid successors nullid
146 146 [255]
147 147
148 148 Check that graphlog detect that a changeset is obsolete:
149 149
150 150 $ hg log -G
151 151 @ 5:5601fb93a350 (draft) [tip ] add new_3_c
152 152 |
153 153 o 1:7c3bad9141dc (draft) [ ] add b
154 154 |
155 155 o 0:1f0dee641bb7 (draft) [ ] add a
156 156
157 157
158 158 check that heads does not report them
159 159
160 160 $ hg heads
161 161 5:5601fb93a350 (draft) [tip ] add new_3_c
162 162 $ hg heads --hidden
163 163 5:5601fb93a350 (draft) [tip ] add new_3_c
164 164 4:ca819180edb9 (draft *obsolete*) [ ] add new_2_c [rewritten as 5:5601fb93a350]
165 165 3:cdbce2fbb163 (draft *obsolete*) [ ] add new_c [rewritten as 4:ca819180edb9]
166 166 2:245bde4270cd (draft *obsolete*) [ ] add original_c [rewritten as 3:cdbce2fbb163]
167 167
168 168
169 169 check that summary does not report them
170 170
171 171 $ hg init ../sink
172 172 $ echo '[paths]' >> .hg/hgrc
173 173 $ echo 'default=../sink' >> .hg/hgrc
174 174 $ hg summary --remote
175 175 parent: 5:5601fb93a350 tip
176 176 add new_3_c
177 177 branch: default
178 178 commit: (clean)
179 179 update: (current)
180 180 phases: 3 draft
181 181 remote: 3 outgoing
182 182
183 183 $ hg summary --remote --hidden
184 184 parent: 5:5601fb93a350 tip
185 185 add new_3_c
186 186 branch: default
187 187 commit: (clean)
188 188 update: 3 new changesets, 4 branch heads (merge)
189 189 phases: 6 draft
190 190 remote: 3 outgoing
191 191
192 192 check that various commands work well with filtering
193 193
194 194 $ hg tip
195 195 5:5601fb93a350 (draft) [tip ] add new_3_c
196 196 $ hg log -r 6
197 197 abort: unknown revision '6'!
198 198 [255]
199 199 $ hg log -r 4
200 abort: hidden revision '4'!
200 abort: hidden revision '4' was rewritten as: 5601fb93a350!
201 201 (use --hidden to access hidden revisions)
202 202 [255]
203 203 $ hg debugrevspec 'rev(6)'
204 204 $ hg debugrevspec 'rev(4)'
205 205 $ hg debugrevspec 'null'
206 206 -1
207 207
208 208 Check that public changeset are not accounted as obsolete:
209 209
210 210 $ hg --hidden phase --public 2
211 211 $ hg log -G
212 212 @ 5:5601fb93a350 (draft phase-divergent) [tip ] add new_3_c
213 213 |
214 214 | o 2:245bde4270cd (public) [ ] add original_c
215 215 |/
216 216 o 1:7c3bad9141dc (public) [ ] add b
217 217 |
218 218 o 0:1f0dee641bb7 (public) [ ] add a
219 219
220 220
221 221 And that bumped changeset are detected
222 222 --------------------------------------
223 223
224 224 If we didn't filtered obsolete changesets out, 3 and 4 would show up too. Also
225 225 note that the bumped changeset (5:5601fb93a350) is not a direct successor of
226 226 the public changeset
227 227
228 228 $ hg log --hidden -r 'phasedivergent()'
229 229 5:5601fb93a350 (draft phase-divergent) [tip ] add new_3_c
230 230
231 231 And that we can't push bumped changeset
232 232
233 233 $ hg push ../tmpa -r 0 --force #(make repo related)
234 234 pushing to ../tmpa
235 235 searching for changes
236 236 warning: repository is unrelated
237 237 adding changesets
238 238 adding manifests
239 239 adding file changes
240 240 added 1 changesets with 1 changes to 1 files (+1 heads)
241 241 $ hg push ../tmpa
242 242 pushing to ../tmpa
243 243 searching for changes
244 244 abort: push includes phase-divergent changeset: 5601fb93a350!
245 245 [255]
246 246
247 247 Fixing "bumped" situation
248 248 We need to create a clone of 5 and add a special marker with a flag
249 249
250 250 $ hg summary
251 251 parent: 5:5601fb93a350 tip (phase-divergent)
252 252 add new_3_c
253 253 branch: default
254 254 commit: (clean)
255 255 update: 1 new changesets, 2 branch heads (merge)
256 256 phases: 1 draft
257 257 phase-divergent: 1 changesets
258 258 $ hg up '5^'
259 259 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
260 260 $ hg revert -ar 5
261 261 adding new_3_c
262 262 $ hg ci -m 'add n3w_3_c'
263 263 created new head
264 264 $ hg debugobsolete -d '1338 0' --flags 1 `getid new_3_c` `getid n3w_3_c`
265 265 obsoleted 1 changesets
266 266 $ hg log -r 'phasedivergent()'
267 267 $ hg log -G
268 268 @ 6:6f9641995072 (draft) [tip ] add n3w_3_c
269 269 |
270 270 | o 2:245bde4270cd (public) [ ] add original_c
271 271 |/
272 272 o 1:7c3bad9141dc (public) [ ] add b
273 273 |
274 274 o 0:1f0dee641bb7 (public) [ ] add a
275 275
276 276
277 277 Basic exclusive testing
278 278
279 279 $ hg log -G --hidden
280 280 @ 6:6f9641995072 (draft) [tip ] add n3w_3_c
281 281 |
282 282 | x 5:5601fb93a350 (draft *obsolete*) [ ] add new_3_c [rewritten as 6:6f9641995072]
283 283 |/
284 284 | x 4:ca819180edb9 (draft *obsolete*) [ ] add new_2_c [rewritten as 5:5601fb93a350]
285 285 |/
286 286 | x 3:cdbce2fbb163 (draft *obsolete*) [ ] add new_c [rewritten as 4:ca819180edb9]
287 287 |/
288 288 | o 2:245bde4270cd (public) [ ] add original_c
289 289 |/
290 290 o 1:7c3bad9141dc (public) [ ] add b
291 291 |
292 292 o 0:1f0dee641bb7 (public) [ ] add a
293 293
294 294 $ hg debugobsolete --rev 6f9641995072
295 295 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
296 296 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
297 297 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
298 298 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
299 299 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
300 300 $ hg debugobsolete --rev 6f9641995072 --exclusive
301 301 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
302 302 $ hg debugobsolete --rev 5601fb93a350 --hidden
303 303 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
304 304 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
305 305 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
306 306 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
307 307 $ hg debugobsolete --rev 5601fb93a350 --hidden --exclusive
308 308 $ hg debugobsolete --rev 5601fb93a350+6f9641995072 --hidden --exclusive
309 309 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
310 310 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
311 311 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
312 312
313 313 $ cd ..
314 314
315 315 Revision 0 is hidden
316 316 --------------------
317 317
318 318 $ hg init rev0hidden
319 319 $ cd rev0hidden
320 320
321 321 $ mkcommit kill0
322 322 $ hg up -q null
323 323 $ hg debugobsolete `getid kill0`
324 324 obsoleted 1 changesets
325 325 $ mkcommit a
326 326 $ mkcommit b
327 327
328 328 Should pick the first visible revision as "repo" node
329 329
330 330 $ hg archive ../archive-null
331 331 $ cat ../archive-null/.hg_archival.txt
332 332 repo: 1f0dee641bb7258c56bd60e93edfa2405381c41e
333 333 node: 7c3bad9141dcb46ff89abf5f61856facd56e476c
334 334 branch: default
335 335 latesttag: null
336 336 latesttagdistance: 2
337 337 changessincelatesttag: 2
338 338
339 339
340 340 $ cd ..
341 341
342 342 Exchange Test
343 343 ============================
344 344
345 345 Destination repo does not have any data
346 346 ---------------------------------------
347 347
348 348 Simple incoming test
349 349
350 350 $ hg init tmpc
351 351 $ cd tmpc
352 352 $ hg incoming ../tmpb
353 353 comparing with ../tmpb
354 354 0:1f0dee641bb7 (public) [ ] add a
355 355 1:7c3bad9141dc (public) [ ] add b
356 356 2:245bde4270cd (public) [ ] add original_c
357 357 6:6f9641995072 (draft) [tip ] add n3w_3_c
358 358
359 359 Try to pull markers
360 360 (extinct changeset are excluded but marker are pushed)
361 361
362 362 $ hg pull ../tmpb
363 363 pulling from ../tmpb
364 364 requesting all changes
365 365 adding changesets
366 366 adding manifests
367 367 adding file changes
368 368 added 4 changesets with 4 changes to 4 files (+1 heads)
369 369 5 new obsolescence markers
370 370 new changesets 1f0dee641bb7:6f9641995072
371 371 (run 'hg heads' to see heads, 'hg merge' to merge)
372 372 $ hg debugobsolete
373 373 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
374 374 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
375 375 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
376 376 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
377 377 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
378 378
379 379 Rollback//Transaction support
380 380
381 381 $ hg debugobsolete -d '1340 0' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
382 382 $ hg debugobsolete
383 383 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
384 384 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
385 385 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
386 386 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
387 387 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
388 388 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 (Thu Jan 01 00:22:20 1970 +0000) {'user': 'test'}
389 389 $ hg rollback -n
390 390 repository tip rolled back to revision 3 (undo debugobsolete)
391 391 $ hg rollback
392 392 repository tip rolled back to revision 3 (undo debugobsolete)
393 393 $ hg debugobsolete
394 394 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
395 395 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
396 396 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
397 397 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
398 398 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
399 399
400 400 $ cd ..
401 401
402 402 Try to push markers
403 403
404 404 $ hg init tmpd
405 405 $ hg -R tmpb push tmpd
406 406 pushing to tmpd
407 407 searching for changes
408 408 adding changesets
409 409 adding manifests
410 410 adding file changes
411 411 added 4 changesets with 4 changes to 4 files (+1 heads)
412 412 5 new obsolescence markers
413 413 $ hg -R tmpd debugobsolete | sort
414 414 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
415 415 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
416 416 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
417 417 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
418 418 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
419 419
420 420 Check obsolete keys are exchanged only if source has an obsolete store
421 421
422 422 $ hg init empty
423 423 $ hg --config extensions.debugkeys=debugkeys.py -R empty push tmpd
424 424 pushing to tmpd
425 425 listkeys phases
426 426 listkeys bookmarks
427 427 no changes found
428 428 listkeys phases
429 429 [1]
430 430
431 431 clone support
432 432 (markers are copied and extinct changesets are included to allow hardlinks)
433 433
434 434 $ hg clone tmpb clone-dest
435 435 updating to branch default
436 436 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
437 437 $ hg -R clone-dest log -G --hidden
438 438 @ 6:6f9641995072 (draft) [tip ] add n3w_3_c
439 439 |
440 440 | x 5:5601fb93a350 (draft *obsolete*) [ ] add new_3_c [rewritten as 6:6f9641995072]
441 441 |/
442 442 | x 4:ca819180edb9 (draft *obsolete*) [ ] add new_2_c [rewritten as 5:5601fb93a350]
443 443 |/
444 444 | x 3:cdbce2fbb163 (draft *obsolete*) [ ] add new_c [rewritten as 4:ca819180edb9]
445 445 |/
446 446 | o 2:245bde4270cd (public) [ ] add original_c
447 447 |/
448 448 o 1:7c3bad9141dc (public) [ ] add b
449 449 |
450 450 o 0:1f0dee641bb7 (public) [ ] add a
451 451
452 452 $ hg -R clone-dest debugobsolete
453 453 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
454 454 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
455 455 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
456 456 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
457 457 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
458 458
459 459
460 460 Destination repo have existing data
461 461 ---------------------------------------
462 462
463 463 On pull
464 464
465 465 $ hg init tmpe
466 466 $ cd tmpe
467 467 $ hg debugobsolete -d '1339 0' 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00
468 468 $ hg pull ../tmpb
469 469 pulling from ../tmpb
470 470 requesting all changes
471 471 adding changesets
472 472 adding manifests
473 473 adding file changes
474 474 added 4 changesets with 4 changes to 4 files (+1 heads)
475 475 5 new obsolescence markers
476 476 new changesets 1f0dee641bb7:6f9641995072
477 477 (run 'hg heads' to see heads, 'hg merge' to merge)
478 478 $ hg debugobsolete
479 479 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
480 480 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
481 481 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
482 482 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
483 483 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
484 484 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
485 485
486 486
487 487 On push
488 488
489 489 $ hg push ../tmpc
490 490 pushing to ../tmpc
491 491 searching for changes
492 492 no changes found
493 493 1 new obsolescence markers
494 494 [1]
495 495 $ hg -R ../tmpc debugobsolete
496 496 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
497 497 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
498 498 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
499 499 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
500 500 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
501 501 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
502 502
503 503 detect outgoing obsolete and unstable
504 504 ---------------------------------------
505 505
506 506
507 507 $ hg log -G
508 508 o 3:6f9641995072 (draft) [tip ] add n3w_3_c
509 509 |
510 510 | o 2:245bde4270cd (public) [ ] add original_c
511 511 |/
512 512 o 1:7c3bad9141dc (public) [ ] add b
513 513 |
514 514 o 0:1f0dee641bb7 (public) [ ] add a
515 515
516 516 $ hg up 'desc("n3w_3_c")'
517 517 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
518 518 $ mkcommit original_d
519 519 $ mkcommit original_e
520 520 $ hg debugobsolete --record-parents `getid original_d` -d '0 0'
521 521 obsoleted 1 changesets
522 522 $ hg debugobsolete | grep `getid original_d`
523 523 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
524 524 $ hg log -r 'obsolete()'
525 525 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
526 526 $ hg summary
527 527 parent: 5:cda648ca50f5 tip (orphan)
528 528 add original_e
529 529 branch: default
530 530 commit: (clean)
531 531 update: 1 new changesets, 2 branch heads (merge)
532 532 phases: 3 draft
533 533 orphan: 1 changesets
534 534 $ hg log -G -r '::orphan()'
535 535 @ 5:cda648ca50f5 (draft orphan) [tip ] add original_e
536 536 |
537 537 x 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
538 538 |
539 539 o 3:6f9641995072 (draft) [ ] add n3w_3_c
540 540 |
541 541 o 1:7c3bad9141dc (public) [ ] add b
542 542 |
543 543 o 0:1f0dee641bb7 (public) [ ] add a
544 544
545 545
546 546 refuse to push obsolete changeset
547 547
548 548 $ hg push ../tmpc/ -r 'desc("original_d")'
549 549 pushing to ../tmpc/
550 550 searching for changes
551 551 abort: push includes obsolete changeset: 94b33453f93b!
552 552 [255]
553 553
554 554 refuse to push unstable changeset
555 555
556 556 $ hg push ../tmpc/
557 557 pushing to ../tmpc/
558 558 searching for changes
559 559 abort: push includes orphan changeset: cda648ca50f5!
560 560 [255]
561 561
562 562 Test that extinct changeset are properly detected
563 563
564 564 $ hg log -r 'extinct()'
565 565
566 566 Don't try to push extinct changeset
567 567
568 568 $ hg init ../tmpf
569 569 $ hg out ../tmpf
570 570 comparing with ../tmpf
571 571 searching for changes
572 572 0:1f0dee641bb7 (public) [ ] add a
573 573 1:7c3bad9141dc (public) [ ] add b
574 574 2:245bde4270cd (public) [ ] add original_c
575 575 3:6f9641995072 (draft) [ ] add n3w_3_c
576 576 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
577 577 5:cda648ca50f5 (draft orphan) [tip ] add original_e
578 578 $ hg push ../tmpf -f # -f because be push unstable too
579 579 pushing to ../tmpf
580 580 searching for changes
581 581 adding changesets
582 582 adding manifests
583 583 adding file changes
584 584 added 6 changesets with 6 changes to 6 files (+1 heads)
585 585 7 new obsolescence markers
586 586
587 587 no warning displayed
588 588
589 589 $ hg push ../tmpf
590 590 pushing to ../tmpf
591 591 searching for changes
592 592 no changes found
593 593 [1]
594 594
595 595 Do not warn about new head when the new head is a successors of a remote one
596 596
597 597 $ hg log -G
598 598 @ 5:cda648ca50f5 (draft orphan) [tip ] add original_e
599 599 |
600 600 x 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
601 601 |
602 602 o 3:6f9641995072 (draft) [ ] add n3w_3_c
603 603 |
604 604 | o 2:245bde4270cd (public) [ ] add original_c
605 605 |/
606 606 o 1:7c3bad9141dc (public) [ ] add b
607 607 |
608 608 o 0:1f0dee641bb7 (public) [ ] add a
609 609
610 610 $ hg up -q 'desc(n3w_3_c)'
611 611 $ mkcommit obsolete_e
612 612 created new head
613 613 $ hg debugobsolete `getid 'original_e'` `getid 'obsolete_e'` \
614 614 > -u 'test <test@example.net>'
615 615 obsoleted 1 changesets
616 616 $ hg outgoing ../tmpf # parasite hg outgoing testin
617 617 comparing with ../tmpf
618 618 searching for changes
619 619 6:3de5eca88c00 (draft) [tip ] add obsolete_e
620 620 $ hg push ../tmpf
621 621 pushing to ../tmpf
622 622 searching for changes
623 623 adding changesets
624 624 adding manifests
625 625 adding file changes
626 626 added 1 changesets with 1 changes to 1 files (+1 heads)
627 627 1 new obsolescence markers
628 628 obsoleted 1 changesets
629 629
630 630 test relevance computation
631 631 ---------------------------------------
632 632
633 633 Checking simple case of "marker relevance".
634 634
635 635
636 636 Reminder of the repo situation
637 637
638 638 $ hg log --hidden --graph
639 639 @ 6:3de5eca88c00 (draft) [tip ] add obsolete_e
640 640 |
641 641 | x 5:cda648ca50f5 (draft *obsolete*) [ ] add original_e [rewritten as 6:3de5eca88c00 by test <test@example.net>]
642 642 | |
643 643 | x 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
644 644 |/
645 645 o 3:6f9641995072 (draft) [ ] add n3w_3_c
646 646 |
647 647 | o 2:245bde4270cd (public) [ ] add original_c
648 648 |/
649 649 o 1:7c3bad9141dc (public) [ ] add b
650 650 |
651 651 o 0:1f0dee641bb7 (public) [ ] add a
652 652
653 653
654 654 List of all markers
655 655
656 656 $ hg debugobsolete
657 657 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
658 658 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
659 659 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
660 660 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
661 661 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
662 662 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
663 663 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
664 664 cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test <test@example.net>'} (glob)
665 665
666 666 List of changesets with no chain
667 667
668 668 $ hg debugobsolete --hidden --rev ::2
669 669
670 670 List of changesets that are included on marker chain
671 671
672 672 $ hg debugobsolete --hidden --rev 6
673 673 cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test <test@example.net>'} (glob)
674 674
675 675 List of changesets with a longer chain, (including a pruned children)
676 676
677 677 $ hg debugobsolete --hidden --rev 3
678 678 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
679 679 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
680 680 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
681 681 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
682 682 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
683 683 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
684 684 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
685 685
686 686 List of both
687 687
688 688 $ hg debugobsolete --hidden --rev 3::6
689 689 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
690 690 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
691 691 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
692 692 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
693 693 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
694 694 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
695 695 cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test <test@example.net>'} (glob)
696 696 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
697 697
698 698 List of all markers in JSON
699 699
700 700 $ hg debugobsolete -Tjson
701 701 [
702 702 {
703 703 "date": [1339.0, 0],
704 704 "flag": 0,
705 705 "metadata": {"user": "test"},
706 706 "prednode": "1339133913391339133913391339133913391339",
707 707 "succnodes": ["ca819180edb99ed25ceafb3e9584ac287e240b00"]
708 708 },
709 709 {
710 710 "date": [1339.0, 0],
711 711 "flag": 0,
712 712 "metadata": {"user": "test"},
713 713 "prednode": "1337133713371337133713371337133713371337",
714 714 "succnodes": ["5601fb93a350734d935195fee37f4054c529ff39"]
715 715 },
716 716 {
717 717 "date": [121.0, 120],
718 718 "flag": 12,
719 719 "metadata": {"user": "test"},
720 720 "prednode": "245bde4270cd1072a27757984f9cda8ba26f08ca",
721 721 "succnodes": ["cdbce2fbb16313928851e97e0d85413f3f7eb77f"]
722 722 },
723 723 {
724 724 "date": [1338.0, 0],
725 725 "flag": 1,
726 726 "metadata": {"user": "test"},
727 727 "prednode": "5601fb93a350734d935195fee37f4054c529ff39",
728 728 "succnodes": ["6f96419950729f3671185b847352890f074f7557"]
729 729 },
730 730 {
731 731 "date": [1338.0, 0],
732 732 "flag": 0,
733 733 "metadata": {"user": "test"},
734 734 "prednode": "ca819180edb99ed25ceafb3e9584ac287e240b00",
735 735 "succnodes": ["1337133713371337133713371337133713371337"]
736 736 },
737 737 {
738 738 "date": [1337.0, 0],
739 739 "flag": 0,
740 740 "metadata": {"user": "test"},
741 741 "prednode": "cdbce2fbb16313928851e97e0d85413f3f7eb77f",
742 742 "succnodes": ["ca819180edb99ed25ceafb3e9584ac287e240b00"]
743 743 },
744 744 {
745 745 "date": [0.0, 0],
746 746 "flag": 0,
747 747 "metadata": {"user": "test"},
748 748 "parentnodes": ["6f96419950729f3671185b847352890f074f7557"],
749 749 "prednode": "94b33453f93bdb8d457ef9b770851a618bf413e1",
750 750 "succnodes": []
751 751 },
752 752 {
753 753 "date": *, (glob)
754 754 "flag": 0,
755 755 "metadata": {"user": "test <test@example.net>"},
756 756 "prednode": "cda648ca50f50482b7055c0b0c4c117bba6733d9",
757 757 "succnodes": ["3de5eca88c00aa039da7399a220f4a5221faa585"]
758 758 }
759 759 ]
760 760
761 761 Template keywords
762 762
763 763 $ hg debugobsolete -r6 -T '{succnodes % "{node|short}"} {date|shortdate}\n'
764 764 3de5eca88c00 ????-??-?? (glob)
765 765 $ hg debugobsolete -r6 -T '{join(metadata % "{key}={value}", " ")}\n'
766 766 user=test <test@example.net>
767 767 $ hg debugobsolete -r6 -T '{metadata}\n{metadata}\n'
768 768 'user': 'test <test@example.net>'
769 769 'user': 'test <test@example.net>'
770 770 $ hg debugobsolete -r6 -T '{succnodes}\n{succnodes}\n'
771 771 3de5eca88c00aa039da7399a220f4a5221faa585
772 772 3de5eca88c00aa039da7399a220f4a5221faa585
773 773 $ hg debugobsolete -r6 -T '{flag} {get(metadata, "user")}\n'
774 774 0 test <test@example.net>
775 775
776 776 Test the debug output for exchange
777 777 ----------------------------------
778 778
779 779 $ hg pull ../tmpb --config 'experimental.obsmarkers-exchange-debug=True' # bundle2
780 780 pulling from ../tmpb
781 781 searching for changes
782 782 no changes found
783 783 obsmarker-exchange: 346 bytes received
784 784
785 785 check hgweb does not explode
786 786 ====================================
787 787
788 788 $ hg unbundle $TESTDIR/bundles/hgweb+obs.hg
789 789 adding changesets
790 790 adding manifests
791 791 adding file changes
792 792 added 62 changesets with 63 changes to 9 files (+60 heads)
793 793 new changesets 50c51b361e60:c15e9edfca13
794 794 (run 'hg heads .' to see heads, 'hg merge' to merge)
795 795 $ for node in `hg log -r 'desc(babar_)' --template '{node}\n'`;
796 796 > do
797 797 > hg debugobsolete $node
798 798 > done
799 799 obsoleted 1 changesets
800 800 obsoleted 1 changesets
801 801 obsoleted 1 changesets
802 802 obsoleted 1 changesets
803 803 obsoleted 1 changesets
804 804 obsoleted 1 changesets
805 805 obsoleted 1 changesets
806 806 obsoleted 1 changesets
807 807 obsoleted 1 changesets
808 808 obsoleted 1 changesets
809 809 obsoleted 1 changesets
810 810 obsoleted 1 changesets
811 811 obsoleted 1 changesets
812 812 obsoleted 1 changesets
813 813 obsoleted 1 changesets
814 814 obsoleted 1 changesets
815 815 obsoleted 1 changesets
816 816 obsoleted 1 changesets
817 817 obsoleted 1 changesets
818 818 obsoleted 1 changesets
819 819 obsoleted 1 changesets
820 820 obsoleted 1 changesets
821 821 obsoleted 1 changesets
822 822 obsoleted 1 changesets
823 823 obsoleted 1 changesets
824 824 obsoleted 1 changesets
825 825 obsoleted 1 changesets
826 826 obsoleted 1 changesets
827 827 obsoleted 1 changesets
828 828 obsoleted 1 changesets
829 829 obsoleted 1 changesets
830 830 obsoleted 1 changesets
831 831 obsoleted 1 changesets
832 832 obsoleted 1 changesets
833 833 obsoleted 1 changesets
834 834 obsoleted 1 changesets
835 835 obsoleted 1 changesets
836 836 obsoleted 1 changesets
837 837 obsoleted 1 changesets
838 838 obsoleted 1 changesets
839 839 obsoleted 1 changesets
840 840 obsoleted 1 changesets
841 841 obsoleted 1 changesets
842 842 obsoleted 1 changesets
843 843 obsoleted 1 changesets
844 844 obsoleted 1 changesets
845 845 obsoleted 1 changesets
846 846 obsoleted 1 changesets
847 847 obsoleted 1 changesets
848 848 obsoleted 1 changesets
849 849 obsoleted 1 changesets
850 850 obsoleted 1 changesets
851 851 obsoleted 1 changesets
852 852 obsoleted 1 changesets
853 853 obsoleted 1 changesets
854 854 obsoleted 1 changesets
855 855 obsoleted 1 changesets
856 856 obsoleted 1 changesets
857 857 obsoleted 1 changesets
858 858 obsoleted 1 changesets
859 859 $ hg up tip
860 860 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
861 861
862 862 #if serve
863 863
864 864 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
865 865 $ cat hg.pid >> $DAEMON_PIDS
866 866
867 867 check changelog view
868 868
869 869 $ get-with-headers.py --headeronly localhost:$HGPORT 'shortlog/'
870 870 200 Script output follows
871 871
872 872 check graph view
873 873
874 874 $ get-with-headers.py --headeronly localhost:$HGPORT 'graph'
875 875 200 Script output follows
876 876
877 877 check filelog view
878 878
879 879 $ get-with-headers.py --headeronly localhost:$HGPORT 'log/'`hg log -r . -T "{node}"`/'babar'
880 880 200 Script output follows
881 881
882 882 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/68'
883 883 200 Script output follows
884 884 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/67'
885 885 404 Not Found
886 886 [1]
887 887
888 888 check that web.view config option:
889 889
890 890 $ killdaemons.py hg.pid
891 891 $ cat >> .hg/hgrc << EOF
892 892 > [web]
893 893 > view=all
894 894 > EOF
895 895 $ wait
896 896 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
897 897 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/67'
898 898 200 Script output follows
899 899 $ killdaemons.py hg.pid
900 900
901 901 Checking _enable=False warning if obsolete marker exists
902 902
903 903 $ echo '[experimental]' >> $HGRCPATH
904 904 $ echo "evolution=" >> $HGRCPATH
905 905 $ hg log -r tip
906 906 68:c15e9edfca13 (draft) [tip ] add celestine
907 907
908 908 reenable for later test
909 909
910 910 $ echo '[experimental]' >> $HGRCPATH
911 911 $ echo "evolution.exchange=True" >> $HGRCPATH
912 912 $ echo "evolution.createmarkers=True" >> $HGRCPATH
913 913
914 914 $ rm hg.pid access.log errors.log
915 915 #endif
916 916
917 917 Several troubles on the same changeset (create an unstable and bumped changeset)
918 918
919 919 $ hg debugobsolete `getid obsolete_e`
920 920 obsoleted 1 changesets
921 921 $ hg debugobsolete `getid original_c` `getid babar`
922 922 $ hg log --config ui.logtemplate= -r 'phasedivergent() and orphan()'
923 923 changeset: 7:50c51b361e60
924 924 user: test
925 925 date: Thu Jan 01 00:00:00 1970 +0000
926 926 instability: orphan, phase-divergent
927 927 summary: add babar
928 928
929 929
930 930 test the "obsolete" templatekw
931 931
932 932 $ hg log -r 'obsolete()'
933 933 6:3de5eca88c00 (draft *obsolete*) [ ] add obsolete_e [pruned]
934 934
935 935 test the "troubles" templatekw
936 936
937 937 $ hg log -r 'phasedivergent() and orphan()'
938 938 7:50c51b361e60 (draft orphan phase-divergent) [ ] add babar
939 939
940 940 test the default cmdline template
941 941
942 942 $ hg log -T default -r 'phasedivergent()'
943 943 changeset: 7:50c51b361e60
944 944 user: test
945 945 date: Thu Jan 01 00:00:00 1970 +0000
946 946 instability: orphan, phase-divergent
947 947 summary: add babar
948 948
949 949 $ hg log -T default -r 'obsolete()'
950 950 changeset: 6:3de5eca88c00
951 951 parent: 3:6f9641995072
952 952 user: test
953 953 date: Thu Jan 01 00:00:00 1970 +0000
954 954 obsolete: pruned
955 955 summary: add obsolete_e
956 956
957 957
958 958 test the obsolete labels
959 959
960 960 $ hg log --config ui.logtemplate= --color=debug -r 'phasedivergent()'
961 961 [log.changeset changeset.draft changeset.unstable instability.orphan instability.phase-divergent|changeset: 7:50c51b361e60]
962 962 [log.user|user: test]
963 963 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
964 964 [log.instability|instability: orphan, phase-divergent]
965 965 [log.summary|summary: add babar]
966 966
967 967
968 968 $ hg log -T default -r 'phasedivergent()' --color=debug
969 969 [log.changeset changeset.draft changeset.unstable instability.orphan instability.phase-divergent|changeset: 7:50c51b361e60]
970 970 [log.user|user: test]
971 971 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
972 972 [log.instability|instability: orphan, phase-divergent]
973 973 [log.summary|summary: add babar]
974 974
975 975
976 976 $ hg log --config ui.logtemplate= --color=debug -r "obsolete()"
977 977 [log.changeset changeset.draft changeset.obsolete|changeset: 6:3de5eca88c00]
978 978 [log.parent changeset.draft|parent: 3:6f9641995072]
979 979 [log.user|user: test]
980 980 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
981 981 [log.obsfate|obsolete: pruned]
982 982 [log.summary|summary: add obsolete_e]
983 983
984 984
985 985 $ hg log -T default -r 'obsolete()' --color=debug
986 986 [log.changeset changeset.draft changeset.obsolete|changeset: 6:3de5eca88c00]
987 987 [log.parent changeset.draft|parent: 3:6f9641995072]
988 988 [log.user|user: test]
989 989 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
990 990 [log.obsfate|obsolete: pruned]
991 991 [log.summary|summary: add obsolete_e]
992 992
993 993
994 994 test summary output
995 995
996 996 $ hg up -r 'phasedivergent() and orphan()'
997 997 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
998 998 $ hg summary
999 999 parent: 7:50c51b361e60 (orphan, phase-divergent)
1000 1000 add babar
1001 1001 branch: default
1002 1002 commit: (clean)
1003 1003 update: 2 new changesets (update)
1004 1004 phases: 4 draft
1005 1005 orphan: 2 changesets
1006 1006 phase-divergent: 1 changesets
1007 1007 $ hg up -r 'obsolete()'
1008 1008 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1009 1009 $ hg summary
1010 1010 parent: 6:3de5eca88c00 (obsolete)
1011 1011 add obsolete_e
1012 1012 branch: default
1013 1013 commit: (clean)
1014 1014 update: 3 new changesets (update)
1015 1015 phases: 4 draft
1016 1016 orphan: 2 changesets
1017 1017 phase-divergent: 1 changesets
1018 1018
1019 1019 #if serve
1020 1020
1021 1021 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
1022 1022 $ cat hg.pid >> $DAEMON_PIDS
1023 1023
1024 1024 check obsolete changeset
1025 1025
1026 1026 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=paper' | grep '<span class="obsolete">'
1027 1027 <span class="phase">draft</span> <span class="obsolete">obsolete</span>
1028 1028 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=coal' | grep '<span class="obsolete">'
1029 1029 <span class="phase">draft</span> <span class="obsolete">obsolete</span>
1030 1030 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=gitweb' | grep '<span class="logtags">'
1031 1031 <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="obsoletetag" title="obsolete">obsolete</span> </span>
1032 1032 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=monoblue' | grep '<span class="logtags">'
1033 1033 <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="obsoletetag" title="obsolete">obsolete</span> </span>
1034 1034 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=spartan' | grep 'class="obsolete"'
1035 1035 <th class="obsolete">obsolete:</th>
1036 1036 <td class="obsolete">pruned</td>
1037 1037
1038 1038 check an obsolete changeset that has been rewritten
1039 1039 $ get-with-headers.py localhost:$HGPORT 'rev/cda648ca50f5?style=paper' | grep rewritten
1040 1040 <td>rewritten as <a href="/rev/3de5eca88c00?style=paper">3de5eca88c00</a> </td>
1041 1041 $ get-with-headers.py localhost:$HGPORT 'rev/cda648ca50f5?style=coal' | grep rewritten
1042 1042 <td>rewritten as <a href="/rev/3de5eca88c00?style=coal">3de5eca88c00</a> </td>
1043 1043 $ get-with-headers.py localhost:$HGPORT 'rev/cda648ca50f5?style=gitweb' | grep rewritten
1044 1044 <tr><td>obsolete</td><td>rewritten as <a class="list" href="/rev/3de5eca88c00?style=gitweb">3de5eca88c00</a> </td></tr>
1045 1045 $ get-with-headers.py localhost:$HGPORT 'rev/cda648ca50f5?style=monoblue' | grep rewritten
1046 1046 <dt>obsolete</dt><dd>rewritten as <a href="/rev/3de5eca88c00?style=monoblue">3de5eca88c00</a> </dd>
1047 1047 $ get-with-headers.py localhost:$HGPORT 'rev/cda648ca50f5?style=spartan' | grep rewritten
1048 1048 <td class="obsolete">rewritten as <a href="/rev/3de5eca88c00?style=spartan">3de5eca88c00</a> </td>
1049 1049
1050 1050 check changeset with instabilities
1051 1051
1052 1052 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=paper' | grep '<span class="instability">'
1053 1053 <span class="phase">draft</span> <span class="instability">orphan</span> <span class="instability">phase-divergent</span>
1054 1054 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=coal' | grep '<span class="instability">'
1055 1055 <span class="phase">draft</span> <span class="instability">orphan</span> <span class="instability">phase-divergent</span>
1056 1056 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=gitweb' | grep '<span class="logtags">'
1057 1057 <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="instabilitytag" title="orphan">orphan</span> <span class="instabilitytag" title="phase-divergent">phase-divergent</span> </span>
1058 1058 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=monoblue' | grep '<span class="logtags">'
1059 1059 <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="instabilitytag" title="orphan">orphan</span> <span class="instabilitytag" title="phase-divergent">phase-divergent</span> </span>
1060 1060 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=spartan' | grep 'class="instabilities"'
1061 1061 <th class="instabilities">instabilities:</th>
1062 1062 <td class="instabilities">orphan phase-divergent </td>
1063 1063
1064 1064 $ killdaemons.py
1065 1065
1066 1066 $ rm hg.pid access.log errors.log
1067 1067 #endif
1068 1068
1069 1069 Test incoming/outcoming with changesets obsoleted remotely, known locally
1070 1070 ===============================================================================
1071 1071
1072 1072 This test issue 3805
1073 1073
1074 1074 $ hg init repo-issue3805
1075 1075 $ cd repo-issue3805
1076 1076 $ echo "base" > base
1077 1077 $ hg ci -Am "base"
1078 1078 adding base
1079 1079 $ echo "foo" > foo
1080 1080 $ hg ci -Am "A"
1081 1081 adding foo
1082 1082 $ hg clone . ../other-issue3805
1083 1083 updating to branch default
1084 1084 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1085 1085 $ echo "bar" >> foo
1086 1086 $ hg ci --amend
1087 1087 $ cd ../other-issue3805
1088 1088 $ hg log -G
1089 1089 @ 1:29f0c6921ddd (draft) [tip ] A
1090 1090 |
1091 1091 o 0:d20a80d4def3 (draft) [ ] base
1092 1092
1093 1093 $ hg log -G -R ../repo-issue3805
1094 1094 @ 2:323a9c3ddd91 (draft) [tip ] A
1095 1095 |
1096 1096 o 0:d20a80d4def3 (draft) [ ] base
1097 1097
1098 1098 $ hg incoming
1099 1099 comparing with $TESTTMP/tmpe/repo-issue3805
1100 1100 searching for changes
1101 1101 2:323a9c3ddd91 (draft) [tip ] A
1102 1102 $ hg incoming --bundle ../issue3805.hg
1103 1103 comparing with $TESTTMP/tmpe/repo-issue3805
1104 1104 searching for changes
1105 1105 2:323a9c3ddd91 (draft) [tip ] A
1106 1106 $ hg outgoing
1107 1107 comparing with $TESTTMP/tmpe/repo-issue3805
1108 1108 searching for changes
1109 1109 1:29f0c6921ddd (draft) [tip ] A
1110 1110
1111 1111 #if serve
1112 1112
1113 1113 $ hg serve -R ../repo-issue3805 -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
1114 1114 $ cat hg.pid >> $DAEMON_PIDS
1115 1115
1116 1116 $ hg incoming http://localhost:$HGPORT
1117 1117 comparing with http://localhost:$HGPORT/
1118 1118 searching for changes
1119 1119 2:323a9c3ddd91 (draft) [tip ] A
1120 1120 $ hg outgoing http://localhost:$HGPORT
1121 1121 comparing with http://localhost:$HGPORT/
1122 1122 searching for changes
1123 1123 1:29f0c6921ddd (draft) [tip ] A
1124 1124
1125 1125 $ killdaemons.py
1126 1126
1127 1127 #endif
1128 1128
1129 1129 This test issue 3814
1130 1130
1131 1131 (nothing to push but locally hidden changeset)
1132 1132
1133 1133 $ cd ..
1134 1134 $ hg init repo-issue3814
1135 1135 $ cd repo-issue3805
1136 1136 $ hg push -r 323a9c3ddd91 ../repo-issue3814
1137 1137 pushing to ../repo-issue3814
1138 1138 searching for changes
1139 1139 adding changesets
1140 1140 adding manifests
1141 1141 adding file changes
1142 1142 added 2 changesets with 2 changes to 2 files
1143 1143 1 new obsolescence markers
1144 1144 $ hg out ../repo-issue3814
1145 1145 comparing with ../repo-issue3814
1146 1146 searching for changes
1147 1147 no changes found
1148 1148 [1]
1149 1149
1150 1150 Test that a local tag blocks a changeset from being hidden
1151 1151
1152 1152 $ hg tag -l visible -r 1 --hidden
1153 1153 $ hg log -G
1154 1154 @ 2:323a9c3ddd91 (draft) [tip ] A
1155 1155 |
1156 1156 | x 1:29f0c6921ddd (draft *obsolete*) [visible ] A [rewritten using amend as 2:323a9c3ddd91]
1157 1157 |/
1158 1158 o 0:d20a80d4def3 (draft) [ ] base
1159 1159
1160 1160 Test that removing a local tag does not cause some commands to fail
1161 1161
1162 1162 $ hg tag -l -r tip tiptag
1163 1163 $ hg tags
1164 1164 tiptag 2:323a9c3ddd91
1165 1165 tip 2:323a9c3ddd91
1166 1166 visible 1:29f0c6921ddd
1167 1167 $ hg --config extensions.strip= strip -r tip --no-backup
1168 1168 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1169 1169 $ hg tags
1170 1170 visible 1:29f0c6921ddd
1171 1171 tip 1:29f0c6921ddd
1172 1172
1173 1173 Test bundle overlay onto hidden revision
1174 1174
1175 1175 $ cd ..
1176 1176 $ hg init repo-bundleoverlay
1177 1177 $ cd repo-bundleoverlay
1178 1178 $ echo "A" > foo
1179 1179 $ hg ci -Am "A"
1180 1180 adding foo
1181 1181 $ echo "B" >> foo
1182 1182 $ hg ci -m "B"
1183 1183 $ hg up 0
1184 1184 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1185 1185 $ echo "C" >> foo
1186 1186 $ hg ci -m "C"
1187 1187 created new head
1188 1188 $ hg log -G
1189 1189 @ 2:c186d7714947 (draft) [tip ] C
1190 1190 |
1191 1191 | o 1:44526ebb0f98 (draft) [ ] B
1192 1192 |/
1193 1193 o 0:4b34ecfb0d56 (draft) [ ] A
1194 1194
1195 1195
1196 1196 $ hg clone -r1 . ../other-bundleoverlay
1197 1197 adding changesets
1198 1198 adding manifests
1199 1199 adding file changes
1200 1200 added 2 changesets with 2 changes to 1 files
1201 1201 new changesets 4b34ecfb0d56:44526ebb0f98
1202 1202 updating to branch default
1203 1203 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1204 1204 $ cd ../other-bundleoverlay
1205 1205 $ echo "B+" >> foo
1206 1206 $ hg ci --amend -m "B+"
1207 1207 $ hg log -G --hidden
1208 1208 @ 2:b7d587542d40 (draft) [tip ] B+
1209 1209 |
1210 1210 | x 1:44526ebb0f98 (draft *obsolete*) [ ] B [rewritten using amend as 2:b7d587542d40]
1211 1211 |/
1212 1212 o 0:4b34ecfb0d56 (draft) [ ] A
1213 1213
1214 1214
1215 1215 $ hg incoming ../repo-bundleoverlay --bundle ../bundleoverlay.hg
1216 1216 comparing with ../repo-bundleoverlay
1217 1217 searching for changes
1218 1218 1:44526ebb0f98 (draft) [ ] B
1219 1219 2:c186d7714947 (draft) [tip ] C
1220 1220 $ hg log -G -R ../bundleoverlay.hg
1221 1221 o 3:c186d7714947 (draft) [tip ] C
1222 1222 |
1223 1223 | @ 2:b7d587542d40 (draft) [ ] B+
1224 1224 |/
1225 1225 o 0:4b34ecfb0d56 (draft) [ ] A
1226 1226
1227 1227
1228 1228 #if serve
1229 1229
1230 1230 Test issue 4506
1231 1231
1232 1232 $ cd ..
1233 1233 $ hg init repo-issue4506
1234 1234 $ cd repo-issue4506
1235 1235 $ echo "0" > foo
1236 1236 $ hg add foo
1237 1237 $ hg ci -m "content-0"
1238 1238
1239 1239 $ hg up null
1240 1240 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1241 1241 $ echo "1" > bar
1242 1242 $ hg add bar
1243 1243 $ hg ci -m "content-1"
1244 1244 created new head
1245 1245 $ hg up 0
1246 1246 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1247 1247 $ hg graft 1
1248 1248 grafting 1:1c9eddb02162 "content-1" (tip)
1249 1249
1250 1250 $ hg debugobsolete `hg log -r1 -T'{node}'` `hg log -r2 -T'{node}'`
1251 1251 obsoleted 1 changesets
1252 1252
1253 1253 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
1254 1254 $ cat hg.pid >> $DAEMON_PIDS
1255 1255
1256 1256 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/1'
1257 1257 404 Not Found
1258 1258 [1]
1259 1259 $ get-with-headers.py --headeronly localhost:$HGPORT 'file/tip/bar'
1260 1260 200 Script output follows
1261 1261 $ get-with-headers.py --headeronly localhost:$HGPORT 'annotate/tip/bar'
1262 1262 200 Script output follows
1263 1263
1264 1264 $ killdaemons.py
1265 1265
1266 1266 #endif
1267 1267
1268 1268 Test heads computation on pending index changes with obsolescence markers
1269 1269 $ cd ..
1270 1270 $ cat >$TESTTMP/test_extension.py << EOF
1271 1271 > from __future__ import absolute_import
1272 1272 > from mercurial.i18n import _
1273 1273 > from mercurial import cmdutil, registrar
1274 1274 >
1275 1275 > cmdtable = {}
1276 1276 > command = registrar.command(cmdtable)
1277 1277 > @command(b"amendtransient",[], _('hg amendtransient [rev]'))
1278 1278 > def amend(ui, repo, *pats, **opts):
1279 1279 > opts['message'] = 'Test'
1280 1280 > opts['logfile'] = None
1281 1281 > cmdutil.amend(ui, repo, repo['.'], {}, pats, opts)
1282 1282 > ui.write('%s\n' % repo.changelog.headrevs())
1283 1283 > EOF
1284 1284 $ cat >> $HGRCPATH << EOF
1285 1285 > [extensions]
1286 1286 > testextension=$TESTTMP/test_extension.py
1287 1287 > EOF
1288 1288 $ hg init repo-issue-nativerevs-pending-changes
1289 1289 $ cd repo-issue-nativerevs-pending-changes
1290 1290 $ mkcommit a
1291 1291 $ mkcommit b
1292 1292 $ hg up ".^"
1293 1293 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1294 1294 $ echo aa > a
1295 1295 $ hg amendtransient
1296 1296 [1, 2]
1297 1297
1298 1298 Test cache consistency for the visible filter
1299 1299 1) We want to make sure that the cached filtered revs are invalidated when
1300 1300 bookmarks change
1301 1301 $ cd ..
1302 1302 $ cat >$TESTTMP/test_extension.py << EOF
1303 1303 > from __future__ import absolute_import, print_function
1304 1304 > import weakref
1305 1305 > from mercurial import (
1306 1306 > bookmarks,
1307 1307 > cmdutil,
1308 1308 > extensions,
1309 1309 > repoview,
1310 1310 > )
1311 1311 > def _bookmarkchanged(orig, bkmstoreinst, *args, **kwargs):
1312 1312 > reporef = weakref.ref(bkmstoreinst._repo)
1313 1313 > def trhook(tr):
1314 1314 > repo = reporef()
1315 1315 > hidden1 = repoview.computehidden(repo)
1316 1316 > hidden = repoview.filterrevs(repo, 'visible')
1317 1317 > if sorted(hidden1) != sorted(hidden):
1318 1318 > print("cache inconsistency")
1319 1319 > bkmstoreinst._repo.currenttransaction().addpostclose('test_extension', trhook)
1320 1320 > orig(bkmstoreinst, *args, **kwargs)
1321 1321 > def extsetup(ui):
1322 1322 > extensions.wrapfunction(bookmarks.bmstore, '_recordchange',
1323 1323 > _bookmarkchanged)
1324 1324 > EOF
1325 1325
1326 1326 $ hg init repo-cache-inconsistency
1327 1327 $ cd repo-issue-nativerevs-pending-changes
1328 1328 $ mkcommit a
1329 1329 a already tracked!
1330 1330 $ mkcommit b
1331 1331 $ hg id
1332 1332 13bedc178fce tip
1333 1333 $ echo "hello" > b
1334 1334 $ hg commit --amend -m "message"
1335 1335 $ hg book bookb -r 13bedc178fce --hidden
1336 1336 $ hg log -r 13bedc178fce
1337 1337 4:13bedc178fce (draft *obsolete*) [ bookb] add b [rewritten using amend as 5:a9b1f8652753]
1338 1338 $ hg book -d bookb
1339 1339 $ hg log -r 13bedc178fce
1340 abort: hidden revision '13bedc178fce'!
1340 abort: hidden revision '13bedc178fce' was rewritten as: a9b1f8652753!
1341 1341 (use --hidden to access hidden revisions)
1342 1342 [255]
1343 1343
1344 1344 Empty out the test extension, as it isn't compatible with later parts
1345 1345 of the test.
1346 1346 $ echo > $TESTTMP/test_extension.py
1347 1347
1348 1348 Test ability to pull changeset with locally applying obsolescence markers
1349 1349 (issue4945)
1350 1350
1351 1351 $ cd ..
1352 1352 $ hg init issue4845
1353 1353 $ cd issue4845
1354 1354
1355 1355 $ echo foo > f0
1356 1356 $ hg add f0
1357 1357 $ hg ci -m '0'
1358 1358 $ echo foo > f1
1359 1359 $ hg add f1
1360 1360 $ hg ci -m '1'
1361 1361 $ echo foo > f2
1362 1362 $ hg add f2
1363 1363 $ hg ci -m '2'
1364 1364
1365 1365 $ echo bar > f2
1366 1366 $ hg commit --amend --config experimental.evolution.createmarkers=True
1367 1367 $ hg log -G
1368 1368 @ 3:b0551702f918 (draft) [tip ] 2
1369 1369 |
1370 1370 o 1:e016b03fd86f (draft) [ ] 1
1371 1371 |
1372 1372 o 0:a78f55e5508c (draft) [ ] 0
1373 1373
1374 1374 $ hg log -G --hidden
1375 1375 @ 3:b0551702f918 (draft) [tip ] 2
1376 1376 |
1377 1377 | x 2:e008cf283490 (draft *obsolete*) [ ] 2 [rewritten using amend as 3:b0551702f918]
1378 1378 |/
1379 1379 o 1:e016b03fd86f (draft) [ ] 1
1380 1380 |
1381 1381 o 0:a78f55e5508c (draft) [ ] 0
1382 1382
1383 1383
1384 1384 $ hg strip --hidden -r 2 --config extensions.strip= --config devel.strip-obsmarkers=no
1385 1385 saved backup bundle to $TESTTMP/tmpe/issue4845/.hg/strip-backup/e008cf283490-ede36964-backup.hg
1386 1386 $ hg debugobsolete
1387 1387 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 b0551702f918510f01ae838ab03a463054c67b46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
1388 1388 $ hg log -G
1389 1389 @ 2:b0551702f918 (draft) [tip ] 2
1390 1390 |
1391 1391 o 1:e016b03fd86f (draft) [ ] 1
1392 1392 |
1393 1393 o 0:a78f55e5508c (draft) [ ] 0
1394 1394
1395 1395 $ hg log -G --hidden
1396 1396 @ 2:b0551702f918 (draft) [tip ] 2
1397 1397 |
1398 1398 o 1:e016b03fd86f (draft) [ ] 1
1399 1399 |
1400 1400 o 0:a78f55e5508c (draft) [ ] 0
1401 1401
1402 1402 $ hg debugbundle .hg/strip-backup/e008cf283490-*-backup.hg
1403 1403 Stream params: {Compression: BZ}
1404 1404 changegroup -- {nbchanges: 1, version: 02}
1405 1405 e008cf2834908e5d6b0f792a9d4b0e2272260fb8
1406 1406 phase-heads -- {}
1407 1407 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 draft
1408 1408
1409 1409 $ hg pull .hg/strip-backup/e008cf283490-*-backup.hg
1410 1410 pulling from .hg/strip-backup/e008cf283490-ede36964-backup.hg
1411 1411 searching for changes
1412 1412 no changes found
1413 1413 $ hg debugobsolete
1414 1414 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 b0551702f918510f01ae838ab03a463054c67b46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
1415 1415 $ hg log -G
1416 1416 @ 2:b0551702f918 (draft) [tip ] 2
1417 1417 |
1418 1418 o 1:e016b03fd86f (draft) [ ] 1
1419 1419 |
1420 1420 o 0:a78f55e5508c (draft) [ ] 0
1421 1421
1422 1422 $ hg log -G --hidden
1423 1423 @ 2:b0551702f918 (draft) [tip ] 2
1424 1424 |
1425 1425 o 1:e016b03fd86f (draft) [ ] 1
1426 1426 |
1427 1427 o 0:a78f55e5508c (draft) [ ] 0
1428 1428
1429 1429
1430 1430 Testing that strip remove markers:
1431 1431
1432 1432 $ hg strip -r 1 --config extensions.strip=
1433 1433 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
1434 1434 saved backup bundle to $TESTTMP/tmpe/issue4845/.hg/strip-backup/e016b03fd86f-65ede734-backup.hg
1435 1435 $ hg debugobsolete
1436 1436 $ hg log -G
1437 1437 @ 0:a78f55e5508c (draft) [tip ] 0
1438 1438
1439 1439 $ hg log -G --hidden
1440 1440 @ 0:a78f55e5508c (draft) [tip ] 0
1441 1441
1442 1442 $ hg debugbundle .hg/strip-backup/e016b03fd86f-*-backup.hg
1443 1443 Stream params: {Compression: BZ}
1444 1444 changegroup -- {nbchanges: 2, version: 02}
1445 1445 e016b03fd86fcccc54817d120b90b751aaf367d6
1446 1446 b0551702f918510f01ae838ab03a463054c67b46
1447 1447 obsmarkers -- {}
1448 1448 version: 1 (92 bytes)
1449 1449 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 b0551702f918510f01ae838ab03a463054c67b46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
1450 1450 phase-heads -- {}
1451 1451 b0551702f918510f01ae838ab03a463054c67b46 draft
1452 1452
1453 1453 $ hg unbundle .hg/strip-backup/e016b03fd86f-*-backup.hg
1454 1454 adding changesets
1455 1455 adding manifests
1456 1456 adding file changes
1457 1457 added 2 changesets with 2 changes to 2 files
1458 1458 1 new obsolescence markers
1459 1459 new changesets e016b03fd86f:b0551702f918
1460 1460 (run 'hg update' to get a working copy)
1461 1461 $ hg debugobsolete | sort
1462 1462 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 b0551702f918510f01ae838ab03a463054c67b46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
1463 1463 $ hg log -G
1464 1464 o 2:b0551702f918 (draft) [tip ] 2
1465 1465 |
1466 1466 o 1:e016b03fd86f (draft) [ ] 1
1467 1467 |
1468 1468 @ 0:a78f55e5508c (draft) [ ] 0
1469 1469
1470 1470 $ hg log -G --hidden
1471 1471 o 2:b0551702f918 (draft) [tip ] 2
1472 1472 |
1473 1473 o 1:e016b03fd86f (draft) [ ] 1
1474 1474 |
1475 1475 @ 0:a78f55e5508c (draft) [ ] 0
1476 1476
1477 1477 Test that 'hg debugobsolete --index --rev' can show indices of obsmarkers when
1478 1478 only a subset of those are displayed (because of --rev option)
1479 1479 $ hg init doindexrev
1480 1480 $ cd doindexrev
1481 1481 $ echo a > a
1482 1482 $ hg ci -Am a
1483 1483 adding a
1484 1484 $ hg ci --amend -m aa
1485 1485 $ echo b > b
1486 1486 $ hg ci -Am b
1487 1487 adding b
1488 1488 $ hg ci --amend -m bb
1489 1489 $ echo c > c
1490 1490 $ hg ci -Am c
1491 1491 adding c
1492 1492 $ hg ci --amend -m cc
1493 1493 $ echo d > d
1494 1494 $ hg ci -Am d
1495 1495 adding d
1496 1496 $ hg ci --amend -m dd --config experimental.evolution.track-operation=1
1497 1497 $ hg debugobsolete --index --rev "3+7"
1498 1498 1 6fdef60fcbabbd3d50e9b9cbc2a240724b91a5e1 d27fb9b066076fd921277a4b9e8b9cb48c95bc6a 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1499 1499 3 4715cf767440ed891755448016c2b8cf70760c30 7ae79c5d60f049c7b0dd02f5f25b9d60aaf7b36d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1500 1500 $ hg debugobsolete --index --rev "3+7" -Tjson
1501 1501 [
1502 1502 {
1503 1503 "date": [0.0, 0],
1504 1504 "flag": 0,
1505 1505 "index": 1,
1506 1506 "metadata": {"ef1": "1", "operation": "amend", "user": "test"},
1507 1507 "prednode": "6fdef60fcbabbd3d50e9b9cbc2a240724b91a5e1",
1508 1508 "succnodes": ["d27fb9b066076fd921277a4b9e8b9cb48c95bc6a"]
1509 1509 },
1510 1510 {
1511 1511 "date": [0.0, 0],
1512 1512 "flag": 0,
1513 1513 "index": 3,
1514 1514 "metadata": {"ef1": "1", "operation": "amend", "user": "test"},
1515 1515 "prednode": "4715cf767440ed891755448016c2b8cf70760c30",
1516 1516 "succnodes": ["7ae79c5d60f049c7b0dd02f5f25b9d60aaf7b36d"]
1517 1517 }
1518 1518 ]
1519 1519
1520 1520 Test the --delete option of debugobsolete command
1521 1521 $ hg debugobsolete --index
1522 1522 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1523 1523 1 6fdef60fcbabbd3d50e9b9cbc2a240724b91a5e1 d27fb9b066076fd921277a4b9e8b9cb48c95bc6a 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1524 1524 2 1ab51af8f9b41ef8c7f6f3312d4706d870b1fb74 29346082e4a9e27042b62d2da0e2de211c027621 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1525 1525 3 4715cf767440ed891755448016c2b8cf70760c30 7ae79c5d60f049c7b0dd02f5f25b9d60aaf7b36d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1526 1526 $ hg debugobsolete --delete 1 --delete 3
1527 1527 deleted 2 obsolescence markers
1528 1528 $ hg debugobsolete
1529 1529 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1530 1530 1ab51af8f9b41ef8c7f6f3312d4706d870b1fb74 29346082e4a9e27042b62d2da0e2de211c027621 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1531 1531
1532 1532 Test adding changeset after obsmarkers affecting it
1533 1533 (eg: during pull, or unbundle)
1534 1534
1535 1535 $ mkcommit e
1536 1536 $ hg bundle -r . --base .~1 ../bundle-2.hg
1537 1537 1 changesets found
1538 1538 $ getid .
1539 1539 $ hg --config extensions.strip= strip -r .
1540 1540 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1541 1541 saved backup bundle to $TESTTMP/tmpe/issue4845/doindexrev/.hg/strip-backup/9bc153528424-ee80edd4-backup.hg
1542 1542 $ hg debugobsolete 9bc153528424ea266d13e57f9ff0d799dfe61e4b
1543 1543 $ hg unbundle ../bundle-2.hg
1544 1544 adding changesets
1545 1545 adding manifests
1546 1546 adding file changes
1547 1547 added 1 changesets with 1 changes to 1 files
1548 1548 (run 'hg update' to get a working copy)
1549 1549 $ hg log -G
1550 1550 @ 7:7ae79c5d60f0 (draft) [tip ] dd
1551 1551 |
1552 1552 | o 6:4715cf767440 (draft) [ ] d
1553 1553 |/
1554 1554 o 5:29346082e4a9 (draft) [ ] cc
1555 1555 |
1556 1556 o 3:d27fb9b06607 (draft) [ ] bb
1557 1557 |
1558 1558 | o 2:6fdef60fcbab (draft) [ ] b
1559 1559 |/
1560 1560 o 1:f9bd49731b0b (draft) [ ] aa
1561 1561
1562 1562
1563 1563 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now