hgkw/keyword.py
branchsolo-extension
changeset 60 9771775ef322
parent 59 94b26168791d
child 61 1fe48bf82d05
equal deleted inserted replaced
59:94b26168791d 60:9771775ef322
    12 
    12 
    13 There are many good reasons why this is not needed in a distributed
    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
    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
    15 files (like LaTeX packages), that are mostly addressed to an audience
    16 not running a version control system.
    16 not running a version control system.
       
    17 
       
    18 Supported keywords are (changeset 000000000000):
       
    19     $Revision: 000000000000 $
       
    20     $Author: Your Name <address@example.com> $
       
    21     $Date: %a %b %d %H:%M:%S %Y %z $
       
    22     $RCSFile: basename,v $
       
    23     $Source: /path/to/basename,v $
       
    24     $Id: basename,v 000000000000 %Y-%m-%d %H:%M:%S %z shortname $
       
    25     $Header: /path/to/basename,v 000000000000 %Y-%m-%d %H:%M:%S %z shortname $
    17 
    26 
    18 The extension, according to its hackish nature, is a hybrid and consists
    27 The extension, according to its hackish nature, is a hybrid and consists
    19 actually in 2 parts:
    28 actually in 2 parts:
    20 
    29 
    21     1. pure extension code (reposetup) that is triggered on checkout and
    30     1. pure extension code (reposetup) that is triggered on checkout and
    62     RCSFile = os.path.basename(path)+',v'
    71     RCSFile = os.path.basename(path)+',v'
    63     Source = repo.wjoin(path)+',v'
    72     Source = repo.wjoin(path)+',v'
    64     Date = util.datestr(date=date)
    73     Date = util.datestr(date=date)
    65     revdateauth = '%s %s %s' % (Revision,
    74     revdateauth = '%s %s %s' % (Revision,
    66             util.datestr(date=date, format=util.defaultdateformats[0]),
    75             util.datestr(date=date, format=util.defaultdateformats[0]),
    67             util.shortuser(Author))             # %Y-%m-%d %H:%M:%S
    76             util.shortuser(Author))
    68     Header = '%s %s' % (Source, revdateauth)
    77     Header = '%s %s' % (Source, revdateauth)
    69     Id = '%s %s' % (RCSFile, revdateauth)
    78     Id = '%s %s' % (RCSFile, revdateauth)
    70 
    79 
    71     return '$%s: %s $' % (matchobj.group(1), eval(matchobj.group(1)))
    80     return '$%s: %s $' % (matchobj.group(1), eval(matchobj.group(1)))
    72 
    81 
   126 
   135 
   127 def pretxnkw(ui, repo, hooktype, **args):
   136 def pretxnkw(ui, repo, hooktype, **args):
   128     '''pretxncommit hook that collects candidates for keyword expansion
   137     '''pretxncommit hook that collects candidates for keyword expansion
   129     on commit and expands keywords in working dir.'''
   138     on commit and expands keywords in working dir.'''
   130 
   139 
   131     if hooktype != 'pretxncommit': # bail out with error
   140     if hooktype != 'pretxncommit':
   132         return True
   141         return True
   133 
   142 
   134     # reparse args, opts again as pretxncommit hook is silent about them
   143     # reparse args, opts again as pretxncommit hook is silent about them
   135     cmd, sysargs, globalopts, cmdopts = commands.parse(ui, sys.argv[1:])[1:]
   144     cmd, sysargs, globalopts, cmdopts = commands.parse(ui, sys.argv[1:])[1:]
   136     # exclude tag and import
   145     # exclude tag and import