changeset 489:417b2fd694df

Applying patch bitten-284.diff from Emmanuel Blot. Thanks for the patch. Closes #284.
author wbell
date Sun, 11 May 2008 19:38:55 +0000
parents 9b3d97297201
children 5c6c56fbd9d7
files bitten/build/shtools.py bitten/build/svntools.py
diffstat 2 files changed, 24 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/build/shtools.py
+++ b/bitten/build/shtools.py
@@ -68,7 +68,7 @@
                    % (executable or file_, returncode))
 
 def execute(ctxt, executable=None, file_=None, input_=None, output=None,
-            args=None, dir_=None):
+            args=None, dir_=None, filter_=None):
     """Generic external program execution.
     
     This function is not itself bound to a recipe command, but rather used from
@@ -84,6 +84,8 @@
     :param output: name of the file to which the output of the script should be
                    written
     :param args: command-line arguments to pass to the script
+    :param dirs:
+    :param filter\_: function to filter out messages from the executable stdout
     """
     if args:
         if isinstance(args, basestring):
@@ -115,10 +117,13 @@
     else:
         output_file = None
 
-	if dir_ and os.path.isdir(ctxt.resolve(dir_)):
-		dir_ = ctxt.resolve(dir_)
-	else:
-		dir_ = ctxt.basedir
+    if dir_ and os.path.isdir(ctxt.resolve(dir_)):
+        dir_ = ctxt.resolve(dir_)
+    else:
+        dir_ = ctxt.basedir
+        
+    if not filter_:
+        filter_=lambda s: s
 
     try:
         cmdline = CommandLine(executable, args, input=input_file,
@@ -127,9 +132,11 @@
         for out, err in cmdline.execute():
             if out is not None:
                 log.info(out)
-                log_elem.append(xmlio.Element('message', level='info')[
-                    out.replace(ctxt.basedir + os.sep, '')
-                       .replace(ctxt.basedir, '')
+                info = filter_(out)
+                if info:
+                    log_elem.append(xmlio.Element('message', level='info')[
+                        info.replace(ctxt.basedir + os.sep, '')
+                            .replace(ctxt.basedir, '')
                 ])
                 if output:
                     output_file.write(out + os.linesep)
--- a/bitten/build/svntools.py
+++ b/bitten/build/svntools.py
@@ -12,12 +12,13 @@
 
 import logging
 import posixpath
+import re
 
 log = logging.getLogger('bitten.build.svntools')
 
 __docformat__ = 'restructuredtext en'
 
-def checkout(ctxt, url, path=None, revision=None, dir_='.'):
+def checkout(ctxt, url, path=None, revision=None, dir_='.', verbose=False):
     """Perform a checkout from a Subversion repository.
     
     :param ctxt: the build context
@@ -26,6 +27,7 @@
     :param path: the path inside the repository
     :param revision: the revision to check out
     :param dir_: the name of a local subdirectory to check out into
+    :param verbose: whether to log the list of checked out files
     """
     args = ['checkout']
     if revision:
@@ -34,8 +36,13 @@
         url = posixpath.join(url, path.lstrip('/'))
     args += [url, dir_]
 
+    cofilter = None
+    if not verbose:
+        cre = re.compile(r'^[AU]\s.*$')
+        cofilter = lambda s: cre.sub('', s)
     from bitten.build import shtools
-    returncode = shtools.execute(ctxt, file_='svn', args=args)
+    returncode = shtools.execute(ctxt, file_='svn', args=args, 
+                                 filter_=cofilter)
     if returncode != 0:
         ctxt.error('svn checkout failed (%s)' % returncode)
 
Copyright (C) 2012-2017 Edgewall Software