11
11
r"\g<prews><a href='issue\g<id>'>issue\g<ws>\g<id></a>" ),
12
12
# matching the typical number:hash format of hg's own output
13
13
# 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+|$)' ),
15
15
r'\g<prews><a href="' + hg_url_base + '\g<refhash>">\g<revstr>\g<revnumber>:\g<refhash></a>\g<post>' ),
16
16
# matching hg revison number or hash
17
17
(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):
29
29
def init (instance ):
30
30
instance .registerUtil ('localReplace' , local_replace )
31
31
32
- def quicktest (msgstr , should_replace = True ):
32
+ def quicktest (msgstr , should_replace = True , substr = True ):
33
33
testcount ['run' ] += 1
34
34
replacedstr = local_replace (msgstr )
35
35
36
36
if not (not replacedstr == msgstr ) == should_replace :
37
37
print ("(fail)" , end = ' ' )
38
38
testcount ['failed' ] += 1
39
+ elif substr and (msgstr not in replacedstr ):
40
+ print ("(fail)" , end = ' ' )
41
+ testcount ['failed' ] += 1
39
42
40
43
if replacedstr == msgstr :
41
44
print ( "'%s'" % (msgstr ,))
@@ -45,11 +48,11 @@ def quicktest(msgstr, should_replace = True):
45
48
if "__main__" == __name__ :
46
49
testcount = {'run' :0 , 'failed' : 0 }
47
50
print ("Replacement examples:" )
48
- quicktest (" debian:#222" )
49
- quicktest (" #555" )
51
+ quicktest (" debian:#222" , substr = False )
52
+ quicktest (" #555" , substr = False )
50
53
quicktest ("issue333" )
51
- quicktest (" revision 222" )
52
- quicktest (" r 222" )
54
+ quicktest (" revision 222" , substr = False )
55
+ quicktest (" r 222" , substr = False )
53
56
quicktest (" wordthatendswithr 222" , False )
54
57
quicktest (" references" , False )
55
58
quicktest (" too many spaces r 222" , False )
@@ -58,12 +61,14 @@ def quicktest(msgstr, should_replace = True):
58
61
quicktest ("rev 012" , False ) # too short for a hg hash
59
62
quicktest ("rev 0123" )
60
63
quicktest ("re140eb" )
61
- quicktest (" r7140eb" )
62
- quicktest (" rev7140eb " )
64
+ quicktest (" r7140eb" , substr = False )
65
+ quicktest (" rev7140eb " , substr = False )
63
66
quicktest ("rev7140eb" )
64
- quicktest ("rev7140eb," )
67
+ quicktest ("rev7140eb," , substr = False )
65
68
quicktest ("rev4891:ad3d628e73f2" )
66
69
quicktest ("hg4891:ad3d628e73f2" )
67
70
quicktest ("changeset: 4542:46239c21a1eb" )
71
+ quicktest ("rev 4542:46239c21a1eb" )
72
+ quicktest ("rev 4542:46239c21a1eb" ) # many spaces
68
73
print ()
69
74
print (testcount )
0 commit comments