hgkw/keyword.py
branchsolo-extension
changeset 48 59fedb6b41da
parent 47 0617e7d497f6
child 49 5acfe7dc3086
equal deleted inserted replaced
47:0617e7d497f6 48:59fedb6b41da
       
     1 # keyword.py - keyword expansion for mercurial
       
     2 #
       
     3 # Copyright 2006 Christian Ebert <blacktrash@gmx.net>
       
     4 #
       
     5 # This software may be used and distributed according to the terms
       
     6 # of the GNU General Public License, incorporated herein by reference.
       
     7 
       
     8 '''keyword expansion hack against the grain of a DSCM
       
     9 
       
    10 This extension lets you expand RCS/CVS-like keywords in a Mercurial
       
    11 repository.
       
    12 
       
    13 There are many good reasons why this is not needed in a distributed
       
    14 SCM, still it may be useful in very small projects based on single
       
    15 files (like LaTeX packages), that are mostly addressed to an audience
       
    16 not running version control.
       
    17 
       
    18 The extension consists actually in 2 parts:
       
    19 
       
    20     1. extension code (reposetup) that is triggered on checkout and
       
    21        logging of changes.
       
    22     2. a pretxncommit hook (hgrc (5)) that expands keywords immediately
       
    23        at commit time in the working directory.
       
    24 
       
    25 Simple setup in hgrc:
       
    26 
       
    27     # enable extension
       
    28     hgext.keyword =
       
    29     
       
    30     # filename patterns for expansion are configured in this section
       
    31     [keyword]
       
    32     *.sty = expand
       
    33     ...
       
    34 
       
    35     # set up pretxncommit hook
       
    36     [hooks]
       
    37     pretxncommit =
       
    38     pretxncommit.keyword = python:hgext.keyword.pretxnkw
       
    39 '''
       
    40 
     1 from mercurial.i18n import _
    41 from mercurial.i18n import _
     2 from mercurial import commands, cmdutil, context, filelog, revlog, util
    42 from mercurial import commands, cmdutil, context, filelog, revlog, util
     3 import os.path, re, sys
    43 import os.path, re, sys
     4 
    44 
     5 # supported keywords for use in regexes
    45 # supported keywords for use in regexes