stablerange: use the new cache object in the 'mergepoint' version
Every improvement to the cache should reflect on the stable range from there.
Since we no longer use the basic sort function, we can simplify the inheritance
by dropping one layer.
$."$TESTDIR/testlib/topic_setup.sh"Initialsetup$cat<<EOF>>$HGRCPATH>[ui]>logtemplate={rev}{branch} \{{get(namespaces,"topics")}}{phase}{desc|firstline}\n>[experimental]>evolution=all>EOF$hginitmain$cdmain$hgtopicothermarkedworkingdirectoryastopic:other$echoaaa>aaa$hgaddaaa$hgcommit-mc_aactivetopic'other'grewitsfirstchangeset$echoaaa>bbb$hgaddbbb$hgcommit-mc_b$hgtopicfoo$echoaaa>ccc$hgaddccc$hgcommit-mc_cactivetopic'foo'grewitsfirstchangeset$echoaaa>ddd$hgaddddd$hgcommit-mc_d$echoaaa>eee$hgaddeee$hgcommit-mc_e$echoaaa>fff$hgaddfff$hgcommit-mc_f$hglog-G@5default{foo}draftc_f|o4default{foo}draftc_e|o3default{foo}draftc_d|o2default{foo}draftc_c|o1default{other}draftc_b|o0default{other}draftc_aCheckthattopicwithoutanyparentdoesnotcrash--list---------------------------------------------------------$hgupotherswitchingtotopicother0filesupdated,0filesmerged,4filesremoved,0filesunresolved$hgtopic--list ### topic: other ### target: default (branch)t2@c_b(current)t1:c_a$hgphase--public'topic("other")'activetopic'other'isnowemptyAfterchangingthephaseofallthechangesetsin"other"topublic,thetopicshouldstillbeactive,butisempty.Weshouldbebetteratinformatingtheuseraboutitanddisplayinggooddatainthiscase.$hgtopicfoo(4changesets)*other(0changesets)$hgstack###topic:other ### target: default (branch)(stackisempty)t0^c_b(basecurrent)$hgupfooswitchingtotopicfoo4filesupdated,0filesmerged,0filesremoved,0filesunresolvedSimpletest-----------'hg stack'listallchangesetinthetopic$hgtopic*foo(4changesets)$hgstack###topic:foo ### target: default (branch)t4@c_f(current)t3:c_et2:c_dt1:c_ct0^c_b(base)$hgstack-v ### topic: foo ### target: default (branch)t4(6559e6d93aea)@c_f(current)t3(0f9ac936c87d):c_et2(e629654d7050):c_dt1(8522f9e3fee9):c_ct0(ea705abc4f51)^c_b(base)$hgstack-Tjson|python-mjson.tool[{"isentry":true,"topic.stack.desc":"c_f","topic.stack.index":4,"topic.stack.state":["current"],"topic.stack.state.symbol":"@"},{"isentry":true,"topic.stack.desc":"c_e","topic.stack.index":3,"topic.stack.state":["clean"],"topic.stack.state.symbol":":"},{"isentry":true,"topic.stack.desc":"c_d","topic.stack.index":2,"topic.stack.state":["clean"],"topic.stack.state.symbol":":"},{"isentry":true,"topic.stack.desc":"c_c","topic.stack.index":1,"topic.stack.state":["clean"],"topic.stack.state.symbol":":"},{"isentry":false,"topic.stack.desc":"c_b","topic.stack.index":0,"topic.stack.state":["base"],"topic.stack.state.symbol":"^"}]$hgstack-v-Tjson|python-mjson.tool[{"isentry":true,"topic.stack.desc":"c_f","topic.stack.index":4,"topic.stack.shortnode":"6559e6d93aea","topic.stack.state":["current"],"topic.stack.state.symbol":"@"},{"isentry":true,"topic.stack.desc":"c_e","topic.stack.index":3,"topic.stack.shortnode":"0f9ac936c87d","topic.stack.state":["clean"],"topic.stack.state.symbol":":"},{"isentry":true,"topic.stack.desc":"c_d","topic.stack.index":2,"topic.stack.shortnode":"e629654d7050","topic.stack.state":["clean"],"topic.stack.state.symbol":":"},{"isentry":true,"topic.stack.desc":"c_c","topic.stack.index":1,"topic.stack.shortnode":"8522f9e3fee9","topic.stack.state":["clean"],"topic.stack.state.symbol":":"},{"isentry":false,"topic.stack.desc":"c_b","topic.stack.index":0,"topic.stack.shortnode":"ea705abc4f51","topic.stack.state":["base"],"topic.stack.state.symbol":"^"}]checkthattopicsandstackareavailableevenifui.strict=true$hgtopics*foo(4changesets)$hgstack###topic:foo ### target: default (branch)t4@c_f(current)t3:c_et2:c_dt1:c_ct0^c_b(base)$hgtopics--configui.strict=true*foo(4changesets)$hgstack--configui.strict=true ### topic: foo ### target: default (branch)t4@c_f(current)t3:c_et2:c_dt1:c_ct0^c_b(base)errorcase,nothingtolist$hgtopic--clear$hgstack ### target: default (branch)(stackisempty)b0^c_f(basecurrent)Test"t#"reference-------------------$hgupt2abort:cannotresolve"t2":noactivetopic[255]$hgtopicfoomarkedworkingdirectoryastopic:foo$hgupt42abort:cannotresolve"t42":topic"foo"hasonly4changesets[255]$hgupt20filesupdated,0filesmerged,2filesremoved,0filesunresolved$hgsummaryparent:3:e629654d7050c_dbranch:defaultcommit:(clean)update:(current)phases:4drafttopic:fooCasewithsomeofthetopicunstable------------------------------------$echobbb>ddd$hgcommit--amend$hglog-G@6default{foo}draftc_d||o5default{foo}draftc_f|||o4default{foo}draftc_e|||x3default{foo}draftc_d|/o2default{foo}draftc_c|o1default{}publicc_b|o0default{}publicc_a$hgtopic--list ### topic: foo ### target: default (branch)t4$c_f(unstable)t3$c_e(unstable)t2@c_d(current)t1:c_ct0^c_b(base)$hgupt32filesupdated,0filesmerged,0filesremoved,0filesunresolved$hgtopic--list ### topic: foo ### target: default (branch)t4$c_f(unstable)t3$c_e(currentunstable)t2:c_dt1:c_ct0^c_b(base)$hgtopic--list--color=debug[topic.stack.summary.topic|###topic:[topic.active|foo]][topic.stack.summary.branches|###target:default(branch)][topic.stack.indextopic.stack.index.unstable|t4][topic.stack.statetopic.stack.state.unstable|$][topic.stack.desctopic.stack.desc.unstable|c_f][topic.stack.statetopic.stack.state.unstable|(unstable)][topic.stack.indextopic.stack.index.currenttopic.stack.index.unstable|t3][topic.stack.statetopic.stack.state.currenttopic.stack.state.unstable|$][topic.stack.desctopic.stack.desc.currenttopic.stack.desc.unstable|c_e][topic.stack.statetopic.stack.state.currenttopic.stack.state.unstable|(currentunstable)][topic.stack.indextopic.stack.index.clean|t2][topic.stack.statetopic.stack.state.clean|:][topic.stack.desctopic.stack.desc.clean|c_d][topic.stack.indextopic.stack.index.clean|t1][topic.stack.statetopic.stack.state.clean|:][topic.stack.desctopic.stack.desc.clean|c_c][topic.stack.indextopic.stack.index.base|t0][topic.stack.statetopic.stack.state.base|^][topic.stack.desctopic.stack.desc.base|c_b][topic.stack.statetopic.stack.state.base|(base)]$hgupt21filesupdated,0filesmerged,1filesremoved,0filesunresolvedAlsotesttherevset:$hglog-r'stack()'2default{foo}draftc_c6default{foo}draftc_d4default{foo}draftc_e5default{foo}draftc_f$hglog-r'stack(foo)'hg:parseerror:stack()takesnoargument,itworksoncurrenttopic[255]$hglog-r'stack(foobar)'hg:parseerror:stack()takesnoargument,itworksoncurrenttopic[255]Casewithmultipleheadsonthetopic-------------------------------------Makethingslinearagain$hgrebase-s'desc(c_e)'-d'desc(c_d) - obsolete()'rebasing4:0f9ac936c87d"c_e"(foo)rebasing5:6559e6d93aea"c_f"(foo)$hglog-Go8default{foo}draftc_f|o7default{foo}draftc_e|@6default{foo}draftc_d|o2default{foo}draftc_c|o1default{}publicc_b|o0default{}publicc_aCreatethesecondbranch$hgup'desc(c_d)'0filesupdated,0filesmerged,0filesremoved,0filesunresolved$echoaaa>ggg$hgaddggg$hgcommit-mc_g$echoaaa>hhh$hgaddhhh$hgcommit-mc_h$hglog-G@10default{foo}draftc_h|o9default{foo}draftc_g||o8default{foo}draftc_f|||o7default{foo}draftc_e|/o6default{foo}draftc_d|o2default{foo}draftc_c|o1default{}publicc_b|o0default{}publicc_aTestoutput$hgtop-l ### topic: foo (2 heads) ### target: default (branch)t6@c_h(current)t5:c_gt2^c_d(base)t4:c_ft3:c_et2:c_dt1:c_ct0^c_b(base)Casewithmultipleheadsonthetopicwithunstabilityinvolved---------------------------------------------------------------Weamendthemessagetomakesurethedisplaybasepicktherightchangeset$hgup'desc(c_d)'0filesupdated,0filesmerged,2filesremoved,0filesunresolved$echoccc>ddd$hgcommit--amend-m'c_D'$hgrebase-d.-s'desc(c_g)'rebasing9:81264ae8a36a"c_g"(foo)rebasing10:fde5f5941642"c_h"(foo)$hglog-Go13default{foo}draftc_h|o12default{foo}draftc_g|@11default{foo}draftc_D||o8default{foo}draftc_f|||o7default{foo}draftc_e|||x6default{foo}draftc_d|/o2default{foo}draftc_c|o1default{}publicc_b|o0default{}publicc_a$hgtopic--list ### topic: foo (2 heads) ### target: default (branch)t6:c_ht5:c_gt2^c_D(basecurrent)t4$c_f(unstable)t3$c_e(unstable)t2@c_D(current)t1:c_ct0^c_b(base)Tryingtolistnonexistingtopic$hgstackthisdoesnotexistabort:cannotresolve"thisdoesnotexist":nosuchtopicfound[255]$hgtopic--listthisdoesnotexistabort:cannotresolve"thisdoesnotexist":nosuchtopicfound[255]Complexcaseswherecommitswithsametopicarenotconsecutivebutarelinear==============================================================================$hglog--grapho13default{foo}draftc_h|o12default{foo}draftc_g|@11default{foo}draftc_D||o8default{foo}draftc_f|||o7default{foo}draftc_e|||x6default{foo}draftc_d|/o2default{foo}draftc_c|o1default{}publicc_b|o0default{}publicc_aConvertingintoalinearchain$hgrebase-s'desc("c_e") - obsolete()'-d'desc("c_h") - obsolete()'rebasing7:215bc359096a"c_e"(foo)rebasing8:ec9267b3f33f"c_f"(foo)$hglog-Go15default{foo}draftc_f|o14default{foo}draftc_e|o13default{foo}draftc_h|o12default{foo}draftc_g|@11default{foo}draftc_D|o2default{foo}draftc_c|o1default{}publicc_b|o0default{}publicc_aChangingtopicsonsomecommitsinbetween$hgtopicfoobar-r'desc(c_e) + desc(c_D)'switchingtotopicfoobarchangedtopicon2changes$hglog-G@17default{foobar}draftc_D||o16default{foobar}draftc_e||||o15default{foo}draftc_f|||||x14default{foo}draftc_e||/|o13default{foo}draftc_h|||o12default{foo}draftc_g|||x11default{foo}draftc_D|/o2default{foo}draftc_c|o1default{}publicc_b|o0default{}publicc_a$hgrebase-s'desc("c_f") - obsolete()'-d'desc("c_e") - obsolete()'rebasing15:77082e55de88"c_f"(foo)switchingtotopicfooswitchingtotopicfoobar$hgrebase-s'desc("c_g") - obsolete()'-d'desc("c_D") - obsolete()'rebasing12:0c3e8aed985d"c_g"(foo)switchingtotopicfoorebasing13:b9e4f3709bc5"c_h"(foo)rebasing16:4bc813530301"c_e"(foobar)switchingtotopicfoobarrebasing18:4406ea4be852"c_f"(tipfoo)switchingtotopicfooswitchingtotopicfoobar$hgup3filesupdated,0filesmerged,0filesremoved,0filesunresolved$hglog--grapho22default{foo}draftc_f|@21default{foobar}draftc_e|o20default{foo}draftc_h|o19default{foo}draftc_g|o17default{foobar}draftc_D|o2default{foo}draftc_c|o1default{}publicc_b|o0default{}publicc_aXXX:ThefollowingshouldshowsingleheadsXXX:Thebehindcountisweird,becausethetopicareinterleaved.$hgstack ### topic: foobar ### target: default (branch), 3 behindt2@c_e(current)^c_ht1:c_Dt0^c_c(base)$hgstackfoo###topic:foo ### target: default (branch), ambiguous rebase destination - topic 'foo' has 3 headst4:c_f^c_et3:c_ht2:c_g^c_Dt1:c_ct0^c_b(base)caseinvolvingamerge----------------------$cd..$hginitstack-gap-merge$cdstack-gap-merge$echoaaa>aaa$hgcommit-Am'c_A'addingaaa$hgtopicredmarkedworkingdirectoryastopic:red$echobbb>bbb$hgcommit-Am'c_B'addingbbbactivetopic'red'grewitsfirstchangeset$echoccc>ccc$hgcommit-Am'c_C'addingccc$hgtopicblue$echoddd>ddd$hgcommit-Am'c_D'addingdddactivetopic'blue'grewitsfirstchangeset$hgup'desc("c_B")'switchingtotopicred0filesupdated,0filesmerged,2filesremoved,0filesunresolved$echoeee>eee$hgcommit-Am'c_E'addingeee$echofff>fff$hgcommit-Am'c_F'addingfff$hgtopicblue$echoggg>ggg$hgcommit-Am'c_G'addingggg$hgup'desc("c_D")'2filesupdated,0filesmerged,3filesremoved,0filesunresolved$hgtopicred$hgmerge'desc("c_G")'3filesupdated,0filesmerged,0filesremoved,0filesunresolved(branchmerge,don't forget to commit) $ hg commit -Am 'c_H' $ hg topic blue $ echo iii > iii $ hg ci -Am 'c_I' adding iii $ hg log -G @ 8 default {blue} draft c_I | o 7 default {red} draft c_H |\ | o 6 default {blue} draft c_G | | | o 5 default {red} draft c_F | | | o 4 default {red} draft c_E | | o | 3 default {blue} draft c_D | | o | 2 default {red} draft c_C |/ o 1 default {red} draft c_B | o 0 default {} draft c_A $ hg stack red ### topic: red ### target: default (branch), 6 behind t5: c_H ^ c_G ^ c_D t4: c_C t1^ c_B (base) t3: c_F t2: c_E t1: c_B t0^ c_A (base) $ hg stack blue ### topic: blue ### target: default (branch), ambiguous rebase destination - topic 'blue' has 3 heads t3@ c_I (current) ^ c_H t2: c_D ^ c_C t1: c_G t0^ c_F (base)Even with some obsolete and orphan changesets(the ordering of each branch of "blue" change because their hash change. weshould stabilize this eventuelly) $ hg up 'desc("c_B")' switching to topic red 0 files updated, 0 files merged, 6 files removed, 0 files unresolved $ hg commit --amend --user test2 $ hg up 'desc("c_C")' 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg commit --amend --user test2 $ hg up 'desc("c_D")' switching to topic blue 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg commit --amend --user test2 $ hg log -G --rev 'sort(all(),"topo")' @ 11 default {blue} draft c_D | | o 8 default {blue} draft c_I | | | o 7 default {red} draft c_H | |\ | | o 6 default {blue} draft c_G | | | | | o 5 default {red} draft c_F | | | | | o 4 default {red} draft c_E | | | | x | 3 default {blue} draft c_D |/ / x / 2 default {red} draft c_C |/ | o 10 default {red} draft c_C |/ x 1 default {red} draft c_B | | o 9 default {red} draft c_B |/ o 0 default {} draft c_A $ hg stack red ### topic: red ### target: default (branch), ambiguous rebase destination - topic 'red' has 3 heads t5$ c_H (unstable) ^ c_G ^ c_D t4$ c_C (unstable) t1^ c_B (base) t3$ c_F (unstable) t2$ c_E (unstable) t1: c_B t0^ c_A (base) $ hg stack blue ### topic: blue ### target: default (branch), ambiguous rebase destination - topic 'blue' has 3 heads t3$ c_I (unstable) ^ c_H t2$ c_G (unstable) ^ c_F t1$ c_D (current unstable) t0^ c_C (base unstable)more obsolescence $ hg up 'max(desc("c_H"))' switching to topic red 3 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg commit --amend --user test3 $ hg up 'max(desc("c_G"))' switching to topic blue 0 files updated, 0 files merged, 2 files removed, 0 files unresolved $ hg commit --amend --user test3 $ hg up 'max(desc("c_B"))' switching to topic red 0 files updated, 0 files merged, 3 files removed, 0 files unresolved $ hg commit --amend --user test3 $ hg up 'max(desc("c_C"))' 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg commit --amend --user test3 $ hg up 'max(desc("c_D"))' switching to topic blue 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg commit --amend --user test3 $ hg log -G --rev 'sort(all(),"topo")' @ 16 default {blue} draft c_D | | o 13 default {blue} draft c_G | | | | o 12 default {red} draft c_H | | |\ | | | | o 8 default {blue} draft c_I | | | | | | | +---x 7 default {red} draft c_H | | | |/ | +---x 6 default {blue} draft c_G | | | | o | 5 default {red} draft c_F | | | | o | 4 default {red} draft c_E | | | +---x 3 default {blue} draft c_D | | x | 2 default {red} draft c_C |/ | o 15 default {red} draft c_C |/ x 1 default {red} draft c_B | | o 14 default {red} draft c_B |/ o 0 default {} draft c_A $ hg stack red ### topic: red ### target: default (branch), ambiguous rebase destination - topic 'red' has 3 heads t5$ c_H (unstable) ^ c_G ^ c_D t4$ c_F (unstable) t3$ c_E (unstable) t1^ c_B (base) t2$ c_C (unstable) t1: c_B t0^ c_A (base) $ hg stack blue ### topic: blue ### target: default (branch), ambiguous rebase destination - topic 'blue' has 3 heads t3$ c_I (unstable) ^ c_H t2$ c_G (unstable) ^ c_F t1$ c_D (current unstable) t0^ c_C (base unstable)Test stack behavior with a split--------------------------------get things linear again $ hg rebase -r t1 -d default rebasing 16:1d84ec948370 "c_D" (tip blue) switching to topic blue $ hg rebase -r t2 -d t1 rebasing 13:3ab2eedae500 "c_G" (blue) $ hg rebase -r t3 -d t2 rebasing 8:3bfe800e0486 "c_I" (blue) $ hg stack ### topic: blue ### target: default (branch) t3: c_I t2: c_G t1@ c_D (current) t0^ c_A (base)making a split(first get something to split) $ hg up t2 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg status --change . A ggg $ echo zzz > Z $ hg add Z $ hg commit --amend $ hg status --change . A Z A ggg $ hg stack ### topic: blue ### target: default (branch) t3$ c_I (unstable) t2@ c_G (current) t1: c_D t0^ c_A (base) $ hg --config extensions.evolve= --config ui.interactive=yes split <<EOF>y>y>n>y>EOF0filesupdated,0filesmerged,2filesremoved,0filesunresolvedaddingZaddinggggdiff--gita/Zb/Znewfilemode100644examinechangesto'Z'?[Ynesfdaq?]y@@-0,0+1,1@@+zzzrecordchange1/2to'Z'?[Ynesfdaq?]ydiff--gita/gggb/gggnewfilemode100644examinechangesto'ggg'?[Ynesfdaq?]nDonesplitting?[yN]y$hg--configextensions.evolve=obslog--allodde94df880e9(21)c_G||@e7ea874afbd5(22)c_G|/xb24bab30ac12(20)c_G|rewritten(parent,content)asdde94df880e9,e7ea874afbd5bytest(ThuJan0100:00:001970+0000)|x907f7d3c2333(18)c_G|rewritten(content)asb24bab30ac12bytest(ThuJan0100:00:001970+0000)|x3ab2eedae500(13)c_G|rewritten(parent)as907f7d3c2333bytest(ThuJan0100:00:001970+0000)|xc7d60a180d05(6)c_Grewritten(user)as3ab2eedae500bytest(ThuJan0100:00:001970+0000)$hgexport. # HG changeset patch # User test3 # Date 0 0 # Thu Jan 01 00:00:00 1970 +0000 # Node ID e7ea874afbd5c17aeee366d39a828dbcb01682ce # Parent dde94df880e97f4a1ee8c5408254b429b3d90204 # EXP-Topic bluec_Gdiff-rdde94df880e9-re7ea874afbd5ggg---/dev/nullThuJan0100:00:001970+0000+++b/gggThuJan0100:00:001970+0000@@-0,0+1,1@@+ggg$hgexport.^ # HG changeset patch # User test3 # Date 0 0 # Thu Jan 01 00:00:00 1970 +0000 # Node ID dde94df880e97f4a1ee8c5408254b429b3d90204 # Parent f3328cd199dc389b850ca952f65a15a8e6dbc79b # EXP-Topic bluec_Gdiff-rf3328cd199dc-rdde94df880e9Z---/dev/nullThuJan0100:00:001970+0000+++b/ZThuJan0100:00:001970+0000@@-0,0+1,1@@+zzzCheckthatstackouputstillmakesense$hgstack ### topic: blue ### target: default (branch)t4$c_I(unstable)t3@c_G(current)t2:c_Gt1:c_Dt0^c_A(base)