# HG changeset patch # User Jeff Hammel # Date 1380370214 25200 # Node ID 7ae60d2ff1c217a463ca87194544997b926d3cc9 # Parent 08dd6fbbec3a91724718e30ae13f8c0e9f0bc878 commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff diff -r 08dd6fbbec3a -r 7ae60d2ff1c2 commitwatcher/agent.py --- a/commitwatcher/agent.py Fri Sep 27 14:23:53 2013 -0700 +++ b/commitwatcher/agent.py Sat Sep 28 05:10:14 2013 -0700 @@ -3,6 +3,7 @@ """ import feedparser +from abc import abstractmethod from .commit import Commit from .store import MemoryStore @@ -38,10 +39,30 @@ feed = feedparser.parse(self.feed()) for entry in feed['entries']: - # get paths from diff link = entry['link'] - print link files = self.files(link) # TODO # TODO commit = Commit() + +class FeedAgentDiff(FeedAgent): + """read files from diff""" + + def diff_url(self, link): + """ + returns diff_url from revision link: + + >>> diff_url('http://hg.mozilla.org/mozilla-central/rev/4e1a3919e741') + 'http://hg.mozilla.org/mozilla-central/raw-rev/4e1a3919e741' + """ + return '/raw-rev/'.join(link.rsplit('/rev/', 1)) + + def files(self, revision): + """ + revision -- revision link + """ + + raw_rev = self.diff_url(revision) + print raw_rev + + # get paths from diff diff -r 08dd6fbbec3a -r 7ae60d2ff1c2 mozbasewatcher.py --- a/mozbasewatcher.py Fri Sep 27 14:23:53 2013 -0700 +++ b/mozbasewatcher.py Sat Sep 28 05:10:14 2013 -0700 @@ -9,7 +9,7 @@ import optparse import os import sys -from commitwatcher import FeedAgent +from commitwatcher import FeedAgentDiff def main(args=sys.argv[1:]): @@ -20,7 +20,7 @@ # watch mozilla-central repo = 'http://hg.mozilla.org/mozilla-central' - watcher = FeedAgent(repository=repo) + watcher = FeedAgentDiff(repository=repo) watcher.update() if __name__ == '__main__': diff -r 08dd6fbbec3a -r 7ae60d2ff1c2 tests/41701d2c0341.diff --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/41701d2c0341.diff Sat Sep 28 05:10:14 2013 -0700 @@ -0,0 +1,68 @@ + +# HG changeset patch +# User Raymond Lee +# Date 1380236746 -28800 +# Node ID 41701d2c03414fb308a4233f5f69a0416008bf9c +# Parent a00aba84b699ea26bc3e90428938124d8dae6d26 +Bug 875731 - Replace callers of nsIDownloadManager.usersDownloadsDirectory with Downloads.getUserDownloadsDirectory mobile/andriod/. r=mfinkle + +diff --git a/mobile/android/components/HelperAppDialog.js b/mobile/android/components/HelperAppDialog.js +--- a/mobile/android/components/HelperAppDialog.js ++++ b/mobile/android/components/HelperAppDialog.js +@@ -8,16 +8,21 @@ const Cu = Components.utils; + const Cr = Components.results; + + const PREF_BD_USEDOWNLOADDIR = "browser.download.useDownloadDir"; + const URI_GENERIC_ICON_DOWNLOAD = "drawable://alert_download"; + + Cu.import("resource://gre/modules/XPCOMUtils.jsm"); + Cu.import("resource://gre/modules/Services.jsm"); + ++XPCOMUtils.defineLazyModuleGetter(this, "Downloads", ++ "resource://gre/modules/Downloads.jsm"); ++XPCOMUtils.defineLazyModuleGetter(this, "Task", ++ "resource://gre/modules/Task.jsm"); ++ + // ----------------------------------------------------------------------- + // HelperApp Launcher Dialog + // ----------------------------------------------------------------------- + + function HelperAppLauncherDialog() { } + + HelperAppLauncherDialog.prototype = { + classID: Components.ID("{e9d277a0-268a-4ec2-bb8c-10fdf3e44611}"), +@@ -25,25 +30,26 @@ HelperAppLauncherDialog.prototype = { + + show: function hald_show(aLauncher, aContext, aReason) { + // Save everything by default + aLauncher.MIMEInfo.preferredAction = Ci.nsIMIMEInfo.useSystemDefault; + aLauncher.saveToDisk(null, false); + }, + + promptForSaveToFile: function hald_promptForSaveToFile(aLauncher, aContext, aDefaultFile, aSuggestedFileExt, aForcePrompt) { +- // Retrieve the user's default download directory +- let dnldMgr = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager); +- let defaultFolder = dnldMgr.userDownloadsDirectory; ++ return Task.spawn(function() { ++ // Retrieve the user's default download directory ++ let defaultFolder = yield Downloads.getPreferredDownloadsDirectory(); + +- try { +- file = this.validateLeafName(defaultFolder, aDefaultFile, aSuggestedFileExt); +- } catch (e) { } ++ try { ++ file = this.validateLeafName(defaultFolder, aDefaultFile, aSuggestedFileExt); ++ } catch (e) { } + +- return file; ++ throw new Task.Result(file); ++ }.bind(this)); + }, + + validateLeafName: function hald_validateLeafName(aLocalFile, aLeafName, aFileExt) { + if (!(aLocalFile && this.isUsableDirectory(aLocalFile))) + return null; + + // Remove any leading periods, since we don't want to save hidden files + // automatically. +