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

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Jun 5 02:52:02 CDT 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 222e2ebff7b1a1ff7bb3acadbbf35f72ca3e71d0
# Parent  1232fc348f6f12466aa73ecca1100d272f74ac84
keyword: suppress keyword expansion while 'hg rebase' for internal merge

Before this patch, 'hg rebase' may cause unexpected conflict, if 'hg
rebase'-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 rebase' for internal
merge by adding 'rebase' to 'restricted' command list like 'merge'.

This patch specifies '--keep' to 'hg rebase', because revision #10 is
useful also for tests in succeeding patches.

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -103,7 +103,7 @@ 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'
-              ' unshelve')
+              ' unshelve rebase')
 
 # 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
@@ -1199,4 +1199,48 @@ Test restricted mode with unshelve
    $Xinfo$
   +xxxx
 
+Test restricted mode with rebase
+
+  $ cat <<EOF >> $HGRCPATH
+  > [extensions]
+  > rebase =
+  > EOF
+
+  $ hg update -q -C 9
+
+  $ echo xxxx >> a
+  $ hg commit -m '#11'
+  $ hg diff -c 11
+  diff -r 800511b3a22d -r b07670694489 a
+  --- a/a	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+  @@ -2,3 +2,4 @@
+   do not process $Id:
+   xxx $
+   $Xinfo$
+  +xxxx
+
+  $ hg diff -c 10
+  diff -r 27d48ee14f67 -r 4aa30d025d50 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 $
+
+  $ hg rebase -q -s 10 -d 11 --keep
+  $ hg diff -r 9 -r 12 a
+  diff -r 800511b3a22d -r 1939b927726c a
+  --- a/a	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,4 +1,6 @@
+  +foobranch
+   expand $Id$
+   do not process $Id:
+   xxx $
+   $Xinfo$
+  +xxxx
+
   $ cd ..


More information about the Mercurial-devel mailing list