# HG changeset patch # User Christian Ebert # Date 1202336073 -3600 # Node ID 1038b1458d7a202c1b61d44e984e36c22432fae1 # Parent adf73753eb7dd8e6b1c84f64abc6a694f7fc4d5c keyword: safeguards against erroneous behaviour or aborts prevent issues due to global [keyword] filename patterns: - add email to nokwcommands - protect everything under .hg from expansion (tested with qcommit) - exclude everything starting with .hg* just in case prevent abort when pulling from bundlerepo: - do not set up kwrepo for bundlerepo expansion inside a bundle is nonsense bundlerepo issue spotted and test case provided by pmezard. diff -r adf73753eb7d -r 1038b1458d7a hgext/keyword.py --- a/hgext/keyword.py Thu Feb 07 15:56:20 2008 +0100 +++ b/hgext/keyword.py Wed Feb 06 23:14:33 2008 +0100 @@ -88,7 +88,7 @@ # hg commands that do not act on keywords nokwcommands = ('add addremove bundle copy export grep identify incoming init' - ' log outgoing push remove rename rollback tip convert') + ' log outgoing push remove rename rollback tip convert email') # hg commands that trigger expansion only when writing to working dir, # not when reading filelog, and unexpand when reading from working dir @@ -410,8 +410,12 @@ This is done for local repos only, and only if there are files configured at all for keyword substitution.''' - if not repo.local(): - return + try: + if (not repo.local() or '.hg' in repo.root.split('/') + or repo._url.startswith('bundle:')): + return + except AttributeError: + pass hgcmd, func, args, opts, cmdopts = dispatch._parse(ui, sys.argv[1:]) if hgcmd in nokwcommands.split(): @@ -426,7 +430,7 @@ if node1 is not None and node1 != repo.changectx().node(): hgcmd = 'diff1' - inc, exc = [], ['.hgtags'] + inc, exc = [], ['.hg*'] for pat, opt in ui.configitems('keyword'): if opt != 'ignore': inc.append(pat) diff -r adf73753eb7d -r 1038b1458d7a tests/test-keyword --- a/tests/test-keyword Thu Feb 07 15:56:20 2008 +0100 +++ b/tests/test-keyword Wed Feb 06 23:14:33 2008 +0100 @@ -24,8 +24,8 @@ hg --quiet kwdemo "Branch = {branches}" -hg init Test -cd Test +hg init Test-bndl +cd Test-bndl echo % kwshrink should exit silently in empty/invalid repo hg kwshrink @@ -69,6 +69,16 @@ mv $HGRCPATH.nohook $HGRCPATH rm hooktest +echo % bundle +hg bundle --base null ../kw.hg + +cd .. +hg init Test +cd Test + +echo % pull from bundle +hg pull -u ../kw.hg + echo % touch touch a b echo % status @@ -90,8 +100,12 @@ echo % compare changenodes in a c cat a c +echo % qinit -c +hg qinit -c echo % qimport hg qimport -r tip -n mqtest.diff +echo % qcommit +hg qcommit -mqtest echo % keywords should not be expanded in patch cat .hg/patches/mqtest.diff echo % qpop diff -r adf73753eb7d -r 1038b1458d7a tests/test-keyword.out --- a/tests/test-keyword.out Thu Feb 07 15:56:20 2008 +0100 +++ b/tests/test-keyword.out Wed Feb 06 23:14:33 2008 +0100 @@ -138,6 +138,16 @@ a % diff a hooktest % removing commit hook from config +% bundle +1 changesets found +% pull from bundle +pulling from ../kw.hg +requesting all changes +adding changesets +adding manifests +adding file changes +added 1 changesets with 3 changes to 3 files +3 files updated, 0 files merged, 0 files removed, 0 files unresolved % touch % status % update @@ -162,7 +172,9 @@ xxx $ $Id: c,v ba4426d1938e 1970/01/01 00:00:01 user $ tests for different changenodes +% qinit -c % qimport +% qcommit % keywords should not be expanded in patch # HG changeset patch # User User Name