[jhbuild] Correct min-age option and docs (GNOME bug 634866 and 634867)



commit 06b0e5bc2d02c181b0feafd2bbd446bb1f6e4a7f
Author: Craig Keogh <cskeogh adam com au>
Date:   Wed Dec 1 21:05:31 2010 +1030

    Correct min-age option and docs (GNOME bug 634866 and 634867)
    
    Based upon patch by Adam Dingle

 README                           |    4 ++--
 doc/C/jhbuild.xml                |    4 ++--
 jhbuild/config.py                |   12 +++++++-----
 jhbuild/defaults.jhbuildrc       |    8 ++++----
 jhbuild/frontends/buildscript.py |    4 ++--
 tests/mock.py                    |    2 +-
 6 files changed, 18 insertions(+), 16 deletions(-)
---
diff --git a/README b/README
index 3b95f0a..ed19489 100644
--- a/README
+++ b/README
@@ -126,11 +126,11 @@ jhbuild build [--autogen] [--clean] [--dist] [--distcheck]
   build the module. This option forces JHBuild to build optional
   dependencies.
 
-  --min-time=time
+  --min-age=time
   Skip modules installed more recently than the specified relative
   time. The time string format is a number followed by a unit. The
   following units are supported: seconds (s), minutes (m), hours (h)
-  and days (d). For example, --min-time=2h will skip modules built
+  and days (d). For example, --min-age=2h will skip modules built
   less than two hours ago.
 
 jhbuild buildone [--autogen] [--clean] [--distcheck] [--no-network]
diff --git a/doc/C/jhbuild.xml b/doc/C/jhbuild.xml
index 95a4d2c..19d3e17 100644
--- a/doc/C/jhbuild.xml
+++ b/doc/C/jhbuild.xml
@@ -1035,14 +1035,14 @@ jhbuildbot_password = 'password'
 	</varlistentry>
 
     <varlistentry>
-      <term><option>--min-time</option>=<replaceable>time</replaceable></term>
+      <term><option>--min-age</option>=<replaceable>time</replaceable></term>
       <listitem>
         <simpara>Skip modules installed more recently than the
         specified relative time. The <replaceable>time</replaceable>
         string format is a number followed by a unit. The
         following units are supported: seconds (s), minutes (m),
         hours (h) and days (d). For example,
-        <option>--min-time=2h</option> will skip modules built less
+        <option>--min-age=2h</option> will skip modules built less
         than two hours ago.</simpara>
       </listitem>
     </varlistentry>
diff --git a/jhbuild/config.py b/jhbuild/config.py
index 1565568..26b53f7 100644
--- a/jhbuild/config.py
+++ b/jhbuild/config.py
@@ -19,8 +19,10 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 import os
+import re
 import sys
 import traceback
+import time
 import types
 import logging
 import __builtin__
@@ -47,7 +49,7 @@ _known_keys = [ 'moduleset', 'modules', 'skip', 'tags', 'prefix',
                 'tarballdir', 'pretty_print', 'svn_program', 'makedist',
                 'makedistcheck', 'nonotify', 'notrayicon', 'cvs_program',
                 'checkout_mode', 'copy_dir', 'module_checkout_mode',
-                'build_policy', 'trycheckout', 'min_time',
+                'build_policy', 'trycheckout', 'min_age',
                 'nopoison', 'module_nopoison', 'forcecheck',
                 'makecheck_advisory', 'quiet_mode', 'progress_bar',
                 'module_extra_env', 'jhbuildbot_master', 'jhbuildbot_slavename',
@@ -135,7 +137,7 @@ def parse_relative_time(s):
         coeffs = {'s': 1, 'm': 60, 'h': 3600, 'd': 86400, 'w':7*86400}
         return float(m.group(1)) * coeffs[m.group(2)]
     else:
-        raise ValueError(_('unable to parse \'%s\' as relative time.') % s)
+        raise ValueError
 
 
 class Config:
@@ -542,10 +544,10 @@ class Config:
             self.build_policy = 'all'
         if hasattr(options, 'min_age') and options.min_age:
             try:
-                self.min_time = time.time() - parse_relative_time(options.min_age)
+                self.min_age = time.time() - parse_relative_time(options.min_age)
             except ValueError:
-                raise FatalError(_('Failed to parse relative time'))
-
+                raise FatalError(_('Failed to parse \'min_age\' relative '
+                                   'time'))
 
     def __setattr__(self, k, v):
         '''Override __setattr__ for additional checks on some options.'''
diff --git a/jhbuild/defaults.jhbuildrc b/jhbuild/defaults.jhbuildrc
index 6563f75..fe31688 100644
--- a/jhbuild/defaults.jhbuildrc
+++ b/jhbuild/defaults.jhbuildrc
@@ -21,10 +21,10 @@ modules = [ 'meta-gnome-core' ]
 #    have changed.
 build_policy = 'updated-deps'
 
-# skip modules installed before $min_time (in seconds since epoch)
-# for example: min_time = time.time() - 3600 will skip modules that
-# have been installed less than one hour ago.
-min_time = None
+# Skip modules installed more recently than the specified relative time.
+# min_age can only be specified via the command-line. Setting min_age within
+# the configuration file has no effect.
+min_age = None
 
 # modules to skip during dependency expansion
 skip = []
diff --git a/jhbuild/frontends/buildscript.py b/jhbuild/frontends/buildscript.py
index 20118b2..747d9ce 100644
--- a/jhbuild/frontends/buildscript.py
+++ b/jhbuild/frontends/buildscript.py
@@ -81,9 +81,9 @@ class BuildScript:
         for module in self.modulelist:
             self.module_num = self.module_num + 1
 
-            if self.config.min_time is not None:
+            if self.config.min_age is not None:
                 installdate = self.packagedb.installdate(module.name)
-                if installdate > self.config.min_time:
+                if installdate > self.config.min_age:
                     self.message(_('Skipping %s (installed recently)') % module.name)
                     continue
 
diff --git a/tests/mock.py b/tests/mock.py
index 4c1d124..3913afa 100644
--- a/tests/mock.py
+++ b/tests/mock.py
@@ -52,7 +52,7 @@ class Config(jhbuild.config.Config):
     module_makeargs = {}
     build_targets = ['install']
 
-    min_time = None
+    min_age = None
 
     prefix = '/tmp/'
 



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