# HG changeset patch # User Christian Ebert # Date 1285230838 -7200 # Node ID 2941e3ddd1b1f94bd79fbb848cda7b35522d0600 # Parent 13bba4066f900d7d626dd71be92333ef3f4c286f# Parent 630d72ae4f76566f0344d27180085ebaf14aa199 Merge with stable diff -r 13bba4066f90 -r 2941e3ddd1b1 tests/run-tests.py --- a/tests/run-tests.py Wed Sep 22 23:46:57 2010 +0200 +++ b/tests/run-tests.py Thu Sep 23 10:33:58 2010 +0200 @@ -503,14 +503,31 @@ def rematch(el, l): try: - # hack to deal with graphlog, which looks like bogus regexes - if el.startswith('|'): - el = '\\' + el - return re.match(el, l) + # ensure that the regex matches to the end of the string + return re.match(el + r'\Z', l) except re.error: # el is an invalid regex return False + def globmatch(el, l): + # The only supported special characters are * and ?. Escaping is + # supported. + i, n = 0, len(el) + res = '' + while i < n: + c = el[i] + i += 1 + if c == '\\' and el[i] in '*?\\': + res += el[i - 1:i + 1] + i += 1 + elif c == '*': + res += '.*' + elif c == '?': + res += '.' + else: + res += re.escape(c) + return rematch(res, l) + pos = -1 postout = [] ret = 0 @@ -530,10 +547,12 @@ if el == l: # perfect match (fast) postout.append(" " + l) - elif el and rematch(el, l): # fallback regex match - postout.append(" " + el) - else: # mismatch - let diff deal with it - postout.append(" " + l) + elif (el and + (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l) or + el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l))): + postout.append(" " + el) # fallback regex/glob match + else: + postout.append(" " + l) # let diff deal with it if pos in after: postout += after.pop(pos) diff -r 13bba4066f90 -r 2941e3ddd1b1 tests/test-keyword.t --- a/tests/test-keyword.t Wed Sep 22 23:46:57 2010 +0200 +++ b/tests/test-keyword.t Thu Sep 23 10:33:58 2010 +0200 @@ -26,14 +26,14 @@ RCSfile = {file|basename},v Revision = {node|short} Source = {root}/{file},v - \$Author: test \$ - \$Date: ..../../.. ..:..:.. \$ - \$Header: .*/demo.txt,v ............ ..../../.. ..:..:.. test \$ - \$Id: demo.txt,v ............ ..../../.. ..:..:.. test \$ - \$RCSFile: demo.txt,v \$ - \$RCSfile: demo.txt,v \$ - \$Revision: ............ \$ - \$Source: .*/demo.txt,v \$ + $Author: test $ + $Date: ????/??/?? ??:??:?? $ (glob) + $Header: */demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob) + $Id: demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob) + $RCSFile: demo.txt,v $ + $RCSfile: demo.txt,v $ + $Revision: ???????????? $ (glob) + $Source: */demo.txt,v $ (glob) $ hg --quiet kwdemo "Branch = {branches}" [extensions] @@ -71,7 +71,7 @@ hg bundle --base null ../test-keyword.hg $ hg pull -u "$TESTDIR"/test-keyword.hg - pulling from .*test-keyword.hg + pulling from *test-keyword.hg (glob) requesting all changes adding changesets adding manifests @@ -150,7 +150,7 @@ do not process $Id: xxx $ ignore $Id$ - a.* + a* (glob) Test hook execution @@ -195,15 +195,15 @@ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit - Date: .* - Subject: changeset in .* + Date: * (glob) + Subject: changeset in * (glob) From: mercurial X-Hg-Notification: changeset a2392c293916 - Message-Id: + Message-Id: (glob) To: Test - changeset a2392c293916 in .* - details: .*?cmd=changeset;node=a2392c293916 + changeset a2392c293916 in * (glob) + details: *cmd=changeset;node=a2392c293916 (glob) description: addsym @@ -218,15 +218,15 @@ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit - Date:.* - Subject: changeset in.* + Date:* (glob) + Subject: changeset in* (glob) From: User Name X-Hg-Notification: changeset ef63ca68695b - Message-Id: + Message-Id: (glob) To: Test - changeset ef63ca68695b in .* - details: .*?cmd=changeset;node=ef63ca68695b + changeset ef63ca68695b in * (glob) + details: *cmd=changeset;node=ef63ca68695b (glob) description: absym @@ -335,7 +335,7 @@ $ hg diff diff -r d17e03c92c97 a --- a/a Wed Dec 31 23:59:51 1969 -0000 - \+\+\+ b/a .* + +++ b/a * (glob) @@ -2,3 +2,4 @@ foo do not process $Id: @@ -479,7 +479,7 @@ $ hg diff --rev 1 diff -r ef63ca68695b c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 - \+\+\+ b/c .* + +++ b/c * (glob) @@ -0,0 +1,3 @@ +expand $Id$ +do not process $Id: @@ -527,7 +527,7 @@ do not process $Id: xxx $ ignore $Id$ - a.* + a* (glob) Write custom keyword and prepare multiline commit message @@ -577,7 +577,7 @@ xxx $ $Xinfo: User Name : firstline $ ignore $Id$ - a.* + a* (glob) annotate @@ -648,7 +648,7 @@ > default = ../Test > EOF $ hg incoming - comparing with .*test-keyword.t/Test + comparing with *test-keyword.t/Test (glob) searching for changes changeset: 2:bb948857c743 tag: tip @@ -718,7 +718,7 @@ kwexpand nonexistent $ hg kwexpand nonexistent - nonexistent:.* + nonexistent:* (glob) hg serve @@ -907,7 +907,7 @@ xxx $ $Xinfo: User Name : firstline $ ignore $Id$ - a.* + a* (glob) Now disable keyword expansion @@ -924,4 +924,4 @@ xxx $ $Xinfo$ ignore $Id$ - a.* + a* (glob)