Make sure there are no newlines in expansion
authorChristian Ebert <blacktrash@gmx.net>
Thu, 19 Jul 2007 03:43:20 +0200
changeset 201 e826c3cdc52d
parent 200 7eae2cfd26fa
child 202 e2a2f9ca8271
Make sure there are no newlines in expansion Note confinement to one line in help. Adapt test output.
hgkw/keyword.py
tests/test-keyword.out
--- a/hgkw/keyword.py	Wed Jul 18 22:50:47 2007 +0200
+++ b/hgkw/keyword.py	Thu Jul 19 03:43:20 2007 +0200
@@ -69,6 +69,10 @@
 and do not want to store expanded keywords in change history, run
 "hg kwshrink", and then change configuration.
 
+Expansions spanning more than one line and incremental exapansions
+(like CVS' $Log$) are not supported. A keyword template map
+"Log = {desc}" expands to the first line of the changeset description.
+
 Caveat: "hg import" fails if the patch context contains an active
         keyword. In that case run "hg kwshrink", reimport, and then
         "hg kwexpand".
@@ -101,6 +105,8 @@
 nokwcommands = ('add', 'addremove', 'bundle', 'clone', 'copy', 'export',
                 'incoming', 'outgoing', 'push', 'remove', 'rename', 'rollback')
 
+keyword_raw = r'\$(%s)[^$\n\r]*?\$'
+
 def utcdate(date):
     '''Returns hgdate in cvs-like UTC format.'''
     return time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(date[0]))
@@ -148,7 +154,7 @@
                                                      quoted=False)
         self.templates = templates or deftemplates
         escaped = [re.escape(k) for k in self.templates.keys()]
-        self.re_kw = re.compile(r'\$(%s)[^$]*?\$' % '|'.join(escaped))
+        self.re_kw = re.compile(keyword_raw % '|'.join(escaped))
         if expand:
             templater.common_filters['utcdate'] = utcdate
             try:
--- a/tests/test-keyword.out	Wed Jul 18 22:50:47 2007 +0200
+++ b/tests/test-keyword.out	Thu Jul 19 03:43:20 2007 +0200
@@ -36,6 +36,10 @@
 and do not want to store expanded keywords in change history, run
 "hg kwshrink", and then change configuration.
 
+Expansions spanning more than one line and incremental exapansions
+(like CVS' $Log$) are not supported. A keyword template map
+"Log = {desc}" expands to the first line of the changeset description.
+
 Caveat: "hg import" fails if the patch context contains an active
         keyword. In that case run "hg kwshrink", reimport, and then
         "hg kwexpand".