keyword: suppress keyword expansion while 'hg fetch' for internal merge
Before this patch, 'hg fetch' may cause unexpected conflict, if 'hg
fetch'-ed changes are located near lines in which keywords are
embedded, because keywords are substituted with other strings in the
working directory.
This patch suppresses keyword expansion while 'hg fetch' for internal
merge by adding 'fetch' to 'restricted' command list like 'merge'.
This patch uses 'hg import' to safely create the new head to be merged
at succeeding 'hg fetch', because:
- branch of revision #10 is different from one of #11 in 'Test'
repository, so just 'hg fetch -r 11' doesn't cause merging between
them
this means the new head should be created manually.
- 'hg import' is easier and safer than 'cat <<EOF' and 'hg commit'
to replay same changes including special characters like '$'
safeness of 'hg import' with keyword extension is already examined
in 'test-keyword.t'.
--- a/hgext/keyword.py Thu Jun 05 16:47:14 2014 +0900
+++ b/hgext/keyword.py Thu Jun 05 16:47:14 2014 +0900
@@ -103,7 +103,7 @@
# hg commands that trigger expansion only when writing to working dir,
# not when reading filelog, and unexpand when reading from working dir
restricted = ('merge kwexpand kwshrink record qrecord resolve transplant'
- ' unshelve rebase graft backout histedit')
+ ' unshelve rebase graft backout histedit fetch')
# names of extensions using dorecord
recordextensions = 'record'
--- a/tests/test-keyword.t Thu Jun 05 16:47:14 2014 +0900
+++ b/tests/test-keyword.t Thu Jun 05 16:47:14 2014 +0900
@@ -1284,4 +1284,27 @@
> pick 01a68de1003a 13 9foobranch
> EOF
+Test restricted mode with fetch (with merge)
+
+ $ cat <<EOF >> $HGRCPATH
+ > [extensions]
+ > fetch =
+ > EOF
+
+ $ hg clone -q -r 9 . ../fetch-merge
+ $ cd ../fetch-merge
+ $ hg -R ../Test export 10 | hg import -q -
+ $ hg fetch -q -r 11
+ $ hg diff -r 9 a
+ diff -r 800511b3a22d a
+ --- a/a Thu Jan 01 00:00:00 1970 +0000
+ +++ b/a * (glob)
+ @@ -1,4 +1,6 @@
+ +foobranch
+ expand $Id$
+ do not process $Id:
+ xxx $
+ $Xinfo$
+ +xxxx
+
$ cd ..