[states] fix strip but a case still does not work (see test test-state-strip.t)
MutableHistoryandcollaboration=====================================================================Historymutation=====================..AlbertBeugras..RenédeRobertHereissmallintroductionofSingleDeveloperUsage======================Thistutorialshowshowtouseevolutiontoreplacethebasicsof*mq*.Amendingachangeset---------------------Firstthereissomesetupphaseyouwillunderstandlater.thereisalocalrepositoryandaremoteone.Pleasecloseyoureyes.$hginitlocal$cat>>local/.hg/hgrc<<EOF>[paths]>remote=../remote>[ui]>user=AlbertBeugras>[diff]>git=1>[alias]>amend=amend-d'0 0'>tlog=log--template"{node|short}: '{desc}'\n">ttlog=log--template"{node|short}: '{desc}' ({state})\n">tglog=log-G--template"{node|short}: '{desc}' {branches}\n">[extensions]>hgext.graphlog=>hgext.rebase=>EOF$echo"states=$(echo $(dirname $TESTDIR))/hgext/states.py">>local/.hg/hgrc$echo"obsolete=$(echo $(dirname $TESTDIR))/hgext/obsolete.py">>local/.hg/hgrc$echo"evolution=$(echo $(dirname $TESTDIR))/hgext/evolution.py">>local/.hg/hgrc$hginitremote$cat>>remote/.hg/hgrc<<EOF>[paths]>local=../local>[ui]>user=RenédeRobert>[diff]>git=1>[alias]>amend=amend-d'0 0'>tlog=log--template"{node|short}: '{desc}' {branches}\n">ttlog=log--template"{node|short}: '{desc}' {state}\n">tglog=log-G--template"{node|short}: '{desc}' {branches}\n">[extensions]>hgext.graphlog=>hgext.rebase=>EOF$echo"states=$(echo $(dirname $TESTDIR))/hgext/states.py">>remote/.hg/hgrc$echo"obsolete=$(echo $(dirname $TESTDIR))/hgext/obsolete.py">>remote/.hg/hgrc$echo"evolution=$(echo $(dirname $TESTDIR))/hgext/evolution.py">>remote/.hg/hgrc$cdlocalYoucanreopenyoueyes.Nowwemakeafirstversionofourshoppinglist.$cat>>shopping<<EOF>Spam>Whizzobutter>Albatross>Rat(ratheralot)>Juggedfish>Blancmange>Salmonmousse>EOF$hgcommit-A-m"Monthy Python Shopping list"addingshoppingWesharethisfirstversionwiththeoutside.$hgpushremotepushingto$TESTTMP/remotesearchingforchangesaddingchangesetsaddingmanifestsaddingfilechangesadded1changesetswith1changesto1filesLaterIaddadditionalitemtomylist$cat>>shopping<<EOF>Egg>Suggar>Vinegar>Oil>EOF$hgcommit-m"adding condiment"$cat>>shopping<<EOF>Bananos>Pear>Apple>EOF$hgcommit-m"adding fruit"Inowhavethefollowinghistory:$hgtlogd85de4546133:'adding fruit'4d5dc8187023:'adding condiment'7e82d3f3c2cb:'Monthy Python Shopping list'But,Ijustnotice,ImadeatypoinBanana.$hgexporttip # HG changeset patch # User test # Date 0 0 # Node ID d85de4546133030c82d257bbcdd9b1b416d0c31c # Parent 4d5dc81870237d492284826e21840b2ca00e26d1addingfruitdiff--gita/shoppingb/shopping---a/shopping+++b/shopping@@-9,3+9,6@@SuggarVinegarOil+Bananos+Pear+Applehopefully.Icanusehgamendtorewritemyfaultychangeset!$sed-i''-es/Bananos/Banana/shopping$hgdiffdiff--gita/shoppingb/shopping---a/shopping+++b/shopping@@-9,6+9,6@@SuggarVinegarOil-Bananos+BananaPearApple$hgamendabort:cannotrewriteimmutablechangesetd85de4546133[255]Bydefaultallchangesetareconsidered"published"andcan't be rewrittent. $ hg ttlogYou need to enable a mutable state in your repo the "ready" one $ hg states ready --clever $ hg ttlog d85de4546133: 'addingfruit' (ready) 4d5dc8187023: 'addingcondiment' (ready) 7e82d3f3c2cb: 'MonthyPythonShoppinglist' (published)Notice that changeset you already shared with the outside have been keeppublished.The changeset we want to rewrite is now in a mutable state. $ hg amendA new changeset with the right diff replace the wrong one. $ hg tlog 0cacb48f4482: 'addingfruit' 4d5dc8187023: 'addingcondiment' 7e82d3f3c2cb: 'MonthyPythonShoppinglist' $ hg export tip # HG changeset patch # User test # Date 0 0 # Node ID 0cacb48f44828d2fd31c4e45e18fde32a5b2f07b # Parent 4d5dc81870237d492284826e21840b2ca00e26d1 adding fruit diff --git a/shopping b/shopping --- a/shopping +++ b/shopping @@ -9,3 +9,6 @@ Suggar Vinegar Oil +Banana +Pear +AppleGetting Ride of branchy history----------------------------------While I was working on my list. someone help made a change remotly.close your eyes $ cd ../remote $ hg up -q $ sed -i'' -e 's/Spam/SpamSpamSpam/' shopping $ hg ci -m 'SPAM' $ cd ../localopen your eyes $ hg pull remote pulling from $TESTTMP/remote searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) (run 'hgheads.' to see heads, 'hgmerge' to merge)I now have a new heads. Note that the remote head is immutable $ hg ttlog 9ca060c80d74: 'SPAM' (published) 0cacb48f4482: 'addingfruit' (ready) 4d5dc8187023: 'addingcondiment' (ready) 7e82d3f3c2cb: 'MonthyPythonShoppinglist' (published) $ hg tglog -r "::(9ca060c80d74 + 0cacb48f4482)" o 9ca060c80d74: 'SPAM' | | @ 0cacb48f4482: 'addingfruit' | | | o 4d5dc8187023: 'addingcondiment' |/ o 7e82d3f3c2cb: 'MonthyPythonShoppinglist'instead of merging my head with the new one. I'mgoingtorebasemywork$hgdiff$hgrebase-d9ca060c80d74-s4d5dc8187023mergingshoppingmergingshoppingmergingshoppingmergingshoppingMylocalworkisnowrebaseontheremoteone.$hgkille7a71e229632ad97bbd3e37d#XXXfixmeinstead$hgttlog387187ad9bd9:'adding fruit'(ready)dfd3a2d7691e:'adding condiment'(ready)9ca060c80d74:'SPAM'(published)7e82d3f3c2cb:'Monthy Python Shopping list'(published)$hgtglog-r'::.'@387187ad9bd9:'adding fruit'|odfd3a2d7691e:'adding condiment'|o9ca060c80d74:'SPAM'|o7e82d3f3c2cb:'Monthy Python Shopping list'Removingchangeset------------------------Iaddnewitemtomylist$cat>>shopping<<EOF>car>bus>plane>boat>EOF$hgci-m'transport'$hgttlogd58c77aa15d7:'transport'(ready)387187ad9bd9:'adding fruit'(ready)dfd3a2d7691e:'adding condiment'(ready)9ca060c80d74:'SPAM'(published)7e82d3f3c2cb:'Monthy Python Shopping list'(published)IhaveanewcommitbutIrealizethatdon't want it. (transport shop list doesnot fit well in my standard shopping list) $ hg kill . # . is for working directory parent. 1 files updated, 0 files merged, 0 files removed, 0 files unresolved working directory now at 387187ad9bd9The silly changeset is gone. $ hg ttlog 387187ad9bd9: 'addingfruit' (ready) dfd3a2d7691e: 'addingcondiment' (ready) 9ca060c80d74: 'SPAM' (published) 7e82d3f3c2cb: 'MonthyPythonShoppinglist' (published)Reordering changeset------------------------We create two changeset. $ cat >> shopping <<EOF>Shampoo>Toothbrush>...Morebathroomstufftocome>Towel>Soap>EOF$hgci-m'bathroom stuff'-q#XXXremovethe-q$sed-i''-e's/Spam/Spam Spam Spam/g'shopping$hgci-m'SPAM SPAM'$hgttlogc48f32fb1787:'SPAM SPAM'(ready)8d39a843582d:'bathroom stuff'(ready)387187ad9bd9:'adding fruit'(ready)dfd3a2d7691e:'adding condiment'(ready)9ca060c80d74:'SPAM'(published)7e82d3f3c2cb:'Monthy Python Shopping list'(published)..note:don't amend changeset 7e82d3f3c2cb or 9ca060c80d74 as they areimmutable.I now want to push to remote all my change but the bathroom one that i'mnottotallyhappywithyet.Tobeabletopush"SPAM SPAM"Ineedaversionof"SPAM SPAM"notchildrenof"bathroom stuff"Youcanuserebaseorrelocateforthat:$hgrelocate'p1(8d39a843582d)'--tracebackmergingshopping$hgtglog-r'::(. + 8d39a843582d)'@02e33960e937:'SPAM SPAM'||o8d39a843582d:'bathroom stuff'|/o387187ad9bd9:'adding fruit'|odfd3a2d7691e:'adding condiment'|o9ca060c80d74:'SPAM'|o7e82d3f3c2cb:'Monthy Python Shopping list'WehaveanewSPAMSPAMversionwithoutthebathroomstuff$grepSpamshopping#enouthspammSpamSpamSpamSpamSpamSpamSpamSpamSpam$grepToothbrushshopping#noToothbrush[1]$hgexport. # HG changeset patch # User test # Date 0 0 # Node ID 02e33960e937ad1bd59241ebdafd7a2494240ddf # Parent 387187ad9bd9d8f9a00a9fa804a26231db547429SPAMSPAMdiff--gita/shoppingb/shopping---a/shopping+++b/shopping@@-1,4+1,4@@-SpamSpamSpam+SpamSpamSpamSpamSpamSpamSpamSpamSpamWhizzobutterAlbatrossRat(ratheralot)wecannowpushourchange:$hgpush-r.remotepushingto$TESTTMP/remotesearchingforchangesaddingchangesetsaddingmanifestsaddingfilechangesadded3changesetswith3changesto1filesforsimplicityshakewerelocatethebathroomchangeset$hgrelocate-r8d39a843582d02e33960e937mergingshoppingSplittingchange------------------Tobedone(currentlyachievewith"two commit + debugobsolete")Collapsingchange------------------Tobedone(currentlyachievewith"revert + debugobsolete"or"rebase --collapse")collaboration====================sharingmutablechangeset----------------------------Tosharemutablechangesetwithotherjustcheckthatbothhavethe"ready"stateactivated.Otherwiseyouwillgetthepreviouslyobservebehaviorwhereexchangedchangesetareautomaticallypublished.$cd../remote$hgstatespublishedTheremoterepositoryhaveonlytheimmutable"published"stateactivated.Anychangesetechangedfrom"local"to"remote"willbesetinthepublisedstate:$hg-R../localpush-fremote#XXXweshouldpullbutthesupportisawfulpushingto$TESTTMP/remotesearchingforchangesaddingchangesetsaddingmanifestsaddingfilechangesadded1changesetswith1changesto1files$hgttloga3515e5d0332:'bathroom stuff'published02e33960e937:'SPAM SPAM'published387187ad9bd9:'adding fruit'publisheddfd3a2d7691e:'adding condiment'published9ca060c80d74:'SPAM'published7e82d3f3c2cb:'Monthy Python Shopping list'publishedWedonotwanttopublishthe"bathroom changeset".Let's rollback the last transaction $ hg rollback repository tip rolled back to revision 4 (undo push) working directory now based on revision 1 $ hg ttlog 02e33960e937: 'SPAMSPAM' published 387187ad9bd9: 'addingfruit' published dfd3a2d7691e: 'addingcondiment' published 9ca060c80d74: 'SPAM' published 7e82d3f3c2cb: 'MonthyPythonShoppinglist' published $ rm ../local/.hg/states/published-heads # XXX USE --exact $ hg -R ../local publish 02e33960e937 # XXX FIX THE BUGTo enable the mutable "ready" state in a repository, use the states command. $ hg states ready $ hg states published readyI can nom exchange mutable changeset between "remote" and "local" repository. $ hg pull local # XXX We pull too much stuff pulling from $TESTTMP/local searching for changes adding changesets adding manifests adding file changes added 10 changesets with 10 changes to 1 files (+5 heads) (run 'hgheads' to see heads, 'hgmerge' to merge) $ hg ttlog a3515e5d0332: 'bathroomstuff' ready 02e33960e937: 'SPAMSPAM' published 387187ad9bd9: 'addingfruit' published dfd3a2d7691e: 'addingcondiment' published 9ca060c80d74: 'SPAM' published 7e82d3f3c2cb: 'MonthyPythonShoppinglist' publishedRebasing out-of-sync change after update----------------------------------------------Remotely someone add a new changeset on top of our mutable "bathroom" on. $ hg up a3515e5d0332 -q $ cat >> shopping <<EOF>Giraffe>Rhino>Lion>Bear>EOF$hgci-m'animals'-q#XXXremovethe-qWhilethistimelocally,werebasetheupdatedthe"bathroom changeset"$cd../local$hgupa3515e5d0332-q$sed-i''-e's/... More bathroom stuff to come/Bath Robe/'shopping$hgamend$hgtlog962d3a7d27ad:'bathroom stuff'02e33960e937:'SPAM SPAM'387187ad9bd9:'adding fruit'dfd3a2d7691e:'adding condiment'9ca060c80d74:'SPAM'7e82d3f3c2cb:'Monthy Python Shopping list'Whenwepullfromremoteagainwegetanunstablestate!$hgpullremotepullingfrom$TESTTMP/remotesearchingforchangesaddingchangesetsaddingmanifestsaddingfilechangesadded1changesetswith1changesto1files(+1heads)(run'hg heads .'toseeheads,'hg merge'tomerge)$hgtlog0b061760b677:'animals'962d3a7d27ad:'bathroom stuff'a3515e5d0332:'bathroom stuff'02e33960e937:'SPAM SPAM'387187ad9bd9:'adding fruit'dfd3a2d7691e:'adding condiment'9ca060c80d74:'SPAM'7e82d3f3c2cb:'Monthy Python Shopping list'Thenewchangeset"animal"isbasedoneanoldchangesetof"bathroom".Youcanseebothversionshowingupthelog.$hgtglog-r'::(962d3a7d27ad + 0b061760b677)'o0b061760b677:'animals'||@962d3a7d27ad:'bathroom stuff'||o|a3515e5d0332:'bathroom stuff'|/o02e33960e937:'SPAM SPAM'|o387187ad9bd9:'adding fruit'|odfd3a2d7691e:'adding condiment'|o9ca060c80d74:'SPAM'|o7e82d3f3c2cb:'Monthy Python Shopping list'Inhgviewnthereisanicedotedrelationhighlighting962d3a7d27adisanewversionofa3515e5d0332.thisisnotyetportedtographlog.Toresolvethisunstablestate,youneedtorelocate0b061760b677onto962d3a7d27adthe"hg evolve"willmakethethinkingforyouandsuggestittoyou.$hgevolvehgrelocate--rev0b061760b677962d3a7d27adLet's do it $ hg relocate --rev 0b061760b677 962d3a7d27ad merging shoppingThe old vesion of bathroom is hidden again now. $ hg tlog 39a85a192689: 'animals' 962d3a7d27ad: 'bathroomstuff' 02e33960e937: 'SPAMSPAM' 387187ad9bd9: 'addingfruit' dfd3a2d7691e: 'addingcondiment' 9ca060c80d74: 'SPAM' 7e82d3f3c2cb: 'MonthyPythonShoppinglist'We can push this evolution to remote $ hg push -f remote # XXX should not require -f pushing to $TESTTMP/remote searching for changes adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 1 files (+1 heads)remote get a warning that current working directory is based on an obsolete changeset $ cd ../remote $ hg up . # XXX "loulz" 0 files updated, 0 files merged, 0 files removed, 0 files unresolved Working directory parent is obsolete $ hg up 39a85a192689 1 files updated, 0 files merged, 0 files removed, 0 files unresolvedRelocating out-of-sync change after kill----------------------------------------------The remote guy keep working $ sed -i'' -e 's/Spam/SpamSpamSpamSpam/g' shopping $ hg commit -m "SPAM SPAM SPAM"Work I can keep getting localy $ cd ../local $ hg pull remote pulling from $TESTTMP/remote searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (run 'hgupdate' to get a working copy) $ hg tlog e768beeb835c: 'SPAMSPAMSPAM' 39a85a192689: 'animals' 962d3a7d27ad: 'bathroomstuff' 02e33960e937: 'SPAMSPAM' 387187ad9bd9: 'addingfruit' dfd3a2d7691e: 'addingcondiment' 9ca060c80d74: 'SPAM' 7e82d3f3c2cb: 'MonthyPythonShoppinglist'In the mean time I noticed you can'tbuyanimalsinasupermarketandIkilltheanimalchangeset:$hgkill39a85a192689#issuewarninghere1filesupdated,0filesmerged,0filesremoved,0filesunresolvedworkingdirectorynowat962d3a7d27adTheanimalschangesetisstilldisplayedbecausethe"SPAM SPAM SPAM"changesetisneitherdeadorobsolete.Myrepositoryisinanunstablestateagain.$hgtloge768beeb835c:'SPAM SPAM SPAM'39a85a192689:'animals'962d3a7d27ad:'bathroom stuff'02e33960e937:'SPAM SPAM'387187ad9bd9:'adding fruit'dfd3a2d7691e:'adding condiment'9ca060c80d74:'SPAM'7e82d3f3c2cb:'Monthy Python Shopping list'$hgtglog-r'::e768beeb835c'oe768beeb835c:'SPAM SPAM SPAM'|o39a85a192689:'animals'|@962d3a7d27ad:'bathroom stuff'|o02e33960e937:'SPAM SPAM'|o387187ad9bd9:'adding fruit'|odfd3a2d7691e:'adding condiment'|o9ca060c80d74:'SPAM'|o7e82d3f3c2cb:'Monthy Python Shopping list'# $ hg evolve # XXX not ready yet# hg relocate --rev e768beeb835c 962d3a7d27ad$hgrelocate-re768beeb835c'p1(39a85a192689)'mergingshopping$hgtlog19098f8178f3:'SPAM SPAM SPAM'962d3a7d27ad:'bathroom stuff'02e33960e937:'SPAM SPAM'387187ad9bd9:'adding fruit'dfd3a2d7691e:'adding condiment'9ca060c80d74:'SPAM'7e82d3f3c2cb:'Monthy Python Shopping list'HandlingConflictingamend----------------------------------------------Wecandetectthatmultiplediverging//conflicting amend have been made. Therewillbea"evol-merge"commandtomergeconflictingamendcollaboration====================Turningchangesetimmutable----------------------------------------------*pushonpublished//only repo*tag*explicitepublishedcommandHandlingInvalidamendonpublishedchangeset----------------------------------------------youcan't amend published changeset. changeset that do this will have an "invalid amend" obsolete-status