# HG changeset patch # User Christian Ebert # Date 1184809400 -7200 # Node ID e826c3cdc52dce8888779b8a5733756ca424726e # Parent 7eae2cfd26faa62720617cdac0268a82c7ac5550 Make sure there are no newlines in expansion Note confinement to one line in help. Adapt test output. diff -r 7eae2cfd26fa -r e826c3cdc52d hgkw/keyword.py --- 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: diff -r 7eae2cfd26fa -r e826c3cdc52d tests/test-keyword.out --- 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".