diff treepkg/readconfig.py @ 304:6cffb43a28ca

Add a way to specify svn subset checkouts where only parts of a source tree are checked out. The subset can be specified in the configuration file on a per-track basis. This feature was already present for some of the kde enterprise packagers but is now part of the base classes.
author Bernhard Herzog <bh@intevation.de>
date Thu, 26 Nov 2009 20:20:57 +0000
parents e82fb08781a2
children 3781e9958eba
line wrap: on
line diff
--- a/treepkg/readconfig.py	Thu Nov 26 15:37:48 2009 +0000
+++ b/treepkg/readconfig.py	Thu Nov 26 20:20:57 2009 +0000
@@ -23,8 +23,50 @@
     raise ValueError("cannot determine boolean value of %r" % (s,))
 
 
+def convert_subversion_subset(raw):
+    """Converts the string representation an svn subset into internal form
+    The format in the config file is typically:
+    svn_url: svn://example.com/repository/trunk
+    svn_subset: -N .
+                subdir1
+                subdir2
+
+    Each line of the svn_subset value consists of an optional flag
+    followed by a subdirectory.  Empty lines are ignored.  Each
+    non-empty line is split into words using shlex.split, so whitespace
+    characters can be included in filenames using e.g. quotes (see the
+    shlex documentation for details).  The only flag supported is -N
+    which indicates that the subdirectory on that line is not to be
+    checked out recursively.  If -N is given on a line, svn checkout
+    will be called with -N as parameter.
+
+    The example above will be converted into the internal form [('.',
+    False), ('subdir1', True), ('subdir2', True)] used by the
+    treepkg.subversion module.
+    """
+    subset = []
+    for line in raw.splitlines():
+        split = shlex.split(line)
+        if len(split) < 1:
+            # ignore empty lines
+            continue
+        subdir = split[-1]
+        recurse = True
+        flags = split[:-1]
+        if flags:
+            if flags == ["-N"]:
+                recurse = False
+            else:
+                raise ValueError("Only -N is supported as flag, but flags = %r"
+                                 % (flags,))
+        subset.append((subdir, recurse))
+    return subset
+
+
 packager_desc = [
-    "name", "base_dir", "svn_url", ("rules_svn_url", str, ""), "packager_class",
+    "name", "base_dir",
+    "svn_url", ("svn_subset", convert_subversion_subset, ""),
+    ("rules_svn_url", str, ""), "packager_class",
     ("root_cmd", shlex.split, "sudo"), "pbuilderrc",
     "deb_email", "deb_fullname", ("deb_build_options", str, ""),
     "pkg_revision_template", ("pkg_basename", str, ""),
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)