[gnome-continuous] Add 'ostbuild update indices' to regenerate indices



commit f3f8cb25a640b4872f119c4d1909d7c92a74157d
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Jul 28 00:43:05 2014 +0200

    Add 'ostbuild update indices' to regenerate indices
    
    To be able to retroactively have the revision => target map for
    older builds, add a new builtin that regenerates the index.json
    for each day. (It could also regenerate indices on higher levels
    if we extend those in the future - right now there is no reason
    to rebuild them, so we don't.)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=733838

 Makefile-ostbuild.am              |    1 +
 src/js/builtins/update_indices.js |   42 +++++++++++++++++++++++++++++++++++++
 src/js/main.js                    |    3 +-
 src/js/versioneddir.js            |   26 ++++++++++++++++++++++
 4 files changed, 71 insertions(+), 1 deletions(-)
---
diff --git a/Makefile-ostbuild.am b/Makefile-ostbuild.am
index b46ce63..bc435f0 100644
--- a/Makefile-ostbuild.am
+++ b/Makefile-ostbuild.am
@@ -86,6 +86,7 @@ jsostbuiltins_DATA= \
        src/js/builtins/qa_make_disk.js \
        src/js/builtins/run_task.js \
        src/js/builtins/shell.js \
+       src/js/builtins/update_indices.js \
        $(NULL)
 
 jsosttasksdir=$(jsostbuilddir)/tasks
diff --git a/src/js/builtins/update_indices.js b/src/js/builtins/update_indices.js
new file mode 100644
index 0000000..12a1b82
--- /dev/null
+++ b/src/js/builtins/update_indices.js
@@ -0,0 +1,42 @@
+// -*- indent-tabs-mode: nil; tab-width: 2; -*-
+// Copyright (C) 2013 Colin Walters <walters verbum org>
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the
+// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+const Lang = imports.lang;
+
+const Builtin = imports.builtin;
+const VersionedDir = imports.versioneddir;
+
+const UpdateIndices = new Lang.Class({
+    Name: 'UpdateIndices',
+    Extends: Builtin.Builtin,
+
+    DESCRIPTION: "Update all JSON indices",
+
+    _init: function() {
+        this.parent();
+    },
+
+    execute: function(args, loop, cancellable) {
+             this._initWorkdir(null, cancellable);
+
+        let buildsDir = new VersionedDir.VersionedDir(this.workdir.get_child('builds'));
+        buildsDir.updateAllIndices(cancellable);
+
+        return true;
+    }
+});
diff --git a/src/js/main.js b/src/js/main.js
index 2d7f5d7..5e2d343 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -25,7 +25,8 @@ const BUILTINS = ['autobuilder',
                   'make',
                   'qa-make-disk',
                   'run-task',
-                  'shell'];
+                  'shell',
+                  'update-indices'];
 
 function getModule(unixName) {
     return imports.builtins[unixName.replace(/-/g, '_')];
diff --git a/src/js/versioneddir.js b/src/js/versioneddir.js
index 47dde51..d2a97bd 100644
--- a/src/js/versioneddir.js
+++ b/src/js/versioneddir.js
@@ -237,5 +237,31 @@ const VersionedDir = new Lang.Class({
         let path = this.createPathForVersion(version);
        let parent = path.get_parent();
         this._updateIndex(parent, true, cancellable);
+    },
+
+    _updateIndicesTargetsYear: function(yeardir, cancellable) {
+       this._iterateChildrenMatching(yeardir, this._MONTH_OR_DAY_VERSION_RE,
+                                     Lang.bind(this, function(srcpath, match, cancellable) {
+                                         this._updateIndicesTargetsMonth(srcpath, cancellable);
+                                     }), cancellable);
+    },
+
+    _updateIndicesTargetsMonth: function(monthdir, cancellable) {
+       this._iterateChildrenMatching(monthdir, this._MONTH_OR_DAY_VERSION_RE,
+                                     Lang.bind(this, function(srcpath, match, cancellable) {
+                                         this._updateIndicesTargetsDay(srcpath, cancellable);
+                                     }), cancellable);
+    },
+
+    _updateIndicesTargetsDay: function(daydir, cancellable) {
+       print("Updating index for " + this.path.get_relative_path(daydir));
+        this._updateIndex(daydir, true, cancellable);
+    },
+
+    updateAllIndices: function(cancellable) {
+       this._iterateChildrenMatching(this.path, this._YEAR_OR_SERIAL_VERSION_RE,
+                                     Lang.bind(this, function(srcpath, match, cancellable) {
+                                         this._updateIndicesTargetsYear(srcpath, cancellable);
+                                     }), cancellable);
     }
 });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]