[PATCH 1 of 6 STABLE] keyword: suppress keyword expansion while 'hg unshelve' for internal merge

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Jun 5 07:52:01 UTC 2014


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1401954433 -32400
#      Thu Jun 05 16:47:13 2014 +0900
# Branch stable
# Node ID 1232fc348f6f12466aa73ecca1100d272f74ac84
# Parent  dedb68a9532cafde83ccafee1ef2c1e6b02ac189
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'.

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -102,7 +102,8 @@ nokwcommands = ('add addremove annotate 
 
 # 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'
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -1137,6 +1137,7 @@ Keywords shrunk in working directory, bu
 
 Now disable keyword expansion
 
+  $ cp $HGRCPATH $HGRCPATH.backup
   $ rm "$HGRCPATH"
   $ cat a b
   expand $Id$
@@ -1152,4 +1153,50 @@ Now disable keyword expansion
   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 ..


More information about the Mercurial-devel mailing list