|
Lines 110-118
class ChangeLogEntry(object):
a/Tools/Scripts/webkitpy/common/checkout/changelog.py_sec1
|
| 110 |
# e.g. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96161 268f45cc-cd09-0410-ab3c-d52691b4dbfc |
110 |
# e.g. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96161 268f45cc-cd09-0410-ab3c-d52691b4dbfc |
| 111 |
svn_id_regexp = r'git-svn-id: http://svn.webkit.org/repository/webkit/trunk@(?P<svnid>\d+) ' |
111 |
svn_id_regexp = r'git-svn-id: http://svn.webkit.org/repository/webkit/trunk@(?P<svnid>\d+) ' |
| 112 |
|
112 |
|
| 113 |
def __init__(self, contents, committer_list=CommitterList()): |
113 |
def __init__(self, contents, committer_list=CommitterList(), revision=None): |
| 114 |
self._contents = contents |
114 |
self._contents = contents |
| 115 |
self._committer_list = committer_list |
115 |
self._committer_list = committer_list |
|
|
116 |
self._revision = revision |
| 116 |
self._parse_entry() |
117 |
self._parse_entry() |
| 117 |
|
118 |
|
| 118 |
@staticmethod |
119 |
@staticmethod |
|
Lines 167-172
class ChangeLogEntry(object):
a/Tools/Scripts/webkitpy/common/checkout/changelog.py_sec2
|
| 167 |
|
168 |
|
| 168 |
self._touched_files = re.findall(self.touched_files_regexp, self._contents, re.MULTILINE) |
169 |
self._touched_files = re.findall(self.touched_files_regexp, self._contents, re.MULTILINE) |
| 169 |
|
170 |
|
|
|
171 |
def revision(self): |
| 172 |
return self._revision |
| 173 |
|
| 170 |
def author_name(self): |
174 |
def author_name(self): |
| 171 |
return self._author_name |
175 |
return self._author_name |
| 172 |
|
176 |
|
|
Lines 237-242
class ChangeLog(object):
a/Tools/Scripts/webkitpy/common/checkout/changelog.py_sec3
|
| 237 |
entry_lines.append(line) |
241 |
entry_lines.append(line) |
| 238 |
return None # We never found a date line! |
242 |
return None # We never found a date line! |
| 239 |
|
243 |
|
|
|
244 |
svn_blame_regexp = re.compile(r'^(\s*(?P<revision>\d+) [^ ]+)\s(?P<line>.*?\n)') |
| 245 |
|
| 246 |
@staticmethod |
| 247 |
def _sepearate_revision_and_line(line): |
| 248 |
match = ChangeLog.svn_blame_regexp.match(line) |
| 249 |
if not match: |
| 250 |
return None, line |
| 251 |
return int(match.group('revision')), match.group('line') |
| 252 |
|
| 240 |
@staticmethod |
253 |
@staticmethod |
| 241 |
def parse_entries_from_file(changelog_file): |
254 |
def parse_entries_from_file(changelog_file): |
| 242 |
"""changelog_file must be a file-like object which returns |
255 |
"""changelog_file must be a file-like object which returns |
|
Lines 244-263
class ChangeLog(object):
a/Tools/Scripts/webkitpy/common/checkout/changelog.py_sec4
|
| 244 |
to pass file objects to this class.""" |
257 |
to pass file objects to this class.""" |
| 245 |
date_line_regexp = re.compile(ChangeLogEntry.date_line_regexp) |
258 |
date_line_regexp = re.compile(ChangeLogEntry.date_line_regexp) |
| 246 |
rolled_over_regexp = re.compile(ChangeLogEntry.rolled_over_regexp) |
259 |
rolled_over_regexp = re.compile(ChangeLogEntry.rolled_over_regexp) |
| 247 |
entry_lines = [] |
260 |
|
| 248 |
# The first line should be a date line. |
261 |
# The first line should be a date line. |
| 249 |
first_line = changelog_file.readline() |
262 |
revision, first_line = ChangeLog._sepearate_revision_and_line(changelog_file.readline()) |
| 250 |
assert(isinstance(first_line, unicode)) |
263 |
assert(isinstance(first_line, unicode)) |
| 251 |
if not date_line_regexp.match(first_line): |
264 |
if not date_line_regexp.match(ChangeLog.svn_blame_regexp.sub('', first_line)): |
| 252 |
raise StopIteration |
265 |
raise StopIteration |
| 253 |
entry_lines.append(first_line) |
|
|
| 254 |
|
266 |
|
|
|
267 |
entry_lines = [first_line] |
| 268 |
revisions_in_entry = {revision: 1} if revision != None else None |
| 255 |
for line in changelog_file: |
269 |
for line in changelog_file: |
| 256 |
if date_line_regexp.match(line) or rolled_over_regexp.match(line): |
270 |
if revisions_in_entry: |
|
|
271 |
revision, line = ChangeLog._sepearate_revision_and_line(line) |
| 272 |
|
| 273 |
if rolled_over_regexp.match(line): |
| 274 |
break |
| 275 |
|
| 276 |
if date_line_regexp.match(line): |
| 277 |
most_probable_revision = max(revisions_in_entry, key=revisions_in_entry.__getitem__) if revisions_in_entry else None |
| 257 |
# Remove the extra newline at the end |
278 |
# Remove the extra newline at the end |
| 258 |
yield ChangeLogEntry(''.join(entry_lines[:-1])) |
279 |
yield ChangeLogEntry(''.join(entry_lines[:-1]), revision=most_probable_revision) |
| 259 |
entry_lines = [] |
280 |
entry_lines = [] |
|
|
281 |
revisions_in_entry = {revision: 0} |
| 282 |
|
| 260 |
entry_lines.append(line) |
283 |
entry_lines.append(line) |
|
|
284 |
if revisions_in_entry: |
| 285 |
revisions_in_entry[revision] = revisions_in_entry.get(revision, 0) + 1 |
| 286 |
|
| 287 |
most_probable_revision = max(revisions_in_entry, key=revisions_in_entry.__getitem__) if revisions_in_entry else None |
| 288 |
yield ChangeLogEntry(''.join(entry_lines[:-1]), revision=most_probable_revision) |
| 261 |
|
289 |
|
| 262 |
def latest_entry(self): |
290 |
def latest_entry(self): |
| 263 |
# ChangeLog files are always UTF-8, we read them in as such to support Reviewers with unicode in their names. |
291 |
# ChangeLog files are always UTF-8, we read them in as such to support Reviewers with unicode in their names. |