hgkw/keyword.py
changeset 201 e826c3cdc52d
parent 192 0d2a6c9f8343
child 203 20eaa6147391
equal deleted inserted replaced
200:7eae2cfd26fa 201:e826c3cdc52d
    66 Again, run "hg kwdemo" to control the results of your config changes.
    66 Again, run "hg kwdemo" to control the results of your config changes.
    67 
    67 
    68 When you change keyword configuration, especially the active keywords,
    68 When you change keyword configuration, especially the active keywords,
    69 and do not want to store expanded keywords in change history, run
    69 and do not want to store expanded keywords in change history, run
    70 "hg kwshrink", and then change configuration.
    70 "hg kwshrink", and then change configuration.
       
    71 
       
    72 Expansions spanning more than one line and incremental exapansions
       
    73 (like CVS' $Log$) are not supported. A keyword template map
       
    74 "Log = {desc}" expands to the first line of the changeset description.
    71 
    75 
    72 Caveat: "hg import" fails if the patch context contains an active
    76 Caveat: "hg import" fails if the patch context contains an active
    73         keyword. In that case run "hg kwshrink", reimport, and then
    77         keyword. In that case run "hg kwshrink", reimport, and then
    74         "hg kwexpand".
    78         "hg kwexpand".
    75         Or, better, use bundle/unbundle to share changes.
    79         Or, better, use bundle/unbundle to share changes.
    98     'Header': '{root}/{file},v {node|short} {date|utcdate} {author|user}',
   102     'Header': '{root}/{file},v {node|short} {date|utcdate} {author|user}',
    99 }
   103 }
   100 
   104 
   101 nokwcommands = ('add', 'addremove', 'bundle', 'clone', 'copy', 'export',
   105 nokwcommands = ('add', 'addremove', 'bundle', 'clone', 'copy', 'export',
   102                 'incoming', 'outgoing', 'push', 'remove', 'rename', 'rollback')
   106                 'incoming', 'outgoing', 'push', 'remove', 'rename', 'rollback')
       
   107 
       
   108 keyword_raw = r'\$(%s)[^$\n\r]*?\$'
   103 
   109 
   104 def utcdate(date):
   110 def utcdate(date):
   105     '''Returns hgdate in cvs-like UTC format.'''
   111     '''Returns hgdate in cvs-like UTC format.'''
   106     return time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(date[0]))
   112     return time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(date[0]))
   107 
   113 
   146             for k in templates.keys():
   152             for k in templates.keys():
   147                 templates[k] = templater.parsestring(templates[k],
   153                 templates[k] = templater.parsestring(templates[k],
   148                                                      quoted=False)
   154                                                      quoted=False)
   149         self.templates = templates or deftemplates
   155         self.templates = templates or deftemplates
   150         escaped = [re.escape(k) for k in self.templates.keys()]
   156         escaped = [re.escape(k) for k in self.templates.keys()]
   151         self.re_kw = re.compile(r'\$(%s)[^$]*?\$' % '|'.join(escaped))
   157         self.re_kw = re.compile(keyword_raw % '|'.join(escaped))
   152         if expand:
   158         if expand:
   153             templater.common_filters['utcdate'] = utcdate
   159             templater.common_filters['utcdate'] = utcdate
   154             try:
   160             try:
   155                 self.t = cmdutil.changeset_templater(ui, repo,
   161                 self.t = cmdutil.changeset_templater(ui, repo,
   156                                                      False, '', False)
   162                                                      False, '', False)