Differences between revisions 1 and 19 (spanning 18 versions)
Revision 1 as of 2007-01-17 20:41:39
Size: 1330
Comment: Add keyword expansion page
Revision 19 as of 2007-09-24 05:56:28
Size: 3454
Comment: document "hg kwfiles"
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
It's being developed by Christian Ebert and can be downloaded from its [http://www.blacktrash.org/cgi-bin/hgwebdir.cgi/hgkeyword/ keyword expansion repository]. ''Author: Christian Ebert''

Download site: [http://www.blacktrash.org/hg/hgkeyword/ keyword extension repository] (backwards compatible with Mercurial 0.9.2).

Mirror of crew repo plus keyword extension: [http://www.blacktrash.org/hg/hg-crew-keyword/ Mercurial crew + keyword].
Line 8: Line 12:
This extension allows the expansion of RCS/CVS-like and user defined keys in Mercurial repositories. This extension allows the expansion of RCS/CVS-like and user defined keys in text files tracked by Mercurial.
Ex
pansion takes place in the working directory or/and when creating a distribution using "hg archive".
Line 15: Line 20:
hgext.keyword = path/to/keyword.py
#or, if keyword.py is in the hgext folder:
#hgext.keyword=
hgext.keyword=
#or, if keyword.py is not in the hgext folder:
#keyword=/path/to/keyword.py
Line 20: Line 25:
Additional configuration is dones in they [keyword] and [keywordmaps] sections in your configuration file: Additional configuration is done in the [keyword] and [keywordmaps] sections in your configuration file:
Line 23: Line 28:
# files matching patterns with value 'ignore' are ignored
Line 25: Line 29:
# expand keywords in all python files in working dir
Line 26: Line 31:
# do not expand keywords in files matching "x*" in working dir
Line 28: Line 34:
# in case you prefer your own keyword maps over the cvs-like defaults:
#
using {{{key-to-be-expanded = value}}} lines, where values are taken from the avaliable Mercurial template names.
# override the cvs-like default mappings with customized keyword = expansion pairs,
#
where expansion values contain Mercurial templates and filters
Line 32: Line 38:
lastlog = {desc} ## same as {desc|firstline} in this context lastlog = {desc}
Line 37: Line 43:
The defined keys (or default ones) are automatically expanded, without user interaction. The main functionality of the extension is done in background by automatically expanding the defined keys (or default ones), without user interaction. An additional template filter "utcdate" is provided to get {{{%Y/%m/%d %H:%M:%S}}} date format.

However, the extension provides the following convenience commands:

==== kwdemo, kwfiles ====
To get an idea what the extension actually does and/or to test your customizations (templates are rather sparsely documented), run "hg kwdemo".

Example output of "hg kwdemo --default":

{{{
        config using default keyword template maps
[keyword]
demo.txt =
[keywordmaps]
RCSFile = {file|basename},v
Author = {author|user}
Header = {root}/{file},v {node|short} {date|utcdate} {author|user}
Source = {root}/{file},v
Date = {date|utcdate}
Id = {file|basename},v {node|short} {date|utcdate} {author|user}
Revision = {node|short}

        default keywords expanded
$RCSFile: demo.txt,v $
$Author: blacktrash $
$Header: /tmp/kwdemo.Oz46E2/demo.txt,v 2ad3dcb8d811 2007/07/17 12:00:47 blacktrash $
$Source: /tmp/kwdemo.Oz46E2/demo.txt,v $
$Date: 2007/07/17 12:00:47 $
$Id: demo.txt,v 2ad3dcb8d811 2007/07/17 12:00:47 blacktrash $
$Revision: 2ad3dcb8d811 $
}}}

To crosscheck which files in your working directory are matched by the current {{{[keyword]}}} patterns, use "hg kwfiles".

==== kwshrink, kwexpand ====
Run "hg kwshrink" before eg. changing the currently active keywords, if you don't want the expanded keywords stored in the change history.

Run "hg kwexpand" to force expansion after enabling it, or after a keyword configuration change.

Expanding keywords only in the current working copy allows you to share changes with other repos that do not have the same or no keyword setup. This can sometimes cause a problem with "hg import" if the change context contains an active keyword. To overcome this run "hg kwshrink" and (re)import. Or, better, use bundle/unbundle to share changes.

----
CategoryExtension

Keyword Expansion extension

This extension is not being distributed along with Mercurial.

Author: Christian Ebert

Download site: [http://www.blacktrash.org/hg/hgkeyword/ keyword extension repository] (backwards compatible with Mercurial 0.9.2).

Mirror of crew repo plus keyword extension: [http://www.blacktrash.org/hg/hg-crew-keyword/ Mercurial crew + keyword].

Overview

This extension allows the expansion of RCS/CVS-like and user defined keys in text files tracked by Mercurial. Expansion takes place in the working directory or/and when creating a distribution using "hg archive".

Configuration

To enable this extension add it to the '[extensions]' stanza in the hgrc file:

[extensions]
hgext.keyword=
#or, if keyword.py is not in the hgext folder:
#keyword=/path/to/keyword.py

Additional configuration is done in the [keyword] and [keywordmaps] sections in your configuration file:

# filename patterns for expansion are configured in this section
[keyword]
# expand keywords in all python files in working dir
**.py =
# do not expand keywords in files matching "x*" in working dir
x* = ignore
...
# override the cvs-like default mappings with customized keyword = expansion pairs,
# where expansion values contain Mercurial templates and filters
[keywordmaps]
HGdate = {date|rfc822date}
lastlog = {desc}
checked in by = {author}

Usage

The main functionality of the extension is done in background by automatically expanding the defined keys (or default ones), without user interaction. An additional template filter "utcdate" is provided to get %Y/%m/%d %H:%M:%S date format.

However, the extension provides the following convenience commands:

kwdemo, kwfiles

To get an idea what the extension actually does and/or to test your customizations (templates are rather sparsely documented), run "hg kwdemo".

Example output of "hg kwdemo --default":

        config using default keyword template maps
[keyword]
demo.txt =
[keywordmaps]
RCSFile = {file|basename},v
Author = {author|user}
Header = {root}/{file},v {node|short} {date|utcdate} {author|user}
Source = {root}/{file},v
Date = {date|utcdate}
Id = {file|basename},v {node|short} {date|utcdate} {author|user}
Revision = {node|short}

        default keywords expanded
$RCSFile: demo.txt,v $
$Author: blacktrash $
$Header: /tmp/kwdemo.Oz46E2/demo.txt,v 2ad3dcb8d811 2007/07/17 12:00:47 blacktrash $
$Source: /tmp/kwdemo.Oz46E2/demo.txt,v $
$Date: 2007/07/17 12:00:47 $
$Id: demo.txt,v 2ad3dcb8d811 2007/07/17 12:00:47 blacktrash $
$Revision: 2ad3dcb8d811 $

To crosscheck which files in your working directory are matched by the current [keyword] patterns, use "hg kwfiles".

kwshrink, kwexpand

Run "hg kwshrink" before eg. changing the currently active keywords, if you don't want the expanded keywords stored in the change history.

Run "hg kwexpand" to force expansion after enabling it, or after a keyword configuration change.

Expanding keywords only in the current working copy allows you to share changes with other repos that do not have the same or no keyword setup. This can sometimes cause a problem with "hg import" if the change context contains an active keyword. To overcome this run "hg kwshrink" and (re)import. Or, better, use bundle/unbundle to share changes.


CategoryExtension

KeywordExtension (last edited 2024-03-06 12:11:11 by ChristianEbert)