[jhbuild] replace the "force_checkout" label by "wipe directory and start over"



commit 8cefae68f49f7bbf9f59e8a9330b2ac4d805001d
Author: Frédéric Péters <fpeters 0d be>
Date:   Sun Jul 19 16:13:24 2009 +0200

    replace the "force_checkout" label by "wipe directory and start over"
    
    This makes the effect of the option clearer, and won't disturb git users
    that expects "checkout" to mean something else. (GNOME bug 582446)

 jhbuild/frontends/gtkui.py     |    6 ++++-
 jhbuild/frontends/terminal.py  |    6 ++++-
 jhbuild/modtypes/__init__.py   |   53 +++++++++++++++++++++++++--------------
 jhbuild/modtypes/ant.py        |   20 +++------------
 jhbuild/modtypes/autotools.py  |   17 +++----------
 jhbuild/modtypes/cmake.py      |   17 +++----------
 jhbuild/modtypes/distutils.py  |   17 +++----------
 jhbuild/modtypes/perl.py       |   17 +++----------
 jhbuild/modtypes/testmodule.py |   21 ++++-----------
 jhbuild/modtypes/waf.py        |   17 +++----------
 10 files changed, 74 insertions(+), 117 deletions(-)
---
diff --git a/jhbuild/frontends/gtkui.py b/jhbuild/frontends/gtkui.py
index 1b9ff9f..ba7c340 100644
--- a/jhbuild/frontends/gtkui.py
+++ b/jhbuild/frontends/gtkui.py
@@ -400,8 +400,12 @@ class AppWindow(gtk.Window, buildscript.BuildScript):
         self.error_resolution_model.append(
                 (_('Give up on module'), 'fail'))
         for altphase in altphases:
+            try:
+                altphase_label = _(getattr(getattr(module, 'do_' + altphase), 'label'))
+            except AttributeError:
+                altphase_label = altphase
             self.error_resolution_model.append(
-                    (_('Go to stage %s') % altphase, altphase))
+                    (_('Go to phase "%s"') % altphase_label, altphase))
         self.error_resolution_model.append(('', ''))
         self.error_resolution_model.append(
                 (_('Open Terminal'), 'shell'))
diff --git a/jhbuild/frontends/terminal.py b/jhbuild/frontends/terminal.py
index 77a11b8..07fa57f 100644
--- a/jhbuild/frontends/terminal.py
+++ b/jhbuild/frontends/terminal.py
@@ -288,7 +288,11 @@ class TerminalBuildScript(buildscript.BuildScript):
             uprint('  [5] %s' % _('Reload configuration'))
             nb_options = i = 6
             for altphase in altphases:
-                uprint('  [%d] %s' % (i, _('Go to phase %s') % altphase))
+                try:
+                    altphase_label = _(getattr(getattr(module, 'do_' + altphase), 'label'))
+                except AttributeError:
+                    altphase_label = altphase
+                uprint('  [%d] %s' % (i, _('Go to phase "%s"') % altphase_label))
                 i += 1
             val = raw_input(uencode(_('choice: ')))
             val = val.strip()
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index bb90506..2f5761b 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -195,25 +195,6 @@ class Package:
                         _('Skipping %s (package and dependencies not updated)') % self.name)
                 return self.PHASE_DONE
 
