Implement support for mq; handle (q)record more gracefully
mq:
Ensure that expanded keywords do not make it into patches.
- disable expansion when reading filelog
- shrink expanded keywords when reading from working dir (wread)
(q)record:
Avoid additional hunks due to expanded keywords. However this is
still a compromise, as keyword expansions are not updated in
working directory because record should not overwrite files.
Mention above shortcomings and "hg kwexpand" workaround in help
and update test output.
system argument parsing:
Command detection might be slightly more expensive with
dispatch._parse, but we will need this for improving "hg diff"
output.
%helpkeywordextension-keywordexpansioninlocalrepositoriesThisextensionexpandsRCS/CVS-likeorself-customized$Keywords$intrackedtextfilesselectedbyyourconfiguration.Keywordsareonlyexpandedinlocalrepositoriesandnotstoredinthechangehistory.Themechanismcanberegardedasaconvenienceforthecurrentuserorforarchivedistribution.Configurationisdoneinthe[keyword]and[keywordmaps]sectionsofhgrcfiles.Example:[keyword]#expandkeywordsineverypythonfileexceptthosematching"x*"**.py=x*=ignoreNote:themorespecificyouareinyourfilenamepatternsthelessyoulosespeedinhugerepos.For[keywordmaps]templatemappingandexpansiondemonstrationandcontrolrun"hg kwdemo".Anadditionaldatetemplatefilter{date|utcdate}isprovided.Thedefaulttemplatemappings(viewwith"hg kwdemo -d")canbereplacedwithcustomizedkeywordsandtemplates.Again,run"hg kwdemo"tocontroltheresultsofyourconfigchanges.Beforechanging/disablingactivekeywords,run"hg kwshrink"toavoidtheriskofinadvertedlystoringexpandedkeywordsinthechangehistory.Toforceexpansionafterenablingit,oraconfigurationchange,run"hg kwexpand".Also,whencommittingwiththerecordextensionorusingmq's qrecord, be awarethat keywords cannot be updated. Again, run "hg kwexpand" on the files inquestion to update keyword expansions after all changes have been checked in.Expansions spanning more than one line and incremental expansions,like CVS'$Log$,arenotsupported.Akeywordtemplatemap"Log = {desc}"expandstothefirstlineofthechangesetdescription.listofcommands:kwdemoprint[keywordmaps]configurationandanexpansionexamplekwexpandexpandkeywordsinworkingdirectorykwfilesprintfilescurrentlyconfiguredforkeywordexpansionkwshrinkrevertexpandedkeywordsinworkingdirectoryuse"hg -v help keyword"toshowaliasesandglobaloptions%hgkwdemo[extensions]hgext.keyword=[keyword]*=b=ignoredemo.txt=[keywordmaps]RCSFile={file|basename},vAuthor={author|user}Header={root}/{file},v{node|short}{date|utcdate}{author|user}Source={root}/{file},vDate={date|utcdate}Id={file|basename},v{node|short}{date|utcdate}{author|user}Revision={node|short}$RCSFile:demo.txt,v$$Author:test$$Header:/TMP/demo.txt,vxxxxxxxxxxxx2000/00/0000:00:00test$$Source:/TMP/demo.txt,v$$Date:2000/00/0000:00:00$$Id:demo.txt,vxxxxxxxxxxxx2000/00/0000:00:00test$$Revision:xxxxxxxxxxxx$[extensions]hgext.keyword=[keyword]*=b=ignoredemo.txt=[keywordmaps]Branch={branches}$Branch:demobranch$%kwshrinkshouldexitsilentlyinempty/invalidrepo%catexpand$Id$donotprocess$Id:xxx$expand$Id$donotprocess$Id:xxx$ignore$Id$%addremoveaddingaaddingbaddingsym%statusAaAbAsym%defaultkeywordexpansionincludingcommithook%interruptedcommitshouldnotchangestateorruncommithookabsymtransactionabort!rollbackcompletedabort:emptycommitmessage%statusAaAbAsym%commitabsymoverwritingaexpandingkeywordsrunninghookcommit.test:cpahooktest%status?hooktest%identifyf782df5f9602%catexpand$Id:a,vf782df5f96021970/01/0100:00:00user$donotprocess$Id:xxx$expand$Id:a,vf782df5f96021970/01/0100:00:00user$donotprocess$Id:xxx$ignore$Id$%hgcatexpand$Id:a,vf782df5f96021970/01/0100:00:00user$donotprocess$Id:xxx$ignore$Id$a%diffahooktest%removingcommithookfromconfig%touch%status%update3filesupdated,0filesmerged,0filesremoved,0filesunresolved%catexpand$Id:a,vf782df5f96021970/01/0100:00:00user$donotprocess$Id:xxx$expand$Id:a,vf782df5f96021970/01/0100:00:00user$donotprocess$Id:xxx$ignore$Id$%checkwhetherexpansionisfilewise%commitcaddingc%forceexpansionoverwritingaexpandingkeywordsoverwritingcexpandingkeywords%comparechangenodesinacexpand$Id:a,vf782df5f96021970/01/0100:00:00user$donotprocess$Id:xxx$$Id:c,vba4426d1938e1970/01/0100:00:01user$testsfordifferentchangenodes%rollbackandremovecrollingbacklasttransaction%copy%kwfilesaddedac%commitcc:copya:0045e12f6c5791aac80ca6cbfd97709a88307292overwritingcexpandingkeywords%catacexpand$Id:a,vf782df5f96021970/01/0100:00:00user$donotprocess$Id:xxx$expand$Id:c,v0ba462c0f0771970/01/0100:00:01user$donotprocess$Id:xxx$%touchcopiedcafter1second%status%kwfilesac%diff--revdiff-rf782df5f9602c---/dev/nullThuJan0100:00:001970+0000@@-0,0+1,3@@+expand$Id:c,v0ba462c0f0771970/01/0100:00:01user$+donotprocess$Id:+xxx$%rollbackrollingbacklasttransaction%statusAc%update-C0filesupdated,0filesmerged,1filesremoved,0filesunresolved%customkeywordexpansion%trywithkwdemo[extensions]hgext.keyword=[keyword]*=b=ignoredemo.txt=[keywordmaps]Xinfo={author}:{desc}$Xinfo:test:hgkeywordconfigandexpansionexample$%catexpand$Id:a,vf782df5f96021970/01/0100:00:00user$donotprocess$Id:xxx$expand$Id:a,vf782df5f96021970/01/0100:00:00user$donotprocess$Id:xxx$ignore$Id$%hgcatexpand$Id:af782df5f9602Thu,01Jan197000:00:00+0000user$donotprocess$Id:xxx$ignore$Id$a%interruptedcommitshouldnotchangestatetransactionabort!rollbackcompletedabort:emptycommitmessage%statusMa?log%commitaoverwritingaexpandingkeywords%status%catexpand$Id:a0729690beff6Thu,01Jan197000:00:02+0000user$donotprocess$Id:xxx$$Xinfo:UserName<user@example.com>:firstline$expand$Id:a0729690beff6Thu,01Jan197000:00:02+0000user$donotprocess$Id:xxx$$Xinfo:UserName<user@example.com>:firstline$ignore$Id$%hgcatexpand$Id:a0729690beff6Thu,01Jan197000:00:02+0000user$donotprocess$Id:xxx$$Xinfo:UserName<user@example.com>:firstline$ignore$Id$a%remove%status%rollbackrollingbacklasttransaction%statusRa%reverta%cataexpand$Id:a0729690beff6Thu,01Jan197000:00:02+0000user$donotprocess$Id:xxx$$Xinfo:UserName<user@example.com>:firstline$%clonetotestincomingrequestingallchangesaddingchangesetsaddingmanifestsaddingfilechangesadded1changesetswith3changesto3files3filesupdated,0filesmerged,0filesremoved,0filesunresolved%incomingcomparingwithtest-keyword/Test-a/../Testsearchingforchangeschangeset:1:0729690beff6tag:tipuser:UserName<user@example.com>date:ThuJan0100:00:021970+0000summary:firstline%commitrejecttestaoverwritingaexpandingkeywords%export%importapplying../rejecttest.diff%catexpand$Id:a82983f13f138Thu,01Jan197000:00:03+0000user$rejecttestdonotprocess$Id:rejecttestxxx$$Xinfo:UserName<user@example.com>:rejects?$expand$Id:a82983f13f138Thu,01Jan197000:00:03+0000user$rejecttestdonotprocess$Id:rejecttestxxx$$Xinfo:UserName<user@example.com>:rejects?$ignore$Id$%rollbackrollingbacklasttransaction%cleanupdate1filesupdated,0filesmerged,0filesremoved,0filesunresolved%kwexpand/kwshrinkonselectedfiles%copyax/a%kwexpandaoverwritingaexpandingkeywords%kwexpandx/ashouldabortabort:outstandinguncommittedchangesingivenfilesx/ax/a:copya:779c764182ce5d43e2b1eb66ce06d7b47bfe342eoverwritingx/aexpandingkeywords%cataexpand$Id:x/af27c134d2d9bThu,01Jan197000:00:03+0000user$donotprocess$Id:xxx$$Xinfo:UserName<user@example.com>:xa$%kwshrinkainsidedirectoryxoverwritingx/ashrinkingkeywords%cataexpand$Id$donotprocess$Id:xxx$$Xinfo$%kwexpandnonexistentnonexistent:Nosuchfileordirectory%switchoffexpansion%kwshrinkwithunknownfileuoverwritingashrinkingkeywordsoverwritingx/ashrinkingkeywords%catexpand$Id$donotprocess$Id:xxx$$Xinfo$expand$Id$donotprocess$Id:xxx$$Xinfo$ignore$Id$%hgcatexpand$Id:a0729690beff6Thu,01Jan197000:00:02+0000user$donotprocess$Id:xxx$$Xinfo:UserName<user@example.com>:firstline$ignore$Id$a%catexpand$Id$donotprocess$Id:xxx$$Xinfo$expand$Id$donotprocess$Id:xxx$$Xinfo$ignore$Id$%hgcatexpand$Id$donotprocess$Id:xxx$$Xinfo$ignore$Id$a