hgkw/keyword.py
branchkwmap-templates
changeset 103 e086f7eb0198
parent 102 393d6f8ea83c
child 104 e8b9a500f2e1
equal deleted inserted replaced
102:393d6f8ea83c 103:e086f7eb0198
    14 For in-depth discussion refer to
    14 For in-depth discussion refer to
    15 <http://www.selenic.com/mercurial/wiki/index.cgi/KeywordPlan>.
    15 <http://www.selenic.com/mercurial/wiki/index.cgi/KeywordPlan>.
    16 
    16 
    17 You can either use the default cvs-like keywords or provide your
    17 You can either use the default cvs-like keywords or provide your
    18 own in hgrc.
    18 own in hgrc.
       
    19 
       
    20 Expansions spanning more than one line are truncated to their first line.
       
    21 Incremental expansion (like CVS' $Log$) is not supported.
    19 
    22 
    20 Default $keywords$ and their $keyword: substition $ are:
    23 Default $keywords$ and their $keyword: substition $ are:
    21     Revision: changeset id
    24     Revision: changeset id
    22     Author:   username
    25     Author:   username
    23     Date:     %Y/%m/%d %H:%M:%S [UTC]
    26     Date:     %Y/%m/%d %H:%M:%S [UTC]
    38     **.py = expand
    41     **.py = expand
    39     ...
    42     ...
    40     # in case you prefer your own keyword maps over the cvs-like defaults:
    43     # in case you prefer your own keyword maps over the cvs-like defaults:
    41     [keywordmaps]
    44     [keywordmaps]
    42     HGdate = {date|rfc822date}
    45     HGdate = {date|rfc822date}
    43     lastlog = {desc|firstline}
    46     lastlog = {desc} ## same as {desc|firstline} in this context
    44     checked in by = {author}
    47     checked in by = {author}
    45     ...
    48     ...
    46 '''
    49 '''
    47 
    50 
    48 from mercurial import cmdutil, templater, util
    51 from mercurial import cmdutil, templater, util
   104         kw = mobj.group(1)
   107         kw = mobj.group(1)
   105         template = templater.parsestring(self.templates[kw], quoted=False)
   108         template = templater.parsestring(self.templates[kw], quoted=False)
   106         self.t.use_template(template)
   109         self.t.use_template(template)
   107         self.ui.pushbuffer()
   110         self.ui.pushbuffer()
   108         self.t.show(changenode=node, root=self.repo.root, file=path)
   111         self.t.show(changenode=node, root=self.repo.root, file=path)
   109         return '$%s: %s $' % (kw, self.ui.popbuffer())
   112         expansion = templater.firstline(self.ui.popbuffer())
       
   113         return '$%s: %s $' % (kw, expansion)
   110 
   114 
   111 
   115 
   112 def reposetup(ui, repo):
   116 def reposetup(ui, repo):
   113     from mercurial import context, filelog, revlog
   117     from mercurial import context, filelog, revlog
   114     if not repo.local():
   118     if not repo.local():