# HG changeset patch # User Christian Ebert # Date 1166727145 -3600 # Node ID 59fedb6b41da15f5322f86d01a7371df1dee54b6 # Parent 0617e7d497f6f205d903d919254d6cd8321dad37 add header and start documentation diff -r 0617e7d497f6 -r 59fedb6b41da hgkw/keyword.py --- a/hgkw/keyword.py Thu Dec 21 16:58:28 2006 +0100 +++ b/hgkw/keyword.py Thu Dec 21 19:52:25 2006 +0100 @@ -1,3 +1,43 @@ +# keyword.py - keyword expansion for mercurial +# +# Copyright 2006 Christian Ebert +# +# This software may be used and distributed according to the terms +# of the GNU General Public License, incorporated herein by reference. + +'''keyword expansion hack against the grain of a DSCM + +This extension lets you expand RCS/CVS-like keywords in a Mercurial +repository. + +There are many good reasons why this is not needed in a distributed +SCM, still it may be useful in very small projects based on single +files (like LaTeX packages), that are mostly addressed to an audience +not running version control. + +The extension consists actually in 2 parts: + + 1. extension code (reposetup) that is triggered on checkout and + logging of changes. + 2. a pretxncommit hook (hgrc (5)) that expands keywords immediately + at commit time in the working directory. + +Simple setup in hgrc: + + # enable extension + hgext.keyword = + + # filename patterns for expansion are configured in this section + [keyword] + *.sty = expand + ... + + # set up pretxncommit hook + [hooks] + pretxncommit = + pretxncommit.keyword = python:hgext.keyword.pretxnkw +''' + from mercurial.i18n import _ from mercurial import commands, cmdutil, context, filelog, revlog, util import os.path, re, sys