77import re
88import shutil
99import sys
10+ import datetime
1011import subprocess
1112import tarfile
1213import urllib
@@ -23,6 +24,14 @@ def prepare_upstream(prefix, commit=None):
2324 os .chdir (base )
2425 return commit
2526
27+ def get_commit_date (prefix , commit = None ):
28+ upstream_url = 'https://chromium.googlesource.com/libyuv/libyuv/+/' + commit
29+ text = urllib .urlopen (upstream_url ).readlines ()
30+ text = "" .join (text )
31+ regex = '<tr><th class="Metadata-title">committer</th><td>.+</td><td>[^\s]+ ([0-9a-zA-Z: ]+)\s*\+*[0-9]*</td></tr>'
32+ date = re .search (regex , text ).groups (0 )[0 ]
33+ return datetime .datetime .strptime (date , "%b %d %H:%M:%S %Y" )
34+
2635def cleanup_upstream ():
2736 os .remove (os .path .join (base , 'libyuv/.gitignore' ))
2837
@@ -44,13 +53,13 @@ def apply_patches():
4453 # Patch for bug 1342732
4554 os .system ("patch -p3 < row_any.patch" )
4655
47- def update_readme (commit ):
56+ def update_readme (commit , commitdate ):
4857 with open ('README_MOZILLA' ) as f :
4958 readme = f .read ()
5059
5160 if 'The git commit ID last used to import was ' in readme :
52- new_readme = re .sub ('The git commit ID last used to import was [v\.a-f0-9]+' ,
53- 'The git commit ID last used to import was %s' % commit , readme )
61+ new_readme = re .sub ('The git commit ID last used to import was [v\.a-f0-9]+ \(.+\) ' ,
62+ 'The git commit ID last used to import was %s (%s) ' % ( commit , commitdate ) , readme )
5463 else :
5564 new_readme = "%s\n \n The git commit ID last used to import was %s\n " % (readme , commit )
5665
@@ -72,9 +81,10 @@ def update_readme(commit):
7281 prefix = os .path .join (base , 'libyuv/' )
7382
7483 commit = prepare_upstream (prefix , commit )
84+ commitdate = get_commit_date (prefix , commit )
7585
7686 apply_patches ()
77- update_readme (commit )
87+ update_readme (commit , commitdate )
7888
7989 print ('Patches applied; run "hg addremove --similarity 70 libyuv" before committing changes' )
8090
0 commit comments