changeset 10117:98867145f4b5 stable

keyword: go into restricted mode when transplanting Expanded keyword is read into diff with transplant -b otherwise. Test this scenario. Thanks to Adam Berkes for providing an example case.
author Christian Ebert <blacktrash@gmx.net>
date Wed, 23 Dec 2009 12:04:17 +0000
parents 4b514a70ea72
children 333193c025ad fb890a546d44
files hgext/keyword.py tests/test-keyword tests/test-keyword.out
diffstat 3 files changed, 47 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/keyword.py	Wed Dec 23 12:04:04 2009 +0000
+++ b/hgext/keyword.py	Wed Dec 23 12:04:17 2009 +0000
@@ -93,7 +93,8 @@
 
 # hg commands that trigger expansion only when writing to working dir,
 # not when reading filelog, and unexpand when reading from working dir
-restricted = 'merge record resolve qfold qimport qnew qpush qrefresh qrecord'
+restricted = ('merge record resolve qfold qimport qnew qpush qrefresh qrecord'
+              ' transplant')
 
 # provide cvs-like UTC date filter
 utcdate = lambda x: util.datestr(x, '%Y/%m/%d %H:%M:%S')
--- a/tests/test-keyword	Wed Dec 23 12:04:04 2009 +0000
+++ b/tests/test-keyword	Wed Dec 23 12:04:17 2009 +0000
@@ -5,6 +5,7 @@
 hgext.keyword =
 hgext.mq =
 hgext.notify =
+hgext.transplant =
 EOF
 
 # demo before [keyword] files are set up
@@ -337,6 +338,23 @@
 hg commit -m localresolve
 cat m
 
+echo % test restricted mode with transplant -b
+hg update 6
+hg branch foo
+mv a a.bak
+echo foobranch > a
+cat a.bak >> a
+rm a.bak
+hg commit -m 9foobranch
+hg update default
+hg -y transplant -b foo tip
+echo % no expansion in changeset
+hg tip -p
+echo % expansion in file
+head -n 2 a
+hg -q rollback
+hg -q update -C
+
 echo % switch off expansion
 echo % kwshrink with unknown file u
 cp a u
--- a/tests/test-keyword.out	Wed Dec 23 12:04:04 2009 +0000
+++ b/tests/test-keyword.out	Wed Dec 23 12:04:17 2009 +0000
@@ -420,6 +420,33 @@
 % resolve to local
 $Id: m 43dfd2854b5b Thu, 01 Jan 1970 00:00:00 +0000 test $
 bar
+% test restricted mode with transplant -b
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+marked working directory as branch foo
+created new head
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+applying 1c4378f51c4d
+1c4378f51c4d transplanted to 7d855abcab87
+% no expansion in changeset
+changeset:   11:7d855abcab87
+tag:         tip
+parent:      9:43dfd2854b5b
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     9foobranch
+
+diff -r 43dfd2854b5b -r 7d855abcab87 a
+--- a/a	Thu Jan 01 00:00:00 1970 +0000
++++ b/a	Thu Jan 01 00:00:00 1970 +0000
+@@ -1,3 +1,4 @@
++foobranch
+ expand $Id$
+ do not process $Id:
+ xxx $
+
+% expansion in file
+foobranch
+expand $Id: a 7d855abcab87 Thu, 01 Jan 1970 00:00:00 +0000 test $
 % switch off expansion
 % kwshrink with unknown file u
 overwriting a shrinking keywords