-    def checkout(self, buildscript):
-        srcdir = self.get_srcdir(buildscript)
-        buildscript.set_action(_('Checking out'), self)
-        self.branch.checkout(buildscript)
-        # did the checkout succeed?
-        if not os.path.exists(srcdir):
-            raise BuildStateError(_('source directory %s was not created') % srcdir)
-
-        if self.check_build_policy(buildscript) == self.PHASE_DONE:
-            raise SkipToEnd()
-
-    def skip_checkout(self, buildscript, last_phase):
-        # skip the checkout stage if the nonetwork flag is set
-        if not self.branch.may_checkout(buildscript):
-            if self.check_build_policy(buildscript) == self.PHASE_DONE:
-                raise SkipToEnd()
-            return True
-        return False
-
     def xml_tag_and_attrs(self):
         """Return a (tag, attrs) pair, describing how to serialize this
         module.
@@ -253,6 +234,40 @@ class Package:
         return self.branch.to_sxml()
 
 
+class DownloadableModule():
+    PHASE_CHECKOUT = 'checkout'
+    PHASE_FORCE_CHECKOUT = 'force_checkout'
+
+    def do_checkout(self, buildscript):
+        self.checkout(buildscript)
+    do_checkout.error_phases = [PHASE_FORCE_CHECKOUT]
+
+    def checkout(self, buildscript):
+        srcdir = self.get_srcdir(buildscript)
+        buildscript.set_action(_('Checking out'), self)
+        self.branch.checkout(buildscript)
+        # did the checkout succeed?
+        if not os.path.exists(srcdir):
+            raise BuildStateError(_('source directory %s was not created') % srcdir)
+
+        if self.check_build_policy(buildscript) == self.PHASE_DONE:
+            raise SkipToEnd()
+
+    def skip_checkout(self, buildscript, last_phase):
+        # skip the checkout stage if the nonetwork flag is set
+        if not self.branch.may_checkout(buildscript):
+            if self.check_build_policy(buildscript) == self.PHASE_DONE:
+                raise SkipToEnd()
+            return True
+        return False
+
+    def do_force_checkout(self, buildscript):
+        buildscript.set_action(_('Checking out'), self)
+        self.branch.force_checkout(buildscript)
+    do_force_checkout.error_phases = [PHASE_FORCE_CHECKOUT]
+    do_force_checkout.label = N_('wipe directory and start over')
+
+
 class MetaModule(Package):
     """A simple module type that consists only of dependencies."""
     type = 'meta'
diff --git a/jhbuild/modtypes/ant.py b/jhbuild/modtypes/ant.py
index b662711..d498bbc 100644
--- a/jhbuild/modtypes/ant.py
+++ b/jhbuild/modtypes/ant.py
@@ -24,17 +24,17 @@ import os
 
 from jhbuild.errors import BuildStateError, CommandError
 from jhbuild.modtypes import \
-     Package, get_dependencies, get_branch, register_module_type
+     Package, DownloadableModule, get_dependencies, get_branch, register_module_type
 from jhbuild.commands.sanitycheck import inpath
 
 __all__ = [ 'AntModule' ]
 
-class AntModule(Package):
+class AntModule(Package, DownloadableModule):
     """Base type for modules that are built with Ant."""
     type = 'ant'
 
-    PHASE_CHECKOUT = 'checkout'
-    PHASE_FORCE_CHECKOUT = 'force_checkout'
+    PHASE_CHECKOUT = DownloadableModule.PHASE_CHECKOUT
+    PHASE_FORCE_CHECKOUT = DownloadableModule.PHASE_FORCE_CHECKOUT
     PHASE_BUILD = 'build'
     PHASE_INSTALL = 'install'
 
@@ -59,18 +59,6 @@ class AntModule(Package):
     def get_revision(self):
         return self.branch.branchname
 
-    def do_checkout(self, buildscript):
-        self.checkout(buildscript)
-    do_checkout.error_phases = [PHASE_FORCE_CHECKOUT]
-
-    def skip_force_checkout(self, buildscript, last_phase):
-        return False
-
-    def do_force_checkout(self, buildscript):
-        buildscript.set_action(_('Checking out'), self)
-        self.branch.force_checkout(buildscript)
-    do_force_checkout.error_phases = [PHASE_FORCE_CHECKOUT]
-
     def do_build(self, buildscript):
         buildscript.set_action(_('Building'), self)
         srcdir = self.get_srcdir(buildscript)
diff --git a/jhbuild/modtypes/autotools.py b/jhbuild/modtypes/autotools.py
index 4be49a3..f55c15f 100644
--- a/jhbuild/modtypes/autotools.py
+++ b/jhbuild/modtypes/autotools.py
@@ -26,18 +26,18 @@ import stat
 
 from jhbuild.errors import FatalError, BuildStateError, CommandError
 from jhbuild.modtypes import \
-     Package, get_dependencies, get_branch, register_module_type
+     Package, DownloadableModule, get_dependencies, get_branch, register_module_type
 
 __all__ = [ 'AutogenModule' ]
 
-class AutogenModule(Package):
+class AutogenModule(Package, DownloadableModule):
     '''Base type for modules that are distributed with a Gnome style
     "autogen.sh" script and the GNU build tools.  Subclasses are
     responsible for downloading/updating the working copy.'''
     type = 'autogen'
 
-    PHASE_CHECKOUT       = 'checkout'
-    PHASE_FORCE_CHECKOUT = 'force_checkout'
+    PHASE_CHECKOUT = DownloadableModule.PHASE_CHECKOUT
+    PHASE_FORCE_CHECKOUT = DownloadableModule.PHASE_FORCE_CHECKOUT
     PHASE_CLEAN          = 'clean'
     PHASE_DISTCLEAN      = 'distclean'
     PHASE_CONFIGURE      = 'configure'
@@ -81,15 +81,6 @@ class AutogenModule(Package):
     def get_revision(self):
         return self.branch.tree_id()
 
-    def do_checkout(self, buildscript):
-        self.checkout(buildscript)
-    do_checkout.error_phases = [PHASE_FORCE_CHECKOUT]
-
-    def do_force_checkout(self, buildscript):
-        buildscript.set_action(_('Checking out'), self)
-        self.branch.force_checkout(buildscript)
-    do_force_checkout.error_phases = [PHASE_FORCE_CHECKOUT]
-
     def skip_configure(self, buildscript, last_phase):
         # skip if manually instructed to do so
         if self.skip_autogen is True:
diff --git a/jhbuild/modtypes/cmake.py b/jhbuild/modtypes/cmake.py
index 421be2d..d91fde8 100644
--- a/jhbuild/modtypes/cmake.py
+++ b/jhbuild/modtypes/cmake.py
@@ -23,16 +23,16 @@ import os
 
 from jhbuild.errors import BuildStateError
 from jhbuild.modtypes import \
-     Package, get_dependencies, get_branch, register_module_type
+     Package, DownloadableModule, get_dependencies, get_branch, register_module_type
 
 __all__ = [ 'CMakeModule' ]
 
-class CMakeModule(Package):
+class CMakeModule(Package, DownloadableModule):
     """Base type for modules that use CMake build system."""
     type = 'cmake'
 
-    PHASE_CHECKOUT = 'checkout'
-    PHASE_FORCE_CHECKOUT = 'force_checkout'
+    PHASE_CHECKOUT = DownloadableModule.PHASE_CHECKOUT
+    PHASE_FORCE_CHECKOUT = DownloadableModule.PHASE_FORCE_CHECKOUT
     PHASE_CONFIGURE = 'configure'
     PHASE_BUILD = 'build'
     PHASE_DIST = 'dist'
@@ -56,15 +56,6 @@ class CMakeModule(Package):
     def get_revision(self):
         return self.branch.tree_id()
 
-    def do_checkout(self, buildscript):
-        self.checkout(buildscript)
-    do_checkout.error_phases = [PHASE_FORCE_CHECKOUT]
-
-    def do_force_checkout(self, buildscript):
-        buildscript.set_action(_('Checking out'), self)
-        self.branch.force_checkout(buildscript)
-    do_force_checkout.error_phases = [PHASE_FORCE_CHECKOUT]
-
     def skip_configure(self, buildscript, last_phase):
         return buildscript.config.nobuild
     
diff --git a/jhbuild/modtypes/distutils.py b/jhbuild/modtypes/distutils.py
index b39f151..455cbca 100644
--- a/jhbuild/modtypes/distutils.py
+++ b/jhbuild/modtypes/distutils.py
@@ -23,17 +23,17 @@ import os
 
 from jhbuild.errors import BuildStateError
 from jhbuild.modtypes import \
-     Package, get_dependencies, get_branch, register_module_type
+     Package, DownloadableModule, get_dependencies, get_branch, register_module_type
 
 __all__ = [ 'DistutilsModule' ]
 
-class DistutilsModule(Package):
+class DistutilsModule(Package, DownloadableModule):
     """Base type for modules that are distributed with a Python
     Distutils style setup.py."""
     type = 'distutils'
 
-    PHASE_CHECKOUT = 'checkout'
-    PHASE_FORCE_CHECKOUT = 'force_checkout'
+    PHASE_CHECKOUT = DownloadableModule.PHASE_CHECKOUT
+    PHASE_FORCE_CHECKOUT = DownloadableModule.PHASE_FORCE_CHECKOUT
     PHASE_BUILD = 'build'
     PHASE_INSTALL = 'install'
 
@@ -58,15 +58,6 @@ class DistutilsModule(Package):
     def get_revision(self):
         return self.branch.tree_id()
 
-    def do_checkout(self, buildscript):
-        self.checkout(buildscript)
-    do_checkout.error_phases = [PHASE_FORCE_CHECKOUT]
-
-    def do_force_checkout(self, buildscript):
-        buildscript.set_action(_('Checking out'), self)
-        self.branch.force_checkout(buildscript)
-    do_force_checkout.error_phase = [PHASE_FORCE_CHECKOUT]
-
     def do_build(self, buildscript):
         buildscript.set_action(_('Building'), self)
         srcdir = self.get_srcdir(buildscript)
diff --git a/jhbuild/modtypes/perl.py b/jhbuild/modtypes/perl.py
index 2efea1e..ca9eb13 100644
--- a/jhbuild/modtypes/perl.py
+++ b/jhbuild/modtypes/perl.py
@@ -24,17 +24,17 @@ import re
 
 from jhbuild.errors import BuildStateError
 from jhbuild.modtypes import \
-     Package, get_dependencies, get_branch, register_module_type
+     Package, DownloadableModule, get_dependencies, get_branch, register_module_type
 
 __all__ = [ 'PerlModule' ]
 
-class PerlModule(Package):
+class PerlModule(Package, DownloadableModule):
     """Base type for modules that are distributed with a Perl style
     "Makefile.PL" Makefile."""
     type = 'perl'
 
-    PHASE_CHECKOUT = 'checkout'
-    PHASE_FORCE_CHECKOUT = 'force_checkout'
+    PHASE_CHECKOUT = DownloadableModule.PHASE_CHECKOUT
+    PHASE_FORCE_CHECKOUT = DownloadableModule.PHASE_FORCE_CHECKOUT
     PHASE_BUILD = 'build'
     PHASE_INSTALL = 'install'
 
@@ -54,15 +54,6 @@ class PerlModule(Package):
     def get_revision(self):
         return self.branch.branchname
 
-    def do_checkout(self, buildscript):
-        self.checkout(buildscript)
-    do_checkout.error_phases = [PHASE_FORCE_CHECKOUT]
-
-    def do_force_checkout(self, buildscript):
-        buildscript.set_action(_('Checking out'), self)
-        self.branch.force_checkout(buildscript)
-    do_force_checkout.error_phases = [PHASE_FORCE_CHECKOUT]
-
     def do_build(self, buildscript):
         buildscript.set_action(_('Building'), self)
         builddir = self.get_builddir(buildscript)
diff --git a/jhbuild/modtypes/testmodule.py b/jhbuild/modtypes/testmodule.py
index 598586d..d47e568 100644
--- a/jhbuild/modtypes/testmodule.py
+++ b/jhbuild/modtypes/testmodule.py
@@ -23,7 +23,7 @@ import os, time, signal, sys, subprocess, random, md5, tempfile
 
 from jhbuild.errors import FatalError, CommandError, BuildStateError
 from jhbuild.modtypes import \
-     Package, get_dependencies, get_branch, register_module_type
+     Package, DownloadableModule, get_dependencies, get_branch, register_module_type
 from jhbuild.modtypes.autotools import AutogenModule
 
 import xml.dom.minidom
@@ -31,12 +31,12 @@ import xml.dom.minidom
 __all__ = ['TestModule']
 __test_types__ = ['ldtp' , 'dogtail']
 
-class TestModule(Package):
+class TestModule(Package, DownloadableModule):
     type = 'test'
     
-    STATE_CHECKOUT       = 'checkout'
-    STATE_FORCE_CHECKOUT = 'force_checkout'
-    STATE_TEST           = 'test'
+    PHASE_CHECKOUT = DownloadableModule.PHASE_CHECKOUT
+    PHASE_FORCE_CHECKOUT = DownloadableModule.PHASE_FORCE_CHECKOUT
+    PHASE_TEST           = 'test'
     
     def __init__(self, name, branch, test_type, dependencies=[], after=[], tested_pkgs=[]):
         Package.__init__(self, name)
@@ -58,15 +58,6 @@ class TestModule(Package):
     def get_revision(self):
         return self.branch.branchname
 
-    def do_checkout(self, buildscript):
-        self.checkout(buildscript)
-    do_checkout.error_phases = [STATE_FORCE_CHECKOUT]
-        
-    def do_force_checkout(self, buildscript):
-        buildscript.set_action('Checking out', self)
-        self.branch.force_checkout(buildscript)
-    do_force_checkout.error_phases = [STATE_FORCE_CHECKOUT]
-
     def _get_display(self):
         # get free display
         servernum = 99
@@ -125,7 +116,7 @@ class TestModule(Package):
                     os.environ['XAUTHORITY'] = old_xauth
                 else:
                     os.unsetenv('XAUTHORITY')
-    do_test.depends = [STATE_CHECKOUT]
+    do_test.depends = [PHASE_CHECKOUT]
 
     def get_ldtp_log_file(self, filename):
         # <ldtp>
diff --git a/jhbuild/modtypes/waf.py b/jhbuild/modtypes/waf.py
index e01dc52..c6012a3 100644
--- a/jhbuild/modtypes/waf.py
+++ b/jhbuild/modtypes/waf.py
@@ -26,17 +26,17 @@ import re
 
 from jhbuild.errors import FatalError, BuildStateError, CommandError
 from jhbuild.modtypes import \
-     Package, get_dependencies, get_branch, register_module_type
+     Package, DownloadableModule, get_dependencies, get_branch, register_module_type
 from jhbuild.commands.sanitycheck import inpath
 
 __all__ = [ 'WafModule' ]
 
-class WafModule(Package):
+class WafModule(Package, DownloadableModule):
     '''Base type for modules that are distributed with a WAF script.'''
     type = 'waf'
 
-    PHASE_CHECKOUT       = 'checkout'
-    PHASE_FORCE_CHECKOUT = 'force_checkout'
+    PHASE_CHECKOUT = DownloadableModule.PHASE_CHECKOUT
+    PHASE_FORCE_CHECKOUT = DownloadableModule.PHASE_FORCE_CHECKOUT
     PHASE_CLEAN          = 'clean'
     PHASE_CONFIGURE      = 'configure'
     PHASE_BUILD          = 'build'
@@ -59,15 +59,6 @@ class WafModule(Package):
     def get_revision(self):
         return self.branch.tree_id()
 
-    def do_checkout(self, buildscript):
-        self.checkout(buildscript)
-    do_checkout.error_phases = [PHASE_FORCE_CHECKOUT]
-
-    def do_force_checkout(self, buildscript):
-        buildscript.set_action(_('Checking out'), self)
-        self.branch.force_checkout(buildscript)
-    do_force_checkout.error_phases = [PHASE_FORCE_CHECKOUT]
-
     def skip_configure(self, buildscript, last_phase):
         # don't skip this stage if we got here from one of the
         # following phases:



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