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

login
register
mail settings
Submitter Katsunori FUJIWARA
Date June 5, 2014, 7:52 a.m.
Message ID <f286bee15cd71eac7210.1401954726@juju>
Download mbox | patch
Permalink /patch/4933/
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 1401954434 -32400
#      Thu Jun 05 16:47:14 2014 +0900
# Branch stable
# Node ID f286bee15cd71eac7210fc04da4dab26cf3f7c00
# Parent  c6842a36e5778ae3117402d505af8a54fb81beb5
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'.

Patch

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 rebase graft backout histedit')
+              ' unshelve rebase graft backout histedit fetch')
 
 # 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
@@ -1284,4 +1284,27 @@  Test restricted mode with histedit
   > 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 ..