==================================== Test for the stabletailgraph package ==================================== This test file contains a bunch of small test graphs with some minimal yet non-trivial structure, on which the various stable-tail graph and stable-tail sort functions are tested. Each case consists of the creation of the interesting graph structure, followed by a check, for each noteworthy node, of: - the stable-tail sort output (with the linear parts globbed), - the leap set, - the specific leap set. In the ASCII art of the diagrams, the side of the exclusive part which is followed in priority is denoted with "<" or ">" if it is on the left or right respectively. The intermediary linear parts in the example graph are there to force the exclusive part choice (made on a min rank condition). Setup ===== Enable the rank computation to test sorting based on the rank. $ cat << EOF >> $HGRCPATH > [format] > exp-use-changelog-v2=enable-unstable-format-and-corrupt-my-data > > [alias] > test-sts = debug::stable-tail-sort -T '{tags},' > test-leaps = debug::stable-tail-sort-leaps -T '{tags}' > test-log = log --graph -T '{tags} rank={_fast_rank}' --rev 'tagged()' > EOF Example 1: single merge node ============================ A base case with one branchpoint "b" and one merge node "e". The exclusive part, starting with the lowest-ranking parent "c" of "e", appears first in stable-tail sort of "e" and "f". # f # | # e # | # --<-- # | | # c d # | | # --+-- <- at this point, the sort of "e" is done consuming its # | exclusive part [c] and jumps back to its other parent "d" # b # | # a $ hg init example-1 $ cd example-1 $ hg debugbuilddag '.:a*a:b*b:c-- | <- in the sort of "f", we need to skip "c" and leap to the # | | | inherited part of "d" # | +---- # b | # | c # | | # --+-- # | # a $ hg init example-4 $ cd example-4 $ hg debugbuilddag '.:a*a+1:b-- | # | | | # | g | # | | | # | +---- <- in the sort of "f", leaping from "g" to "b" # b | # | c # | | # --+-- # | # a $ hg init example-5 $ cd example-5 $ hg debugbuilddag '.:a*a+2:b-- --<-- # | | | | # g e h i # | | | | # | --+-- | <- at this point, for the sort of "l", the iteration on # f | | the end of excl(j) is postponed to the iteration of # | d | excl(k) # | | | # | c | # | | | # ---+--- | # | | # b | # | | # ----+----- # | # a $ hg init example-7 $ cd example-7 $ hg debugbuilddag \ > '.:a*a:b*b:c*c:d*d:e*b:f------ # | | # n l # | | # | ----<---- # | | | # | i k # m | | # | ---<--- | # | | | | # | d h | # | | | j # | | g | # | c | | # | | +----- # -----+ | # | f # b | # | e <- Done with excl(o) by element count, without # | | having emitted "b". Implicitly unstack open # ---+--- merges to leap e->n. # | # a $ hg init example-10 $ cd example-10 $ hg debugbuilddag ' > .:a > *a:b.:c.:d > *a:e.:f.:g.:h > *d/h:i > *f:j+6:k > *i/k:l > *b:m+15:n > *n/l:o. > ' $ hg test-log o o rank=34 |\ | o n rank=18 | : | o m rank=3 | | o | l rank=17 |\ \ | o | k rank=10 | : | | o | j rank=4 | | | o | | i rank=9 |\ \ \ | o | | h rank=5 | | | | | o | | g rank=4 | |/ / | o | f rank=3 | | | | o | e rank=2 | | | o | | d rank=4 | | | o---+ c rank=3 / / | o b rank=2 |/ o a rank=1 Check the stable-tail sort of "o": $ hg test-sts o o,l,i,d,c,h,g,k,*,j,f,e,n,*,m,b,a, (no-eol) (glob) Stale-tail sort of "l" for reference: $ hg test-sts l l,i,d,c,b,h,g,k,*,j,f,e,a, (no-eol) (glob) Check the corresponding leaps: $ hg test-leaps o ch gk en $ hg test-leaps --specific o ch $ hg test-leaps l bh gk $ hg test-leaps --specific l $ cd .. Example 11: adjusting other leaps with the same destination =========================================================== This is a variant of the previous test, checking the adjustment of leaps having the same destination in particular. # r # | # ------>------ # | | # | o # q | # | ------>------ # | | | # | n l # | | | # | | ----<---- # p | | | # | | i k # | m | | # | | ---<--- | # | | | | | # | | d h | # | | | | j # -----]|[---+ | | <- in sts(r): leap d->h # | | g | # | c | | # | | +----- # -----+ | <- the leap c->h of sts(o) # | f is shadowed in sts(r) # b | # | e # | | # ---+--- # | # a $ hg init example-11 $ cd example-11 $ hg debugbuilddag ' > .:a > *a:b.:c.:d > *a:e.:f.:g.:h > *d/h:i > *f:j+6:k > *i/k:l > *b:m+15:n > *n/l:o > *c:p+31:q > *o/q:r. > ' $ hg test-log o r rank=67 |\ | o q rank=35 | : | o p rank=4 | | o | o rank=34 |\ \ | o | n rank=18 | : | | o | m rank=3 | | | o | | l rank=17 |\ \ \ | o | | k rank=10 | : | | | o | | j rank=4 | | | | o | | | i rank=9 |\ \ \ \ | o | | | h rank=5 | | | | | | o | | | g rank=4 | |/ / / | o | | f rank=3 | | | | | o | | e rank=2 | | | | o-----+ d rank=4 / / / | | o c rank=3 | |/ | o b rank=2 |/ o a rank=1 Check the stable-tail sort of "r": $ hg test-sts r r,o,l,i,d,h,g,k,*,j,f,e,n,*,m,q,*,p,c,b,a, (no-eol) (glob) Stable-tail sort of "o" for reference: $ hg test-sts o o,l,i,d,c,h,g,k,*,j,f,e,n,*,m,b,a, (no-eol) (glob) Check the associated leaps: $ hg test-leaps r dh gk en mq $ hg test-leaps --specific r dh $ hg test-leaps o ch gk en $ hg test-leaps --specific o ch $ cd .. Example 12 ========== This is a variant of the previous test, checking the adjustments of leaps in the open merge stack having a lower destination (which should appear only later in the stable-tail sort of the head). # t # | # ------>------ # | | # | o # s | # | ------>------ # | | | # | n l # r | | # | | ----<---- # | | | | # --<-- | i k # | | m | | # p q | ---<--- | # | | | | | | # | ---]|[--]|[----+ | # | | | | | # | | d h | # | | | | j # -------]|[---+ | | <- d->k is sts(t) # | | g | # | c | | # | | +----- # -----+ | <- c->h in sts(o), not applying in sts(t) # | f # b | # | e # | | # ---+--- # | # a $ hg init example-12 $ cd example-12 $ hg debugbuilddag ' > .:a > *a:b.:c.:d > *a:e.:f.:g.:h > *d/h:i > *f:j+6:k > *i/k:l > *b:m+15:n > *n/l:o > *c:p > *h:q > *p/q:r+25:s > *o/s:t. > ' $ hg test-log o t rank=63 |\ | o s rank=35 | : | o r rank=10 | |\ | | o q rank=6 | | | | o | p rank=4 | | | o | | o rank=34 |\ \ \ | o | | n rank=18 | : | | | o | | m rank=3 | | | | o | | | l rank=17 |\ \ \ \ | o | | | k rank=10 | : | | | | o | | | j rank=4 | | | | | o-------+ i rank=9 | | | | | | | | | o h rank=5 | | | | | | +-----o g rank=4 | | | | | o | | f rank=3 | | | | | o | | e rank=2 | | | | o-----+ d rank=4 / / / | | o c rank=3 | |/ | o b rank=2 |/ o a rank=1 Check the stable-tail sort of "t": $ hg test-sts t t,o,l,i,d,k,*,j,n,*,m,s,*,r,p,c,b,q,h,g,f,e,a, (no-eol) (glob) Stable-tail sort of "o" for reference: $ hg test-sts o o,l,i,d,c,h,g,k,*,j,f,e,n,*,m,b,a, (no-eol) (glob) Check the associated leaps: $ hg test-leaps t dk jn ms bq $ hg test-leaps --specific t dk jn $ hg test-leaps o ch gk en $ hg test-leaps --specific o ch $ cd ..