]> scripts.mit.edu Git - wizard.git/commitdiff
Hookify research interface.
authorEdward Z. Yang <ezyang@mit.edu>
Tue, 22 Dec 2009 18:36:22 +0000 (13:36 -0500)
committerEdward Z. Yang <ezyang@mit.edu>
Tue, 22 Dec 2009 18:36:22 +0000 (13:36 -0500)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
wizard/app/__init__.py
wizard/app/mediawiki.py
wizard/command/research.py

index a40ff04debd06810cf2f0c7b73522f247a036784..17d4f92ab75071782c643a40d0ee87634fac9e20 100644 (file)
@@ -377,6 +377,23 @@ class Application(object):
         # bogus config files in the -scripts versions of installs.  Maybe
         # we should check a hash or something?
         raise NotImplementedError
+    def researchFilter(self, filename, added, deleted):
+        """
+        Allows an application to selectively ignore certain diffstat signatures
+        during research; for example, configuration files will have a very
+        specific set of changes, so ignore them; certain installation files
+        may be removed, etc.  Return ``True`` if a diffstat signature should be
+        ignored,
+        """
+        return False
+    def researchVerbose(self, filename):
+        """
+        Allows an application to exclude certain dirty files from the output
+        report; usually this will just be parametrized files, since those are
+        guaranteed to have changes.  Return ``True`` if a file should only
+        be displayed in verbose mode.
+        """
+        return filename in self.parametrized_files
     @staticmethod
     def make(name):
         """Makes an application, but uses the correct subtype if available."""
index b676b9fac457069b973b5b5c3e22457b3270d185..9d0468411636be48589753b713dcb99999f9e523 100644 (file)
@@ -87,6 +87,14 @@ class Application(app.Application):
         app.restore_database(backup_dir, deployment)
     def remove(self, deployment, options):
         app.remove_database(deployment)
+    def researchFilter(self, filename, added, deleted):
+        if filename == "LocalSettings.php":
+            return added == deleted == 10 or added == deleted == 9
+        elif filename == "AdminSettings.php":
+            return added == 0 and deleted == 20
+        elif filename == "config/index.php" or filename == "config/index.php5":
+            return added == 0
+        return False
 
 Application.resolutions = {
 'LocalSettings.php': [
index add825b44e8278fae20738e19fc46ffd7a22902c..a95c32fcd07f7333a7f11600c6d51b9ca6cb9dc9 100644 (file)
@@ -3,10 +3,12 @@ import traceback
 import itertools
 import random
 
-from wizard import command, deploy, shell, util
+from wizard import app, command, deploy, shell, util
 
 def main(argv, baton):
     options, show = parse_args(argv, baton)
+    appname = show[0]
+    application = app.applications()[appname]
     sh = shell.Shell()
     deploys = deploy.parse_install_lines(show, options.versions_path)
     stats = {}
@@ -35,19 +37,7 @@ def main(argv, baton):
                         if deleted == '-': continue
                         added = int(added)
                         deleted = int(deleted)
-                        # hook
-                        if filename == "LocalSettings.php":
-                            if added == deleted == 10:
-                                continue
-                            elif added == deleted == 9:
-                                continue
-                        elif filename == "AdminSettings.php":
-                            if added == 0 and deleted == 20:
-                                continue
-                        elif filename == "config/index.php" or filename == "config/index.php5":
-                            if added == 0:
-                                continue
-                        if not added and not deleted:
+                        if not added and not deleted or application.researchFilter(filename, added, deleted):
                             continue
                         results.append((added,deleted,filename))
                     if len(results) > options.filter:
@@ -59,8 +49,7 @@ def main(argv, baton):
                     for added,deleted,filename in results:
                         stats.setdefault(filename, 0)
                         stats[filename] += 1
-                        # hook
-                        if filename == "LocalSettings.php" and not options.verbose:
+                        if application.researchVerbose(filename) and not options.verbose:
                             continue
                         print "%-7d %-7d %s/%s" % (added,deleted,d.location,filename)
             except (deploy.NotConfiguredError, deploy.NotMigratedError):