diff --git a/diff-trees.py b/diff-trees.py index be639b3..39c13eb 100644 --- a/diff-trees.py +++ b/diff-trees.py @@ -3,24 +3,24 @@ import urllib2 import simplejson import re +import math from datetime import datetime +import os -srcdir_1 = "./mozilla-central" -srcdir_2 = "./mozilla-aurora" -directory_of_interest_1a = "mobile/android" -directory_of_interest_2a = "mobile/android" -directory_of_interest_1b = "widget/src/android" -directory_of_interest_2b = "widget/android" -aurora_merge_date = datetime.strptime("2011-12-21", "%Y-%m-%d"); +srcdir_1 = "./mozilla-aurora" +srcdir_2 = "./mozilla-beta" +directories_of_interest = "mobile/android widget/src/android widget/android" +aurora_merge_date_str = "2011-12-21" +aurora_merge_date = datetime.strptime(aurora_merge_date_str, "%Y-%m-%d"); -srcdir_1_hash = {} -srcdir_2_hash = {} +landedBugs = {} +unlandedBugs = [] def getBugInfo(bug): try: - req = urllib2.Request("https://api-dev.bugzilla.mozilla.org/latest/bug/" + bug, - None, - {'user-agent':'dougt/rocks', 'Content-Type': 'application/json'}) + spec = "https://api-dev.bugzilla.mozilla.org/latest/bug/" + bug + print "Getting: " + spec + req = urllib2.Request(spec, None, {'user-agent':'dougt/rocks', 'Content-Type': 'application/json'}) opener = urllib2.build_opener() f = opener.open(req) result = simplejson.load(f) @@ -29,53 +29,69 @@ def getBugInfo(bug): return None try: if "not-fennec-11" in result['whiteboard']: - not11 = "true" + return None except KeyError: not11 = "false" return result['assigned_to']['real_name'], result['summary'], not11 except urllib2.HTTPError: return "Stuart", "I do not have a pony. See bug " + bug, "true" -def populateHash(srcdir, hashtable, dir_to_diff): - cmd = "hg log " + dir_to_diff +def getLandedBugs(srcdir, dirs_to_diff): + cmd = "hg log -d \">" + aurora_merge_date_str + "\" --template '{desc|firstline}\n' " + dirs_to_diff p = Popen(cmd, cwd=srcdir, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate() - - matches = re.findall(r'(summary:\s+.Bug )(\d+)', stdout) - for match in matches: - # do something with each found email string - hashtable[match[1]] = '1' + lines = stdout.splitlines() + for line in lines: + try: # if the bugNum isn't a number it'll throw + bugNum = int(line[4:10], 10) + print "bug number: " + str(bugNum) + landedBugs[bugNum] = True + except ValueError: + print "not a bug: " + line + + +def getUnlandedBugs(srcdir, dirs_to_diff): + cmd = "hg log -d \">" + aurora_merge_date_str + "\" --template '{rev}\t{node|short}\t{author}\t{desc|firstline}\n' " + dirs_to_diff + p = Popen(cmd, cwd=srcdir, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE) + stdout, stderr = p.communicate() + lines = stdout.splitlines() + for line in lines: + tmp = line.partition('\t') + rev = tmp[0] + remander = tmp[2].partition('\t') + changeset = remander[0] + remander2 = remander[2].partition('\t') + author = remander2[0] + summary = remander2[2] + try: # if the bugNum isn't a number it'll throw + bugNum = int(summary[4:10], 10) + print "bug num: " + str(bugNum) + if not landedBugs.has_key(bugNum): + tup = rev, bugNum, changeset, author, summary + unlandedBugs.append(tup) + except ValueError: + print "not a bug: " + summary print "updating source directories:" -subprocess.call(["hg", "pull", "-u"], cwd=srcdir_1) subprocess.call(["hg", "pull", "-u"], cwd=srcdir_2) - -print "collecting data about " + srcdir_1 -populateHash(srcdir_1, srcdir_1_hash, directory_of_interest_1a) -populateHash(srcdir_1, srcdir_1_hash, directory_of_interest_1b) +subprocess.call(["hg", "pull", "-u"], cwd=srcdir_1) print "collecting data about " + srcdir_2 -populateHash(srcdir_2, srcdir_2_hash, directory_of_interest_2a) -populateHash(srcdir_2, srcdir_2_hash, directory_of_interest_2b) - -print "checking to see what hasn't landed in " + srcdir_2 - -bugs_that_have_not_landed = []; -for index in enumerate(srcdir_1_hash): - #check to see if it is also in srcdir_2_hash, if not print it. - if (srcdir_2_hash.has_key(index[1]) == False): - bugs_that_have_not_landed.append(index[1]) +getLandedBugs(srcdir_2, directories_of_interest) +print "collecting data about " + srcdir_1 +getUnlandedBugs(srcdir_1, directories_of_interest) +print str(len(unlandedBugs)) + " havent' landed in " + srcdir_2 html_out =\ \ "