\x89\x50\x4E\x47\x0D\x0A\x1A\x0A PNG  \x89\x50\x4E\x47\x0D\x0A\x1A\x0A  13\c @@sdZddlmZddlZddlZddlZddlmZddlm Z ddl m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZmZiZej eZ dZ!d Z"d Z#d Z$d Z%id d6dd6dd6dd6dd6Z&ej'Z'iZ(ej)e(Z)e)ddde*e'ddej+dZ,e'ddej+dZ-e'ddej+d Z.id!d"6Z/d#Z0d$Z1d%Z2d&e3fd'YZ4d(ejfd)YZ5d*Z6d+Z7e d,d-dded.fd/d0d!ed1ed2fged3d4e9d5Z:e d6e j;ed7d8e9d9Z<e d:d;d<ded=fd>d?ded@fdAdBdedCfge j;edDd8e9dEZ=e dFe j;edGd8e9dHZ>ddIZ?dJZ@dKZAdLZBe*dMZCdNZDdOZEdPZFdQZGdS(RsCexpand keywords in tracked files This extension expands RCS/CVS-like or self-customized $Keywords$ in tracked text files selected by your configuration. Keywords are only expanded in local repositories and not stored in the change history. The mechanism can be regarded as a convenience for the current user or for archive distribution. Keywords expand to the changeset data pertaining to the latest change relative to the working directory parent of each file. Configuration is done in the [keyword], [keywordset] and [keywordmaps] sections of hgrc files. Example:: [keyword] # expand keywords in every python file except those matching "x*" **.py = x* = ignore [keywordset] # prefer svn- over cvs-like default keywordmaps svn = True .. note:: The more specific you are in your filename patterns the less you lose speed in huge repositories. For [keywordmaps] template mapping and expansion demonstration and control run :hg:`kwdemo`. See :hg:`help templates` for a list of available templates and filters. Three additional date template filters are provided: :``utcdate``: "2006/09/18 15:13:13" :``svnutcdate``: "2006-09-18 15:13:13Z" :``svnisodate``: "2006-09-18 08:13:13 -700 (Mon, 18 Sep 2006)" The default template mappings (view with :hg:`kwdemo -d`) can be replaced with customized keywords and templates. Again, run :hg:`kwdemo` to control the results of your configuration changes. Before changing/disabling active keywords, you must run :hg:`kwshrink` to avoid storing expanded keywords in the change history. To force expansion after enabling it, or a configuration change, run :hg:`kwexpand`. Expansions spanning more than one line and incremental expansions, like CVS' $Log$, are not supported. A keyword template map "Log = {desc}" expands to the first line of the changeset description. i(tabsolute_importN(t_(t webcommands(tcmdutiltcontexttdispatchterrort extensionstfilelogt localrepot logcmdutiltmatchtpatchtpathutiltpycompatt registrartscmutilttemplatefilterst templateutiltutil(tdateutilt stringutilsships-with-hg-coresgadd addremove annotate bundle export grep incoming init log outgoing push tip verify convert email glogs/annotate changeset rev filediff diff comparisonsfmerge kwexpand kwshrink record qrecord resolve transplant unshelve rebase graft backout histedit fetchtrecords green boldskwfiles.enabledscyan bold underlineskwfiles.deletedtgreenskwfiles.enabledunknowntboldskwfiles.ignoredtnoneskwfiles.ignoredunknownt keywordsettsvntdefaulttutcdatetintypecC@s d}tj|ddf|S(sDDate. Returns a UTC-date in this format: "2009/08/18 11:00:13". s%Y/%m/%d %H:%M:%Si(Rtdatestr(tdatet dateformat((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyRst svnisodatecC@stj|dS(s]Date. Returns a date in this format: "2009-08-18 13:00:13 +0200 (Tue, 18 Aug 2009)". s%%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)(RR(R ((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyR"st svnutcdatecC@s d}tj|ddf|S(sIDate. Returns a UTC-date in this format: "2009-08-18 11:00:13Z". s%Y-%m-%d %H:%M:%SZi(RR(R R!((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyR#stthgcmdcC@sidd6dd6}idd6dd6dd 6d d 6d d 6dd6idd6dd 6dd6dd6dd6f}|j||jdd|S(sBReturns default keywordmaps according to keywordset configuration.s {node|short}tRevisions {author|user}tAuthors{date|utcdate}tDates{file|basename},vtRCSfiletRCSFiles{root}/{file},vtSources;{file|basename},v {node|short} {date|utcdate} {author|user}tIds9{root}/{file},v {node|short} {date|utcdate} {author|user}tHeaders{date|svnisodate}s>{file|basename},v {node|short} {date|svnutcdate} {author|user}tLastChangedRevisiont LastChangedBytLastChangedDateRR(tupdatet configbool(tuit templatestkwsets((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt_defaultkwmapss$  cC@s |d|S(slHelper for keyword expansion removal in text. Depending on subfunc also returns number of substitutions.s$\1$((ttexttsubfunc((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt _shrinktextscC@sZg|jD]}||kr |^q }g|jD]}||kr2|^q2}||fS(sRetrieves modified and added files from a working directory state and returns the subset of each contained in given changed files retrieved from a change context.(tmodifiedtadded(twstatustchangedtfR:R;((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt _preselects((t kwtemplatercB@seZdZdZedZejdZejdZ ejdZ dZ dZ dZ d Zed Zd Zd Zd ZRS(sr Sets up keyword templates, corresponding keyword regex, and provides keyword substitution functions. cC@s||_tj||_tj|jdg|||_tdtjk|_ t |_ |jj d}|rt ||_nt|j|_dS(NR$R%t keywordmaps(R3tweakreftreft_repoR troottkwtoolst restrictedtsplittrestricttFalset postcommitt configitemstdictR4R6(tselfR3trepotinctexctkwmaps((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt__init__s ! cC@s |jS(N(RD(RN((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyROscC@s"djttj|jjS(s+Returns bar-separated and escaped keywords.t|(tjointmapRtreescapeR4tkeys(RN((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytescapescC@stjd|jS(s&Returns regex for unexpanded keywords.s\$(%s)\$(tretcompileRY(RN((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytrekwscC@stjd|jS(s$Returns regex for expanded keywords.s\$(%s): [^$\n\r]*? \$(RZR[RY(RN((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytrekwexpsc@s"fd}|||S(s1Replaces keywords in data with expanded template.c@s|jd}tjjjj|}jj|jdjjdt j jj }d||fS(NiREtfiles $%s: %s $( tgroupR t maketemplaterR3ROR4t pushbuffertshowRERt firstlinet popbuffer(tmobjtkwtcttekw(tctxtpathRN(s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytkwsubs ((RNtdataRjRiR8Rk((RiRjRNs3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt substitutescC@s|jj|d|jS(s4Similar to filelog.linkrev, but returns a changectx.tfileid(ROtfilectxt changectx(RNRjRn((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytlinkctxscC@s[|j rW|j|rWtj| rW|j||}|j||||jjS|S(s$Returns data with keywords expanded.(RIR RtbinaryRqRmR\tsub(RNRjtnodeRlRi((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytexpands cC@s;g|D]0}|j|rd|j|kr|^qS(skReturns subset of candidates which are configured for keyword expansion but are not symbolic links.tl(R tflags(RNtcandRiR>((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytiskwfilescC@s|js|s|jr-|j||}n|s7dS|joC|}|js[|rj|rj|j}n|jsy|r|j}n |j}|rtd} n td} x|D]} |jr|jj| j || } n|jj | } t j | rqn|r|j } |r?|j| || }ng|jrt| dkrxI| D]>} | | kra| | j||  ra| | j}PqaqaWn|j| | ||j\} }n3|jr|j| }nt| |j\} }|r|jj| | |jj| ddt}|j| |j|re|jjj| q|jr|jjj| qqqWdS(s7Overwrites selected files expanding/shrinking keywords.Ns"overwriting %s expanding keywords s"overwriting %s shrinking keywords itwbt atomictemp(RIRKRytmanifestR\R]RROR^treadtwreadRRrtparentsRqtlentcmpRpRmtsubntsearchR9R3tnotetwvfstTruetwritetclosetdirstatetnormalt normallookup(RNRit candidatestlookupRuR\tkwcmdtmftre_kwtmsgR>RlRtptfoundtfp((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt overwrite!sR     "  $ $    cC@s6|j|r2tj| r2t||jjS|S(s4Returns text with all keyword substitutions removed.(R RRrR9R]Rs(RNtfnameR7((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytshrinkTscC@sP|j|rLdj|}tj|sLt||jjjtSn|S(s1Returns lines with keyword substitutions removed.R$( R RURRrR9R]Rst splitlinesR(RNRtlinesR7((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt shrinklinesZs cC@s|jr|j||S|S(s]If in restricted mode returns data read from wdir with keyword substitutions removed.(RIR(RNRRl((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyR~bs (t__name__t __module__t__doc__RStpropertyRORt propertycacheRYR\R]RmRqRuRyRJRRRR~(((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyR@s     3  t kwfilelogcB@s8eZdZdZdZdddZdZRS(s Subclass of filelog to hook into its read, add, cmp methods. Keywords are "stored" unexpanded, and processed on reading. cC@s/tt|j||||_||_dS(N(tsuperRRStkwtRj(RNtopenerRRj((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyRSns cC@sDtt|j|}|j|r+|S|jj|j||S(s&Expands keywords when reading filelog.(RRR}trenamedRRuRj(RNRtRl((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyR}sscC@s=|jj|j|}tt|j||||||S(s5Removes keyword substitutions when adding to filelog.(RRRjRRtadd(RNR7tmetattrtlinktp1tp2((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyRzscC@s1|jj|j|}tt|j||S(s-Removes keyword substitutions for comparison.(RRRjRRR(RNRtR7((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyRsN(RRRRSR}tNoneRR(((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyRis   cO@s|rXtj|}|jdtj|||dtd|jdpT|jdS|jdrtj t dntj t ddS( s\Bails out if [keyword] configuration is not active. Returns status of working directory.R tcleantunknowntalltkeywords[keyword] patterns cannot matchs no [keyword] patterns configuredN( Rt byteskwargststatusRR RtgetRLRtAbortR(R3ROtwctxRtpatstopts((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt_statuss$c O@s|d}t|jdkr:tjtdnt|dd}|jut||||||}|j s|j s|j s|j rtjtdn|j ||jt|WdQXdS(s7Selects files and passes them to kwtemplater.overwrite.isoutstanding uncommitted merget _keywordkwtsoutstanding uncommitted changesN(RRRRRRtgetattrtwlockRR:R;tremovedtdeletedRRR(R3RORuRRRRR((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt _kwfwrites  $tkwdemotds"show default keyword template mapsR>trcfilesread maps from rcfiletFILEs+hg kwdemo [-d] [-f RCFILE] [TEMPLATEMAP]...t optionalrepoc@sgfd}d}tjdd}jtd||dkrS}n |j}tj||dt}j d|ddj dd }j dd |dj d } |s|j d rj td | rj td n|j ds| rM|r7j tdqMj tdn|j d ruj|j d n|rddj|} |jjd| j|jjdntj d } n|j drq|rj tdnj tdt} | rj tdx3| jD]"\} } j d | | dqEWqn4j td| rt| } n t} tt|jd|dj d|dj d|d | jddjt| jd}|jj|||dj|gjtd|j||j|jjdWdQXx^j dD]M\}}|jd d!d"jd#d$kr|j j d|ddqqWtd%}jd&||j!d'|j td(j|j"||jj#|j$dS()sprint [keywordmaps] configuration and an expansion example Show current, custom, or default keyword template maps and their expansions. Extend the current configuration by specifying maps as arguments and using -f/--rcfile to source an external hgrc file. Use -d/--default to disable current configuration. See :hg:`help templates` for information on templates and filters. c@sjjd|xRt|D]D\}}t|trKtj|}njd||fqWdS(Ns[%s] s%s = %s (Rtsortedt isinstancetboolRtpprint(tsectiontitemstktv(R3(s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt demoitemss sdemo.txtR$skwdemo.s$creating temporary repository at %s tcreateRRRRARs3 configuration using custom keyword template maps s! extending current template maps Rs# overriding default svn keywordset s# overriding default cvs keywordset s[keywordmaps] %s s thgrcs- configuration using default svn keywordset s- configuration using default cvs keywordset s! disabling current template maps s4 configuration using current keyword template maps s[extensions] keyword = t$s$ $s$ s keywords written to %s: t demobranchNthookst.iitcommitis.hg keyword configuration and expansion exampleshg ci -m '%s' R7s keywords expanded (%RtmkdtempRRRtbaseuiR tinstanceRt setconfigR2RLRRt readconfigRUtvfsRRMR6t iteritemstuisetupt reposetupRRXRRRRt setbranchRHtfindR3RR~trmtreeRE(R3ROtargsRRtfnttmpdirRRtuikwmapstrcmapsRRRRtkeywordstnametcmdR((R3s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytdemos|         #  %  tkwexpands!hg kwexpand [OPTION]... [FILE]...t inferrepocO@st||t||dS(sexpand keywords in the working directory Run after (re)enabling keyword expansion. kwexpand refuses to run if given files contain local changes. N(RR(R3RORR((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyRus tkwfilestARs&show keyword status flags of all filestitignores"show files excluded from expansiontuRs%only show unknown (not tracked) filess hg kwfiles [OPTION]... [FILE]...cO@st|dd}|d}t||||||}|rL|j}nd}g}tj|}|jd s|jdrt|j|j |j }n|j ||} |j |j |} |j |j |} |jd s|jdr| | | f} ngggf} |jds@|jdr| g|D]} | | krJ| ^qJg|j D]} | | kro| ^qof7} ndj}t|tjd| }|jd|}d }|jds|jrd }nx{|D]s\}}}d |}xW|D]O} |j|jd |d | |j|||j| |fd|qWqW|jdS(sshow files configured for keyword expansion List which files in the working directory are matched by the [keyword] configuration patterns. Useful to prevent inadvertent keyword expansion and to speed up execution by including only files that are actual candidates for expansion. See :hg:`help keyword` on how to construct patterns both for inclusion and exclusion of files. With -A/--all and -v/--verbose the codes used to show the status of files are:: K = keyword expansion candidate k = keyword expansion candidate (not tracked) I = ignored i = ignored (not tracked) RR$RRRs5enabled deleted enabledunknown ignored ignoredunknownsK!kIiRs%.0s%s s%s %s skwfiles.tkwstatusRjtlabelN(RRRtgetcwdRRRRR:R;RRyRRRHtziptbytestrt formattertverboset startitemRltplaintpathtotend(R3RORRRRRtcwdtfilesRt kwdeletedt kwunknownt showfilesR>tkwlabelstkwstatestfmtfmttkwstatetchart filenamesR((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyR s@  %/     1tkwshrinks!hg kwshrink [OPTION]... [FILE]...cO@st||t||dS(srevert expanded keywords in the working directory Must be run before changing/disabling active keywords. kwshrink refuses to run if given files contain local changes. N(RRJ(R3RORR((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyRIs cC@s_|||||||tt|dddd}|r[|j|j|j|_ndS(stMonkeypatch/wrap patch.patchfile.__init__ to avoid rejects or conflicts due to expanded keywords in working dir.RORN(RRRRR(torigRNR3tgptbackendtstoreteolmodeR((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytkwpatchfile_initYsco@smt|dd}|r-|j}t|_nz&x||||D] }|VqCWWd|rh||_nXdS(s*Monkeypatch patch.diff to avoid expansion.RN(RRRIR(RRORtkwargsRRItchunk((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytkwdiffbs   cc@smt|jdd}|r3|j}tj|_nz x||D] }|VqCWWd|rh||_nXdS(s2Wraps webcommands.x turning off keyword expansion.RN(RRORR Rtnever(RtwebRt origmatchR((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt kwweb_skipos  c C@st|dd}|dkr7|||||||S|jzt|_|||||||}||jkr||} t|_|j| | jt tt |_n|SWdQXdS(s3Wraps cmdutil.amend expanding keywords after amend.RN( RRRRRKRtRIRRRJ( RR3ROtoldtextraRRRtnewidRi((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytkw_amend|s      c @stdddkr4|||||Sj||||||jdrjdSdjfd}gjjD]-}dj|kr||r|^q}j|t t WdQXdS(sWraps cmdutil.copy so that copy/rename destinations do not contain expanded keywords. Note that the source of a regular file destination may also be a symlink: hg cp sym x -> x is symlink cp sym x; hg cp -A sym x -> x is file (maybe expanded keywords) For the latter we have to follow the symlink to find out whether its target is configured for expansion and we therefore must unexpand the keywords in the destination.Rtdry_runNc@s[jj|}dj|krNtjjtjj|}nj |S(sReturns true if dest is a regular file and configured for expansion or a symlink which points to a file configured for expansion. Rv( RtcopiedRwR t canonpathREtosRjtrealpathR (tdesttsource(RRROR(s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt haskwsources Rv( RRRRRRtcopiesRwRRJ( RR3RORRtrenameRR>R((RRRORs3/usr/lib64/python2.7/site-packages/hgext/keyword.pytkw_copys      -c O@st|dd}|dkr4||||||S|jt|_|d}|j}||||||} |d} || krt|| j\} } t|_ |j | | tt|j | | tttt|_ n| SWdQXdS(s9Wraps record.dorecord expanding keywords after recording.RRN( RRRRRKRR?RRJRIR( RR3ROt commitfuncRRRRiR<trettrecctxR:R;((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt kw_dorecords          cC@s|jr|j|St|jdd}|dkrD|||S|jdkr|jjs|j|jrd|j ks|j d|j ks|j |j kr|j j|j|j St S(NRRvi(t _customcmpRRRDRt _filenodet_encodefilterpatsR RjRwtsizet_filelogRlR(RRNtfctxR((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyt kwfilectx_cmps     'cC@sd}tjtd|tjtjdttjtjdttjtdt tjt dt tjt dt tjt dt x'tjD]}tjt|tqWd S( s! Monkeypatches dispatch._parse to retrieve user command. Overrides file method to return kwfilelog instead of filelog if file matches user configuration. Wraps commit to overwrite configured files with updated keyword substitutions. Monkeypatches patch and webcommands.cS@s;|||\}}}}}|td<|||||fS(s9Monkeypatch dispatch._parse to obtain running hg command.R%(RF(RR3RRtfunctoptionst cmdoptions((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytkwdispatch_parses t_parseRRStdifftamendtcopytdorecordN(Rt wrapfunctionRRRoR-R t patchfileR RRRR"R&tnokwwebcommandsRHRR(R3R1tc((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyRs c@syU|j sPtdtjksPdtj|jksP|jjdrTdSWnt k rhnXgdg}}xF|j dD]5\}}|dkr|j |q|j |qW|sdSt ||||d|j ffd Y|_ |_dS( s0Sets up repo as kwrepo for keyword substitution.R%s.hgsbundle:Ns.hg*RRtkwrepoc@seeZfdZfdZfdZefdZeefdZRS(c@s0|ddkr|d}nt|j|S(Nit/i(Rtsvfs(RNR>(R(s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyR^s c@s(t|j|}j||S(N(RR~(RNtfilenameRl(R;R(s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyR~sc@s7|j|_zt|j||SWd|`XdS(N(t kwcommitctxt commitctxRR(RNRR(R;(s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyR s c@svt|j||}jsrj}t_j||t|j|jt t|_n|S(N( RR@RKRIRRRR;R:RJ(RNRiRtnRI(R;R(s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyR?s   &  c @s|jj}z|s2|dj}nt|j||}|s|d}t|j|\}}t_j||t t j||t tn|SWd|_XWdQXdS(NR( RRIRRtrollbackR?RRJRR( RNtdryruntforcet origrestrictR=R$RiR:R;(R;R(s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyRBs    (RRR^R~RRJR?RB((R;R(s3/usr/lib64/python2.7/site-packages/hgext/keyword.pyR;s   (tlocalRFt nokwcommandsRHRt splitpathREt_urlt startswithtAttributeErrorRLtappendR@t __class__R(R3RORPRQtpattopt((R;Rs3/usr/lib64/python2.7/site-packages/hgext/keyword.pyRs$#  "/ (HRt __future__RRRZRBtmercurial.i18nRtmercurial.hgwebRt mercurialRRRRRRR R R R R RRRRRRtmercurial.utilsRRtcmdtabletcommandt testedwithRGR9RGtrecordextensionst colortablettemplatefiltert configtablet configitemRJR RR"R#RFR6R9R?tobjectR@RRRRRRtwalkoptsRuRRR RRRR"R&R-RR(((s3/usr/lib64/python2.7/site-packages/hgext/keyword.pytSs   p          \   9   "