Implement handle and hook for external callers
Allows external callers that do not use the command line to
pass current hg command to keyword extension.
This implementation might change in the future, if wrapping
of patch.diff is possible to the effect of avoiding external
handles.
#!/bin/shcat<<EOF >> $HGRCPATH[extensions]hgext.keyword =hgext.mq =[keyword]* =b = ignore[hooks]commit=commit.test=cp a hooktestEOFecho%helphghelpkeywordecho%hgkwdemohg--quietkwdemo--default\|sed-e's![^ ][^ ]*demo.txt,v!/TMP/demo.txt,v!'\-e's/,v [a-z0-9][a-z0-9]* /,v xxxxxxxxxxxx /'\-e'/[$]Revision/ s/: [a-z0-9][a-z0-9]* /: xxxxxxxxxxxx /'\-e's! 20[0-9][0-9]/[01][0-9]/[0-3][0-9] [0-2][0-9]:[0-6][0-9]:[0-6][0-9]! 2000/00/00 00:00:00!'hg--quietkwdemo"Branch = {branches}"hginitTestcdTestecho%kwshrinkshouldexitsilentlyinempty/invalidrepohgkwshrinkecho'expand $Id$'>aecho'do not process $Id:'>>aecho'xxx $'>>aecho'ignore $Id$'>bln-sasymecho%catcatsymabecho%addremovehgaddremoveecho%statushgstatusecho%defaultkeywordexpansionincludingcommithookecho%interruptedcommitshouldnotchangestateorruncommithookhg--debugcommitecho%statushgstatusecho%commithg--debugcommit-mabsym-d'0 0'-u'User Name <user@example.com>'echo%statushgstatusecho%identifyhg--quietidentifyecho%catcatsymabecho%hgcathgcatsymabechoecho%diffahooktestdiffahooktestecho%removingcommithookfromconfigsed-e'/\[hooks\]/,$ d'$HGRCPATH>$HGRCPATH.nohookmv$HGRCPATH.nohook$HGRCPATHrmhooktestecho%touchtouchabecho%statushgstatusrmsymabecho%updatehgupdateecho%catcatsymabecho%checkwhetherexpansionisfilewiseecho'$Id$'>cecho'tests for different changenodes'>>cecho%commitchgcommit-A-mcndiff-d'1 0'-u'User Name <user@example.com>'echo%forceexpansionhg-vkwexpandecho%comparechangenodesinaccatacecho%qimporthgqimport-rtip-nmqtest.diffecho%keywordsshouldnotbeexpandedinpatchcat.hg/patches/mqtest.diffecho%qpophgqpopecho%qgoto-shouldimplyqpushhgqgotomqtest.diffecho%catcatcecho%qpopandmoveonhgqpopecho%copyhgcpacecho%kwfilesaddedhgkwfilesecho%commithg--debugcommit-ma2c-d'1 0'-u'User Name <user@example.com>'echo%cataccatacecho%touchcopiedcafter1secondsleep1touchcecho%statushgstatusecho%kwfileshgkwfilesecho%diff--revhgdiff--rev0|grep-v'b/c'echo%rollbackhgrollbackecho%statushgstatusecho%update-Chgupdate--cleanecho%customkeywordexpansionecho%trywithkwdemohg--quietkwdemo"Xinfo = {author}: {desc}"cat<<EOF >>$HGRCPATH[keywordmaps]Id = {file} {node|short} {date|rfc822date} {author|user}Xinfo = {author}: {desc}EOFecho%catcatsymabecho%hgcathgcatsymabechoecho'$Xinfo$'>>acat<<EOF >> logfirstlinesecondlineEOFecho%interruptedcommitshouldnotchangestatehgcommitecho%statushgstatusecho%commithg--debugcommit-llog-d'2 0'-u'User Name <user@example.com>'rmlogecho%statushgstatusecho%catcatsymabecho%hgcathgcatsymabechoecho%removehgremoveahg--debugcommit-mrmaecho%statushgstatusecho%rollbackhgrollbackecho%statushgstatusecho%revertahgrevert--no-backup--revtipaecho%catacataecho%clonetotestincomingcd..hgclone-r0TestTest-acdTest-acat<<EOF >> .hg/hgrc[paths]default = ../TestEOFecho%incoming# remove path to temp dirhgincoming|sed-e's/^\(comparing with \).*\(test-keyword.*\)/\1\2/'sed-e's/Id.*/& rejecttest/'a>a.newmva.newaecho%commitrejecttesthg--debugcommit-m'rejects?'-d'3 0'-u'User Name <user@example.com>'echo%exporthgexport-o../rejecttest.difftipcd../Testecho%importhgimport../rejecttest.diffecho%catcatsymabechoecho%rollbackhgrollbackecho%cleanupdatehgupdate--cleanecho%kwexpand/kwshrinkonselectedfilesmkdirxecho%copyax/ahgcopyax/aecho%kwexpandahg--verbosekwexpandaecho%kwexpandx/ashouldaborthg--verbosekwexpandx/acdxhg--debugcommit-mxa-d'3 0'-u'User Name <user@example.com>'echo%catacataecho%kwshrinkainsidedirectoryxhg--verbosekwshrinkaecho%catacatacd..echo%kwexpandnonexistenthgkwexpandnonexistentecho%switchoffexpansionecho%kwshrinkwithunknownfileucpauhg--verbosekwshrinkecho%catcatsymabecho%hgcathgcatsymabechorm$HGRCPATHecho%catcatsymabecho%hgcathgcatsymabecho