##// END OF EJS Templates
dagop: fix subsetparentswalker to set p1/p2 chains at merge revision...
Yuya Nishihara -
r45147:67f757ed default
parent child Browse files
Show More
@@ -391,7 +391,9 b' class subsetparentswalker(object):'
391 #
391 #
392 # Once all pending paths have been resolved, 'pendingcnt[rev]' becomes
392 # Once all pending paths have been resolved, 'pendingcnt[rev]' becomes
393 # 0 and 'parents[rev]' contains the unsorted list of parent revisions
393 # 0 and 'parents[rev]' contains the unsorted list of parent revisions
394 # and p1/p2 chains (excluding linear paths.)
394 # and p1/p2 chains (excluding linear paths.) The p1/p2 chains will be
395 # used as a sort key preferring p1. 'len(chain)' should be the number
396 # of merges between two revisions.
395
397
396 subset = self._subset
398 subset = self._subset
397 tovisit = self._tovisit # heap queue of [-rev]
399 tovisit = self._tovisit # heap queue of [-rev]
@@ -458,9 +460,12 b' class subsetparentswalker(object):'
458 (unresolved.copy(), resolved.copy()),
460 (unresolved.copy(), resolved.copy()),
459 ]
461 ]
460 # 'rev' is a merge revision. increment the pending count
462 # 'rev' is a merge revision. increment the pending count
461 # as the 'unresolved' dict will be duplicated.
463 # as the 'unresolved' dict will be duplicated, and append
464 # p1/p2 code to the existing chains.
462 for r in unresolved:
465 for r in unresolved:
463 pendingcnt[r] += 1
466 pendingcnt[r] += 1
467 parentpointers[0][0][r] += b'1'
468 parentpointers[1][0][r] += b'2'
464 for i, p in enumerate(parentrevs):
469 for i, p in enumerate(parentrevs):
465 assert p < rev
470 assert p < rev
466 heapq.heappush(tovisit, -p)
471 heapq.heappush(tovisit, -p)
@@ -470,7 +475,6 b' class subsetparentswalker(object):'
470 knownunresolved, knownresolved = pointers[p]
475 knownunresolved, knownresolved = pointers[p]
471 unresolved, resolved = parentpointers[i]
476 unresolved, resolved = parentpointers[i]
472 for r, c in unresolved.items():
477 for r, c in unresolved.items():
473 c += [b'1', b'2'][i]
474 if r in knownunresolved:
478 if r in knownunresolved:
475 # unresolved at both paths
479 # unresolved at both paths
476 pendingcnt[r] -= 1
480 pendingcnt[r] -= 1
@@ -488,9 +492,10 b' class subsetparentswalker(object):'
488 # then, populate the active parents directly and add the current
492 # then, populate the active parents directly and add the current
489 # 'rev' to the tracking pointers of the inactive parents.
493 # 'rev' to the tracking pointers of the inactive parents.
490 # 'pointers[p]' may be optimized out if both parents are active.
494 # 'pointers[p]' may be optimized out if both parents are active.
495 chaincodes = [b''] if len(parentrevs) <= 1 else [b'1', b'2']
491 if curactive and bothparentsactive:
496 if curactive and bothparentsactive:
492 for i, p in enumerate(parentrevs):
497 for i, p in enumerate(parentrevs):
493 c = [b'1', b'2'][i]
498 c = chaincodes[i]
494 parents[rev].append((c, p))
499 parents[rev].append((c, p))
495 # no need to mark 'rev' as resolved since the 'rev' should
500 # no need to mark 'rev' as resolved since the 'rev' should
496 # be fully resolved (i.e. pendingcnt[rev] == 0)
501 # be fully resolved (i.e. pendingcnt[rev] == 0)
@@ -499,7 +504,7 b' class subsetparentswalker(object):'
499 for i, p in enumerate(parentrevs):
504 for i, p in enumerate(parentrevs):
500 unresolved, resolved = pointers[p]
505 unresolved, resolved = pointers[p]
501 assert rev not in unresolved
506 assert rev not in unresolved
502 c = [b'1', b'2'][i]
507 c = chaincodes[i]
503 if p in subset:
508 if p in subset:
504 parents[rev].append((c, p))
509 parents[rev].append((c, p))
505 # mark 'rev' as resolved through this path
510 # mark 'rev' as resolved through this path
@@ -63,6 +63,61 b' Test graph-related template functions'
63
63
64 $ cd ..
64 $ cd ..
65
65
66 Create repository containing merges of p1 > p2:
67
68 $ hg init named-branch-order
69 $ cd named-branch-order
70
71 $ hg branch -q b0
72 $ hg ci -m 0
73 $ hg up -q null
74 $ hg branch -q b1
75 $ hg ci -m 1
76 $ hg up -q null
77 $ hg branch -q b2
78 $ hg ci -m 2
79 $ hg merge -q 1
80 $ hg ci -m 3
81 $ hg ci -m 4 --config ui.allowemptycommit=true
82 $ hg merge -q 0
83 $ hg ci -m 5
84 $ hg ci -m 6 --config ui.allowemptycommit=true
85 $ hg up -q 1
86 $ hg branch -q b7
87 $ hg ci -m 7
88 $ hg ci -m 8 --config ui.allowemptycommit=true
89 $ hg up -q 6
90 $ hg ci -m 9 --config ui.allowemptycommit=true
91 $ hg up -q 8
92 $ hg merge -q 9
93 $ hg ci -m 10
94
95 $ hg log -Gq -T'{rev} {branch} -> {p1.rev} {p2.rev}\n'
96 @ 10 b7 -> 8 9
97 |\
98 | o 9 b2 -> 6 -1
99 | |
100 o | 8 b7 -> 7 -1
101 | |
102 o | 7 b7 -> 1 -1
103 | |
104 | o 6 b2 -> 5 -1
105 | |
106 | o 5 b2 -> 4 0
107 | |\
108 | | o 4 b2 -> 3 -1
109 | | |
110 +---o 3 b2 -> 2 1
111 | | |
112 | | o 2 b2 -> -1 -1
113 | |
114 o | 1 b1 -> -1 -1
115 /
116 o 0 b0 -> -1 -1
117
118
119 $ cd ..
120
66 subsetparents
121 subsetparents
67 -------------
122 -------------
68
123
@@ -335,3 +390,51 b' Invalid arguments:'
335 [255]
390 [255]
336
391
337 $ cd ..
392 $ cd ..
393
394 subsetparents: p1/p2 order
395 -------------------------
396
397 $ cd named-branch-order
398
399 Parents should be sorted in p1/p2 order since p1 is likely to belong to
400 the same named branch:
401
402 $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("0+1+2+6"))}\n' -r '0+1+2+6'
403 o 6 : 2 1 0
404 :\
405 : \
406 : :\
407 : : o 2 :
408 : :
409 : o 1 :
410 :
411 o 0 :
412
413
414 $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("0+1+2+6+10"))}\n' -r '0+1+2+6+10'
415 @ 10 tip: 6
416 :\
417 : o 6 : 2 1 0
418 :/:\
419 : : o 2 :
420 : :
421 o : 1 :
422 /
423 o 0 :
424
425
426 And p1 path should be selected if both p1/p2 paths exist:
427
428 $ hg log -Gq -T '{rev} {tags}: {subsetparents(rev, revset("0+1+2+10"))}\n' -r '0+1+2+10'
429 @ 10 tip: 1 2 0
430 :\
431 : \
432 : :\
433 : : o 2 :
434 : :
435 o : 1 :
436 /
437 o 0 :
438
439
440 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now