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

login
register
mail settings
Submitter Katsunori FUJIWARA
Date June 5, 2014, 7:52 a.m.
Message ID <1232fc348f6f12466aa7.1401954721@juju>
Download mbox | patch
Permalink /patch/4932/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - June 5, 2014, 7:52 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@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'.
Christian Ebert - June 5, 2014, 2:30 p.m.
* FUJIWARA Katsunori on Thursday, June 05, 2014 at 16:52:01 +0900
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@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

Thank you very much for taking care of this! It was on my agenda
since ages, but currently I simply do not find time for
Mercurial hacking, sorry.

Christian
Pierre-Yves David - June 5, 2014, 10:29 p.m.
On 06/05/2014 12:52 AM, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@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

I've pushed those 6 for stable. Thanks

(queued)

Patch

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 ..