1111 r"\g<prews><a href='issue\g<id>'>issue\g<ws>\g<id></a>" ),
1212 # matching the typical number:hash format of hg's own output
1313 # and then use use hash instead of the number
14- (re .compile (r'(?P<prews>(^|\s+))(?P<revstr>(rev|hg|changeset: ))(?P<revnumber>\d+):(?P<refhash>[0-9a-fA-F]{12,40})(?P<post>\W+|$)' ),
14+ (re .compile (r'(?P<prews>(^|\s+))(?P<revstr>(rev\s* |hg\s* |changeset: ))(?P<revnumber>\d+):(?P<refhash>[0-9a-fA-F]{12,40})(?P<post>\W+|$)' ),
1515 r'\g<prews><a href="' + hg_url_base + '\g<refhash>">\g<revstr>\g<revnumber>:\g<refhash></a>\g<post>' ),
1616 # matching hg revison number or hash
1717 (re .compile (r'(?P<prews>(^|\s+))(?P<revstr>(revision|rev|r)\s?)(?P<revision>([1-9][0-9]*)|[0-9a-fA-F]{4,40})(?P<post>\W+|$)' ),
@@ -29,13 +29,16 @@ def local_replace(message):
2929def init (instance ):
3030 instance .registerUtil ('localReplace' , local_replace )
3131
32- def quicktest (msgstr , should_replace = True ):
32+ def quicktest (msgstr , should_replace = True , substr = True ):
3333 testcount ['run' ] += 1
3434 replacedstr = local_replace (msgstr )
3535
3636 if not (not replacedstr == msgstr ) == should_replace :
3737 print ("(fail)" , end = ' ' )
3838 testcount ['failed' ] += 1
39+ elif substr and (msgstr not in replacedstr ):
40+ print ("(fail)" , end = ' ' )
41+ testcount ['failed' ] += 1
3942
4043 if replacedstr == msgstr :
4144 print ( "'%s'" % (msgstr ,))
@@ -45,11 +48,11 @@ def quicktest(msgstr, should_replace = True):
4548if "__main__" == __name__ :
4649 testcount = {'run' :0 , 'failed' : 0 }
4750 print ("Replacement examples:" )
48- quicktest (" debian:#222" )
49- quicktest (" #555" )
51+ quicktest (" debian:#222" , substr = False )
52+ quicktest (" #555" , substr = False )
5053 quicktest ("issue333" )
51- quicktest (" revision 222" )
52- quicktest (" r 222" )
54+ quicktest (" revision 222" , substr = False )
55+ quicktest (" r 222" , substr = False )
5356 quicktest (" wordthatendswithr 222" , False )
5457 quicktest (" references" , False )
5558 quicktest (" too many spaces r 222" , False )
@@ -58,12 +61,14 @@ def quicktest(msgstr, should_replace = True):
5861 quicktest ("rev 012" , False ) # too short for a hg hash
5962 quicktest ("rev 0123" )
6063 quicktest ("re140eb" )
61- quicktest (" r7140eb" )
62- quicktest (" rev7140eb " )
64+ quicktest (" r7140eb" , substr = False )
65+ quicktest (" rev7140eb " , substr = False )
6366 quicktest ("rev7140eb" )
64- quicktest ("rev7140eb," )
67+ quicktest ("rev7140eb," , substr = False )
6568 quicktest ("rev4891:ad3d628e73f2" )
6669 quicktest ("hg4891:ad3d628e73f2" )
6770 quicktest ("changeset: 4542:46239c21a1eb" )
71+ quicktest ("rev 4542:46239c21a1eb" )
72+ quicktest ("rev 4542:46239c21a1eb" ) # many spaces
6873 print ()
6974 print (testcount )
0 commit comments