keyword: suppress keyword expansion while 'hg unshelve' for internal merge
Before this patch, 'hg unshelve' may cause unexpected conflict, if 'hg
unshelve'-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 unshelve' for
internal merge by adding 'unshelve' to 'restricted' command list like
'merge'.
--- a/hgext/keyword.py Sun Jun 01 14:15:43 2014 -0700
+++ b/hgext/keyword.py Thu Jun 05 16:47:13 2014 +0900
@@ -102,7 +102,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 kwexpand kwshrink record qrecord resolve transplant'
+restricted = ('merge kwexpand kwshrink record qrecord resolve transplant'
+ ' unshelve')
# names of extensions using dorecord
recordextensions = 'record'
--- a/tests/test-keyword.t Sun Jun 01 14:15:43 2014 -0700
+++ b/tests/test-keyword.t Thu Jun 05 16:47:13 2014 +0900
@@ -1137,6 +1137,7 @@
Now disable keyword expansion
+ $ cp $HGRCPATH $HGRCPATH.backup
$ rm "$HGRCPATH"
$ cat a b
expand $Id$
@@ -1152,4 +1153,50 @@
ignore $Id$
a
+enable keyword expansion again
+
+ $ cat $HGRCPATH.backup >> $HGRCPATH
+
+Test restricted mode with unshelve
+
+ $ cat <<EOF >> $HGRCPATH
+ > [extensions]
+ > shelve =
+ > EOF
+
+ $ echo xxxx >> a
+ $ hg diff
+ diff -r 800511b3a22d a
+ --- a/a Thu Jan 01 00:00:00 1970 +0000
+ +++ b/a * (glob)
+ @@ -2,3 +2,4 @@
+ do not process $Id:
+ xxx $
+ $Xinfo$
+ +xxxx
+ $ hg shelve -q --name tmp
+ $ hg shelve --list --patch
+ tmp (*) changes to 'localresolve' (glob)
+
+ diff --git a/a b/a
+ --- a/a
+ +++ b/a
+ @@ -2,3 +2,4 @@
+ do not process $Id:
+ xxx $
+ $Xinfo$
+ +xxxx
+
+ $ hg update -q -C 10
+ $ hg unshelve -q tmp
+ $ hg diff
+ diff -r 4aa30d025d50 a
+ --- a/a Thu Jan 01 00:00:00 1970 +0000
+ +++ b/a * (glob)
+ @@ -3,3 +3,4 @@
+ do not process $Id:
+ xxx $
+ $Xinfo$
+ +xxxx
+
$ cd ..