[PATCH 2 of 2] keyword: add test

Christian Ebert blacktrash at gmx.net
Thu Feb 8 14:56:35 UTC 2007


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1170945806 -3600
# Node ID ef88576d392369db5316bb6911b19344cec672d7
# Parent  9a2007f392b4d95e115b7c1aaf8b30de0c89c2b5
keyword: add test

diff -r 9a2007f392b4 -r ef88576d3923 tests/test-keyword
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-keyword	Thu Feb 08 15:43:26 2007 +0100
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+cat <<EOF >> $HGRCPATH
+[extensions]
+hgext.keyword =
+[keyword]
+* =
+b* = ignore
+EOF
+
+echo % help
+hg help keyword
+
+hg init a
+cd a
+echo '$Id$' > a
+echo '$Id$' > b
+echo % cat
+cat a b
+
+echo % default keyword expansion
+echo % commit
+hg --debug commit -A -m ab -d '0 0' -u 'User Name <user at example.com>'
+echo % status
+hg status
+
+echo % cat
+cat a b
+echo % hg cat
+hg cat a b
+
+rm a b
+echo % update
+hg update
+echo % cat
+cat a b
+
+echo % custom keyword expansion
+cat <<EOF >>$HGRCPATH
+[keywordmaps]
+Id = {file} {node|short} {date|rfc822date} {author|user}
+Xinfo = {author}: {desc}
+EOF
+
+echo % cat
+cat a b
+echo % hg cat
+hg cat a b
+
+echo '$Xinfo$' >> a
+cat <<EOF >> log
+firstline
+secondline
+EOF
+
+echo % commit
+hg --debug commit -l log -d '1 0' -u 'User Name <user at example.com>'
+rm log
+echo % status
+hg status
+
+echo % cat
+cat a b
+echo % hg cat
+hg cat a b
+
+echo % switch off expansion
+rm $HGRCPATH
+
+echo % cat
+cat a b
+echo % hg cat
+hg cat a b
+
+echo % update
+rm a b
+hg update
+
+echo % cat
+cat a b
diff -r 9a2007f392b4 -r ef88576d3923 tests/test-keyword.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-keyword.out	Thu Feb 08 15:43:26 2007 +0100
@@ -0,0 +1,73 @@
+% help
+keyword extension - keyword expansion in local repositories
+
+This extension expands RCS/CVS-like or self-customized keywords in
+the text files selected by your configuration.
+
+Keywords are only expanded in local repositories and not logged by
+Mercurial internally. The mechanism can be regarded as a convenience
+for the current user and may be turned off anytime.
+
+Substitution takes place on every commit and update of the working
+repository.
+
+Configuration is done in the [keyword] and [keywordmaps] sections of
+hgrc files.
+
+no commands defined
+% cat
+$Id$
+$Id$
+% default keyword expansion
+% commit
+adding a
+adding b
+a
+b
+overwriting a expanding keywords
+% status
+% cat
+$Id: a,v b803250b3164 1970/01/01 00:00:00 user $
+$Id$
+% hg cat
+$Id: a,v b803250b3164 1970/01/01 00:00:00 user $
+$Id$
+% update
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+% cat
+$Id: a,v b803250b3164 1970/01/01 00:00:00 user $
+$Id$
+% custom keyword expansion
+% cat
+$Id: a,v b803250b3164 1970/01/01 00:00:00 user $
+$Id$
+% hg cat
+$Id: a b803250b3164 Thu, 01 Jan 1970 00:00:00 +0000 user $
+$Id$
+% commit
+a
+overwriting a expanding keywords
+% status
+% cat
+$Id: a 375046bad9d3 Thu, 01 Jan 1970 00:00:01 +0000 user $
+$Xinfo: User Name <user at example.com>: firstline $
+$Id$
+% hg cat
+$Id: a 375046bad9d3 Thu, 01 Jan 1970 00:00:01 +0000 user $
+$Xinfo: User Name <user at example.com>: firstline $
+$Id$
+% switch off expansion
+% cat
+$Id: a 375046bad9d3 Thu, 01 Jan 1970 00:00:01 +0000 user $
+$Xinfo: User Name <user at example.com>: firstline $
+$Id$
+% hg cat
+$Id$
+$Xinfo$
+$Id$
+% update
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+% cat
+$Id$
+$Xinfo$
+$Id$



More information about the Mercurial-devel mailing list