[PATCH 2 of 2] keyword: disable expansion in queue repos, and for email

Christian Ebert blacktrash at gmx.net
Tue Feb 5 04:19:52 CST 2008


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1202206654 -3600
# Node ID f714edee203d28087c0ef19e0aac5b2f1fab08ba
# Parent  0e8fed312e6e506fe8bc584455d7e635729b3157
keyword: disable expansion in queue repos, and for email

Prevent global [keyword] filename patterns creating expansion
havoc in versioned mq repos or when sending patchbombs.

Add test with qcommit.

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -88,7 +88,7 @@
 
 # hg commands that do not act on keywords
 nokwcommands = ('add addremove bundle copy export grep identify incoming init'
-                'log outgoing push remove rename rollback tip convert')
+                'log outgoing push remove rename rollback tip convert email')
 
 # hg commands that trigger expansion only when writing to working dir,
 # not when reading filelog, and unexpand when reading from working dir
@@ -410,7 +410,7 @@
     This is done for local repos only, and only if there are
     files configured at all for keyword substitution.'''
 
-    if not repo.local():
+    if not repo.local() or repo.root.endswith('/.hg/patches'):
         return
 
     hgcmd, func, args, opts, cmdopts = dispatch._parse(ui, sys.argv[1:])
diff --git a/tests/test-keyword b/tests/test-keyword
--- a/tests/test-keyword
+++ b/tests/test-keyword
@@ -90,8 +90,12 @@
 echo % compare changenodes in a c
 cat a c
 
+echo % qinit -c
+hg qinit -c
 echo % qimport
 hg qimport -r tip -n mqtest.diff
+echo % qcommit
+hg qcommit -mqtest
 echo % keywords should not be expanded in patch
 cat .hg/patches/mqtest.diff
 echo % qpop
diff --git a/tests/test-keyword.out b/tests/test-keyword.out
--- a/tests/test-keyword.out
+++ b/tests/test-keyword.out
@@ -162,7 +162,9 @@
 xxx $
 $Id: c,v ba4426d1938e 1970/01/01 00:00:01 user $
 tests for different changenodes
+% qinit -c
 % qimport
+% qcommit
 % keywords should not be expanded in patch
 # HG changeset patch
 # User User Name <user at example.com>


More information about the Mercurial-devel mailing list