keyword: avoid additional conflicts during merge/resolve
Make merge and resolve trigger kwtemplater.restricted to compare
data without keyword expansion.
The keyword stays outside the conflict:
$Keyword$
<<<<<<< local
bar
=======
foo
>>>>>>> other
and will again be expanded on commit.
Demonstrate in test case.
--- a/hgext/keyword.py Fri Aug 22 13:25:35 2008 +0200
+++ b/hgext/keyword.py Fri Aug 22 08:26:18 2008 +0200
@@ -94,7 +94,7 @@
# hg commands that trigger expansion only when writing to working dir,
# not when reading filelog, and unexpand when reading from working dir
-restricted = 'record qfold qimport qnew qpush qrefresh qrecord'
+restricted = 'merge record resolve qfold qimport qnew qpush qrefresh qrecord'
def utcdate(date):
'''Returns hgdate in cvs-like UTC format.'''
--- a/tests/test-keyword Fri Aug 22 13:25:35 2008 +0200
+++ b/tests/test-keyword Fri Aug 22 08:26:18 2008 +0200
@@ -301,6 +301,31 @@
echo % errors encountered
cat errors.log
+echo % merge/resolve
+echo '$Id$' > m
+hg add m
+hg commit -m 4kw
+echo foo >> m
+hg commit -m 5foo
+echo % simplemerge
+hg update 4
+echo foo >> m
+hg commit -m 6foo
+hg merge
+hg commit -m simplemerge
+cat m
+echo % conflict
+hg update 4
+echo bar >> m
+hg commit -m 8bar
+hg merge
+echo % keyword stays outside conflict zone
+cat m
+echo % resolve to local
+HGMERGE=internal:local hg resolve
+hg commit -m localresolve
+cat m
+
echo % switch off expansion
echo % kwshrink with unknown file u
cp a u
--- a/tests/test-keyword.out Fri Aug 22 13:25:35 2008 +0200
+++ b/tests/test-keyword.out Fri Aug 22 08:26:18 2008 +0200
@@ -437,9 +437,36 @@
% errors encountered
+% merge/resolve
+% simplemerge
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+created new head
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(branch merge, don't forget to commit)
+$Id: m 8731e1dadc99 Thu, 01 Jan 1970 00:00:00 +0000 test $
+foo
+% conflict
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+created new head
+merging m
+warning: conflicts during merge.
+merging m failed!
+0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+use 'hg resolve' to retry unresolved file merges
+% keyword stays outside conflict zone
+$Id$
+<<<<<<< local
+bar
+=======
+foo
+>>>>>>> other
+% resolve to local
+$Id: m 43dfd2854b5b Thu, 01 Jan 1970 00:00:00 +0000 test $
+bar
% switch off expansion
% kwshrink with unknown file u
overwriting a shrinking keywords
+overwriting m shrinking keywords
overwriting x/a shrinking keywords
% cat
expand $Id$